Something went wrong. Try again.
My version of https://github.com/vercel-labs/fx
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829import { createInterface } from 'node:readline'import { stdin, stdout } from 'node:process'import { createFxAgent } from 'libfx'
const agent = await createFxAgent({ apiKey: process.env.AI_GATEWAY_API_KEY, model: 'openai/gpt-4.1-nano',})const input = createInterface({ input: stdin, output: stdout, prompt: 'You: ' })
try { input.prompt() for await (const prompt of input) { if (prompt.trim() === '/exit') break if (!prompt.trim()) { input.prompt(); continue } stdout.write('Agent: ') const turn = agent.prompt(prompt) for await (const event of turn) { if (event.type === 'text_delta') stdout.write(event.delta) } await turn.result stdout.write('\n\n') input.prompt() }} finally { input.close() await agent.close()}