Repository navigation
Description
提交前确认 · Pre-submission checklist
- 我已搜索过现有 issue,确认这不是重复 / I searched existing issues and confirmed this isn't a duplicate.
- 我已阅读 CONTRIBUTING.md / I've read CONTRIBUTING.md.
问题类别 · Category
稳定性 / 崩溃 · Stability / Crash
涉及的 Agent 框架 · Agent framework
ZCode Agent(自研)
严重程度 · Severity
阻塞使用 · Blocking (无法使用核心功能 / core function unusable)
复现频率 · Reproducibility
必现 · Always
问题描述 · Description
Paid GLM Coding Lite subscriber. GLM-5.2 and the plan are healthy, but ZCode 3.1.6 fails through EVERY entry point — desktop GUI AND terminal CLI. 4 distinct, reproducible bugs:
- Desktop:
write EPIPEon long / webReader tasks; work is lost; EPIPE is not retried. - Desktop: blank/black renderer, even after a clean restart.
- CLI (TUI): missing package
@zcode/tui(absent from the entire install). - CLI login:
OAuth response is not valid JSON(instant failure).
This is NOT quota / account / network / model: a direct call to the Anthropic-compatible endpoint returns HTTP 200, a long streaming reply completes cleanly with no EPIPE, the plan shows as "available", and quota is 96% (5h) / 99% (weekly) free. So the failures are inside the ZCode client / distribution. (Full evidence + IDs in the Logs field below.)
复现步骤 · Steps to reproduce
A) CLI login (clearest — instant):
- In Terminal, run: node "/Applications/ZCode.app/Contents/Resources/glm/zcode.cjs" login
- It fails immediately with: "Error: OAuth response is not valid JSON" (same with --no-browser; no browser ever opens).
B) CLI TUI:
- Run the CLI with no arguments (i.e. open the TUI).
- It fails with: "Cannot find package '@zcode/tui'".
C) Desktop EPIPE + blank renderer:
- Start a long task with webReader / high context (GLM-5.2) in the desktop app.
- After a while it dies with "Cannot connect to API: write EPIPE"; nothing is saved to disk.
- Reopen that conversation, or fully restart the app: the window stays blank and never renders the UI.
期望表现 · Expected behavior
- Desktop runs long tasks without aborting (retry on transient socket close), and renders the UI after a restart.
- The CLI TUI starts (the @zcode/tui package should be shipped in the distribution).
zcode logincompletes the OAuth flow successfully.
实际表现 · Actual behavior
- Desktop: "Cannot connect to API: write EPIPE" (provider=builtin:zai-coding-plan, provider_code=EPIPE, retriable=false) on GLM-5.2 AND GLM-5-Turbo; sometimes shows "Worked for 0s"; unsaved work is lost. The window then stays blank/black after restart.
- CLI (TUI): Error: Cannot find package '@zcode/tui' imported from /Applications/ZCode.app/Contents/Resources/glm/zcode.cjs
- CLI login: Error: OAuth response is not valid JSON — instant, in a real TTY, repeated, never opens a browser. Because login fails, headless --prompt then fails with: "Model config is missing. Create ~/.zcode/cli/config.json ...".
ZCode 版本 · ZCode version
3.1.6 (desktop app); CLI bundle zcode.cjs 0.14.9
设备 / 系统 / 浏览器 · Device / OS / Browser
MacBook Air, Apple Silicon (arm64), macOS
截图 / 录屏 / 日志 · Screenshots / Recordings / Logs
Reference identifiers (one failing session):
TraceID: 4ec84c28-5e2a-4537-b7f0-241d2419bf43
Request ID: 0b40c9a9-1876-489e-bfb9-29cfc223ef51
Evidence it is client-side (NOT model / plan / network):
- Direct POST https://api.z.ai/api/anthropic/v1/messages (glm-5.2) -> HTTP 200.
- A long streaming (SSE) reply (2000 tokens, ~255KB, ~42s) completed cleanly to message_stop, curl exit 0, no EPIPE.
- coding-plan-cache.json: builtin:zai-coding-plan = "available"; quota 5h 96% / weekly 99% free.
@zcode/tui verified ABSENT from the whole install: not in glm/packages, not in app.asar, not in app.asar.unpacked, no node_modules next to the bundle.
Account email available privately on request.
Activity
github-actions commentedon Jun 26, 2026
👋 感谢你的反馈,我们已经收到。
status: 待评估,你可以随时补充信息。needs: 更多信息标签并 @ 你。👋 Thanks — we've received your issue.
status: 待评估(Triage); feel free to add context.needs: 更多信息and ping you.m11a-dev commentedon Jul 24, 2026
Reproduced on ZCode 0.15.2, darwin/arm64. The
loginfailure is instant (no browser opens, no callback server starts) because the endpoint the CLI hits first no longer exists.Root cause
The login flow's initial call is
POST https://api.z.ai/oauth/cli/init(bundle string:`${t}/oauth/cli/init`). That path — and the entire/oauth/namespace onapi.z.ai— now returns a nginx404 Not FoundHTML page. The CLI doesJSON.parse()on that HTML body and throws:Repro (no auth, no CLI needed)
Every
/oauth/*path returns the same 404 HTML (/oauth/cli/init,/oauth/cli/poll/*,/oauth/authorize,/oauth/token).What still works
/api/auth/z/loginonapi.z.aireturns HTTP 200 JSON (the auth-code flow the desktop GUI uses), and the desktop app authenticates fine — it's only the CLIlogincommand that points at the dead/oauth/cli/*paths.Impact
Every headless entrypoint (
zcode login, and thereforezcode --prompt/zcode app-server) can't acquire credentials, because the headless config store (~/.zcode/cli/) never gets populated by the OAuth flow. This blocks all headless/programmatic use.Suggested fix
The login flow should either point at the live
/api/auth/*endpoints the desktop client uses, or confirm whether/oauth/cli/*was intentionally retired andloginneeds a new flow.Flo5k5 commentedon Aug 4, 2026
Reproducing the exact same symptom on macOS (Apple Silicon), ZCode CLI 0.16.1:
Fails instantly (no browser window opens), same as reported above. Desktop app session is fine (GLM-5.2 working normally, active
builtin:zai-coding-planprovider, thousands of calls this week), so this is specifically the bare CLI login flow that's broken — confirms it's not account/quota/network related on my end either.Blocking use case: scripting
zcode -pheadlessly from another tool (subprocess dispatch) requires a CLI-level authenticated session distinct from the desktop app's, which this bug prevents from ever being established.Flo5k5 commentedon Aug 4, 2026
Found the root cause and a workaround, for anyone else blocked on this.
Root cause (from disassembling
zcode.cjs): the headless bootstrap (resolveAppRuntimeConfig→requireRuntimeModelConfig) requiresconfig.modelto already be explicitly set:The desktop app resolves this dynamically at runtime (picks the first
enabled:trueprovider), but the bare CLI bootstrap has no such fallback — and sincezcode loginis broken (this issue), there's no way to populate it through the normal flow either.Workaround: the CLI also has a
parseEnvConfigmodule that readsZCODE_-prefixed env vars and bypasses the config file entirely:Notes:
ANTHROPIC_API_KEYis used because thezai-coding-planprovider haskind:"anthropic"internally — it's read via the generic Anthropic-auth code path, unrelated to the real Anthropic API.~/.zcode/v2/config.jsonunderprovider.builtin:zai-coding-plan.options.apiKey(the desktop app's real session store — separate from~/.zcode/cli/that the bare CLI defaults to), so no new credential is needed, just surfacing the existing one via env var.exit 0) with GLM-5.2. It's a workaround, not a fix —zcode loginitself should still be repaired so this isn't necessary.guanbear commentedon Aug 12, 2026
Reproduced on ZCode Desktop 3.7.5 / bundled CLI 0.16.1 / macOS arm64. The desktop app and headless CLI work in this environment, so this isolates the remaining CLI packaging problem from the original desktop/auth failures.
TUI still cannot start
Both entry points fail:
m11a-dev commentedon Aug 14, 2026
Update 2026-08-14, CLI 0.16.3 —
loginnow targets the newzcode.z.ai/api/v1gateway, and only itsoauth/cli/*routes are missingThe 0.16.3 bundle points the device-style OAuth flow at the new gateway (
apiBaseUrl = https://zcode.z.ai/api/v1):POST https://zcode.z.ai/api/v1/oauth/cli/initGET https://zcode.z.ai/api/v1/oauth/cli/poll/<flowId>(Bearer poll token)Current server state, no auth needed to reproduce:
The second probe is the interesting one: on the same gateway, same
/api/v1prefix, the CLI's own plan-billing routes (/api/v1/zcode-plan/billing/balance,/billing/current) return401— route mounted, auth required — whileoauth/cli/init/oauth/cli/poll/*return404 page not found. The oldhttps://api.z.ai/oauth/*namespace is still nginx-404 too. So the new gateway is clearly live and selectively routed; only the OAuth CLI routes are absent.zcode loginstill fails instantly withOAuth response is not valid JSONon 0.16.3.Two questions:
oauth/cli/*missing from the new gateway by accident (rollout gap), or was CLI OAuth intentionally retired? If retired — what is the intendedzcode loginflow for 0.16.x?ZCODE_BASE_URL=https://api.z.ai/api/anthropic+ the coding-plan provider's API key from the desktop config) the supported interim path — and does it consume Coding Plan quota rather than pay-as-you-go credits? The configuration docs note/api/anthropic"stops billing against balance once a Coding Plan was ever purchased", which reads as plan billing; a confirmation would unblock scripted use for subscribers.This thread now has independent repros on 0.15.2, 0.16.1, and 0.16.3, and the issue has sat at
status: 待评估for ~3 weeks — any triage update appreciated.中文摘要
0.16.3 的
login指向新网关zcode.z.ai/api/v1:其oauth/cli/init、oauth/cli/poll/*返回 404,而同网关同前缀的/api/v1/zcode-plan/billing/*返回 401(路由存在、需鉴权)——疑似新网关缺少 OAuth CLI 路由的挂载。请问是上线遗漏还是有意下线?若下线,0.16.x 的 CLI 登录应走哪条流程?另外请确认:Coding Plan 订阅用户用https://api.z.ai/api/anthropic+ 计划内 API key 做 headless 调用,是否计入 Coding Plan 配额而非按量计费余额?yule1991 commentedon Aug 22, 2026
补充一个数据点:本 issue 第 3 条症状(CLI/TUI 报
Cannot find package '@zcode/tui')在 App 3.8.1(内置 zcode.cjs 0.16.3,macOS arm64) 下仍然存在。复现步骤:
~/.local/bin/zcode是指向/Applications/ZCode.app/Contents/Resources/glm/zcode.cjs的符号链接(由桌面版创建)zcode或zcode tui:glm/下没有node_modules/@zcode/tui;app.asar.unpacked/node_modules只有 node-pty 和 ssh2;~/.zcode运行时目录、公网与内网 npm registry 上均无此包不受影响的部分:
zcode --prompt(headless)、zcode skills list、zcode doctor等子命令正常,桌面 App 本身正常——问题只影响终端 TUI 入口。建议:
@zcode/tui随glm/一起打包(或改为懒加载/失败降级),保证入口文件引用的依赖随包分发~/.local/bin/zcode指向 App 包内文件,App 自动更新会原地替换它,建议更新流程对内置 CLI 做完整性校验,或改为安装独立的 CLI 启动器(与 [建议 / Feature] 桌面版自带 CLI 的 tui 不可用(缺 @zcode/tui 包),并请求独立 CLI 发行版 #270 的建议一致)环境:macOS(Apple Silicon,darwin 25.6.0)/ ZCode App 3.8.1 / 内置 CLI 0.16.3
TerrysPOV commentedon Oct 4, 2026
Still reproducible on the latest build: ZCode Desktop 3.14.4 / bundled CLI 0.16.9, macOS arm64.
Same setup as the earlier reports:
~/.local/bin/zcodeis a symlink intoZCode.app/Contents/Resources/glm/zcode.cjs.zcode doctorreportssea: no (optional)anddefault artifact: node-bundle, and.node-bundle-meta.jsonsaysruntime: electron-node.What I checked, so nobody has to repeat it:
@zcode/tuiis not underContents/Resources/glm/, and it is not inapp.asareither (I read the asar header; no@zcodepackages at all).npm view @zcode/tuireturns 404, so there is nothing tonpm installas a workaround.brew install --cask zcode(cask is also 3.14.4) and the result is identical.zcode --version,doctorandskills listwork, so only the TUI entry point is affected.Impact: tools that need the interactive TUI cannot use ZCode at all. I hit this trying to run ZCode as an agent inside the Orca IDE, which launches it in interactive mode with yolo permissions. The headless route is not a fallback for Coding Plan users, because
zcode -pcannot use the plan key (see zai-org/zai-coding-plugins#34).Request: please either bundle
@zcode/tuiintoresources/glm/(the entry file imports it, so it has to ship with it) or publish the standalone SEA CLI that #270 asked for. A release-time smoke test that runszcode tuifrom the packaged app would catch this, since it has now been broken across at least 0.15.2, 0.16.1, 0.16.3 and 0.16.9.Related: the same non-SEA entry also fails with
Cannot locate CLI ZCode Built-in Provider Config(#855). On macOS I got past that one by symlinkingResources/config/provider/zcode-builtin.jsonnext to the~/.local/bin/zcodeentry, but there is no equivalent workaround for the missing TUI package.YFOOOO commentedon Oct 17, 2026
独立复现 + 版本边界更新(2026-10-17,macOS Apple Silicon,ZCode 3.15.1.8093):
/model切模型(见 [Feature] 请把 zcode CLI 当一等公民做完整:无头模式缺模型选择等自动化必需能力,与 TUI 功能明显不对齐 #1044),两条缺陷互相放大。SeveNOlogy7 commentedon Oct 19, 2026
版本边界更新(Windows,Desktop 3.16.1.8696 / 内置 CLI 0.17.0):仍然缺包;并修正一处结论
复现环境:Windows 11 x64(简体中文),ZCode Desktop 3.16.1 (3.16.1.8696),内置 CLI 0.17.0;
zcode doctor报sea: no (optional)/default artifact: node-bundle,.node-bundle-meta.json为runtime: electron-node。结论:3.16.1 仍然不含
@zcode/tui。证据 1 —— 本次更新往
resources\glm实际写入的只有三样:没有
node_modules\@zcode\tui(该目录的时间戳仍是安装前的时间,说明安装器根本没碰过这个路径)。证据 2 —— 0.17.0 的加载逻辑没变:
证据 3 —— 把
node_modules\@zcode\tui临时挪走后立刻复现:挪回来,同一条命令就能进入 TUI(非 tty 下报
TUI requires an interactive terminal.)。一处结论修正(对上一条评论,仅供定位参考)
上一条说「app 升级不带动内置 CLI」。至少在 3.15.3 → 3.16.1 这一次不成立:内置 CLI 从 0.16.9 升到了 0.17.0(
zcode doctor实测)。所以 app 与内置 CLI 的版本会一起走;真正跨版本持续存在的结构性问题,仍然是发布时没有把@zcode/tui放进resources\glm(0.15.2 / 0.16.1 / 0.16.3 / 0.16.9 / 0.17.0 都如此)。另外,同一个非 SEA 入口还缺内置 provider config(#855)—— 我在那边补了定位:App 其实随包发了这个文件,只是 CLI 的候选路径多绕了 4 层。
建议的发布冒烟测试(能一次性拦住这两个问题):
English summary
Confirmed still broken on Desktop 3.16.1 / bundled CLI 0.17.0 (Windows, node-bundle). The update shipped only
zcode.cjs,packages/and.node-bundle-meta.jsonintoresources/glm— no@zcode/tui. 0.17.0'sloadTuiRuntimestill does a bareimport("@zcode/tui")on the non-SEA path, and temporarily moving the package aside reproducesCannot find package '@zcode/tui'verbatim. Also a correction to the previous comment: the bundled CLI did bump with the app this time (0.16.9 → 0.17.0), so "app upgrades don't move the bundled CLI" is not a general rule; the durable structural gap is that@zcode/tuiis never staged intoresources/glmat build time.ci: add zcode-dist workflow to build standalone distribution artifacts
rizkydwicmt commentedon Nov 12, 2026
Root cause confirmed from the public source mirror (
zai-org/ZCode@ v3.18.0):apps/zcode-cli/packages/cli/scripts/build.mjskeeps@zcode/tuiin the esbuildexternallist — Ink 7 / yoga-layout use top-level await, so the CJS bundle loads the TUI via a runtime dynamicimport("@zcode/tui").scripts/zcode-distribution/assets.mjs→collectSeaTuiAssets), butpackages/desktop/scripts/prepare-agent-node-bundle.mjs— which produces what actually ships inZCode.app/Contents/Resources/glm— never stages it. Its header comment says: "app-server 命令路径不会加载 @zcode/tui,所以这里天然不打包 TUI". On the non-SEA path the bare import hits MODULE_NOT_FOUND, and since the package is absent from public npm, users have no legitimate way to obtain it.Proposed fix — branch
fix/stage-tui-runtime-in-bundled-agenton my fork (PRs appear to be disabled on the source mirror):stageTuiRuntimeForGlm()step inprepare-agent-node-bundle.mjs: builds@zcode/tui, reusescollectSeaTuiAssetsto stage the TUI runtime tree (opentui native packages selected per target platform) intobundled-agents/<platform>/glm/node_modules, and asserts the staged package exists so packaging fails loudly instead of shipping a broken TUI;electron-builder.config.js: mapglm/node_modulesas a separate extraResources entry — electron-builder skipsnode_modulesat thefromroot, same root cause already worked around forcua-helperin the same file;Interim workaround for affected users:
pnpm build:zcodefrom the public source mirror produces a complete standalone distribution (agent/zcode.cjs+ staged TUI runtime +bin/zcode.mjsrunner) whose interactive TUI already works —stageTuiRuntime/copyRuntimeNodeModulesinscripts/zcode-distribution/assets.mjsdo the right thing; the desktop bundle just never received the same treatment. I also added azcode-distGitHub Actions workflow on the fork that builds downloadable dist artifacts with a smoke test asserting the staged TUI runtime exists inside the tarball — the release smoke test proposed in this thread would have caught this gap across all affected versions.Futuri-Risk commentedon Nov 15, 2026
Confirmed the same defect independently on Windows 11 x64 on 2026-11-15 (App 3.18.2, CLI 0.17.1): the desktop-bundled CLI cannot run the interactive TUI. As a workaround we built a standalone dist from @rizkydwicmt's staging-fix branch (
fix/stage-tui-runtime-in-bundled-agent) using its documented build path (pnpm 10.33.2--frozen-lockfile→node scripts/bootstrap.mjs→pnpm build:sea:prepare→node scripts/build-zcode.mjs). The build succeeded after fixing three Windows-only build-script defects (barepnpmENOENT inbuild-zcode.mjs, GNU tar parsingC:drive-letter paths as a remote host, and the bootstrap/build:sea:prepareordering) — filed upstream in #1523, with the fixed branch public at https://github.com/Futuri-Risk/ZCode/tree/fix/windows-build-scripts. The resulting TUI boots and headless mode works; dist sha256479f994bf8835a89bde7ea080ed1eec006e6f8d495cfc4c35dbc4a35e5b6. No maintainer action is needed on this comment — posting it as triage data.rizkydwicmt commentedon Nov 15, 2026
@Futuri-Risk thanks for the independent Windows triage — I've integrated your fixes into
rizkydwicmt/ZCode@fix/stage-tui-runtime-in-bundled-agent(cherry-picked yourd646d1e9onto the v3.18.0-based tree, clean) and added Windows to its dist CI. Getting the Windows job green needed four more fixes, all in the same spirit as yours:Runner image —
windows-latestandwindows-2025both now resolve to the newwindows-2025-vs2026image (VS Enterprise 2026 only).build-windows-runtime-host.mjshardcodes theVisual Studio 17 2022CMake generator and node-gyp postinstalls need VS2022 too, so the dist workflow pinswindows-2022(last image shipping VS Enterprise 2022 17.14). Relevant if you ever CI your branch.zip extraction (
scripts/prebuilt-binary-extract.mjs) — on those runner imagespowershell.exeresolves to pwsh 7, whoseMicrosoft.PowerShell.Archivefails on the ugrep.zip step inprepare:native-searchwithCannot find an overload for "ExtractToDirectory" and the argument count: "3". Patched to try bsdtar first (tar -xfis zip-capable and ships with Windows 10+), keepingExpand-Archiveas fallback. Same fix family as your item 2 — worth porting into your branch.Your [Bug] 发送引导排队的消息无法进行任何操作 #3, ported properly — the root cause is now fixed in
prepare-agent-node-bundle.mjsitself:stageTuiRuntimeForGlm()builds the TUI runtime closure exactly likebuild:sea:prepare's first two steps (tsc -b packages/shared+ recursiveapps/zcode-clibuild), so the desktop prep is bootstrap-order-independent. The dist workflow additionally runsbuild:sea:preparebefore bootstrap as belt-and-braces.Smoke test — relative paths only: the packaged-CLI smoke test hit the same GNU-tar drive-letter parsing on
-C $RUNNER_TEMP("tar: D\:\a\_temp: Cannot open").Current state: 3-OS matrix green —
macos-latest,ubuntu-latest,windows-2022— each uploading a smoke-tested dist artifact (~85-88 MB: tarball + sha256 + install.sh + latest.json): https://github.com/rizkydwicmt/ZCode/actions/runs/43673254747. The Windows tarball's TUI boot was verified by your local build; ours is asserted structurally by the CI smoke test (staged@zcode/tui+ opentui natives present in the extracted tarball).Between the two forks we now have: desktop-bundle TUI staging (#51), Windows-safe build scripts (#1523), and 3-OS CI artifacts. The source mirror remains read-only, so still waiting on z.ai to pick any of this up.