import { Agent, defineTool, openai, type ExecutionPolicy } from "@agentium/core";
import { z } from "zod";
const readCatalog = defineTool({
name: "read_catalog",
description: "Read the local product catalog.",
parameters: z.object({}),
execute: async () => JSON.stringify([{ product: "notebook", price: 5 }]),
});
const policy: ExecutionPolicy = {
decide: ({ toolName }) => ({ action: toolName === "read_catalog" ? "allow" : "deny" }),
resolveEffect: ({ toolName }) => toolName === "read_catalog" ? "read" : "unknown",
};
const agent = new Agent({
name: "catalog-reader",
model: openai(process.env.OPENAI_MODEL ?? "gpt-6.1-sol"),
tools: [readCatalog],
executionPolicy: policy,
});
try {
console.log(await agent.run("List the catalog.", { runMode: "plan" }));
} finally {
await agent.close();
}