()
| 240 | this.emit({ type: 'agent_end', messages: this.state.messages }); |
| 241 | } |
| 242 | async continue(): Promise<void> { |
| 243 | this.call.continues += 1; |
| 244 | const callIndex = agentCalls.indexOf(this.call); |
| 245 | const script = |
| 246 | scriptedAgent.overrideScriptForCallIndex !== undefined && |
| 247 | callIndex >= scriptedAgent.overrideScriptForCallIndex && |
| 248 | scriptedAgent.overrideScript |
| 249 | ? { ...scriptedAgent, ...scriptedAgent.overrideScript } |
| 250 | : scriptedAgent; |
| 251 | |
| 252 | this.emit({ type: 'agent_start' }); |
| 253 | this.emit({ type: 'turn_start' }); |
| 254 | const assistantMsg: AgentMessage = { |
| 255 | role: 'assistant', |
| 256 | // biome-ignore lint/suspicious/noExplicitAny: matches pi-ai Api/Provider literal unions in mocks. |
| 257 | api: 'anthropic-messages' as any, |
| 258 | // biome-ignore lint/suspicious/noExplicitAny: same. |
| 259 | provider: 'anthropic' as any, |
| 260 | model: 'mock-model', |
| 261 | content: [{ type: 'text', text: script.assistantText }], |
| 262 | usage: script.usage ?? { |
| 263 | input: 0, |
| 264 | output: 0, |
| 265 | cacheRead: 0, |
| 266 | cacheWrite: 0, |
| 267 | totalTokens: 0, |
| 268 | cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }, |
| 269 | }, |
| 270 | stopReason: script.stopReason ?? 'stop', |
| 271 | ...(script.errorMessage ? { errorMessage: script.errorMessage } : {}), |
| 272 | timestamp: Date.now(), |
| 273 | }; |
| 274 | this.state.messages.push(assistantMsg); |
| 275 | for (const e of script.events ?? []) this.emit(e); |
| 276 | this.emit({ |
| 277 | type: 'message_update', |
| 278 | message: assistantMsg, |
| 279 | // biome-ignore lint/suspicious/noExplicitAny: AssistantMessageEvent shape not re-exported. |
| 280 | assistantMessageEvent: { type: 'text_delta', delta: script.assistantText } as any, |
| 281 | }); |
| 282 | this.emit({ type: 'message_end', message: assistantMsg }); |
| 283 | this.emit({ type: 'turn_end', message: assistantMsg, toolResults: [] }); |
| 284 | this.emit({ type: 'agent_end', messages: this.state.messages }); |
| 285 | } |
| 286 | async waitForIdle(): Promise<void> { |
| 287 | // no-op in mock |
| 288 | } |
no test coverage detected