import { Agent, openai, defineTool } from "@agentium/core";
import type { Skill } from "@agentium/core";
import { z } from "zod";
const shippingSkill: Skill = {
name: "shipping",
description: "Rates and tracking",
version: "1.0.0",
tools: [
defineTool({
name: "calculate_shipping",
description: "Cost from weight and destination",
parameters: z.object({
weightKg: z.number(),
destination: z.string(),
express: z.boolean().optional(),
}),
execute: async ({ weightKg, destination, express }) => {
const cost = (weightKg * 2.5 * (express ? 2 : 1)).toFixed(2);
return `Shipping to ${destination}: $${cost}`;
},
}),
],
instructions: "When they ask about cost, call calculate_shipping.",
};
const agent = new Agent({
name: "ShippingAssistant",
model: openai(process.env.OPENAI_MODEL ?? "gpt-6.1-sol"),
instructions: "You help with shipping.",
skills: [shippingSkill],
});
await agent.run("How much to ship 5kg to Germany?");