Repository navigation
feat(plugins): 开放原生终端 API 与有界上下文 reopen - #1653
Merged
Merged
Conversation
xiaoyumuxi
marked this pull request as ready for review
November 2, 2026 08:42
This was referenced Nov 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题与结果
工具插件目前无法打开 Lithe 的集成终端,Docker 等交互客户端只能要求用户手动执行命令。本改动在既有函数协议 3 和宿主服务 dispatcher 上开放插件自有原生终端,复用 TerminalFeatureModel、SwiftTerm 和 macOS PTY;宿主不增加 Docker 或其他工具专属分支。
API 编号与本 PR 范围
本 PR 对应原定 API-01–44 中的 API-24:插件自有终端。沿用既有 44 项编号,下面六个公共方法均归属 API-24;这 44 项按能力规划分组,每项可包含多个方法。编号依据:本分支 API-01–44 完成度总表。
lithe/host/terminal/createlithe/host/terminal/showlithe/host/terminal/closelithe/host/terminal/reopenlithe/host/terminal/disposelithe/host/terminal/onExitAPI-24 从“未做”更新为“部分完成”:本 PR 接入本机 macOS;
sendText、输出读取、Windows 和远程支持未开放,完整 GUI 验收仍 pending。六个方法统一要求terminal.create权限、backend:2和既有函数协议 3;API-24 是规划编号,与协议版本、能力版本分别记录。改动
terminal.create(要求backend:2),在 Core 白名单、清单 schema、能力发现和 macOS 组合根注册六个方法:create/show/close/reopen/dispose/onExit。Web 页面经自己的 backend 函数调用,不增加私有终端传输或直接 web terminal bridge。create用 executable/argv 分离的直接进程启动,支持工作区目录资源 cwd、环境覆盖/删除、标题及显示选项。创建与重开均显示可取消执行确认,并在异步边界重新核对 context、authority 和取消;首版本机 macOS,remote 明确拒绝,Windows 不注册 handler。close清理进程树并关闭原生标签,保留启动配置与有界纯文本显示历史;reopen沿用 terminalID、递增 generation 并启动新进程,不重放输入、不恢复 Shell 变量或旧进程内存。retainedContextBytes:默认 16 KiB,范围 0–256 KiB,0 表示不保留;按 UTF-8 scalar 边界截断,使用 SwiftTerm 自己的组合字符解码与宽字符处理,恢复时只喂显示器、从不写 stdin。历史和启动信息仅在宿主内存保存。dispose彻底释放。退出订阅每个 generation 只发布一次,取消重开不伪造退出事件或占用新 generation,旧回调不影响新进程。show:false创建/重开保留已有活动终端,不挂载标签或请求输入焦点;显式show后才挂载并选择。本地验证
.artifacts/test-stability/plugin-terminal-review-fixes.*。原实现另有 46 项相关测试通过,报告为plugin-terminal-final.*。cargo test --manifest-path rust/Cargo.toml -p lithe-core --target aarch64-apple-darwin:1,542 项单测和相关集成全部通过;另对函数协议与 terminal 权限 31 项做独立计时。LITHE_PLUGIN_SDK_TERMINAL_E2E=1 node scripts/sdk-e2e.mjs --source <此工作树> --ref codex/plugin-terminal-api,三个 SDK 的示例后端及原有领域场景对宿主提交f989e5e0a018361645219000e552051f19c6bbb4全部通过。Rust 新场景经真实 Core 验证六方法链路中的创建、订阅、关闭、重开和释放;实际 PTY 由宿主测试验证。范围与后续
node scripts/contract.mjs sync --revision <合并后的 preview commit>,同步契约副本后再发布 SDK;本 PR 不修改 SDK 版本或发布包。