|
| 1 | +import { tool } from "ai"; |
| 2 | +import { z } from "zod"; |
| 3 | + |
| 4 | +import type { AgentResult, CreateAgentProps } from "./types"; |
| 5 | + |
| 6 | +// TODO CHAPTER 3: Implement the Planner Agent |
| 7 | +// |
| 8 | +// The Planner creates personalized study plans and learning roadmaps. |
| 9 | +// It should: |
| 10 | +// 1. Accept a topic, timeframe, hours/day, and current level |
| 11 | +// 2. Use generateObject to create structured study plan data |
| 12 | +// 3. Return weekly breakdown with goals, tasks, and resources |
| 13 | +// |
| 14 | +// In Chapter 4, this will create a study-plan artifact with checkboxes. |
| 15 | +// |
| 16 | +// Triggers: "study plan", "learning roadmap", "how should I learn" |
| 17 | +// |
| 18 | +// See CHAPTER-3.md for the complete implementation. |
| 19 | + |
| 20 | +/** |
| 21 | + * Planner Agent - Creates study plans and learning roadmaps |
| 22 | + * |
| 23 | + * @param _props - Agent props (session, dataStream) |
| 24 | + * @returns AI SDK tool that generates study plans |
| 25 | + */ |
| 26 | +export const createPlannerAgent = (_props: CreateAgentProps) => |
| 27 | + tool({ |
| 28 | + description: |
| 29 | + "Create a personalized study plan or learning roadmap for a topic. " + |
| 30 | + "Use when the user wants to plan their learning, create a study schedule, or get a structured approach. " + |
| 31 | + "Triggers: study plan, learning roadmap, how to learn, schedule, curriculum.", |
| 32 | + inputSchema: z.object({ |
| 33 | + topic: z |
| 34 | + .string() |
| 35 | + .describe("The topic or skill to create a study plan for"), |
| 36 | + timeframe: z |
| 37 | + .string() |
| 38 | + .default("2 weeks") |
| 39 | + .describe("How long the user has to learn (e.g., '1 week', '30 days')"), |
| 40 | + hoursPerDay: z |
| 41 | + .number() |
| 42 | + .min(0.5) |
| 43 | + .max(8) |
| 44 | + .default(1) |
| 45 | + .describe("Hours available for study per day"), |
| 46 | + currentLevel: z |
| 47 | + .enum(["complete beginner", "some basics", "intermediate", "advanced"]) |
| 48 | + .default("complete beginner") |
| 49 | + .describe("User's current knowledge level"), |
| 50 | + }), |
| 51 | + execute: async ({ topic }): Promise<AgentResult> => { |
| 52 | + // TODO: Implement in Chapter 3 |
| 53 | + // 1. Use generateObject with a study plan schema |
| 54 | + // 2. Create weekly breakdown with goals and tasks |
| 55 | + // 3. Format as markdown or create artifact in Chapter 4 |
| 56 | + |
| 57 | + console.log(`[Planner] TODO: Create study plan for "${topic}"`); |
| 58 | + |
| 59 | + // Placeholder await to satisfy linter (remove when implementing) |
| 60 | + await Promise.resolve(); |
| 61 | + |
| 62 | + return { |
| 63 | + agentName: "planner", |
| 64 | + success: false, |
| 65 | + summary: `TODO: Implement planner in Chapter 3 to create study plan for "${topic}"`, |
| 66 | + }; |
| 67 | + }, |
| 68 | + }); |
0 commit comments