feat(hooks): add text_delta event for streaming text monitoring

- New text_delta hook event fires for each chunk of streaming text
- Enables real-time monitoring of agent output
- Plan-mode hook now updates todo progress as [DONE:id] tags stream in
- Each todo item has unique ID for reliable tracking
This commit is contained in:
Helmut Januschka 2026-01-03 16:26:36 +01:00 committed by Mario Zechner
parent 7a03f57fbe
commit d1eea3ac4e
5 changed files with 57 additions and 5 deletions

View file

@ -224,6 +224,15 @@ export class AgentSession {
/** Internal handler for agent events - shared by subscribe and reconnect */
private _handleAgentEvent = async (event: AgentEvent): Promise<void> => {
// Emit text_delta events to hooks for streaming text monitoring
if (
event.type === "message_update" &&
event.assistantMessageEvent.type === "text_delta" &&
this._hookRunner
) {
await this._hookRunner.emit({ type: "text_delta", text: event.assistantMessageEvent.delta });
}
// When a user message starts, check if it's from either queue and remove it BEFORE emitting
// This ensures the UI sees the updated queue state
if (event.type === "message_start" && event.message.role === "user") {