Skip to content

feat(extensions): 新增 TPS 扩展与扩展通知注入点 - #10

Merged
da-liii merged 8 commits into
mainfrom
da/tps
Nov 22, 2026
Merged

da-liii merged 8 commits into
mainfrom
da/tps

Conversation

@da-liii

@da-liii da-liii commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

概述

新增 TPS(token throughput)扩展,并在扩展事件系统中引入会话级通知注入点,使扩展能在 TUI 聊天区输出状态行。

主要变更

  • 新增 tps 扩展(extensions/tps.scm):每次 agent 运行结束时输出 token 吞吐量统计行(TPS/out/in/cache r/w/total/elapsed),移植自 pi 项目的 tps.ts。
  • 新增 extension-notify 模块(code/liii/pi/code/core/extension-notify.scm):作为会话级通知注入点(仿 ai/abort.scm)。TUI worker 会话内 arm 一个经 chan 投递回主线程渲染的回调,扩展经 ctx.ui.notify 触达聊天区状态行;未 arm 时扩展回退 stderr 输出,与 ctx.hasUI 守护语义一致。
  • 扩展事件系统桥接:agent loop 在 agent_start/agent_end 事件同步桥接到扩展事件系统;pi-emit! 自动构造 ctx 时注入 notify/has-ui。
  • TUI 渲染:新增 make-status-card 与 pi-app-add-status-message!,event_chan 的 tps_report 事件渲染为聊天区 dim 提示行(上方一空行间隔)。

测试

新增 tests/liii/pi/extensions/tps-test.scm。

新增 tps 扩展:每次 agent 运行结束时输出 token 吞吐量统计行
(TPS/out/in/cache r/w/total/elapsed),移植自 pi 项目的 tps.ts。

新增 extension-notify 模块作为会话级通知注入点(仿 ai/abort.scm):
TUI worker 会话内 arm 一个经 chan 投递回主线程渲染的回调,扩展经
ctx.ui.notify 触达聊天区状态行;未 arm 时扩展回退 stderr 输出,
与 ctx.hasUI 守护语义一致。

扩展事件系统桥接:agent loop 在 agent_start/agent_end 事件同步桥接
到扩展事件系统,并在 pi-emit! 自动构造 ctx 时注入 notify/has-ui。

TUI 渲染:新增 make-status-card 与 pi-app-add-status-message!,
event_chan 的 tps_report 事件渲染为聊天区 dim 提示行(上方一空行间隔)。
@da-liii
da-liii merged commit 56ef23e into main Nov 22, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant