Repository navigation
feat(agents): 用量速度排行、会话分页读取、Agent 命令行工具安装和 IDE 连接的会话搜索(API-45 0 内补充) - #217
Merged
Merged
Conversation
速度排行改成逐条累加的 SpeedRanker,只保留每个模型的速度值,大量历史不必一次读进内存。lithe/host/agents/usage 和 agentSessions.stats 都返回 speeds,契约、更新记录与四种 SDK 的说明同步。
读取范围在行中间结束时只把完整的行交给插件后端,范围落在一行之内时回答 end 等于起点、不调用后端。契约 README、Core API 表和更新记录同步;新字段都是 agents 0 内的补充。
安装声明的 commands 可以由本插件某个 Agent 的 tool 所指工具定义的 commands 提供;requirements 在 systemCommand 启动之后按声明顺序列出 kind 为 agent、 id 为 Agent ID 的使用方。新增 fixture command-installer-agent.plugin.json 和 三个计划用例(列出使用方、受管目录计划、拒绝没有启动或 Agent 工具用到的命令), 契约 README、工具链参考页、能力版本表和协议更新记录同步。
- lithe_sessions_search(query、可选 agent)和 lithe_sessions_read(sessionID、可选 agent、可选 cursor),权限都是 read,参数里没有路径 - 这两个工具只在宿主声明时提供:没有声明工具清单的宿主照旧提供其余全部工具,但不提供它们;宿主只在用户打开 IDE 连接、打开“允许 MCP 客户端搜索本地会话”并同意读取至少一个 Agent 的会话时声明 - 调用 fixture 加上接受和拒绝的会话工具调用,产品工具清单 fixture 加上两个工具;单测核对只读、无路径参数、撤回声明后拒绝调用 - 新日志事件 agent.records.inspected(由 Lithe 记):只记工具名、结果条数和耗时,不记查询词、会话 ID 和内容 - ide-api v1 契约写明三个条件、结果和字节上限、错误码、不返回路径、不触发同步;更新记录在 #217 条目里补一句
- 游标用连接的密钥签名,重连后旧游标返回 INVALID_ARGUMENTS,从头读取 - 页面最多 65,536 字节文字、2,000 条消息;tooLong 表示单行超过 16 MiB;omitted 表示为长行放大的一次读取里放不下的消息条数 - lithe_sessions_read 的工具说明写明游标只在本连接有效
36 of 39 tasks
xiaoyumuxi
marked this pull request as ready for review
November 28, 2026 06:21
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)的一组
agents0 内补充,外加 API-23 的commandInstallers0 内补充,都是桌面端 1lck/Lithe-IDEA#2492 和三个 Agent 插件(Agent 管理、Claude Code、Codex)要用的:lithe/host/agents/usage和宿主命令agentSessions.stats的回答多一个speeds,按模型列出输出速度中位数(首个令牌之后每秒输出令牌数),最快的在前。agentSessions.list可按sessionID查找、每个会话带readBytes;agentSessions.read回答下一页起点end,只把完整的行交给插件后端。桌面端靠它查看已记录会话的消息。commands可以由本插件某个 Agent 的工具定义提供,requirements列出kind: "agent"的使用方;受管命令目录也参与解析 Agent 工具。命令行工具缺失时,桌面端据此引导到插件管理安装。lithe_sessions_search和lithe_sessions_read,让 MCP 客户端搜索和分页读取用户同意读取的 Agent 会话。宿主声明了才提供;没有声明工具清单的宿主不提供。不新增宿主方法、通知、错误码、权限或能力版本。旧 Core 和旧宿主的行为写在协议更新记录里。
宿主方法与通知 / Host methods and notifications
lithe/host/agents/usagespeeds: [{model, calls, medianTokensPerSecond, lowerBound}],只有模型名和数字下面这些不是插件宿主方法,列出来方便评审:
agentSessions.list/agentSessions.readlist可按sessionID查找并带readBytes;read回答endagentSessions.statsspeedscommandInstallers声明、plugins.commandInstallers.requirementskind: "agent"lithe_sessions_searchlithe_sessions_read主要改动 / Changes
速度排行(85425cc、203c589)
rust/crates/agent-sessions/src/stats.rs:速度排行改成逐条累加的SpeedRanker,每个模型只保留速度值;rank_speed保留为它的简单包装。输出少于 100 令牌、失败、超过 10000 t/s 的调用不计;只给出首令牌时间或总时长时按下界计(≥1000 输出令牌、≥1 s)并标lowerBound。rust/crates/agent-runtime/src/records.rs:summarize在同一次遍历里同时得到汇总和速度,usage与agentSessions.stats都回答speeds。speeds的形状与计入规则;四种 SDK(Rust、Go、Node、Java)的 README 与 usage 方法注释同步。scan的一个既有行为(b801e8f):之后的扫描可以用同一个key再报一次调用,range在它自己的块里,后报的替换先报的。Codex 插件到一轮结束(task_complete)才知道计时,靠它给之前块里的调用补上firstTokenMs和durationMs。自 feat(agent-sessions): add the local agent session record store #199 起 Core 都按(file_id, call_key)替换,agent-sessions补测试a_later_report_of_a_call_replaces_it。分页读取(4e864f7)
agent-sessions/src/store.rs:list支持sessionID条件,回答每个会话已读到的readBytes。agent-runtime/src/records.rs:read在行中间结束时只把完整的行交给后端,回答end;范围落在一行之内时end等于起点、不调用后端。rust-core-api.md、更新记录同步;说明后端messages回答整体不能超过 1 MiB 的函数结果上限。Agent 命令行工具的安装(8a8d13c)
plugin-manifest/src/command_installers.rs:安装声明的命令可以由 Agent 工具的commands提供,requirements在systemCommand启动之后按声明顺序列出 Agent 使用方;只有 Agent 工具用到、又不在任何启动或 Agent 工具里的命令仍被拒绝。command-installer-agent.plugin.json和三个计划用例;契约 README、工具链参考页、能力版本表同步。IDE 连接的会话工具(08ba94e、1cfc556)
ide-host/src/catalog.rs:两个工具的权限都是 read,参数里没有路径;DECLARED_ONLY让没有声明工具清单的宿主不提供它们,调用返回NOT_SUPPORTED。rust/contracts/ide-api/v1.md:写明三个提供条件(IDE 连接打开、“允许 MCP 客户端搜索本地会话”打开、至少同意读取一个 Agent 的会话)、搜索和读取的结果与字节上限、错误码、不返回路径、不触发同步。读取一页最多 65,536 字节文字、2,000 条消息,单条消息截到 4,096 字节、工具名截到 128 字节;tooLong表示单行超过 16 MiB,omitted表示放大后的一次读取里放不下的消息数。游标用连接密钥签名,重连后旧游标返回INVALID_ARGUMENTS,客户端要从头读。agent.records.inspected(由 Lithe 记):只记工具名、结果条数和耗时,不记查询词、会话 ID 和内容。query、多余的limit),产品工具清单 fixture 加上两个工具。更新记录:
protocol-changelog.md时间线的 #217 条目写明上面四项补充和旧版行为,“宿主方法(按 API 编号)”给agents/usage加一行。验证 / Verification
在 1cfc556 上(b801e8f 只加了契约说明和一个测试,另跑了
cargo test -p lithe-agent-sessions:42 个通过,clippy 和 verify-docs 通过):cargo test -p lithe-ide-host -p lithe-agent-runtime -p lithe-agent-sessions -p lithe-plugin-manifest -p lithe-diagnostics:五个 crate 共 164 个通过。cargo test -p lithe-core declarative_plugins:67 个通过(含 Agent 命令安装的清单用例)。cargo fmt --check、cargo clippy -p lithe-ide-host -p lithe-agent-runtime -p lithe-agent-sessions -p lithe-plugin-manifest -- -D warnings:通过。node shared/plugins/scripts/verify-docs.mjs:Plugin docs and contract links are consistent.internal/workbench、internal/settingswindow、internal/agents、internal/core全部测试通过;会话工具的 8 个测试另跑了计时检查(最长 290 ms)和-race。