Repository navigation
feat(agents): support hourly usage with an optional rolling-window anchor - #231
Merged
Merged
Conversation
WhiteZeek
marked this pull request as ready for review
November 30, 2026 01:24
Contributor
There was a problem hiding this comment.
🔍 Devin Review: 3 flags
Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
# Conflicts: # rust/contracts/rust-core-api.md # shared/plugins/reference/protocol-changelog.md
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.
关联 Issue / Linked issue
Refs 1lck/Lithe-IDEA#2513
PR 类型 / Type
改动说明 / What changes
背景 / Why
AI 管理窗口需要按小时统计令牌。用户选择“近 24 小时”时,希望从刷新时刻向前覆盖完整的一天,每小时一根。例如在 10:30 刷新时,需要分别统计昨天 10:30–11:30 和今天 09:30–10:30。
改动 / Changes
agentSessions.stats和插件方法lithe/host/agents/usage接受groupBy: "hour"。默认按utcOffsetSeconds指定的本地整点分组。调用方可传hourAnchorMs对齐任意毫秒起点,桌面滚动窗口将它设为sinceMs。sinceMs、排除untilMs。复用原有用量累计逻辑,按时间升序只返回有调用的桶。每桶用绝对毫秒值key.startMs标识。计算小时边界和检查跨度时避免整数溢出。session、cwd继续仅供宿主使用。桌面小时图示例
截图来自桌面分支的 Viva 无头测试,使用合成用量数据。
今天 横轴从本地零点排到次日零点。每根柱统计一个钟点内的用量。
近 24 小时 10:30 刷新时,24 根柱从昨天 10:30 排到今天 10:30。第一根覆盖昨天 10:30–11:30,最后一根覆盖今天 09:30–10:30。
查看中英文、明暗主题的改动前后对照
不在本 PR 范围内 / Out of scope
桌面图表在应用仓库交付。Node SDK 状态文件的 Windows 写盘问题单独由 #230 修复。
类型专属:feat
多平台对齐
范围检查 / Scope checks
lithe/host/agents/usageagents仍为 v0。旧请求继续沿用原语义,旧宿主对新取值返回参数错误。沿用现有方法、授权、错误与日志处理。验证 / Verification
cargo test --locked -p lithe-agent-sessions -p lithe-agent-runtime --lib -- --test-threads=1,两个包分别 45 项、27 项通过。覆盖 UTC+05:45、本地跨日、回拨、带毫秒的锚点、空小时及查询终点。提交前确认 / Final checks
main,以 Draft 提交。