import { Agent, type Hooks } from "opperai";
const hooks: Hooks = {
onAgentStart: ({ agent, input }) => console.log(`-> ${agent}: ${input}`),
onToolStart: ({ name, input }) => console.log(` tool ${name}(${JSON.stringify(input)})`),
onToolEnd: ({ name, output, durationMs }) =>
console.log(` -> ${JSON.stringify(output)} (${durationMs}ms)`),
onAgentEnd: ({ result, error }) =>
error
? console.log(`<- failed: ${error.message}`)
: console.log(`<- done in ${result!.meta.iterations} iterations`),
};
const agent = new Agent({ name: "city-expert", instructions: "...", tools: [lookupCity], hooks });