import {
Agent, openai, LearnedSkillStore, MongoDBStorage, defineTool,
} from "@radaros/core";
import { z } from "zod";
const storage = new MongoDBStorage({ uri: "mongodb://localhost/radaros" });
const skillStore = new LearnedSkillStore(storage);
// Define the tools the agent can use
const tools = [
defineTool({
name: "run_tests",
description: "Run test suite",
parameters: z.object({ suite: z.string() }),
execute: async ({ suite }) => `All ${suite} tests passed (42/42)`,
}),
defineTool({
name: "build_service",
description: "Build a service for deployment",
parameters: z.object({ service: z.string(), env: z.string() }),
execute: async ({ service, env }) => `Built ${service} for ${env} (v2.3.1)`,
}),
defineTool({
name: "deploy",
description: "Deploy to environment",
parameters: z.object({ service: z.string(), env: z.string() }),
execute: async ({ service, env }) => `Deployed ${service} to ${env} successfully`,
}),
];
const agent = new Agent({
name: "deploy-bot",
model: openai("gpt-4o"),
tools: [...tools, ...skillStore.getTools()],
instructions: "You are a deployment assistant. Save successful multi-step workflows as skills.",
});
// Run 1: Agent figures out the deployment workflow
await agent.run("Deploy the payment service to staging", {
sessionId: "deploy-1",
});
// Agent runs: run_tests → build_service → deploy → save_skill
// Run 2: Agent replays the saved workflow
await agent.run("Deploy the payment service to staging again", {
sessionId: "deploy-2",
});
// Agent: search_skills("deploy payment staging") → found → replay steps