(ctx: DevtoolsMiddlewareContext, info: DevtoolsIterationInfo)
| 291 | }, |
| 292 | |
| 293 | onIteration(ctx: DevtoolsMiddlewareContext, info: DevtoolsIterationInfo) { |
| 294 | const now = Date.now() |
| 295 | |
| 296 | // Emit completed for previous iteration (it ended with tool_calls if we got here) |
| 297 | if (currentIteration >= 0) { |
| 298 | safeEmit('text:iteration:completed', { |
| 299 | ...buildEventContext(ctx), |
| 300 | iteration: currentIteration, |
| 301 | messageId: localMessageId || undefined, |
| 302 | duration: now - iterationStartTime, |
| 303 | finishReason: 'tool_calls', |
| 304 | timestamp: now, |
| 305 | }) |
| 306 | } |
| 307 | |
| 308 | // Track new iteration |
| 309 | currentIteration = info.iteration |
| 310 | iterationStartTime = now |
| 311 | localMessageId = info.messageId |
| 312 | localAccumulatedContent = '' |
| 313 | |
| 314 | // Emit iteration:started with config snapshot |
| 315 | safeEmit('text:iteration:started', { |
| 316 | ...buildEventContext(ctx), |
| 317 | iteration: info.iteration, |
| 318 | messageId: info.messageId, |
| 319 | timestamp: now, |
| 320 | }) |
| 321 | |
| 322 | // Emit assistant message placeholder |
| 323 | safeEmit('text:message:created', { |
| 324 | ...buildEventContext(ctx), |
| 325 | messageId: info.messageId, |
| 326 | role: 'assistant' as const, |
| 327 | content: '', |
| 328 | timestamp: now, |
| 329 | }) |
| 330 | }, |
| 331 | |
| 332 | onChunk(ctx, rawChunk) { |
| 333 | if (!isKnownChunk(rawChunk)) return |
nothing calls this directly
no test coverage detected