zcode-acp-server 0.76.2 → 0.77.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.
- package/README.md +67 -29
- package/README.zh-CN.md +22 -22
- package/dist/account-setup.d.ts +9 -0
- package/dist/account-setup.d.ts.map +1 -0
- package/dist/account-setup.js +80 -0
- package/dist/account-setup.js.map +1 -0
- package/dist/backend/credentials.d.ts +3 -3
- package/dist/backend/credentials.d.ts.map +1 -1
- package/dist/backend/credentials.js +5 -5
- package/dist/backend/credentials.js.map +1 -1
- package/dist/backend/resolve.d.ts +11 -1
- package/dist/backend/resolve.d.ts.map +1 -1
- package/dist/backend/resolve.js +14 -1
- package/dist/backend/resolve.js.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +9 -1
- package/dist/cli.js.map +1 -1
- package/dist/code-fingerprint.json +2 -2
- package/dist/config/account-provider.d.ts +32 -0
- package/dist/config/account-provider.d.ts.map +1 -1
- package/dist/config/account-provider.js +36 -6
- package/dist/config/account-provider.js.map +1 -1
- package/dist/config/bridge-accounts.d.ts +40 -0
- package/dist/config/bridge-accounts.d.ts.map +1 -0
- package/dist/config/bridge-accounts.js +193 -0
- package/dist/config/bridge-accounts.js.map +1 -0
- package/dist/config/options.d.ts.map +1 -1
- package/dist/config/options.js +2 -1
- package/dist/config/options.js.map +1 -1
- package/dist/config/provider-registry.d.ts.map +1 -1
- package/dist/config/provider-registry.js +2 -2
- package/dist/config/provider-registry.js.map +1 -1
- package/dist/handlers/session-titles.d.ts.map +1 -1
- package/dist/handlers/session-titles.js +6 -0
- package/dist/handlers/session-titles.js.map +1 -1
- package/dist/handlers/session.d.ts +0 -26
- package/dist/handlers/session.d.ts.map +1 -1
- package/dist/handlers/session.js +91 -126
- package/dist/handlers/session.js.map +1 -1
- package/dist/remote/session-close-endpoint.d.ts.map +1 -1
- package/dist/remote/session-close-endpoint.js +5 -2
- package/dist/remote/session-close-endpoint.js.map +1 -1
- package/dist/server.d.ts +29 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +42 -0
- package/dist/server.js.map +1 -1
- package/dist/tasks-index.d.ts.map +1 -1
- package/dist/tasks-index.js +5 -2
- package/dist/tasks-index.js.map +1 -1
- package/docs/BACKLOG.md +45 -6
- package/docs/adr/0006-remote-session-close.md +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,27 +193,27 @@ before any config would be readable.
|
|
|
193
193
|
Every `ZCODE_ACP_*` preference variable in this table has a config-file
|
|
194
194
|
field (see [User config file](#user-config-file)); the file value wins.
|
|
195
195
|
|
|
196
|
-
| Variable | Default | Purpose
|
|
197
|
-
| ---------------------------------- | ------------------- |
|
|
198
|
-
| `ZCODE_BIN` | _(auto-discovered)_ | Path to the ZCode CLI binary or its `.cjs` entry. Resolution order: this variable → `zcode` on `PATH` → the desktop-app bundle
|
|
199
|
-
| `ZCODE_NODE` | _(discovered)_ | Explicit Node binary to run `ZCODE_BIN` with (must support `node:sqlite`)
|
|
200
|
-
| `ZCODE_PROVIDER` | _(first enabled)_ | Pin the provider id from `config.json` (e.g. `builtin:zai-coding-plan`). Credentials are read from that provider only, and the model dropdown lists only its models. Unset keeps the default "first enabled provider wins". Set together with `ZCODE_MODEL` to pin the exact model: each new session is switched to `ZCODE_PROVIDER`/`ZCODE_MODEL` right after it is created, and session creation fails if the backend refuses that pair.
|
|
201
|
-
| `ZCODE_HOME` | `~/.zcode` | Directory that replaces `~/.zcode` as the ZCode data root. Everything the bridge reads from there follows it: credentials/provider config (`<dir>/v2/config.json`), the lazy-session alias store (`<dir>/v2/acp-lazy-sessions.json`), the desktop app's settings and tasks index (`<dir>/v2/setting.json`, `<dir>/v2/tasks-index.sqlite`), user skills (`<dir>/skills`), and the CLI config with plugin/skill/MCP enablement (`<dir>/cli/config.json` + plugin cache). Set it before starting the bridge — the credentials and tasks-index paths are resolved once at startup.
|
|
202
|
-
| `ZCODE_MODEL` | _(from config)_ | Override the active model id
|
|
203
|
-
| `ZCODE_DISALLOWED_TOOLS` | _(Cron tools)_ | Space- or comma-separated tool names
|
|
204
|
-
| `ZCODE_ENABLE_AUTOMATION_TOOLS` | _(unset)_ | Set to `1` to stop disallowing the Cron* tools — only useful for a host that actually implements the backend's `automation/*` port.
|
|
205
|
-
| `ZCODE_ACP_AUTO_COMPACT_THRESHOLD` | _(unset)_ | Absolute token count that triggers automatic context compaction. After each successful turn (`end_turn`), if `contextUsed >= threshold`, the server invokes `session/compact` to free up context before the next prompt. Set to `0` or leave unset to disable (default). Example: `240000` triggers compaction at 240K tokens. The compaction target itself is decided by the ZCode backend.
|
|
206
|
-
| `ZCODE_ACP_QUOTA_AUTO_RESUME` | `1` | Wait out GLM usage-cap exhaustion (business codes 1308 …) and continue automatically: a quota-stopped `/auto` goal loop re-enters its rounds after the window reset, and quota-stopped workflow runs are resumed from the journal once the quota card reports the reset. Set `0` to restore pause-for-a-human. The bridge performs the wait (timers + a periodic journal scan), so it works while the editor/app is asleep or detached.
|
|
207
|
-
| `ZCODE_ACP_MODE` | `yolo` | Mode a newly created session starts in. Values are the backend's own modes — `plan`, `build`, `edit`, `yolo`, `auto`. Unset keeps `yolo` (unrestricted), the bridge's historical default. Only affects session creation; the mode dropdown still switches it per session.
|
|
208
|
-
| `ZCODE_ACP_DEBUG` | _(unset)_ | Set to `1` to enable verbose diagnostic logs (event flow, probe loops, status updates). Default is quiet — only warnings (backend pipe errors, command/permission failures, lock timeouts) are emitted. Enable this when diagnosing bridge issues; the logs appear in `Zed.log` prefixed with `[zcode-acp]`.
|
|
209
|
-
| `ZCODE_ACP_REMOTE` | _(unset)_ | Set to `1` to enable [remote access](#remote-access) — serve the same sessions to additional ACP clients over WebSocket.
|
|
210
|
-
| `ZCODE_ACP_REMOTE_TOKEN` | _(unset)_ | Auth token for remote access. **Mandatory** when `ZCODE_ACP_REMOTE=1`; remote stays disabled without it.
|
|
211
|
-
| `ZCODE_ACP_HUB_PORT` | `8377` | Port of the machine-level hub daemon. Map exactly this one port in your tunnel.
|
|
212
|
-
| `ZCODE_ACP_HUB_HOST` | `127.0.0.1` | Hub bind address. `0.0.0.0` exposes a token-only, unencrypted surface — only for a containerized tunnel agent on a private interface (see [Remote Access](#remote-access)).
|
|
213
|
-
| `ZCODE_ACP_REMOTE_PORT` | `8378` | First loopback port for the bridge's ACP endpoint. Each bridge (each editor window) auto-increments to the next free port.
|
|
214
|
-
| `ZCODE_ACP_SANDBOX` | _(unset)_ | Set to `1` to confine the agent's file writes with a macOS Seatbelt sandbox globally; per-project, set `"enabled": true` in `<workspace>/.zcode/acp/sandbox.json` instead (see [Sandbox](#sandbox)).
|
|
215
|
-
| `ZCODE_ACP_LANG` | _(inherited)_ | Language of the bridge's user-facing strings (popups, status/hint lines, command menu descriptions): `zh` or `en`. When unset, the bridge inherits the ZCode app's language (`localePreference`/`locale` in `~/.zcode/v2/setting.json`), then falls back to the `LC_ALL`/`LC_MESSAGES`/`LANG` locale, defaulting to English.
|
|
216
|
-
| `ZCODE_ACP_SHOW_COMPLETION_STATUS` | `1` | Emit successful turn-end status as assistant text. Set `0` or `false` to omit it; `session.showCompletionStatus` overrides the env. Error and cancellation warnings remain visible.
|
|
196
|
+
| Variable | Default | Purpose |
|
|
197
|
+
| ---------------------------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
198
|
+
| `ZCODE_BIN` | _(auto-discovered)_ | Path to the ZCode CLI binary or its `.cjs` entry. Resolution order: this variable → `zcode` on `PATH` → the desktop-app bundle |
|
|
199
|
+
| `ZCODE_NODE` | _(discovered)_ | Explicit Node binary to run `ZCODE_BIN` with (must support `node:sqlite`) |
|
|
200
|
+
| `ZCODE_PROVIDER` | _(first enabled)_ | Pin the provider id from `config.json` (e.g. `builtin:zai-coding-plan`). Credentials are read from that provider only, and the model dropdown lists only its models. Unset keeps the default "first enabled provider wins". Set together with `ZCODE_MODEL` to pin the exact model: each new session is switched to `ZCODE_PROVIDER`/`ZCODE_MODEL` right after it is created, and session creation fails if the backend refuses that pair. |
|
|
201
|
+
| `ZCODE_HOME` | `~/.zcode` | Directory that replaces `~/.zcode` as the ZCode data root. Everything the bridge reads from there follows it: credentials/provider config (`<dir>/v2/config.json`), the lazy-session alias store (`<dir>/v2/acp-lazy-sessions.json`), the desktop app's settings and tasks index (`<dir>/v2/setting.json`, `<dir>/v2/tasks-index.sqlite`), user skills (`<dir>/skills`), and the CLI config with plugin/skill/MCP enablement (`<dir>/cli/config.json` + plugin cache). Set it before starting the bridge — the credentials and tasks-index paths are resolved once at startup. |
|
|
202
|
+
| `ZCODE_MODEL` | _(from config)_ | Override the active model id |
|
|
203
|
+
| `ZCODE_DISALLOWED_TOOLS` | _(Cron tools)_ | Space- or comma-separated tool names removed from every session the bridge creates or resumes (sent as the backend's per-session `toolDenylist` — a registry-level removal, so the tools are neither offered to the model nor executable), merged with the built-in default that disallows `CronCreate CronList CronUpdate CronDelete` (the bridge cannot serve the backend's `automation/*` client requests, so those tools are advertised-but-broken — see #192). Rule forms like `Bash(git *)` remove the whole tool. A backend too old for `toolDenylist` gets one warning and runs without the policy. |
|
|
204
|
+
| `ZCODE_ENABLE_AUTOMATION_TOOLS` | _(unset)_ | Set to `1` to stop disallowing the Cron* tools — only useful for a host that actually implements the backend's `automation/*` port. |
|
|
205
|
+
| `ZCODE_ACP_AUTO_COMPACT_THRESHOLD` | _(unset)_ | Absolute token count that triggers automatic context compaction. After each successful turn (`end_turn`), if `contextUsed >= threshold`, the server invokes `session/compact` to free up context before the next prompt. Set to `0` or leave unset to disable (default). Example: `240000` triggers compaction at 240K tokens. The compaction target itself is decided by the ZCode backend. |
|
|
206
|
+
| `ZCODE_ACP_QUOTA_AUTO_RESUME` | `1` | Wait out GLM usage-cap exhaustion (business codes 1308 …) and continue automatically: a quota-stopped `/auto` goal loop re-enters its rounds after the window reset, and quota-stopped workflow runs are resumed from the journal once the quota card reports the reset. Set `0` to restore pause-for-a-human. The bridge performs the wait (timers + a periodic journal scan), so it works while the editor/app is asleep or detached. |
|
|
207
|
+
| `ZCODE_ACP_MODE` | `yolo` | Mode a newly created session starts in. Values are the backend's own modes — `plan`, `build`, `edit`, `yolo`, `auto`. Unset keeps `yolo` (unrestricted), the bridge's historical default. Only affects session creation; the mode dropdown still switches it per session. |
|
|
208
|
+
| `ZCODE_ACP_DEBUG` | _(unset)_ | Set to `1` to enable verbose diagnostic logs (event flow, probe loops, status updates). Default is quiet — only warnings (backend pipe errors, command/permission failures, lock timeouts) are emitted. Enable this when diagnosing bridge issues; the logs appear in `Zed.log` prefixed with `[zcode-acp]`. |
|
|
209
|
+
| `ZCODE_ACP_REMOTE` | _(unset)_ | Set to `1` to enable [remote access](#remote-access) — serve the same sessions to additional ACP clients over WebSocket. |
|
|
210
|
+
| `ZCODE_ACP_REMOTE_TOKEN` | _(unset)_ | Auth token for remote access. **Mandatory** when `ZCODE_ACP_REMOTE=1`; remote stays disabled without it. |
|
|
211
|
+
| `ZCODE_ACP_HUB_PORT` | `8377` | Port of the machine-level hub daemon. Map exactly this one port in your tunnel. |
|
|
212
|
+
| `ZCODE_ACP_HUB_HOST` | `127.0.0.1` | Hub bind address. `0.0.0.0` exposes a token-only, unencrypted surface — only for a containerized tunnel agent on a private interface (see [Remote Access](#remote-access)). |
|
|
213
|
+
| `ZCODE_ACP_REMOTE_PORT` | `8378` | First loopback port for the bridge's ACP endpoint. Each bridge (each editor window) auto-increments to the next free port. |
|
|
214
|
+
| `ZCODE_ACP_SANDBOX` | _(unset)_ | Set to `1` to confine the agent's file writes with a macOS Seatbelt sandbox globally; per-project, set `"enabled": true` in `<workspace>/.zcode/acp/sandbox.json` instead (see [Sandbox](#sandbox)). |
|
|
215
|
+
| `ZCODE_ACP_LANG` | _(inherited)_ | Language of the bridge's user-facing strings (popups, status/hint lines, command menu descriptions): `zh` or `en`. When unset, the bridge inherits the ZCode app's language (`localePreference`/`locale` in `~/.zcode/v2/setting.json`), then falls back to the `LC_ALL`/`LC_MESSAGES`/`LANG` locale, defaulting to English. |
|
|
216
|
+
| `ZCODE_ACP_SHOW_COMPLETION_STATUS` | `1` | Emit successful turn-end status as assistant text. Set `0` or `false` to omit it; `session.showCompletionStatus` overrides the env. Error and cancellation warnings remain visible. |
|
|
217
217
|
|
|
218
218
|
## Sandbox
|
|
219
219
|
|
|
@@ -241,9 +241,47 @@ powered by Martty), plan quota cards (`zcode-acp quota`, GLM + Opencode Go + Oll
|
|
|
241
241
|
the remote hub daemon (`zcode-acp hub`), and the stdio server editors invoke
|
|
242
242
|
(`zcode-acp server`). TUI keys and quota setup: [docs/CLI.md](docs/CLI.md).
|
|
243
243
|
|
|
244
|
+
## Manual Coding Plan account setup
|
|
245
|
+
|
|
246
|
+
With a supported ZCode CLI installed, run this command in your own terminal:
|
|
247
|
+
|
|
248
|
+
```bash
|
|
249
|
+
zcode-acp setup --provider zai # or: bigmodel
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Enter your individual Coding Plan API key at the hidden prompt. Do not put a
|
|
253
|
+
key in command arguments or environment flags. Setup saves an owner-only
|
|
254
|
+
`~/.zcode/v2/acp-accounts.json` file (`ZCODE_HOME` relocates the `.zcode` root),
|
|
255
|
+
using atomic replacement and an exclusive setup lock. It never modifies the
|
|
256
|
+
Desktop's `config.json`, `setting.json`, or `provider_config.json`.
|
|
257
|
+
|
|
258
|
+
An explicitly configured bridge account overrides that family's Desktop key
|
|
259
|
+
and enablement **in memory**. Other providers and their order are preserved;
|
|
260
|
+
use `ZCODE_PROVIDER=builtin:zai-coding-plan` (or `builtin:bigmodel-coding-plan`)
|
|
261
|
+
to select a specific account for model discovery and quota queries. The
|
|
262
|
+
installed public catalog supplies the plan's models. Runtime account headers,
|
|
263
|
+
model discovery, and quota use the same merged credential source. Saving does
|
|
264
|
+
not verify plan membership or key validity; the first provider request does.
|
|
265
|
+
Restart connected clients after setup. To return to Desktop-only credentials,
|
|
266
|
+
remove the selected family entry from the private account file, preserving
|
|
267
|
+
version `1` and the other account entries.
|
|
268
|
+
|
|
269
|
+
This is manual terminal setup, not an interactive ACP authentication method.
|
|
270
|
+
T3 Code and other clients can continue using the agent-handled authentication
|
|
271
|
+
already advertised by the bridge. No OAuth/captcha flow or alternative remote
|
|
272
|
+
login mechanism is added.
|
|
273
|
+
|
|
274
|
+
If setup is killed while saving, it may leave an `acp-accounts.json.lock`
|
|
275
|
+
directory. After confirming no setup process is running, remove that empty
|
|
276
|
+
lock directory and retry. It may also leave an `acp-accounts.json.<id>.tmp`
|
|
277
|
+
file. That file is owner-only but can hold the key, so delete it. Setup refuses a malformed, linked, or broadly
|
|
278
|
+
readable account file and never overwrites it. The bridge ignores such a
|
|
279
|
+
file with a warning and keeps using Desktop credentials. Fix or remove the
|
|
280
|
+
file, then run setup again.
|
|
281
|
+
|
|
244
282
|
## ACP Registry
|
|
245
283
|
|
|
246
|
-
This server is compatible with the [ACP Registry](https://agentclientprotocol.com/get-started/registry). It advertises a single `agent`-type auth method at `initialize` time —
|
|
284
|
+
This server is compatible with the [ACP Registry](https://agentclientprotocol.com/get-started/registry). It advertises a single `agent`-type auth method at `initialize` time — credentials come from Desktop configuration or a private bridge account created by manual terminal setup, so **no editor-side credentials are required**.
|
|
247
285
|
|
|
248
286
|
The registry submission assets live under [`registry/zcode-acp/`](registry/zcode-acp/) (`agent.json` + `icon.svg`). Once the package is published to npm, copy that directory into a fork of [`agentclientprotocol/registry`](https://github.com/agentclientprotocol/registry) and open a PR — the CI validates the `agent.json` schema, icon, and that `initialize` returns a non-empty `authMethods`.
|
|
249
287
|
|
|
@@ -315,7 +353,7 @@ Thanks to everyone who has contributed (updated automatically from the
|
|
|
315
353
|
<a href="https://github.com/william0wang/zcode-acp/graphs/contributors">
|
|
316
354
|
<!-- release-please re-stamps &v= on every release: the new URL busts the
|
|
317
355
|
contrib.rocks and GitHub camo image caches. -->
|
|
318
|
-
<img src="https://contrib.rocks/image?repo=william0wang/zcode-acp&v=0.
|
|
356
|
+
<img src="https://contrib.rocks/image?repo=william0wang/zcode-acp&v=0.77.0" alt="Contributors" /> <!-- x-release-please-version -->
|
|
319
357
|
</a>
|
|
320
358
|
|
|
321
359
|
## Related Projects
|
|
@@ -340,12 +378,12 @@ ZCode backend over **local pipes**; that data reaches the GLM cloud API only
|
|
|
340
378
|
because the ZCode backend itself sends it there for inference — this server
|
|
341
379
|
adds no extra destinations.
|
|
342
380
|
|
|
343
|
-
| Concern | What & why
|
|
344
|
-
| ----------- |
|
|
345
|
-
| Network | Only one outbound request in the whole codebase: the quota GET (`open.bigmodel.cn` / `api.z.ai`), carrying just your API key — needed to fetch your usage numbers, sends no user content
|
|
346
|
-
| Credentials |
|
|
347
|
-
| Disk | No new files
|
|
348
|
-
| Logging | Diagnostics to stderr for troubleshooting bridge issues. Even with `ZCODE_ACP_DEBUG=1`, no prompts/code/keys are ever logged
|
|
381
|
+
| Concern | What & why |
|
|
382
|
+
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
383
|
+
| Network | Only one outbound request in the whole codebase: the quota GET (`open.bigmodel.cn` / `api.z.ai`), carrying just your API key — needed to fetch your usage numbers, sends no user content |
|
|
384
|
+
| Credentials | Desktop credentials or owner-only `~/.zcode/v2/acp-accounts.json` authenticate native requests and quota queries. Manual setup writes only the private bridge file; Desktop settings are preserved. Never logged. OAuth remains handled by ZCode |
|
|
385
|
+
| Disk | No new files unless you run `zcode-acp setup`. Setup writes the owner-only (0600) `~/.zcode/v2/acp-accounts.json` by atomic replacement, with a transient `acp-accounts.json.lock` directory and `.tmp` file while it saves. Otherwise writes only to the existing `~/.zcode/v2/tasks-index.sqlite` — this **syncs sessions to the ZCode app** so they appear in its history list and full-text search (stores the session title and first prompt) |
|
|
386
|
+
| Logging | Diagnostics to stderr for troubleshooting bridge issues. Even with `ZCODE_ACP_DEBUG=1`, no prompts/code/keys are ever logged |
|
|
349
387
|
|
|
350
388
|
## License
|
|
351
389
|
|
package/README.zh-CN.md
CHANGED
|
@@ -137,22 +137,22 @@ ZCode CLI 内置于桌面应用中,默认不会加到 `PATH`。用 `ZCODE_BIN`
|
|
|
137
137
|
下表中所有 `ZCODE_ACP_*` 偏好类变量都有对应的配置文件字段(见
|
|
138
138
|
[用户配置文件](#用户配置文件)),文件值优先。
|
|
139
139
|
|
|
140
|
-
| 变量 | 默认值 | 用途
|
|
141
|
-
| ---------------------------------- | ---------------- |
|
|
142
|
-
| `ZCODE_BIN` | `zcode` | ZCode CLI 二进制文件路径或其 `.cjs` 入口
|
|
143
|
-
| `ZCODE_NODE` | _(自动发现)_ | 显式指定运行 `ZCODE_BIN` 的 Node 二进制(必须支持 `node:sqlite`)
|
|
144
|
-
| `ZCODE_MODEL` | _(来自 config) | 覆盖当前使用的模型 id
|
|
145
|
-
| `ZCODE_DISALLOWED_TOOLS` | _(Cron 工具)_ |
|
|
146
|
-
| `ZCODE_ENABLE_AUTOMATION_TOOLS` | _(未设置) | 设为 `1` 取消对 Cron* 工具的默认禁用——仅对真正实现了后端 `automation/*` 端口的宿主有意义。
|
|
147
|
-
| `ZCODE_ACP_AUTO_COMPACT_THRESHOLD` | _(未设置) | 触发自动压缩的绝对 token 阈值。每次回合成功完成后(`end_turn`),若 `contextUsed >= 阈值`,服务端会自动调用 `session/compact` 压缩上下文,为下一个 prompt 腾出空间。设为 `0` 或不设置则禁用(默认)。例如 `240000` 表示上下文达 24 万 token 时触发压缩。压缩目标由 ZCode 后端决定。
|
|
148
|
-
| `ZCODE_ACP_DEBUG` | _(未设置) | 设为 `1` 可开启详细诊断日志(事件流、探测循环、状态更新)。默认安静——只输出警告类日志(后端管道错误、命令/权限失败、锁等待超时)。诊断桥接问题时开启;日志出现在 `Zed.log` 中,前缀为 `[zcode-acp]`。
|
|
149
|
-
| `ZCODE_ACP_REMOTE` | _(未设置)_ | 设为 `1` 启用[远程访问](#远程访问)——通过 WebSocket 向更多 ACP 客户端提供相同会话。
|
|
150
|
-
| `ZCODE_ACP_REMOTE_TOKEN` | _(未设置)_ | 远程访问的鉴权 token。启用 `ZCODE_ACP_REMOTE=1` 时**必填**;缺失则远程保持禁用。
|
|
151
|
-
| `ZCODE_ACP_HUB_PORT` | `8377` | 机器级 `zcode-acp-hub` 的端口。隧道只映射这一个端口。
|
|
152
|
-
| `ZCODE_ACP_HUB_HOST` | `127.0.0.1` | hub 绑定地址。`0.0.0.0` 会暴露仅 token 保护的明文面——只用于容器化隧道 agent 所在的私网接口(见[远程访问](#远程访问))。
|
|
153
|
-
| `ZCODE_ACP_REMOTE_PORT` | `8378` | bridge ACP 端点的起始回环端口。每个 bridge(每个编辑器窗口)自动递增取下一个空闲端口。
|
|
154
|
-
| `ZCODE_ACP_SANDBOX` | _(未设置)_ | 设为 `1` 全局启用 macOS Seatbelt 沙箱限制 Agent 的文件写入;项目级则在 `<工作区>/.zcode/acp/sandbox.json` 里设 `"enabled": true`(见[沙箱](#沙箱))。
|
|
155
|
-
| `ZCODE_ACP_LANG` | _(继承)_ | 桥的用户可见文案(弹窗、状态/提示行、命令菜单描述)语言:`zh` 或 `en`。未设置时继承 ZCode APP 的语言设置(`~/.zcode/v2/setting.json` 的 `localePreference`/`locale`),再退回 `LC_ALL`/`LC_MESSAGES`/`LANG` 区域设置,默认英文。
|
|
140
|
+
| 变量 | 默认值 | 用途 |
|
|
141
|
+
| ---------------------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
142
|
+
| `ZCODE_BIN` | `zcode` | ZCode CLI 二进制文件路径或其 `.cjs` 入口 |
|
|
143
|
+
| `ZCODE_NODE` | _(自动发现)_ | 显式指定运行 `ZCODE_BIN` 的 Node 二进制(必须支持 `node:sqlite`) |
|
|
144
|
+
| `ZCODE_MODEL` | _(来自 config) | 覆盖当前使用的模型 id |
|
|
145
|
+
| `ZCODE_DISALLOWED_TOOLS` | _(Cron 工具)_ | 以空格或逗号分隔的工具名,从桥接层创建或恢复的每个会话中移除(作为后端的会话级 `toolDenylist` 下发——注册表层面的移除,工具既不会提供给模型也无法执行),并与内置默认值合并——默认禁用 `CronCreate CronList CronUpdate CronDelete`(桥接层无法应答后端的 `automation/*` 客户端请求,这些工具对模型可见但必然失败,见 #192)。`Bash(git *)` 这类规则形式会移除整个工具。后端过旧不认 `toolDenylist` 时告警一次并在无策略下运行。 |
|
|
146
|
+
| `ZCODE_ENABLE_AUTOMATION_TOOLS` | _(未设置) | 设为 `1` 取消对 Cron* 工具的默认禁用——仅对真正实现了后端 `automation/*` 端口的宿主有意义。 |
|
|
147
|
+
| `ZCODE_ACP_AUTO_COMPACT_THRESHOLD` | _(未设置) | 触发自动压缩的绝对 token 阈值。每次回合成功完成后(`end_turn`),若 `contextUsed >= 阈值`,服务端会自动调用 `session/compact` 压缩上下文,为下一个 prompt 腾出空间。设为 `0` 或不设置则禁用(默认)。例如 `240000` 表示上下文达 24 万 token 时触发压缩。压缩目标由 ZCode 后端决定。 |
|
|
148
|
+
| `ZCODE_ACP_DEBUG` | _(未设置) | 设为 `1` 可开启详细诊断日志(事件流、探测循环、状态更新)。默认安静——只输出警告类日志(后端管道错误、命令/权限失败、锁等待超时)。诊断桥接问题时开启;日志出现在 `Zed.log` 中,前缀为 `[zcode-acp]`。 |
|
|
149
|
+
| `ZCODE_ACP_REMOTE` | _(未设置)_ | 设为 `1` 启用[远程访问](#远程访问)——通过 WebSocket 向更多 ACP 客户端提供相同会话。 |
|
|
150
|
+
| `ZCODE_ACP_REMOTE_TOKEN` | _(未设置)_ | 远程访问的鉴权 token。启用 `ZCODE_ACP_REMOTE=1` 时**必填**;缺失则远程保持禁用。 |
|
|
151
|
+
| `ZCODE_ACP_HUB_PORT` | `8377` | 机器级 `zcode-acp-hub` 的端口。隧道只映射这一个端口。 |
|
|
152
|
+
| `ZCODE_ACP_HUB_HOST` | `127.0.0.1` | hub 绑定地址。`0.0.0.0` 会暴露仅 token 保护的明文面——只用于容器化隧道 agent 所在的私网接口(见[远程访问](#远程访问))。 |
|
|
153
|
+
| `ZCODE_ACP_REMOTE_PORT` | `8378` | bridge ACP 端点的起始回环端口。每个 bridge(每个编辑器窗口)自动递增取下一个空闲端口。 |
|
|
154
|
+
| `ZCODE_ACP_SANDBOX` | _(未设置)_ | 设为 `1` 全局启用 macOS Seatbelt 沙箱限制 Agent 的文件写入;项目级则在 `<工作区>/.zcode/acp/sandbox.json` 里设 `"enabled": true`(见[沙箱](#沙箱))。 |
|
|
155
|
+
| `ZCODE_ACP_LANG` | _(继承)_ | 桥的用户可见文案(弹窗、状态/提示行、命令菜单描述)语言:`zh` 或 `en`。未设置时继承 ZCode APP 的语言设置(`~/.zcode/v2/setting.json` 的 `localePreference`/`locale`),再退回 `LC_ALL`/`LC_MESSAGES`/`LANG` 区域设置,默认英文。 |
|
|
156
156
|
|
|
157
157
|
## 沙箱
|
|
158
158
|
|
|
@@ -265,12 +265,12 @@ commit 约定和 PR 检查清单。重要变更记录在 [CHANGELOG.md](CHANGELO
|
|
|
265
265
|
你的提示词、代码、文件内容通过**本地管道**在编辑器与 ZCode 后端之间中转;这些数据会到达
|
|
266
266
|
GLM 云端 API,仅因 ZCode 后端本身为推理而发送——本服务端不增加任何额外去向。
|
|
267
267
|
|
|
268
|
-
| 方面 | 做什么 & 为什么
|
|
269
|
-
| ---- |
|
|
270
|
-
| 网络 | 全代码库仅一处对外请求:配额 GET(`open.bigmodel.cn` / `api.z.ai`),只带 API key —— 为查询用量数字,不发送用户内容
|
|
271
|
-
| 凭据 |
|
|
272
|
-
| 磁盘 |
|
|
273
|
-
| 日志 | 诊断信息输出到 stderr,用于排查桥接问题。即使开启 `ZCODE_ACP_DEBUG=1`,也绝不记录提示词/代码/密钥
|
|
268
|
+
| 方面 | 做什么 & 为什么 |
|
|
269
|
+
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
270
|
+
| 网络 | 全代码库仅一处对外请求:配额 GET(`open.bigmodel.cn` / `api.z.ai`),只带 API key —— 为查询用量数字,不发送用户内容 |
|
|
271
|
+
| 凭据 | Desktop 凭据或仅所有者可读写的 `~/.zcode/v2/acp-accounts.json` 用于认证原生请求和配额查询。手动 setup 只写入这个私有文件,不修改 Desktop 设置。从不记录日志。OAuth 仍由 ZCode 处理 |
|
|
272
|
+
| 磁盘 | 除非运行 `zcode-acp setup`,否则不创建任何新文件。setup 以原子替换方式写入仅所有者可读写(0600)的 `~/.zcode/v2/acp-accounts.json`,保存期间临时使用 `acp-accounts.json.lock` 目录和 `.tmp` 文件。其余只写入已存在的 `~/.zcode/v2/tasks-index.sqlite` —— 这是**将会话同步到 ZCode App**,使其出现在历史列表和全文搜索中(存会话标题和首条提示词) |
|
|
273
|
+
| 日志 | 诊断信息输出到 stderr,用于排查桥接问题。即使开启 `ZCODE_ACP_DEBUG=1`,也绝不记录提示词/代码/密钥 |
|
|
274
274
|
|
|
275
275
|
## 许可证
|
|
276
276
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReadStream, WriteStream } from "node:tty";
|
|
2
|
+
/** Read a bounded ASCII key without echo, restoring terminal state on every exit. */
|
|
3
|
+
export declare function readHiddenApiKey(input: ReadStream, output: Pick<WriteStream, "write">): Promise<string>;
|
|
4
|
+
export declare function runAccountSetup(args: string[], input?: NodeJS.ReadStream & {
|
|
5
|
+
fd: 0;
|
|
6
|
+
}, output?: NodeJS.WriteStream & {
|
|
7
|
+
fd: 2;
|
|
8
|
+
}): Promise<void>;
|
|
9
|
+
//# sourceMappingURL=account-setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-setup.d.ts","sourceRoot":"","sources":["../src/account-setup.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AASxD,qFAAqF;AACrF,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,GACjC,OAAO,CAAC,MAAM,CAAC,CAmDjB;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EAAE,EACd,KAAK;;CAAgB,EACrB,MAAM;;CAAiB,GACtB,OAAO,CAAC,IAAI,CAAC,CAkBf"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/** Manual terminal setup; no interactive ACP authentication is advertised. */
|
|
2
|
+
import { emitKeypressEvents } from "node:readline";
|
|
3
|
+
import { codingPlanCatalog, readBridgeAccounts, saveBridgeAccount, } from "./config/bridge-accounts.js";
|
|
4
|
+
/** Read a bounded ASCII key without echo, restoring terminal state on every exit. */
|
|
5
|
+
export function readHiddenApiKey(input, output) {
|
|
6
|
+
if (!input.isTTY || typeof input.setRawMode !== "function")
|
|
7
|
+
return Promise.reject(new Error("Run account setup in an interactive terminal"));
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
const wasRaw = input.isRaw;
|
|
10
|
+
// A fresh stdin has readableFlowing=null even though isPaused() is false.
|
|
11
|
+
// Starting reads must not leave that otherwise idle handle alive after setup.
|
|
12
|
+
const wasFlowing = input.readableFlowing === true;
|
|
13
|
+
let value = "";
|
|
14
|
+
let done = false;
|
|
15
|
+
const finish = (error) => {
|
|
16
|
+
if (done)
|
|
17
|
+
return;
|
|
18
|
+
done = true;
|
|
19
|
+
input.off("keypress", onKey);
|
|
20
|
+
input.off("end", onEnd);
|
|
21
|
+
input.off("error", onError);
|
|
22
|
+
input.setRawMode(wasRaw);
|
|
23
|
+
if (!wasFlowing) {
|
|
24
|
+
input.pause();
|
|
25
|
+
// Pausing consumption alone can leave stdin referenced by Node.
|
|
26
|
+
input.unref?.();
|
|
27
|
+
}
|
|
28
|
+
output.write("\n");
|
|
29
|
+
if (error)
|
|
30
|
+
reject(error);
|
|
31
|
+
else
|
|
32
|
+
resolve(value);
|
|
33
|
+
value = "";
|
|
34
|
+
};
|
|
35
|
+
const onEnd = () => finish(new Error("Account setup cancelled"));
|
|
36
|
+
const onError = () => finish(new Error("Cannot read terminal input"));
|
|
37
|
+
const onKey = (text, key) => {
|
|
38
|
+
if (key.ctrl && (key.name === "c" || key.name === "d"))
|
|
39
|
+
return onEnd();
|
|
40
|
+
if (key.name === "return" || key.name === "enter")
|
|
41
|
+
return finish();
|
|
42
|
+
if (key.name === "backspace") {
|
|
43
|
+
value = value.slice(0, -1);
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (key.ctrl || key.meta || !text)
|
|
47
|
+
return;
|
|
48
|
+
if (!/^[!-~]+$/u.test(text))
|
|
49
|
+
return finish(new Error("Invalid Coding Plan API key"));
|
|
50
|
+
if (value.length + text.length > 4096)
|
|
51
|
+
return finish(new Error("Coding Plan API key is too long"));
|
|
52
|
+
value += text;
|
|
53
|
+
};
|
|
54
|
+
emitKeypressEvents(input);
|
|
55
|
+
input.on("keypress", onKey);
|
|
56
|
+
input.once("end", onEnd);
|
|
57
|
+
input.once("error", onError);
|
|
58
|
+
output.write("Coding Plan API key (hidden): ");
|
|
59
|
+
input.setRawMode(true);
|
|
60
|
+
if (!wasFlowing)
|
|
61
|
+
input.ref?.();
|
|
62
|
+
input.resume();
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export async function runAccountSetup(args, input = process.stdin, output = process.stderr) {
|
|
66
|
+
const parts = args.length === 1 ? args[0].split("=") : args;
|
|
67
|
+
if (parts.length !== 2 || parts[0] !== "--provider" || !["zai", "bigmodel"].includes(parts[1]))
|
|
68
|
+
throw new Error("Usage: zcode-acp setup --provider zai|bigmodel");
|
|
69
|
+
const family = parts[1];
|
|
70
|
+
if (!input.isTTY || !output.isTTY)
|
|
71
|
+
throw new Error("Run account setup in an interactive terminal");
|
|
72
|
+
// Refuse before asking for a secret that could not be used or saved.
|
|
73
|
+
codingPlanCatalog(family);
|
|
74
|
+
readBridgeAccounts();
|
|
75
|
+
output.write("Use your individual Coding Plan API key. This saves a private bridge account; Desktop settings are preserved.\n");
|
|
76
|
+
const apiKey = await readHiddenApiKey(input, output);
|
|
77
|
+
await saveBridgeAccount(family, apiKey);
|
|
78
|
+
output.write("Bridge account saved. Restart connected clients; the first model request verifies the key.\n");
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=account-setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"account-setup.js","sourceRoot":"","sources":["../src/account-setup.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAInD,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,6BAA6B,CAAC;AAGrC,qFAAqF;AACrF,MAAM,UAAU,gBAAgB,CAC9B,KAAiB,EACjB,MAAkC;IAElC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,OAAO,KAAK,CAAC,UAAU,KAAK,UAAU;QACxD,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC,CAAC;IACnF,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC;QAC3B,0EAA0E;QAC1E,8EAA8E;QAC9E,MAAM,UAAU,GAAG,KAAK,CAAC,eAAe,KAAK,IAAI,CAAC;QAClD,IAAI,KAAK,GAAG,EAAE,CAAC;QACf,IAAI,IAAI,GAAG,KAAK,CAAC;QACjB,MAAM,MAAM,GAAG,CAAC,KAAa,EAAE,EAAE;YAC/B,IAAI,IAAI;gBAAE,OAAO;YACjB,IAAI,GAAG,IAAI,CAAC;YACZ,KAAK,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;YAC7B,K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AAE,CAAC;QAC7F,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAqB,CAAC;IAC5C,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,KAAK;QAC/B,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAClE,qEAAqE;IACrE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC1B,kBAAkB,EAAE,CAAC;IACrB,MAAM,CAAC,KAAK,CACV,iHAAiH,CAClH,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IACrD,MAAM,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,CACV,8FAA8F,CAC/F,CAAC;AACJ,CAAC"}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* Vendored from the reference Python implementation so this package stays
|
|
5
5
|
* self-contained. The ZCode desktop app stores provider credentials in
|
|
6
6
|
* `~/.zcode/v2/config.json`; GUI-launched processes don't inherit shell env
|
|
7
|
-
* vars, so we read
|
|
8
|
-
* the subprocess environment.
|
|
7
|
+
* vars, so we read Desktop config plus optional bridge accounts and inject
|
|
8
|
+
* the active provider's settings into the subprocess environment.
|
|
9
9
|
*/
|
|
10
10
|
/** Credentials extracted from the active provider. */
|
|
11
11
|
export interface ZcodeCredentials {
|
|
@@ -22,7 +22,7 @@ export interface ZcodeCredentials {
|
|
|
22
22
|
*/
|
|
23
23
|
providerBaseURL?: string;
|
|
24
24
|
}
|
|
25
|
-
/** Read the active provider
|
|
25
|
+
/** Read the active provider from Desktop config plus optional bridge accounts. */
|
|
26
26
|
export declare function loadZcodeCredentials(): ZcodeCredentials;
|
|
27
27
|
/**
|
|
28
28
|
* Merge process.env with config credentials.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/backend/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmBH,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/backend/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmBH,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;;;;OAQG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,kFAAkF;AAClF,wBAAgB,oBAAoB,IAAI,gBAAgB,CA+BvD;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAAC,UAAU,CAc5E"}
|
|
@@ -4,17 +4,17 @@
|
|
|
4
4
|
* Vendored from the reference Python implementation so this package stays
|
|
5
5
|
* self-contained. The ZCode desktop app stores provider credentials in
|
|
6
6
|
* `~/.zcode/v2/config.json`; GUI-launched processes don't inherit shell env
|
|
7
|
-
* vars, so we read
|
|
8
|
-
* the subprocess environment.
|
|
7
|
+
* vars, so we read Desktop config plus optional bridge accounts and inject
|
|
8
|
+
* the active provider's settings into the subprocess environment.
|
|
9
9
|
*/
|
|
10
|
-
import { readFileSync } from "node:fs";
|
|
11
10
|
import process from "node:process";
|
|
11
|
+
import { readCredentialConfig } from "../config/bridge-accounts.js";
|
|
12
12
|
import { DEFAULT_MODEL_ID, providerSelectable } from "../config/options.js";
|
|
13
13
|
import { log, ZCODE_CREDS_PATH } from "../utils.js";
|
|
14
|
-
/** Read the active provider
|
|
14
|
+
/** Read the active provider from Desktop config plus optional bridge accounts. */
|
|
15
15
|
export function loadZcodeCredentials() {
|
|
16
16
|
try {
|
|
17
|
-
const cfg =
|
|
17
|
+
const cfg = readCredentialConfig(ZCODE_CREDS_PATH);
|
|
18
18
|
// ZCODE_PROVIDER pins the provider by id; unset keeps the historical
|
|
19
19
|
// "first enabled provider wins" behaviour.
|
|
20
20
|
const pinned = process.env.ZCODE_PROVIDER;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/backend/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/backend/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA6BpD,kFAAkF;AAClF,MAAM,UAAU,oBAAoB;IAClC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,oBAAoB,CAAC,gBAAgB,CAAgB,CAAC;QAClE,qEAAqE;QACrE,2CAA2C;QAC3C,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;QAC1C,KAAK,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,EAAE,CAAC,EAAE,CAAC;YACjE,gEAAgE;YAChE,oEAAoE;YACpE,sEAAsE;YACtE,mEAAmE;YACnE,+DAA+D;YAC/D,oEAAoE;YACpE,IAAI,CAAC,MAAM,IAAI,CAAC,kBAAkB,CAAC,UAAU,EAAE,CAA6C,CAAC;gBAC3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U;YACpF,wGAAwG,CAC3G,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -40,12 +40,22 @@ export declare const PERSONAL_PROVIDER_ENV = "ZCODE_PERSONAL_PROVIDER_CONFIG_FIL
|
|
|
40
40
|
*/
|
|
41
41
|
export declare function builtinProviderEnv(entryArg?: string): NodeJS.ProcessEnv;
|
|
42
42
|
export declare function zcodeDataBaseDirEnv(): NodeJS.ProcessEnv;
|
|
43
|
+
/**
|
|
44
|
+
* The same merged disallow list as an array — the shape the per-session
|
|
45
|
+
* `toolDenylist` param takes (handlers/session.ts). Empty when nothing is
|
|
46
|
+
* disallowed. Deduped; the user's entries come first, then the defaults.
|
|
47
|
+
*/
|
|
48
|
+
export declare function disallowedToolList(): string[];
|
|
43
49
|
/**
|
|
44
50
|
* The backend subcommand and its flags, shared by every launch path.
|
|
45
51
|
*
|
|
46
52
|
* `ZCODE_DISALLOWED_TOOLS` is merged with the default Cron* disallow list
|
|
47
53
|
* (see AUTOMATION_TOOL_DEFAULTS) and passed as the app-server's
|
|
48
|
-
* `--disallowed-tools` value; unset means only the defaults.
|
|
54
|
+
* `--disallowed-tools` value; unset means only the defaults. NOTE the
|
|
55
|
+
* app-server command path parses this flag but never consumes it (upstream
|
|
56
|
+
* cli/src/run.ts routes `toolDisallowlist` to the prompt/TUI paths only), so
|
|
57
|
+
* the EFFECTIVE channel is the per-session `toolDenylist` on session/create
|
|
58
|
+
* and session/resume (#340). The flag stays for a future CLI that wires it.
|
|
49
59
|
*/
|
|
50
60
|
export declare function backendArgs(): string[];
|
|
51
61
|
/** Resolve the full argv to launch `zcode app-server --stdio`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/backend/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA+HH,eAAO,MAAM,oBAAoB,uCAAuC,CAAC;AACzE,eAAO,MAAM,qBAAqB,wCAAwC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAgBvE;AAyBD,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,UAAU,CAevD;AA8CD
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/backend/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AA+HH,eAAO,MAAM,oBAAoB,uCAAuC,CAAC;AACzE,eAAO,MAAM,qBAAqB,wCAAwC,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,UAAU,CAgBvE;AAyBD,wBAAgB,mBAAmB,IAAI,MAAM,CAAC,UAAU,CAevD;AA8CD;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,EAAE,CAG7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,IAAI,MAAM,EAAE,CAGtC;AAED,kEAAkE;AAClE,wBAAgB,mBAAmB,IAAI,MAAM,EAAE,CA4B9C"}
|
package/dist/backend/resolve.js
CHANGED
|
@@ -263,12 +263,25 @@ function disallowedToolsValue() {
|
|
|
263
263
|
const merged = [...new Set([...user, ...AUTOMATION_TOOL_DEFAULTS])];
|
|
264
264
|
return merged.length > 0 ? merged.join(" ") : undefined;
|
|
265
265
|
}
|
|
266
|
+
/**
|
|
267
|
+
* The same merged disallow list as an array — the shape the per-session
|
|
268
|
+
* `toolDenylist` param takes (handlers/session.ts). Empty when nothing is
|
|
269
|
+
* disallowed. Deduped; the user's entries come first, then the defaults.
|
|
270
|
+
*/
|
|
271
|
+
export function disallowedToolList() {
|
|
272
|
+
const value = disallowedToolsValue();
|
|
273
|
+
return value ? [...new Set(value.split(/[,\s]+/).filter(Boolean))] : [];
|
|
274
|
+
}
|
|
266
275
|
/**
|
|
267
276
|
* The backend subcommand and its flags, shared by every launch path.
|
|
268
277
|
*
|
|
269
278
|
* `ZCODE_DISALLOWED_TOOLS` is merged with the default Cron* disallow list
|
|
270
279
|
* (see AUTOMATION_TOOL_DEFAULTS) and passed as the app-server's
|
|
271
|
-
* `--disallowed-tools` value; unset means only the defaults.
|
|
280
|
+
* `--disallowed-tools` value; unset means only the defaults. NOTE the
|
|
281
|
+
* app-server command path parses this flag but never consumes it (upstream
|
|
282
|
+
* cli/src/run.ts routes `toolDisallowlist` to the prompt/TUI paths only), so
|
|
283
|
+
* the EFFECTIVE channel is the per-session `toolDenylist` on session/create
|
|
284
|
+
* and session/resume (#340). The flag stays for a future CLI that wires it.
|
|
272
285
|
*/
|
|
273
286
|
export function backendArgs() {
|
|
274
287
|
const disallowed = disallowedToolsValue();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../src/backend/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAEnE,oEAAoE;AACpE,SAAS,SAAS,CAAC,GAAW;IAC5B,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC,GAAG,CAAC,EAAE;YACvC,QAAQ,EAAE,MAAM;YAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC;SACpC,CAAC,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,GAAG,IAAI,IAAI,CAA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,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,gBAAgB,EAAE,IAAI,OAAO,CAAC;IACxE,uFAAuF;IACvF,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtC,OAAO,CAAC,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,+EAA+E;IAC/E,KAAK,MAAM,OAAO,IAAI,qBAAqB,EAAE,EAAE,CAAC;QAC9C,IAAI,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;YAChC,IAAI,GAAG,GAAG,GAAG,CAAC;YACd,IAAI,CAAC;gBACH,uEAAuE;gBACvE,GAAG,GAAG,YAAY,CAAC,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE;oBACzC,QAAQ,EAAE,MAAM;oBAChB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;iBAClC,CAAC,CAAC,IAAI,EAAE,CAAC;YACZ,CAAC;YAAC,MAAM,CAAC;gBACP,WAAW;YACb,CAAC;YACD,GAAG,CAAC,sCAAsC,OAAO,KAAK,GAAG,GAAG,CAAC,CAAC;YAC9D,OAAO,CAAC,OAAO,EAAE,GAAG,iBAAiB,EAAE,EAAE,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;IACD,GAAG,CACD,qFAAqF;QACnF,6BAA6B,CAChC,CAAC;IACF,OAAO,CAAC,QAAQ,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC;AACtC,CAAC"}
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;GAWG;AAaH,sFAAsF;AACtF,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAChB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,KAAK,CAAA;CAAE,GACf;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAErC;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAwBxF"}
|
package/dist/cli.js
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { basename } from "node:path";
|
|
15
15
|
import process from "node:process";
|
|
16
|
+
import { runAccountSetup } from "./account-setup.js";
|
|
16
17
|
import { main as runHub } from "./bin/hub.js";
|
|
17
18
|
import { main as runQuota } from "./bin/quota.js";
|
|
18
19
|
import { main as runServer, runHeadless } from "./index.js";
|
|
@@ -46,6 +47,8 @@ export function resolveInvocation(invokedAs, argv) {
|
|
|
46
47
|
return { kind: "serve" };
|
|
47
48
|
case "hub":
|
|
48
49
|
return { kind: "hub" };
|
|
50
|
+
case "setup":
|
|
51
|
+
return { kind: "setup", args: argv.slice(1) };
|
|
49
52
|
case "quota":
|
|
50
53
|
return { kind: "quota", args: argv.slice(1) };
|
|
51
54
|
default:
|
|
@@ -61,6 +64,8 @@ Commands:
|
|
|
61
64
|
(none) | tui Interactive agent chat (Martty TUI): stream output,
|
|
62
65
|
tool rows, model picker, session resume. /exit quits.
|
|
63
66
|
'tui --check' runs a headless wiring check and exits.
|
|
67
|
+
setup --provider zai|bigmodel
|
|
68
|
+
Save an individual Coding Plan API key (hidden terminal input).
|
|
64
69
|
quota [args...] Plan usage cards (was the zcode-quota bin): -w watch,
|
|
65
70
|
-i <sec>, -d detail, -p plain, provider glm|go.
|
|
66
71
|
hub Run the remote-access hub daemon (was zcode-acp-hub;
|
|
@@ -88,7 +93,7 @@ async function main() {
|
|
|
88
93
|
// Long-running surfaces hand over to `bun --smol` when available (idle RSS
|
|
89
94
|
// ~47 MB vs ~81 MB on Node); the instant paths (help/version/unknown) skip
|
|
90
95
|
// the re-exec hop entirely.
|
|
91
|
-
if (invocation.kind !== "help" && invocation.kind !== "unknown") {
|
|
96
|
+
if (invocation.kind !== "help" && invocation.kind !== "unknown" && invocation.kind !== "setup") {
|
|
92
97
|
if (await reexecToBunIfEligible(process.argv[1] ?? "", process.argv.slice(2)))
|
|
93
98
|
return;
|
|
94
99
|
}
|
|
@@ -124,6 +129,9 @@ async function main() {
|
|
|
124
129
|
case "hub":
|
|
125
130
|
await runHub();
|
|
126
131
|
return;
|
|
132
|
+
case "setup":
|
|
133
|
+
await runAccountSetup(invocation.args);
|
|
134
|
+
return;
|
|
127
135
|
case "quota":
|
|
128
136
|
await runQuota(invocation.args);
|
|
129
137
|
return;
|