import { GeminiLiveProvider } from '../src/gemini-live';
import { OBSControlClient } from '../src/obs-control';
import { OpenVTControlClient } from '../src/openvt-control';
import { CharacterRuntime } from '../src/runtime';

const runtime = new CharacterRuntime(new GeminiLiveProvider());
const openvt = new OpenVTControlClient();
const obs = new OBSControlClient({
  sceneName: process.env.OBS_SCENE_NAME ?? 'Scene',
  textInputName: process.env.OBS_TEXT_INPUT_NAME ?? 'Agent Reply',
});

const message = {
  author: process.env.TEST_CHAT_AUTHOR ?? 'streamplace-viewer',
  text: process.env.TEST_CHAT_TEXT ?? 'hey haru what do you think about stream.place?',
  timestamp: new Date().toISOString(),
};

console.log(JSON.stringify({ phase: 'input', message }, null, 2));

await openvt.sendTalkState('start');
await openvt.sendEmotion('curious');

const result = await runtime.handleMessage(message);
console.log(JSON.stringify({ phase: 'output', result }, null, 2));

await openvt.sendText(result.reply);
await obs.setText(result.reply);
await obs.setProgramScene();
await openvt.sendResponse({
  ...result,
  actions: result.actions.filter((action) => action.type !== 'talk:start'),
});

console.log(JSON.stringify({ phase: 'delivered' }, null, 2));

