Files
idoubiandClaude Opus 4.6 197722e84e fix: lazy-load all Anthropic-internal packages and add missing deps
- Convert static imports of @ant/computer-use-mcp,
  @ant/claude-for-chrome-mcp, @ant/computer-use-input, and
  color-diff-napi to lazy require() with no-op fallbacks
- Add cli-boxes and qrcode as runtime dependencies
- Prevents "Cannot find package" errors in Next.js and other
  bundled environments where internal packages are unavailable

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 02:08:40 +08:00

40 lines
1.2 KiB
TypeScript

/**
* Example 3: Multi-Turn Conversation
*
* Demonstrates session persistence across multiple turns.
* The agent remembers context from previous interactions.
*
* Run: npx tsx examples/03-multi-turn.ts
*/
import { createAgent } from '@shipany/open-agent-sdk'
async function main() {
console.log('--- Example 3: Multi-Turn Conversation ---\n')
const agent = createAgent({
model: process.env.ANTHROPIC_MODEL || 'claude-sonnet-4-6',
maxTurns: 5,
})
// Turn 1: Create a file
console.log('> Turn 1: Create a file')
const r1 = await agent.prompt(
'Use Bash to run: echo "Hello Open Agent SDK" > /tmp/oas-test.txt. Confirm briefly.',
)
console.log(` ${r1.text}\n`)
// Turn 2: Read back (should remember context)
console.log('> Turn 2: Read the file back')
const r2 = await agent.prompt('Read the file you just created and tell me its contents.')
console.log(` ${r2.text}\n`)
// Turn 3: Clean up
console.log('> Turn 3: Cleanup')
const r3 = await agent.prompt('Delete that file with Bash. Confirm.')
console.log(` ${r3.text}\n`)
console.log(`Session history: ${agent.getMessages().length} messages`)
}
main().catch(console.error)