Repository navigation
feat(agents): API-45 Agent 能力 agents 0:原生 CLI 会话、会话记录与四种 SDK - #216
Merged
Merged
Conversation
- 契约 README 新增 Agents 章节:声明、四个权限与 onAgent 激活、宿主命令、 原生会话、会话记录、隐私与日志、版本 0 限制 - plugin-manifest.schema.json 加入 agents、requires.agents、四个权限与 onAgent - 新增 fixtures/agents 两个清单和 23 个拒绝用例,Core 测试逐个对照 - 参考页新增 domains/agents.md,API 总表、更新记录、能力版本表加入 API-45 - 会话统计按会话分组时字段名统一为 sessionID
Rust、Go、Node、Java SDK 新增 onAgentSessions(Rust 为 on_agent_sessions):每个会话一个有序 worker,didStart 创建处理器,之后按 Core 发送顺序投递 didOutput、didPrompt、didCancel、didDecidePermission、didExit;启动或提示失败时报告 turnEnded failed 并记日志。agents/did* 通知只能走这个接口,onHostNotification 注册会以 sdk.method.reserved 拒绝。 新增 agents 宿主服务封装:write、report、usage。 新增契约 fixture fixtures/agents/native-session.json,四个 SDK 的测试共用;测试改为确定性等待(闸门与事件驱动),不再用固定时长的 sleep。 README、契约 Native sessions 一节和 Agent 领域参考页补充用法与 fixture 说明。
Node SDK 的 checkViewEvent 拒绝 refresh、expand、loadMore 和 cursor 字段,而类型声明和 Rust、Go、Java SDK 都接受它们,树视图展开和加载更多在 Node 后端会直接失败。补上这三种事件和 cursor,并加测试。 用户运行的命令没有处理器时,Rust、Go 记 operationFailed,Node、Java 记 degraded;命令没有执行,按失败记录,四个 SDK 统一为 operationFailed。
A native session whose output thread could not start stayed in the live list forever with no exited event, and one without its stderr reader could block on a full pipe. Such a session now ends as failed. A close whose grace-period thread cannot start ends the CLI at once. Also documents the public items of plugin-agents and lsp-engine's agent host that rustdoc flagged.
# Conflicts: # shared/plugins/contract/v1/plugin-manifest.schema.json # shared/plugins/reference/protocol-changelog.md
xiaoyumuxi
marked this pull request as ready for review
November 27, 2026 20:43
This was referenced Nov 27, 2026
xiaoyumuxi
added a commit
that referenced
this pull request
Nov 28, 2026
xiaoyumuxi
added a commit
that referenced
this pull request
Nov 28, 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.
概述 / Summary
API-45(Agent)的 Core 部分:插件声明用户自己安装的 Agent CLI,Core 负责启动、转发和回收 CLI 进程,插件后端只做协议翻译。新增能力
agents0,litheFunctions0 内新增 3 个宿主方法和 6 个宿主通知;四个官方 SDK 同步封装。设计见 1lck/Lithe-IDEA#2407 合入的 Agent Note(原生优先、ACP 兜底、本地会话记录在 Core)。Core 不认识任何具体 Agent:CLI 名称、参数、协议、会话目录全部来自插件清单和插件后端,没有
if agent == …,也没有写死的~/.claude、~/.codex路径。测试只用合成插件dev.lithe.test.*、fixture 只用dev.lithe.fixture.*。宿主方法与通知 / Host methods and notifications
lithe/host/agents/writelithe/host/agents/reportlithe/host/agents/usagelithe/host/agents/didStart(通知){session, agentID, cwd, resume?},后端可以写握手行lithe/host/agents/didOutput(通知)lithe/host/agents/didPrompt(通知){session, turn, text},turn由 Core 分配lithe/host/agents/didCancel(通知)lithe/host/agents/didDecidePermission(通知)lithe/host/agents/didExit(通知){session, exitCode?}write、report、usage由 Core 直接回答,不转给桌面端。主要改动 / Changes
rust/crates/plugin-model/src/capabilities.rs:新增agents,版本[0]。plugin-agents:校验agents[](id、displayName、icon?、tool、native?、acp?、terminal?、update?、sessionSources[]),解码启动函数的回答(只能是本 Agent 的tool,不能带环境变量),解析会话根目录(只允许${userHome}、${env:NAME}),生成目录条目和安装审查里的程序列表。plugin-manifest:新增权限agents.run、agents.native、agents.sessions.read、agents.usage.read和激活事件onAgent:<id>;声明多了或少了都拒绝。plugin-rpc:注册 3 个宿主方法和 6 个通知。agent-runtimelive.rs:启动 CLI(只接受origin.source=user、可信的本地工作区、每个 Agent 最多 4 个会话;远程工作区拒绝),每个会话各有输入、输出、错误三个线程;后端会话结束或撤销授权时结束对应的 CLI 进程树。failed结束,宿主照样收到exited;agents.close的等待线程起不来时立即结束 CLI。events.rs:与具体 Agent 无关的会话事件模型和上报校验(事件必须属于正在进行的一轮,权限选项必须在后端列出的范围内),以及有界事件队列(溢出时告诉宿主丢了多少)。records.rs:会话记录的同步、列表、搜索、读取、统计,调用插件的scan、read函数;额度按每个 Agent、每个窗口只保留最新一条。catalog.rs、backend.rs:Agent 目录和授权,以及后端生命周期。lsp-engine/src/agent_host.rs把agents/*宿主请求交给agent-runtime,并为 Core 发起的插件函数调用提供等待器(Core 保留的操作 ID 前缀,结果不进入桌面端事件队列)。agents.configure、agents.catalog、agents.sessions、agents.start、agents.prompt、agents.cancel、agents.respondPermission、agents.close、agents.waitEvents。agentSessions.configure、agentSessions.sync、agentSessions.forget、agentSessions.list、agentSessions.search、agentSessions.read、agentSessions.stats。rust/contracts/rust-core-api.md。agent-sessions里会话记录的分组键统一为sessionID。rust/logging/events/agent.json新增agent.session.started、agent.session.finished、agent.report.rejected、agent.records.updated、agent.records.removed,只记会话 ID、插件和 Agent ID、计数、耗时和结果代码;从不记录提示词、正文、工具参数和输出、CLI 输出、账号和凭据。contract/v1/README.md新增 “Agents” 一节,含原生会话、会话记录、隐私与日志、版本 0 的限制。agents[]和 4 个权限。fixtures/agents/下两个清单和native-session.json,以及 23 个拒绝用例。reference/domains/agents.md(中英)。capabilities-and-versions.md加agents0。on_agent_sessions、GoOnAgentSessions、NodeonAgentSessions、JavaonAgentSessions,外加host().agents()的write、report、usage。turnEnded。refresh、expand、loadMore和cursor,现在与 Rust、Go、Java 一致。版本变化 / Versions
agents,版本 0(已获批准)。pluginAPIVersion、清单schemaVersion、litheFunctions和其他能力版本都不变。版本 0 的限制 / Limits of version 0
acp会被校验,也会出现在安装审查和目录的modes里,但 Core 还不运行 ACP 客户端,所以没有native的 Agent 执行agents.start会得到agents.noNativeMode。跟进:[Feature] API-45 Agent:Core 通用 ACP 客户端,让只提供 ACP 的 Agent 能在工具窗口里对话 1lck/Lithe-IDEA#2487。ide-host的lithe_sessions_search、lithe_sessions_read不在本 PR。跟进:[Feature] API-45 Agent:IDE 连接增加只读 MCP 工具 lithe_sessions_search / lithe_sessions_read 搜索本地会话 1lck/Lithe-IDEA#2488。使用方 / Consumers
6763fb46。lithe-plugin-agent-hub、lithe-plugin-claude-code、lithe-plugin-codex,用本分支的 SDK。验证 / Verification
本机 macOS(Apple Silicon),提交
c4af263f:cargo fmt --manifest-path rust/Cargo.toml --all -- --check:通过。cargo clippy -p lithe-agent-runtime --all-targets -- -D warnings:通过。cargo test:lithe-core:948 个测试通过。lithe-agent-runtime、lithe-plugin-agents、lithe-plugin-manifest、lithe-plugin-rpc、lithe-lsp-engine:全部通过。bash scripts/rust-core/verify-rust-core-comments.sh:通过。node scripts/rust-core/verify-platform-tests.mjs:通过。node shared/plugins/scripts/verify-docs.mjs:通过。node shared/plugins/scripts/sdk-e2e.mjs:通过。cargo test、Go SDKgo test ./...:通过。npm test:94 个测试通过。mvn verify:通过。