Repository navigation
refactor: remove unused session terminal service - #4333
Conversation
The terminal_* WebSocket controls lost their dispatch when the v1 connection was rewritten, so terminals could be created over REST but never attached, written to, or resized. No client uses them: the web UI has no terminal and the desktop app runs its own native PTY. Remove the REST routes, WebSocket schemas, meta capability, error code, session terminal service, host PTY backend, runtime terminal capability, and the node-pty dependency.
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
commit: |
|
❌ Nix build failed Hash mismatch in
Please update |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0049f2f90d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review 上一轮唯一的 P1(认为
另外,上一轮评审之后新增了一个提交,按 Nix CI 给出的值更新了 |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
Requirement or Bug
删除 server 与引擎里已经无法使用、也没有客户端在用的会话终端(PTY)功能。
Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
现状:v1 WebSocket 连接的分发只处理
pong/client_hello/subscribe/subscribe_v2/unsubscribe/unsubscribe_v2,terminal_attach/terminal_input/terminal_resize/terminal_detach/terminal_close落到default被静默丢弃,也从不推送terminal_output/terminal_exit。REST 仍能创建、列出、关闭 PTY,但终端的输入输出没法收发。web 没有终端入口,desktop 用自己的 Electron PTY,都不走这条链路。整条链路一起删:
会话空闲回收的保留条件少了"有运行中的终端"一项:
retained(handle) - if any terminal is running: return true if any agent has cron tasks: return true return busy || pending interaction依赖:
agent-core-v2的dependencies和 CLI 的optionalDependencies去掉node-pty,根postinstall(scripts/fix-node-pty-perms.mjs)一并删除。desktop 的原生终端在 code-app 侧自带node-pty,不受影响。测试与文档:删掉
kap-server/test/terminals.test.ts、agent-core-v2/test/session/terminal/、klient/test/e2e/legacy/terminal.test.ts和 klient e2e harness 里的终端方法;runtime 相关测试里的'terminal'capability 换成现有能力;apiSurface快照少 4 条终端路由;docs/{en,zh}/reference/server-api.md删除"终端"一节和 capabilities 里的terminal(该节提到的--allow-remote-terminals早已不存在)。flake.nix的pnpmDepshash 已按 Nix Build CI 给出的值随 lockfile 更新。Behavior Changes and Affected Users
GET/POST /api/v1/sessions/{session_id}/terminals、GET .../terminals/{terminal_id}、POST .../terminals/{terminal_id}:closeserver-api.md自写脚本的外部调用方只能管理生命周期,拿不到输入输出terminal_*控制消息GET /api/v1/meta的capabilitiesterminal: trueterminalterminal_*控制操作node-pty原生可选依赖终端 REST 接口删除后没有退路;现有客户端都感知不到这些接口,所以本 PR 不写 changeset。这两点需要维护者在 PR 里确认。
code-app 侧同步删除了客户端里对应的死代码:MoonshotAI/kimi-code-app#948。两边互不依赖,合入顺序不限。
受影响模块与验证:
kap-server:apiSurface快照更新;securityExposure.test.ts去掉终端路由断言,保留 shutdown 断言。agent-core-v2:sessionManagerService.test.ts的保留条件用例去掉终端两条,其余不变;runtimeRegistry.test.ts的 degraded 用例改用fs运行时缺少process的组合。pnpm typecheck、pnpm lint(0 error)、node scripts/check-nix-workspace.mjs通过;pnpm vitest run packages/kap-server packages/agent-core-v2 packages/acp-server packages/klient中 9096 个用例通过,唯一失败的test/tool/tool.test.ts > returns the spawned agent id when a foreground subagent times out在origin/main上同样失败,与本 PR 无关。Checklist
/approve).gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.