Skip to content

Repository files navigation

FundingCRM

A CRM with background AI agents that hunt for companies which recently raised funding, file them as leads, and let your team track each one through a pipeline — wrapped in a dark, terminal-style UI.

The agent layer is a deliberately small homage to the klue project's agent architecture: model traffic runs through one provider-abstraction interface (IAgentSdk, the "pi adapter" idea), so you can swap LLM providers without touching the agent loop.


What it does

  • Background scout agents — dispatch an agent (from any page, or via cron) that searches the web for recent funding announcements, verifies each against a source URL, and records structured leads. You watch the run live: a streaming transcript of every search and tool call.
  • Tracker dashboard — deal radar with pipeline breakdown, latest raises, sector mix, and recent agent runs.
  • Leads — filter/search every company; change pipeline status inline; star, prioritize, and open a full profile.
  • Company profile — funding history (rounds, investors, sources), CRM notes, and which agent run discovered it.

Architecture

app/                       Next.js App Router pages + API routes
  page.tsx                 dashboard (deal radar)
  companies/               leads list + [id] profile
  agents/                  agent run history + launcher
  api/agents/run           POST → start a background run
  api/agents/runs/[id]     GET  → poll run status + transcript
  api/companies/[id]       PATCH/DELETE a lead
  api/companies/[id]/notes POST a note

lib/agent/                 ── the agent core ──
  types.ts                 IAgentSdk interface + tool() factory (the abstraction)
  pi.ts                    Pi SDK adapter — drives the loop, emits normalized events
  registry.ts              picks the adapter from env (AGENT_SDK)
  tools.ts                 web_search + record_company tools (bound to a run)
  fundingAgent.ts          the runner: builds prompts, drives the loop, persists transcript
lib/search.ts              web search client (Tavily / Serper)
lib/queries.ts             server-side data access for pages
lib/db.ts                  Prisma client singleton

prisma/schema.prisma       Company · FundingRound · Note · AgentRun (SQLite)
prisma/seed.ts             realistic demo data
scripts/run-agent.ts       headless run for cron: `npm run agent:run`

The Pi adapter

Everything the runner needs from an LLM is behind IAgentSdk (lib/agent/types.ts): run({ model, systemPrompt, prompt, tools }) returns an async stream of normalized AgentEvents. The single adapter, lib/agent/pi.ts, wraps the Pi SDK (@earendil-works/pi-coding-agent) — Pi owns the agentic tool-use loop, and the adapter translates Pi's event stream into our AgentEvents. Pi is multi-provider, so the same code targets Claude, GPT, or any custom Anthropic/OpenAI-protocol endpoint; the provider is chosen from env. We do not depend on @anthropic-ai/sdk — the Anthropic API key is just a credential Pi uses to reach Claude.

Getting started

npm install
cp .env.example .env        # then fill in keys (see below)
npm run db:push             # create the SQLite schema
npm run db:seed             # load demo leads
npm run dev                 # http://localhost:3000

Environment

Var Purpose
ANTHROPIC_API_KEY Claude API key. Set this or CLAUDE_CODE_OAUTH_TOKEN for live runs.
CLAUDE_CODE_OAUTH_TOKEN Claude OAuth token from claude setup-token (prefix sk-ant-oat). Alternative to the API key.
AGENT_MODEL Pi catalog model id (default claude-sonnet-4-6).
SEARCH_PROVIDER tavily (default) or serper.
TAVILY_API_KEY Required if SEARCH_PROVIDER=tavily.
SERPER_API_KEY Required if SEARCH_PROVIDER=serper.
DATABASE_URL SQLite path (default file:./dev.db).
SHOW_DEMO_DATA true (default) shows the seeded demo leads; false hides all demo records so only real, agent-discovered leads appear.
AGENT_RUN_SECRET Optional shared secret to gate the run API (for cron).

Without the keys, the UI and demo data work fully; only live agent runs need ANTHROPIC_API_KEY (or CLAUDE_CODE_OAUTH_TOKEN) + a search key. A run started without them ends cleanly with a "no credentials" message in the transcript.

Run a scout

  • In-app: click Run scout (top bar), set sector/region/recency, dispatch, and watch the live transcript.
  • Headless / cron:
    npm run agent:run -- --sector AI --region Europe --lookback 14 --limit 6

Useful scripts

Command Does
npm run dev dev server
npm run build prisma generate + production build
npm run db:seed seed demo data
npm run db:reset wipe + recreate + reseed
npm run db:studio Prisma Studio
npm run agent:run headless agent run

Stack

Next.js 15 · React 19 · TypeScript · Tailwind CSS · Prisma + SQLite · @earendil-works/pi-coding-agent (Pi SDK) · Zod.

About

AI Powered Agentic CRM

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages