Loading preview…
Loading preview…
Two-phase marketing agent with brand context: Stage 0 extracts brand info from URL or manual input, planning phase gathers requirements and creates a plan with todos, implementation phase executes the plan using web scraping and research tools. Uses callOptionsSchema + prepareCall for dynamic agent configuration.
Loading preview…
Requirements, wiring steps, and what this pattern adds to your project.
Pick how you want to pull this pattern in — then wire env vars and routes the same way.
Install from the preview toolbar
Copy the install command above and run it in your project — Pro patterns include a short-lived token.
Add environment variables to .env.local
OPENAI_API_KEY, FIRECRAWL_API_KEY
Point client fetches at your API routes
Replace preview `/view/.../api/...` paths with `/api/...` in the installed files.
Customize the agent and tool files
Adapt prompts, tools, and stop conditions for your product — Copy for AI in the toolbar helps seed that work.
Run your dev server and open the pattern route
Install dependencies if needed, then start the app and verify responses.
AI SDK APIs
useChatgatewayToolLoopAgenttoolgenerateObjecthasToolCallstepCountIscreateAgentUIStreamResponseInferAgentUIMessagecallOptionsSchemaprepareCallexperimental_contextProviders
External services
app/page.tsxapp/layout.tsxapp/api/agent-usecase-marketing-plan/route.tsapp/api/agent-usecase-marketing-implement/route.tslib/marketing-plan-types.tslib/marketing-plan-actions.tslib/cheerio-scraper.tslib/utils/format-brand-context.tslib/ai/plan/plan-agent.tslib/ai/plan/tools/index.tslib/ai/plan/tools/ask-multiple-choice.tslib/ai/plan/tools/ask-text-input.tslib/ai/plan/tools/generate-plan.tslib/ai/plan/tools/refine-plan.tslib/ai/implement/implement-agent.tslib/ai/implement/tools/index.tslib/ai/implement/tools/read-plan.tslib/ai/implement/tools/update-plan.tslib/ai/implement/tools/read-todo.tslib/ai/implement/tools/update-todo.tslib/ai/implement/tools/finalize.tslib/ai/implement/tools/firecrawl.tslib/ai/implement/tools/url-scraper.tsREADME.mdnpm packages
10
Registry components
agent-usecase-marketing-plan/route.tsPlan phase API route using createAgentUIStreamResponse with callOptions to pass brandContext at runtime.
agent-usecase-marketing-implement/route.tsImplement phase API route passing both brandContext and plan via callOptions.
plan/plan-agent.tsPlan builder ToolLoopAgent with callOptionsSchema + prepareCall for runtime brand context injection into instructions and experimental_context.
tools/ask-multiple-choice.tsBrand-context-aware multiple choice tool. Reads brandContext from experimental_context to tailor AI-generated questions.
tools/generate-plan.tsPlan generation tool with brand context awareness using generateObject with planSchema.
tools/refine-plan.tsPlan refinement tool with brand-context-aware iteration.
tools/ask-text-input.tsBrand-context-aware text input tool for gathering open-ended requirements.
implement/implement-agent.tsAutonomous implementation agent with prepareStep for phased workflow (triage, process todos, research, synthesis, finalize). Most advanced agent pattern: callOptionsSchema, prepareCall, prepareStep, stopWhen.
tools/finalize.tsImplementation finalization tool that reads plan from experimental_context and signals completion.
tools/update-plan.tsTool for updating plan sections from experimental_context.
tools/update-todo.tsTool for updating todo status with validation against plan.
tools/read-plan.tsTool for reading current plan state from experimental_context.
tools/read-todo.tsTool for reading/filtering todos by ID or status from the plan context.
tools/firecrawl.tsFirecrawl web search tool for real-time web research during plan implementation.
lib/marketing-plan-types.tsComplete type system including Zod schemas (BrandContext, Plan, Todo) and all type definitions for both plan and implement phases.
utils/format-brand-context.tsUtility that formats BrandContext into markdown for injection into agent instructions.
Loading preview…
Early-bird pricing — limited time

Open on desktop for the interactive preview.
Two-phase marketing agent with brand context: Stage 0 extracts brand info from URL or manual input, planning phase gathers requirements and creates a plan with todos, implementation phase executes the plan using web scraping and research tools. Uses callOptionsSchema + prepareCall for dynamic agent configuration.