- Move new chat button to left side, bookmark button stays on right - Add max-width constraint (75%) to user messages with proper text wrapping - Remove right-align text from user message frames (keep bubbles on right) - Add overflow handling for code blocks in messages - Change scrollbar color from orange to gray in light and dark modes - Fix pill loading animation flicker by initializing pinnedAgents from localStorage - Add 0.2s base delay to pill animations for staggered reveal - Improve Create new button animation: longer duration (0.6s), bouncy scale sequence, easeInOut easing
10 KiB
Agent Forge & Catalog - Product Requirements Document
Overview
This PRD describes the Agent Forge feature that enables users to collaborate with Morgan (the Agent Architect) to create custom agents whose full prompts are delivered via secure tool calls, rendered with rich UI in chat, and managed in a local catalog.
Goals
- Enable users to mint custom agents through conversation with Morgan
- Securely package agent prompts without exposing them in the UI
- Provide an intuitive catalog for managing pinned agents
- Allow immediate use or persistent storage of created agents
- Set foundation for future voice/multimodal agent creation workflows
User Flows
Creating a Custom Agent
- Initiation: User selects "Create new" chip in hero or asks Morgan to create an agent
- Collaboration: Morgan runs interactive design workflow, asking questions
- Packaging: Once finalized, Morgan emits a
create_agent_packagetool call - Reveal: UI displays Agent Forge Card with animated "forging" sequence
- Action: User chooses to "Use now", "Pin for later", or "Share"
Using a Created Agent
Use Now Flow:
- Agent is registered with backend via
/api/agents/create - System switches active agent to the new custom agent
- Timeline marker confirms switch
- User can immediately start chatting
Pin Flow:
- User adds optional note about when to use the agent
- Agent is saved to localStorage
pinned-agentsarray - Confirmation message displayed
- Agent appears in pinned catalog
Managing Pinned Agents
- User clicks bookmark icon in header
- Drawer slides in from right showing all pinned agents
- User can:
- Reorder agents via drag handles
- Start chat with any agent
- Remove agents from list
- View agent metadata and notes
Technical Architecture
Morgan Behavior Updates
File: .fortura-core/agents/agent-architect.md
Changes:
- Added activation instruction for agent packaging protocol
- Added core principle about secure packaging
- Added detailed workflow documentation after YAML block
Tool Call Format:
{
"type": "tool_call",
"name": "create_agent_package",
"payload": {
"agentId": "custom-{uuid}",
"displayName": "Agent Name",
"summary": "Brief description",
"tags": ["tag1", "tag2"],
"systemPrompt": "# Web Agent Bundle Instructions...",
"hints": {
"recommendedIcon": "🔮",
"whenToUse": "Use when..."
}
}
}
API Routes
/api/agents/create (NEW):
- Accepts agent package from client
- Registers with n8n via
CUSTOM_AGENT_REGISTRATION_WEBHOOK - Fallback: stores locally if webhook not configured
- Returns success and optional
promptToken
/api/chat (UPDATED):
- Detects
create_agent_packagetool calls in responses - Forwards tool calls directly to client in
toolCallfield - Routes custom agents (ID starting with
custom-) toCUSTOM_AGENT_WEBHOOK
/api/flags (UPDATED):
- Now exposes
VOICE_INPUT_ENABLEDflag (default: false)
Type Definitions
File: src/lib/types.ts
New Types:
ToolCall: Generic tool call structureAgentPackagePayload: Agent package from MorganPinnedAgent: Stored pinned agent with metadataCustomAgent: Runtime custom agent extending Agent
Updated Types:
ChatResponse: AddedtoolCall?field
React Components
AgentForgeCard (NEW):
- Location:
src/components/agent-forge-card.tsx - Shows animated "forging" sequence initially
- Reveals metadata card with CTAs after loading
- Handles "Use now", "Pin", and "Share" actions
- Displays status badge and agent info
PinnedAgentsDrawer (NEW):
- Location:
src/components/pinned-agents-drawer.tsx - Slide-in drawer from right side
- Reorderable list with drag handles (Framer Motion Reorder)
- Start chat, view details, or remove agents
- Persists order to localStorage
ChatInterface (UPDATED):
- Added bookmark button to header for pinned drawer
- Added "Create new" chip to hero section
- Detects tool calls in
sendMessage - Renders
AgentForgeCardwhen agent package received - Handles agent registration and switching
- Integrates
PinnedAgentsDrawer
Storage
LocalStorage Keys:
pinned-agents: Array ofPinnedAgentobjectschat-session-{agentId}: Session ID per agentchat-messages-{agentId}: Message history per agent
Data Retention:
- All storage is client-side only (for now)
- System prompts stored unencrypted in localStorage
- Future: Add server-side sync and encryption
Feature Flags
File: src/lib/flags.ts
New Flag:
VOICE_INPUT_ENABLED: boolean (default: false)- Environment variable:
VOICE_INPUT_ENABLED - Future use for voice/multimodal capture
UI/UX Design
Agent Forge Card
Loading State:
- Rotating package icon
- Glass morphism styling
- Three animated progress steps:
- "Gathering intent"
- "Synthesizing persona"
- "Sealing prompt"
- Shimmer background effect
Revealed State:
- Large emoji icon badge
- Display name in Playfair font
- Summary text and tags
- "Prompt secured" status badge
- Three action buttons:
- "Use now" (gradient orange/terracotta)
- "Pin for later" (outline style)
- Share (icon button)
- Optional "When to use" hint
Pinned Agents Drawer
Layout:
- Fixed right side, full height
- Glass morphism with dark gradient
- Header with count and close button
- Scrollable card list
Agent Cards:
- Emoji icon + name + summary
- Tags display
- Optional user note
- Drag handle for reordering
- "Start chat" button
- Remove button (trash icon)
Empty State:
- Centered icon and message
- Guidance to create agents with Morgan
Hero Section Updates
New Chip:
- "+ Create new" button
- Orange gradient styling
- Populates input with creation prompt
- Positioned after agent chips
Header Buttons
Bookmark Button:
- Always visible in top-right
- Opens pinned agents drawer
- Icon: Bookmark glyph
Environment Variables
Development (.env.local)
# Existing
IMAGE_UPLOADS_ENABLED=true
DIFF_TOOL_ENABLED=true
AGENT_1_URL=https://n8n.example.com/webhook/agent-1
AGENT_1_NAME=Agent Name
AGENT_1_DESCRIPTION=Agent description
# New
VOICE_INPUT_ENABLED=false
CUSTOM_AGENT_WEBHOOK=https://n8n.example.com/webhook/custom-agent
CUSTOM_AGENT_REGISTRATION_WEBHOOK=https://n8n.example.com/webhook/register-agent
Production (wrangler.jsonc)
{
"vars": {
"IMAGE_UPLOADS_ENABLED": "true",
"DIFF_TOOL_ENABLED": "true",
"VOICE_INPUT_ENABLED": "false",
"CUSTOM_AGENT_WEBHOOK": "https://n8n.production.com/webhook/custom",
"CUSTOM_AGENT_REGISTRATION_WEBHOOK": "https://n8n.production.com/webhook/register"
}
}
n8n Integration
Custom Agent Webhook
Endpoint: CUSTOM_AGENT_WEBHOOK
Purpose: Handle messages for custom agents
Request:
{
"message": "User message",
"sessionId": "session-custom-xyz-...",
"agentId": "custom-xyz",
"timestamp": "2025-11-15T...",
"images": ["base64..."] // optional
}
Response: Standard n8n response format (streaming or JSON)
Registration Webhook
Endpoint: CUSTOM_AGENT_REGISTRATION_WEBHOOK
Purpose: Store custom agent prompts for later retrieval
Request:
{
"agentId": "custom-xyz",
"systemPrompt": "# Web Agent Bundle...",
"metadata": {
"displayName": "Aurora Researcher",
"summary": "...",
"tags": ["research"],
"recommendedIcon": "🌌",
"whenToUse": "...",
"createdAt": "2025-11-15T..."
}
}
Response:
{
"success": true,
"promptToken": "optional-token-for-retrieval"
}
Future Enhancements
Voice & Multimodal (Phase 2)
Goal: Allow users to create agents using voice and images
Components:
- Microphone button in composer
- Web Speech API or MediaRecorder integration
- Client-side transcription (optional)
- Image annotation overlay for screenshots
- Agent Forge Card shows captured media in "Research materials" section
Flag: VOICE_INPUT_ENABLED=true
Server-Side Sync (Phase 3)
Goal: Sync pinned agents across devices
Approach:
- Add user authentication
- Store pinned agents in Cloudflare KV or D1
- Encrypt system prompts server-side
- Sync on login/agent selection
Sharing & Marketplace (Phase 4)
Goal: Share custom agents with others
Features:
- Generate shareable links with prompt tokens
- Public agent marketplace
- Import from link or ID
- Ratings and reviews
Success Metrics
-
Adoption:
- % of users who create at least one custom agent
- Average custom agents per user
- % of sessions using custom agents
-
Engagement:
- Time spent creating agents
- Messages per custom agent session
- Pin rate (pinned vs. used-once)
-
Quality:
- Agent creation completion rate
- User satisfaction with created agents
- Repeat usage of pinned agents
Testing Checklist
- Morgan emits tool calls correctly
- Agent Forge Card animates and displays properly
- "Use now" registers agent and switches context
- "Pin" saves to localStorage with note
- "Share" copies agent info to clipboard
- Pinned drawer opens/closes smoothly
- Reordering saves to localStorage
- Remove button deletes from list
- Start chat loads custom agent correctly
- Custom agent messages route properly
- Morgan webhook receives tool call format
- Registration webhook stores prompts
- Feature flag disables voice input UI
- Mobile responsive behavior
- Dark mode styling
- Linter checks pass
Known Limitations
- Security: System prompts stored unencrypted in localStorage
- Sync: No cross-device synchronization
- Validation: No prompt validation before registration
- Limits: No cap on number of pinned agents
- Expiration: No automatic cleanup of old custom agents
- Voice: Implementation deferred to Phase 2
Deployment Notes
- Update Morgan's prompt file in production n8n workflows
- Configure
CUSTOM_AGENT_WEBHOOKandCUSTOM_AGENT_REGISTRATION_WEBHOOK - Set
VOICE_INPUT_ENABLED=falseinitially - Monitor custom agent creation rate
- Test tool call parsing in production environment
- Add observability for agent registration failures
Documentation Updates Needed
- Update CLAUDE.md with agent forge workflow
- Add Agent Forge usage guide
- Document n8n webhook setup
- Update README with new features
- Create video walkthrough
Status: Implementation Complete (except voice/multimodal Phase 2)
Version: 1.0
Date: 2025-11-15
Author: AI Agent Development Team