import { CharacterRuntime, StubResponseProvider, type ChatMessage } from './runtime';
import { runLiveLoop } from './live-loop';

function usage() {
  console.log(`character\n\nUsage:\n  bun run src/index.ts\n  bun run scripts/simulate-chat.ts`);
}

const runtime = new CharacterRuntime(new StubResponseProvider());

export function handleMessage(message: ChatMessage) {
  return runtime.handleMessage(message);
}

if (process.argv.includes('--help')) {
  usage();
  process.exit(0);
}

if (process.argv.includes('--live')) {
  await runLiveLoop();
  process.stdin.resume();
  process.exit(0);
}

console.log('character runtime scaffold ready');
console.log('next: wire Gemini Live, stream.place chat, avatar renderer, and stream uplink');
