Autonomous B2B Deal Flow Engine for Service Businesses
Closepilot is an AI-powered system that automates the entire B2B sales pipeline — from the moment a lead email arrives to the point a signed proposal reaches your CRM. A chain of specialized Claude AI agents handles classification, research, scoping, proposal generation, and CRM sync, with a human-in-the-loop approval layer throughout.
Most service businesses lose deals not because they can't close, but because the operational overhead of qualifying leads, scoping projects, and writing proposals is too slow and too manual. Closepilot removes that bottleneck:
- A new lead emails → within minutes a deal is created, the prospect is researched, requirements are extracted, a proposal is drafted, and your CRM is updated
- You review and approve at each major checkpoint — nothing ships without your sign-off
- Everything is audited in a real-time activity stream
End goal: A service business owner should spend zero manual effort between "lead email received" and "proposal sent" for any standard engagement.
Phase 1 complete — full build passing across all 11 packages
| Area | Status | Notes |
|---|---|---|
| Core type system | ✅ Complete | Full deal lifecycle types |
| PostgreSQL schema | ✅ Complete | Deals, activities, approvals, projects, documents |
| MCP server | ✅ Complete | 50+ tools across Deal Store, Gmail, Calendar, Drive |
| MCP client | ✅ Complete | Agent-side wrappers for all tools |
| REST API | ✅ Complete | Deals, activities, approvals endpoints |
| Next.js web UI | ✅ Complete | Dashboard, kanban, approvals, activity stream |
| OAuth / auth | ✅ Complete | Google OAuth with token refresh |
| Activity streaming | ✅ Complete | Server-Sent Events real-time feed |
| Ingestion agent | ✅ Complete | Gmail polling, AI classification, lead extraction |
| Enrichment agent | ✅ Complete | Company & prospect research via Claude |
| Scoping agent | ✅ Complete | Requirement extraction, complexity analysis |
| Proposal agent | ✅ Complete | AI proposal generation with Drive integration |
| CRM Sync agent | ✅ Complete | HubSpot, Salesforce, Pipedrive adapters |
| Orchestrator agent | ✅ Complete | Pipeline coordination with approval gates |
| Docker / deploy | 🔲 Pending | Container setup not yet configured |
| E2E tests | 🔲 Pending | Integration test suite not yet written |
| Production dogfood | 🔲 Pending | First real lead not yet run through pipeline |
Gmail Inbox
│
▼
┌─────────────────────────────────────────────────────────┐
│ Agent Pipeline │
│ │
│ Ingestion → Enrichment → Scoping → Proposal → CRM Sync │
│ ↑ ↑ ↑ ↑ ↑ │
│ └────────────┴──────────┴──────────┴─────────┘ │
│ Orchestrator (approvals) │
└─────────────────────────────────────────────────────────┘
│ │
▼ ▼
MCP Server REST API
(tools) (deal data)
│ │
└───────────┬───────────────┘
▼
PostgreSQL DB
│
▼
Next.js Web UI
(dashboard · approvals · activity)
All agents communicate exclusively through the MCP server — they never import from @closepilot/db directly. This keeps agents stateless and swappable.
| Package | Description | README |
|---|---|---|
@closepilot/core |
Shared TypeScript types for the entire deal lifecycle | → |
@closepilot/db |
PostgreSQL schema and Drizzle ORM queries | → |
@closepilot/mcp-server |
MCP server exposing 50+ tools to agents | → |
@closepilot/mcp-client |
MCP client wrappers used by agents | → |
@closepilot/api |
Hono REST API for the web UI | → |
@closepilot/web |
Next.js 15 dashboard | → |
agents/ingestion |
Gmail polling + AI lead classification | → |
agents/enrichment |
Company and prospect research | → |
agents/scoping |
Requirement extraction and scoping | → |
agents/proposal |
AI proposal generation | → |
agents/crm-sync |
CRM integration (HubSpot, Salesforce, Pipedrive) | → |
agents/orchestrator |
Pipeline coordination and approval gates | → |
| Layer | Technology |
|---|---|
| Runtime | Node.js 20+ |
| Language | TypeScript 5.3+ |
| Package manager | pnpm 8+ (workspaces) |
| Database | PostgreSQL + Drizzle ORM |
| API server | Hono 3 |
| Web UI | Next.js 15, React 18, TanStack Query |
| AI / agents | Anthropic Claude API (claude-3-5-sonnet) |
| Agent protocol | Model Context Protocol (MCP) |
| Google services | Gmail, Calendar, Drive (googleapis) |
| CRM integrations | HubSpot API, jsforce (Salesforce), Pipedrive |
| Drag & drop | @dnd-kit |
| Testing | Vitest |
- Node.js 20+
- pnpm 8+
- PostgreSQL (or Docker)
git clone <repository-url>
cd closepilot
# Install all dependencies
pnpm install
# Copy and fill in environment variables
cp .env.example .env
# Push database schema
pnpm db:push
# Build all packages
pnpm build# Database
DATABASE_URL=postgresql://localhost:5432/closepilot
# Google OAuth
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
GOOGLE_REDIRECT_URI=http://localhost:3002/auth/callback
# Google Service Account (for Drive/Docs)
GOOGLE_SERVICE_ACCOUNT_EMAIL=
GOOGLE_PRIVATE_KEY=
# Anthropic
ANTHROPIC_API_KEY=
# Auth
SESSION_SECRET=pnpm mcp:dev # MCP server → port 3000
pnpm api:dev # REST API → port 3001
pnpm web:dev # Web UI → port 3002pnpm build # Build all packages
pnpm test # Run all tests
pnpm lint # Lint all packages
pnpm typecheck # Type-check all packages
pnpm db:studio # Open Drizzle Studio (visual DB browser)
pnpm db:push # Push schema to database
pnpm db:migrate # Run migrationsThe immediate next steps to reach a production-ready system:
- Docker Compose setup — containerise all services (api, mcp-server, web, postgres) for one-command startup
- E2E integration tests — run a synthetic lead end-to-end through the entire agent pipeline
- Agent YAML configs — Claude Code agent and routine configuration files for managed execution
- Production dogfood — run the first real lead through the pipeline on a live Gmail account
- Monitoring — structured logging, error alerting, deal pipeline metrics dashboard
MIT