zcode-app-cli 3.15.3-35 → 3.15.3-37
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 +6 -1
- package/docs/CONFIGURATION.md +14 -3
- package/docs/CONFIGURATION.zh-CN.md +11 -3
- package/docs/HOST_INTEGRATION.md +160 -0
- package/package.json +10 -7
- package/vendor/cli-config.cjs +52 -0
- package/vendor/extraction.json +6 -1
- package/vendor/node_modules/@zcode/tui/dist/index.js +184 -37
- package/vendor/node_modules/@zcode/tui/package.json +1 -1
- package/vendor/zcode.cjs +2 -2
package/bin/zcode.js
CHANGED
|
@@ -1936,6 +1936,7 @@ async function main(args) {
|
|
|
1936
1936
|
process.once("SIGINT", onPluginSigint);
|
|
1937
1937
|
process.once("SIGTERM", onPluginSigterm);
|
|
1938
1938
|
if (process.platform !== "win32") process.once("SIGHUP", onPluginSighup);
|
|
1939
|
+
const builtinProviderWarnings = /* @__PURE__ */ new Set();
|
|
1939
1940
|
let pluginCommand;
|
|
1940
1941
|
try {
|
|
1941
1942
|
pluginCommand = await runPluginCommand(args, {
|
|
@@ -1943,7 +1944,11 @@ async function main(args) {
|
|
|
1943
1944
|
method,
|
|
1944
1945
|
params,
|
|
1945
1946
|
onStderr: (stderr) => {
|
|
1946
|
-
for (const line of stderr.split(/\r?\n/u))
|
|
1947
|
+
for (const line of stderr.split(/\r?\n/u)) {
|
|
1948
|
+
if (!line.startsWith("ZCode Built-in: ignoring unavailable ZCODE_BUILTIN_PROVIDER_CONFIG_FILE ") || builtinProviderWarnings.has(line)) continue;
|
|
1949
|
+
builtinProviderWarnings.add(line);
|
|
1950
|
+
process.stderr.write(`${line}\n`);
|
|
1951
|
+
}
|
|
1947
1952
|
},
|
|
1948
1953
|
signal: signal ?? pluginAbortController.signal,
|
|
1949
1954
|
transport: {
|
package/docs/CONFIGURATION.md
CHANGED
|
@@ -200,8 +200,11 @@ Plugin controls remain under `plugins`, hook declarations under
|
|
|
200
200
|
These paths distinguish the packaged CLI from the upstream application. The
|
|
201
201
|
source references below are pinned to upstream
|
|
202
202
|
[`29628c9` / `v3.14.3`](https://github.com/zai-org/ZCode/tree/29628c9acdb81b703bbd4080c207a0e7ce5e276e).
|
|
203
|
-
This package's runtime lock selects the separate Desktop 3.15.
|
|
203
|
+
This package's runtime lock selects the separate Desktop 3.15.3 artifact; the
|
|
204
204
|
public source snapshot is not an assertion of that artifact's build commit.
|
|
205
|
+
The configuration boundaries were rechecked on 2026-10-16 against
|
|
206
|
+
[`aac4755` / `v3.15.1`](https://github.com/zai-org/ZCode/tree/aac4755666d09fdcd70272fcf063c077a639015f).
|
|
207
|
+
The pinned links below retain the original audit references.
|
|
205
208
|
|
|
206
209
|
| Client / source | User MCP file | JSON path |
|
|
207
210
|
| --- | --- | --- |
|
|
@@ -318,10 +321,18 @@ Plain `zcode login` recognizes a configured native default and reports its
|
|
|
318
321
|
configuration path. Configuration presence is checked locally; credential
|
|
319
322
|
validation and decryption belong to the runtime.
|
|
320
323
|
|
|
324
|
+
Desktop and the CLI share OAuth login when they use the same data directory and
|
|
325
|
+
credential secret. Signing in on either side lets the other use that account;
|
|
326
|
+
the CLI reads the active shared profile without requiring a second CLI login.
|
|
327
|
+
Explicitly configured manual API keys retain their own account selection.
|
|
328
|
+
Z.AI credentials use Desktop's business-token format. Older CLI OAuth credentials
|
|
329
|
+
are converted after successful validation on their first request; failed
|
|
330
|
+
validation or a concurrent login never overwrites the newer shared session.
|
|
331
|
+
|
|
321
332
|
For macOS OAuth, the CLI temporarily registers a callback receiver, checks
|
|
322
333
|
`state`, restores the previous `zcode://` handler and sends the callback through
|
|
323
|
-
stdin. The runtime
|
|
324
|
-
|
|
334
|
+
stdin. The runtime resolves business and project access before publishing
|
|
335
|
+
encrypted login credentials and saving the native default model. The TUI then rereads
|
|
325
336
|
provider configuration. BigModel uses the runtime's localhost callback, checks
|
|
326
337
|
`state`, and sends the matching callback URI and state to
|
|
327
338
|
`https://zcode.z.ai/api/v1/oauth/token`. Both the BigModel access token and ZCode
|
|
@@ -173,8 +173,11 @@ MCP 服务器按名称合并。当前 runtime 中,**同名服务器的用户
|
|
|
173
173
|
|
|
174
174
|
下面区分本发行包与上游应用。源码引用固定在上游
|
|
175
175
|
[`29628c9` / `v3.14.3`](https://github.com/zai-org/ZCode/tree/29628c9acdb81b703bbd4080c207a0e7ce5e276e)。
|
|
176
|
-
本项目 runtime lock 选择的是独立发布的 Desktop 3.15.
|
|
176
|
+
本项目 runtime lock 选择的是独立发布的 Desktop 3.15.3 产物,不能据此认定该产物
|
|
177
177
|
由这个公开源码提交构建。
|
|
178
|
+
2026-10-16 已针对
|
|
179
|
+
[`aac4755` / `v3.15.1`](https://github.com/zai-org/ZCode/tree/aac4755666d09fdcd70272fcf063c077a639015f)
|
|
180
|
+
复核配置边界;下方固定链接保留原始审计出处。
|
|
178
181
|
|
|
179
182
|
| 客户端/配置源 | 用户级 MCP 文件 | JSON 路径 |
|
|
180
183
|
| --- | --- | --- |
|
|
@@ -273,9 +276,14 @@ Provider 文件中的 `config.defaultModelSelection` 决定新会话使用的模
|
|
|
273
276
|
普通的 `zcode login` 会识别已经配置的原生默认模型并提示配置路径。
|
|
274
277
|
本地仅检查配置是否存在,凭证校验与解密由 runtime 负责。
|
|
275
278
|
|
|
279
|
+
桌面端与 CLI 使用相同的数据目录和凭证加密密钥时,共享 OAuth 登录状态。
|
|
280
|
+
任意一端登录后,另一端即可使用该账号;CLI 直接读取共享的当前账号资料,无需再次登录。
|
|
281
|
+
显式配置的手动 API Key 仍使用其独立的账号选择。Z.AI 凭证统一采用桌面端的业务令牌格式;
|
|
282
|
+
旧版 CLI 保存的 OAuth 令牌会在首次请求验证成功后转换,验证失败或并发登录不会覆盖更新的共享会话。
|
|
283
|
+
|
|
276
284
|
macOS OAuth 会临时注册回调接收器、校验 `state`,恢复原来的 `zcode://` 处理程序,并通过
|
|
277
|
-
stdin 把回调交给 runtime。Runtime
|
|
278
|
-
|
|
285
|
+
stdin 把回调交给 runtime。Runtime 先取得业务和项目访问令牌,再保存加密登录凭证与
|
|
286
|
+
原生默认模型;TUI 随后重新读取 provider 配置。BigModel 使用 runtime 的 localhost
|
|
279
287
|
回调,校验 `state` 后,将匹配的回调地址和 state 提交到
|
|
280
288
|
`https://zcode.z.ai/api/v1/oauth/token`。BigModel access token 和 ZCode JWT 均通过原生
|
|
281
289
|
凭证存储加密保存。回调须能访问运行 CLI 的机器;SSH 环境需要将回调 URL 中的端口转发到该机器。
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Host integration contract
|
|
2
|
+
|
|
3
|
+
This document defines the supported boundary between `zcode-app-cli` and a
|
|
4
|
+
terminal host or agent orchestrator. It is versioned independently from the
|
|
5
|
+
internal runtime implementation so hosts can integrate with the CLI without
|
|
6
|
+
depending on private files under `vendor/`.
|
|
7
|
+
|
|
8
|
+
**Contract version: 1**
|
|
9
|
+
|
|
10
|
+
## Supported entry point
|
|
11
|
+
|
|
12
|
+
Hosts should start the published `zcode` executable and pass user arguments
|
|
13
|
+
through unchanged:
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
zcode [arguments...]
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The public entry point is the `zcode` npm bin exposed by `bin/zcode.js`. Hosts
|
|
20
|
+
must not invoke `vendor/zcode.cjs`, `vendor/extraction.json`, or other package
|
|
21
|
+
internals directly. Those files are implementation details and may change
|
|
22
|
+
between releases.
|
|
23
|
+
|
|
24
|
+
The launcher is a process boundary, not a library API. A host should be able
|
|
25
|
+
to replace the CLI package without changing its own process model.
|
|
26
|
+
|
|
27
|
+
## Terminal and standard streams
|
|
28
|
+
|
|
29
|
+
- For an interactive TUI invocation, allocate one terminal/PTY for the
|
|
30
|
+
`zcode` process and inherit its stdin and stdout. The launcher may capture
|
|
31
|
+
runtime stderr into its bounded diagnostic log, so hosts must not depend on
|
|
32
|
+
raw TUI stderr text being visible in the terminal.
|
|
33
|
+
- Do not insert a second PTY, relay terminal bytes through a second renderer,
|
|
34
|
+
or parse ANSI screen output as an integration protocol.
|
|
35
|
+
- For non-interactive commands, preserve the inherited standard-stream
|
|
36
|
+
contract; the command's documented output is the only supported machine
|
|
37
|
+
interface.
|
|
38
|
+
- Set the child's working directory to the workspace the user selected. The
|
|
39
|
+
launcher passes it to the runtime.
|
|
40
|
+
|
|
41
|
+
Example from a Node host:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
import { spawn } from "node:child_process";
|
|
45
|
+
|
|
46
|
+
const child = spawn("zcode", ["--cwd", workspace, ...args], {
|
|
47
|
+
cwd: workspace,
|
|
48
|
+
env: process.env,
|
|
49
|
+
stdio: "inherit"
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
child.on("exit", (code, signal) => {
|
|
53
|
+
// Preserve the CLI result in the host's run record.
|
|
54
|
+
console.log({ code, signal });
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Signals and exit status
|
|
59
|
+
|
|
60
|
+
The launcher forwards `SIGINT`, `SIGTERM`, and (on Unix) `SIGHUP` to the
|
|
61
|
+
runtime child. Hosts should send those signals to the `zcode` process when a
|
|
62
|
+
run is cancelled or its terminal is closed, then wait for the process to exit.
|
|
63
|
+
|
|
64
|
+
The launcher returns the runtime's exit code. If the runtime exits because of a
|
|
65
|
+
signal, the launcher uses the conventional `128 + signal number` status. A
|
|
66
|
+
host should record the final status rather than treating any non-zero result as
|
|
67
|
+
a transport failure.
|
|
68
|
+
|
|
69
|
+
## Environment and configuration
|
|
70
|
+
|
|
71
|
+
The following variables are supported host integration points:
|
|
72
|
+
|
|
73
|
+
| Variable | Purpose |
|
|
74
|
+
| --- | --- |
|
|
75
|
+
| `ZCODE_NODE` | Override the Node.js executable used to run the bundled runtime. |
|
|
76
|
+
| `ZCODE_BASE_URL` | Override the official ZCode service base URL. |
|
|
77
|
+
| `ZCODE_MODEL_RETRY_MAX_RETRIES` | Override the model retry limit. |
|
|
78
|
+
| `ZCODE_TUI_RUNTIME_LOG` | Choose the bounded diagnostic log for TUI runtime stderr. |
|
|
79
|
+
| `ZCODE_CLI_SETTINGS_FILE` | Choose an absolute path for this process's user settings, including hooks, MCP servers and default tool permissions. |
|
|
80
|
+
|
|
81
|
+
Hosts should pass user configuration through the normal ZCode environment and
|
|
82
|
+
configuration files. Do not put API keys or other secrets in command-line
|
|
83
|
+
arguments or host logs.
|
|
84
|
+
|
|
85
|
+
For example, give each agent a settings directory:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
ZCODE_CLI_SETTINGS_FILE=/host/agent-a/setting.json zcode
|
|
89
|
+
ZCODE_CLI_SETTINGS_FILE=/host/agent-b/setting.json zcode
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
The selected file replaces the default user settings file; its contents are not
|
|
93
|
+
merged with `~/.zcode/cli/setting.json`. Unset or whitespace-only values use the
|
|
94
|
+
default. Explicit runtime file paths and project configuration keep their existing
|
|
95
|
+
precedence. The launcher initializes a missing file and reads legacy `config.json`
|
|
96
|
+
and writes `migrations/` markers in the selected file's directory. Separate
|
|
97
|
+
directories keep each profile's migration state independent.
|
|
98
|
+
|
|
99
|
+
Hook trust commands also read the selected file's `storage.dir`, so grants and
|
|
100
|
+
revocations use the same trust store as the app runtime. Selecting a settings file
|
|
101
|
+
alone does not isolate session databases, persisted project permissions, providers
|
|
102
|
+
or credentials. Use `storage.dir` for separate hook trust storage,
|
|
103
|
+
`ZCODE_SESSION_DB_PATH` for sessions and persisted permissions,
|
|
104
|
+
`ZCODE_PERSONAL_PROVIDER_CONFIG_FILE` for providers, and `ZCODE_CLI_CREDENTIALS_FILE`
|
|
105
|
+
for credentials when the host needs those stores to be independent.
|
|
106
|
+
|
|
107
|
+
Desktop preferences still come from `~/.zcode/v2/setting.json`. This override does
|
|
108
|
+
not synchronize Desktop's user hooks/MCP file (`~/.zcode/cli/config.json`) with the
|
|
109
|
+
CLI settings file. See [configuration files](./CONFIGURATION.md#configuration-files)
|
|
110
|
+
for the ownership and migration rules.
|
|
111
|
+
|
|
112
|
+
The launcher does not install, replace, or select a different npm package
|
|
113
|
+
while a command is running. A host that needs reproducible deployments should
|
|
114
|
+
pin the published `zcode-app-cli` version in its own installation workflow.
|
|
115
|
+
Multi-version retention and rollback are host policy, not part of the `zcode`
|
|
116
|
+
process contract.
|
|
117
|
+
|
|
118
|
+
## Version identity
|
|
119
|
+
|
|
120
|
+
`zcode version`, `zcode --version`, and `zcode -v` report both layers:
|
|
121
|
+
|
|
122
|
+
```text
|
|
123
|
+
zcode-app-cli <distribution-version>
|
|
124
|
+
zcode-runtime <runtime-version>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Hosts may display this output or store it with a run record. They should not
|
|
128
|
+
infer capabilities from the TUI banner or from private runtime file names.
|
|
129
|
+
|
|
130
|
+
## Host responsibilities
|
|
131
|
+
|
|
132
|
+
The host owns:
|
|
133
|
+
|
|
134
|
+
1. installing a published package version;
|
|
135
|
+
2. selecting the workspace and environment;
|
|
136
|
+
3. allocating the terminal when interactive mode is requested;
|
|
137
|
+
4. forwarding cancellation and terminal-close signals;
|
|
138
|
+
5. capturing the exit status and any host-level logs; and
|
|
139
|
+
6. applying its own update, retention, and rollback policy.
|
|
140
|
+
|
|
141
|
+
The CLI owns terminal interaction, model access, sessions, tools, plugins,
|
|
142
|
+
skills, and the runtime-specific command semantics. Hosts should use the
|
|
143
|
+
documented command line and stdio boundary instead of importing internal
|
|
144
|
+
TypeScript modules.
|
|
145
|
+
|
|
146
|
+
## Compatibility rules
|
|
147
|
+
|
|
148
|
+
- A host may support any release that exposes the `zcode` npm bin and this
|
|
149
|
+
contract version.
|
|
150
|
+
- Internal TUI layout, runtime bundle paths, and extracted symbol names are not
|
|
151
|
+
compatibility surfaces.
|
|
152
|
+
- Host-specific branding belongs in the host integration, not in the upstream
|
|
153
|
+
runtime package.
|
|
154
|
+
- If a host needs a new machine-readable capability, it should propose a
|
|
155
|
+
documented CLI output or a new contract version rather than scraping the
|
|
156
|
+
interactive screen.
|
|
157
|
+
|
|
158
|
+
Herdr, Orca, and other terminal orchestrators can therefore share the same
|
|
159
|
+
`zcode` process contract while keeping their own installation and lifecycle
|
|
160
|
+
policies outside the CLI implementation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zcode-app-cli",
|
|
3
|
-
"version": "3.15.3-
|
|
3
|
+
"version": "3.15.3-37",
|
|
4
4
|
"description": "Unofficial terminal client for the ZCode agent runtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"docs/CONFIGURATION.zh-CN.md",
|
|
39
39
|
"docs/PROVIDER_CONFIG.md",
|
|
40
40
|
"docs/PROVIDER_CONFIG.zh-CN.md",
|
|
41
|
+
"docs/HOST_INTEGRATION.md",
|
|
41
42
|
"docs/THIRD_PARTY_CONTENT.md",
|
|
42
43
|
"LICENSES/Apache-2.0.txt",
|
|
43
44
|
"LICENSES/README.md",
|
|
@@ -61,18 +62,17 @@
|
|
|
61
62
|
"check": "bun run build && bun scripts/check-runtime.ts",
|
|
62
63
|
"check:oauth-callback": "bun scripts/smoke-oauth-callback.ts",
|
|
63
64
|
"check:tui": "bun scripts/smoke-tui.ts && bun scripts/smoke-tui-features.ts && bun scripts/smoke-tui-clear.ts && bun scripts/smoke-tui-session-title.ts && bun scripts/smoke-tui-pressure.ts && bun scripts/smoke-tui-widths.ts && bun scripts/smoke-tui-fullscreen.ts && bun scripts/smoke-tui-fullscreen-switch.ts && bun scripts/smoke-tui-fullscreen-layout.ts && bun run check:tui:focus",
|
|
64
|
-
"check:tui:focus": "bun scripts/smoke-tui-focus.ts regular off always && bun scripts/smoke-tui-focus.ts fullscreen
|
|
65
|
+
"check:tui:focus": "bun scripts/smoke-tui-focus.ts regular off always && bun scripts/smoke-tui-focus.ts fullscreen bel unfocused && bun scripts/smoke-tui-focus.ts fullscreen off always built",
|
|
65
66
|
"check:tui:focus:manual": "bun scripts/manual-tui-focus.ts",
|
|
66
|
-
"check:tui-scenarios": "bun run test:tui",
|
|
67
67
|
"test": "bun run test:unit",
|
|
68
68
|
"test:all": "bun run test:unit && bun run test:tui && bun run test:runtime && bun run test:node",
|
|
69
69
|
"test:unit": "bun test test/*.test.ts",
|
|
70
|
-
"test:fast": "bun run test:unit",
|
|
71
70
|
"test:runtime": "bun test test/runtime/*.test.ts",
|
|
71
|
+
"test:runtime:compat": "bun test test/runtime/launcher.test.ts test/runtime/network-retry.test.ts test/runtime/app-server-auth.test.ts test/runtime/execution-state-tui.test.ts",
|
|
72
72
|
"test:node": "node --test test/node/*.test.cjs",
|
|
73
73
|
"test:tui": "bun run test:tui:component && bun run test:tui:e2e",
|
|
74
74
|
"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",
|
|
75
|
-
"test:tui:e2e": "bun test test/tui/allowlisted-shell.test.ts test/tui/dynamic-workflows.test.ts test/tui/http-mock.test.ts test/tui/input-actions.test.ts test/tui/model-resume.test.ts test/tui/permission-request-queue.test.ts test/tui/run-scenario.test.ts test/tui/runtime-refresh.test.ts test/tui/session-rename.test.ts test/tui/terminal-session.test.ts test/tui/write-and-diff.test.ts",
|
|
75
|
+
"test:tui:e2e": "bun test test/tui/allowlisted-shell.test.ts test/tui/dynamic-workflows.test.ts test/tui/http-mock.test.ts test/tui/input-actions.test.ts test/tui/model-resume.test.ts test/tui/model-status.test.ts test/tui/permission-request-queue.test.ts test/tui/run-scenario.test.ts test/tui/runtime-refresh.test.ts test/tui/session-rename.test.ts test/tui/startup.test.ts test/tui/terminal-session.test.ts test/tui/write-and-diff.test.ts",
|
|
76
76
|
"test:tui:host": "bun test test/tui/scenario-mountx.test.ts",
|
|
77
77
|
"test:tui:manual": "bun scripts/tui-scenario.ts --manual",
|
|
78
78
|
"test:tui-scenario": "bun scripts/tui-scenario.ts",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"provenance": true
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
|
-
"@earendil-works/pi-tui": "^
|
|
96
|
+
"@earendil-works/pi-tui": "^1.3.0",
|
|
97
97
|
"playwright-core": "1.59.1"
|
|
98
98
|
},
|
|
99
99
|
"devDependencies": {
|
|
@@ -103,12 +103,15 @@
|
|
|
103
103
|
"bun-types": "1.4.1",
|
|
104
104
|
"cli-highlight": "^2.1.11",
|
|
105
105
|
"diff": "^9.0.0",
|
|
106
|
-
"just-bash": "^3.
|
|
106
|
+
"just-bash": "^3.6.0",
|
|
107
107
|
"mountx": "^0.0.2",
|
|
108
108
|
"msw": "^2.15.0",
|
|
109
109
|
"pkg-pr-new": "0.0.88",
|
|
110
110
|
"tsdown": "^0.22.7",
|
|
111
111
|
"typescript": "^7.0.2",
|
|
112
112
|
"yaml": "^2.8.1"
|
|
113
|
+
},
|
|
114
|
+
"overrides": {
|
|
115
|
+
"undici": "7.30.0"
|
|
113
116
|
}
|
|
114
117
|
}
|
package/vendor/cli-config.cjs
CHANGED
|
@@ -817,6 +817,56 @@ function browserOpenCommand(platform, url) {
|
|
|
817
817
|
};
|
|
818
818
|
}
|
|
819
819
|
//#endregion
|
|
820
|
+
//#region src/shared-oauth.ts
|
|
821
|
+
const activeProviderKey = "oauth:active_provider";
|
|
822
|
+
const identityKey = (provider) => `account-provider:${provider}:identity`;
|
|
823
|
+
const sourceKey = (provider) => `account-provider:${provider}:auth-source`;
|
|
824
|
+
function profileIdentity(value) {
|
|
825
|
+
if (!value) return null;
|
|
826
|
+
try {
|
|
827
|
+
const profile = JSON.parse(value);
|
|
828
|
+
const id = profile?.user_id ?? profile?.id ?? profile?.rawProfile?.user_id;
|
|
829
|
+
return typeof id === "string" && id.trim() ? id.trim() : null;
|
|
830
|
+
} catch {
|
|
831
|
+
return null;
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
/** Desktop owns oauth:*; standalone account markers must not shadow that session. */
|
|
835
|
+
function sharedOAuthCredentialReader(store, providers) {
|
|
836
|
+
const loadMany = async (keys) => {
|
|
837
|
+
const identityKeys = keys.filter((key) => key.startsWith("account-provider:") && key.endsWith(":identity"));
|
|
838
|
+
if (!identityKeys.length) return store.loadMany(keys);
|
|
839
|
+
const catalog = (await providers()).filter((provider) => identityKeys.includes(identityKey(provider.providerId)));
|
|
840
|
+
if (!catalog.length) return store.loadMany(keys);
|
|
841
|
+
const sourceKeys = catalog.map((provider) => sourceKey(provider.providerId));
|
|
842
|
+
const sources = await store.loadMany(sourceKeys);
|
|
843
|
+
const shared = catalog.filter((provider) => sources[sourceKey(provider.providerId)] !== "manual");
|
|
844
|
+
if (!shared.length) return store.loadMany(keys);
|
|
845
|
+
const overridden = new Set(shared.map((provider) => identityKey(provider.providerId)));
|
|
846
|
+
const values = await store.loadMany([...keys.filter((key) => !overridden.has(key)), activeProviderKey]);
|
|
847
|
+
const family = values[activeProviderKey];
|
|
848
|
+
let identity = null;
|
|
849
|
+
if (family && shared.some((provider) => provider.family === family)) {
|
|
850
|
+
const profileKey = `oauth:${family}:user_info`;
|
|
851
|
+
const current = await store.loadMany([activeProviderKey, profileKey]);
|
|
852
|
+
if (current[activeProviderKey] === family) identity = profileIdentity(current[profileKey]);
|
|
853
|
+
}
|
|
854
|
+
for (const provider of shared) values[identityKey(provider.providerId)] = provider.family === family ? identity : null;
|
|
855
|
+
return Object.fromEntries(keys.map((key) => [key, values[key] ?? null]));
|
|
856
|
+
};
|
|
857
|
+
return {
|
|
858
|
+
...store,
|
|
859
|
+
loadMany,
|
|
860
|
+
load: async (key) => (await loadMany([key]))[key] ?? null
|
|
861
|
+
};
|
|
862
|
+
}
|
|
863
|
+
/** A successful OAuth exchange must publish Desktop's business token, never its OAuth input. */
|
|
864
|
+
function zaiBusinessAccessToken(material) {
|
|
865
|
+
const token = material.zaiBusinessToken?.trim();
|
|
866
|
+
if (!token) throw new Error("Z.AI login did not return a business access token.");
|
|
867
|
+
return token;
|
|
868
|
+
}
|
|
869
|
+
//#endregion
|
|
820
870
|
//#region src/config-diagnostics.ts
|
|
821
871
|
const schemaDiagnosticPrefix = /^(?:<config>|modelStream|permission|storage|network|features|memory|mcp|plugins|skills|skill|command|logging|ui|toolConcurrency|modelAnomalyGuard|hooks)(?:[.:[\]]|$)/u;
|
|
822
872
|
function publicDiagnostic(diagnostic, scope) {
|
|
@@ -1040,6 +1090,8 @@ exports.readSessionModelState = readSessionModelState;
|
|
|
1040
1090
|
exports.readTuiRuntimeProjection = readTuiRuntimeProjection;
|
|
1041
1091
|
exports.restoreTuiBackgroundTasks = restoreTuiBackgroundTasks;
|
|
1042
1092
|
exports.sendTuiBackgroundTaskMessage = sendTuiBackgroundTaskMessage;
|
|
1093
|
+
exports.sharedOAuthCredentialReader = sharedOAuthCredentialReader;
|
|
1043
1094
|
exports.sqliteRecoveryStats = sqliteRecoveryStats;
|
|
1044
1095
|
exports.startTuiSavedWorkflow = startTuiSavedWorkflow;
|
|
1045
1096
|
exports.writeConfigurationDoctor = writeConfigurationDoctor;
|
|
1097
|
+
exports.zaiBusinessAccessToken = zaiBusinessAccessToken;
|
package/vendor/extraction.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"appVersion": "3.15.3",
|
|
3
3
|
"cliVersion": "0.16.9",
|
|
4
|
-
"extractedAt": "2026-10-
|
|
4
|
+
"extractedAt": "2026-10-19T10:11:04.295Z",
|
|
5
5
|
"sha512": "9RigUj20tjuaskzBt2sgWLtIuUaIET67x5joShRIgwLlbFcO/oWt1eemrlLn5ZskXUMzcUHtUTCKU8+mHF7kQQ==",
|
|
6
6
|
"source": "https://cdn-zcode.z.ai/zcode/electron/releases/3.15.3/linux-x64/ZCode-3.15.3-linux-x64.deb",
|
|
7
7
|
"runtimeCapabilities": {
|
|
@@ -244,6 +244,11 @@
|
|
|
244
244
|
"requirement": "optional",
|
|
245
245
|
"status": "applied"
|
|
246
246
|
},
|
|
247
|
+
{
|
|
248
|
+
"id": "shared-oauth",
|
|
249
|
+
"requirement": "required",
|
|
250
|
+
"status": "applied"
|
|
251
|
+
},
|
|
247
252
|
{
|
|
248
253
|
"id": "login-model-defaults",
|
|
249
254
|
"requirement": "required",
|