PRP - MeganHarrison/openai-js GitHub Wiki
PRP: Multi-Agent Orchestration Hub with Voice + Notion/Supabase Integration
Goal
Build a modular, extensible AI agent hub using openai-js SDK with a Master Agent (Business Strategist) that delegates to specialized agents based on user input (via chat or voice). Integrate Supabase (auth, db, vector store) and Notion (workspace) with two-way sync using MCP. Support voice interaction using OpenAIβs voice APIs.
Why
β’ Centralize business operations via natural AI interface
β’ Enable orchestrated multi-agent workflows (planning, research, writing, task creation)
β’ Provide flexible, modular architecture to expand agent types
β’ Seamlessly bridge structured backend (Supabase) and user workspace (Notion)
β’ Support natural interaction through voice + text
What
User-visible features:
β’ Chat interface (voice or text) connects to a Master Agent
β’ Master Agent routes requests to sub-agents:
β’ Product Manager (task/project Qs)
β’ Document Agent (RAG + file search)
β’ Financial Analyst
β’ Researcher + Writer
β’ Sales + Admin agents
β’ Output is streamed back to frontend with agent trace metadata
β’ Voice input supported with mic recording + Whisper transcription
Success Criteria
β’ Master Agent + 3 functional sub-agents (Product Manager, Document, Admin)
β’ MCP integration with Supabase + Notion servers
β’ Voice input working with Whisper transcription
β’ Supabase <β> Notion sync bi-directional
β’ Frontend UX: show chat, trace, and streaming output
All Needed Context
Documentation & References:
-
file: examples/agents-as-tools why: Shows how to register + delegate between agents
-
file: example-from-workshop-mcp-crawl4ai-refactor-1.md why: Full-stack RAG refactor, clean agent-tool separation
-
file: cc_tutorials.md why: MCP server usage, sub-agent roles, sync instructions
-
url: https://platform.openai.com/docs/guides/speech-to-text why: OpenAI Whisper API docs (for frontend voice input)
-
url: https://supabase.com/docs why: DB access, row-level auth, vector integration
Current Codebase:
openai-js/
βββ examples/
βββ packages/
β βββ agents-core/
β βββ agents-openai/
β βββ agents-realtime/
β βββ agents-extensions/
βββ scripts/
βββ docs/
βββ frontend/ (to be created)
Desired Codebase:
openai-js/
βββ frontend/ # New frontend app
β βββ pages/
β βββ components/
β βββ lib/agents.ts # Client β Master Agent bridge
β βββ lib/voice.ts # Whisper integration (mic β text)
β βββ app/agent-hub.tsx # Main agent UI
βββ packages/agents-core/
β βββ src/
β β βββ master-agent.ts # Business Strategist
β β βββ agent-registry.ts # Maps intents β agents
β β βββ tools/
β β β βββ mcp-router.ts # Routes to MCP Notion, Supabase, Apollo
βββ .mcp.json # Declares MCP servers
Gotchas & Quirks
// Safe file size < 500 lines // Whisper: supports streaming only in Chrome + Safari // Notion API: rate-limited on bulk writes // Supabase: use Row Level Security for agent-scoped access // Claude: tools must be async + return JSON
Implementation Blueprint
Task 1: Set Up Frontend Framework
CREATE frontend/ with Next.js (App Router)
- TailwindCSS + ShadCN UI
- Framer Motion + TanStack Table
Task 2: Add Voice Recording + Whisper
CREATE frontend/lib/voice.ts:
- RECORD mic input
- STREAM to Whisper endpoint
- RETURN transcript
Task 3: Build Master Agent
CREATE master-agent.ts:
- RECEIVE input
- CLASSIFY intent
- DELEGATE to agent from registry
- COMPOSE result and trace
Task 4: Build Agent Registry
CREATE agent-registry.ts:
- MAP intents to agent functions
- ADD ProductManagerAgent, DocumentAgent, AdminAgent
Task 5: Integrate Tools + MCP
CREATE tools/mcp-router.ts:
- WRAP tool calls to MCP Notion + Supabase
- ADD safeguards + retries
Task 6: Setup .mcp.json
{
"mcpServers": {
"notion": {
"command": "notion-mcp",
"args": ["--token", "$NOTION_TOKEN"]
},
"supabase": {
"command": "supabase-mcp",
"args": ["--url", "$SUPABASE_URL", "--key", "$SUPABASE_SERVICE_KEY"]
}
}
}
Task 7: Create Supabase β Notion Sync Tool
CREATE tools/sync.ts:
- LISTEN to Supabase table changes
- PUSH to Notion DB via MCP
- POLL Notion for changes
- UPSERT into Supabase
Task 8: Frontend Agent Interface
CREATE frontend/app/agent-hub.tsx:
- CHAT UI (text or voice)
- STREAM responses
- SHOW trace of agent/sub-agent/tools
Validation Loop
Level 1: Lint & Type
pnpm lint
pnpm build
Level 2: Agent Tool Tests
// test/tools.test.ts
it("routes correctly to Notion")
it("falls back if Supabase errors")
Level 3: End-to-End Voice Flow
# Start frontend + MCP
pnpm dev
# Speak: "What are our upcoming Q3 deliverables?"
# See: routed β ProductManagerAgent β Notion β Response
βΈ»
Final Checklist
β’ Multi-agent routing tested
β’ Supabase <β> Notion live sync works
β’ Claude/OpenAI tools functional
β’ Voice chat flows validated in browser
β’ UI shows live output + delegation trace
β This PRP is now ready for execution.