import { runPhone } from "./phone"

const apiKey = process.env.ELEVEN_API_KEY
const agentId = process.env.ELEVEN_AGENT_ID

if (!apiKey) {
  console.error("❌ Error: ELEVEN_API_KEY environment variable is required")
  process.exit(1)
}

if (!agentId) {
  console.error(
    "❌ Error: ELEVEN_AGENT_ID environELEVEN_AGENT_ID=agent_5601k4taw2cvfjzrz6snxpgeh7x8 ELEVEN_API_KEY=sk_0313740f112c5992cb62ed96c974ab19b5916f1ea172471fment variable is required",
  )
  console.error("   Create an agent at https://elevenlabs.io/app/conversational-ai")
  process.exit(1)
}

console.log(`☎️ Starting phone with pid=${process.pid}`)
try {
  await runPhone(agentId, apiKey)
} catch (error) {
  console.error(`❌ Error starting phone: ${(error as Error).message}`)
  process.exit(1)
}
console.log(`👋 Goodbye!`)
