()
| 24 | } |
| 25 | |
| 26 | async function main() { |
| 27 | const apiKey = process.env.CODEBUFF_API_KEY |
| 28 | if (!apiKey) { |
| 29 | console.error('❌ CODEBUFF_API_KEY is not set.') |
| 30 | console.error(' Example: CODEBUFF_API_KEY=<key> bun scripts/test-canopywave-e2e.ts') |
| 31 | process.exit(1) |
| 32 | } |
| 33 | |
| 34 | console.log('🔌 CanopyWave E2E Test via Codebuff SDK') |
| 35 | console.log('='.repeat(50)) |
| 36 | console.log() |
| 37 | console.log(`Model: ${minimaxAgent.model}`) |
| 38 | console.log(`Agent: ${minimaxAgent.id}`) |
| 39 | console.log() |
| 40 | |
| 41 | const client = new CodebuffClient({ |
| 42 | apiKey, |
| 43 | cwd: process.cwd(), |
| 44 | }) |
| 45 | |
| 46 | const events: PrintModeEvent[] = [] |
| 47 | let responseText = '' |
| 48 | |
| 49 | const startTime = Date.now() |
| 50 | |
| 51 | const result = await client.run({ |
| 52 | agent: minimaxAgent, |
| 53 | prompt: 'Say hello', |
| 54 | costMode: 'free', |
| 55 | handleEvent: (event) => { |
| 56 | events.push(event) |
| 57 | if (event.type === 'text') { |
| 58 | responseText += event.text |
| 59 | process.stdout.write(event.text) |
| 60 | } else if (event.type === 'reasoning_delta') { |
| 61 | // Don't print reasoning, just note it |
| 62 | } else if (event.type === 'error') { |
| 63 | console.error(`\n❌ Error event: ${event.message}`) |
| 64 | } else if (event.type === 'finish') { |
| 65 | console.log('\n') |
| 66 | } |
| 67 | }, |
| 68 | handleStreamChunk: (chunk) => { |
| 69 | if (typeof chunk === 'string') { |
| 70 | // Already handled in handleEvent |
| 71 | } |
| 72 | }, |
| 73 | }) |
| 74 | |
| 75 | const elapsed = Date.now() - startTime |
| 76 | |
| 77 | console.log(`── Results (${elapsed}ms) ──`) |
| 78 | console.log() |
| 79 | |
| 80 | if (result.output.type === 'error') { |
| 81 | console.error(`❌ Run failed: ${result.output.message}`) |
| 82 | if ('statusCode' in result.output) { |
| 83 | console.error(` Status code: ${result.output.statusCode}`) |
no test coverage detected