(output: AgentOutput)
| 11 | const apiKey = process.env.CODEBUFF_API_KEY |
| 12 | |
| 13 | function extractOutputText(output: AgentOutput): string { |
| 14 | if (output.type !== 'lastMessage' && output.type !== 'allMessages') return '' |
| 15 | const messages = output.value as { role: string; content: unknown }[] |
| 16 | for (const msg of messages) { |
| 17 | if (msg.role !== 'assistant') continue |
| 18 | if (typeof msg.content === 'string') return msg.content |
| 19 | if (Array.isArray(msg.content)) { |
| 20 | for (const part of msg.content) { |
| 21 | if ( |
| 22 | typeof part === 'object' && |
| 23 | part !== null && |
| 24 | 'type' in part && |
| 25 | part.type === 'text' && |
| 26 | 'text' in part |
| 27 | ) { |
| 28 | return String(part.text) |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | } |
| 33 | return '' |
| 34 | } |
| 35 | |
| 36 | describe('Prompt Caching', () => { |
| 37 | it( |
no outgoing calls
no test coverage detected