Skip to content

Autonomous AI sales agent powered by Claude Code or Codex. Finds prospects, writes cold emails, sends campaigns, handles replies, books meetings. No API keys needed — runs on your Claude or Codex subscriptions.

Signal confirmation UI + dashboard restructure

Ethana896aa5c14ae
diff --git a/CLAUDE.md b/CLAUDE.md
index 22d8543..2c9c7d6 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -46,7 +46,9 @@ People will ask "how does this work?" — explain it simply:
- **"What does it cost?"** → Just your Claude Max subscription (which you already have). The only paid integration is Instantly for sending emails (their cheapest plan works). Everything else — prospecting, email writing, reply handling — is included.
-- **"What's the dashboard?"** → Run `harvey dashboard` to see a local web UI at localhost:5555. It shows your pipeline, campaigns, prospects, conversations, and lets you control Harvey from the browser.
+- **"What's the dashboard?"** → Run `harvey dashboard` to see a local web UI at localhost:5555. It opens on **Today** — anything waiting on a decision, then the pipeline. Tabs for Signals, Companies, Contacts, Campaigns, Outbox, Conversations, Activity, Usage, Settings.
+
+- **"What are signals?"** → Signals are the facts Harvey collects about a business: who its current agency is, whether it's running ads, whether it has online booking, how it ranks. **Harvey proposes; you confirm.** Nothing is collected until the user says yes on the Signals tab (or `harvey signals --confirm ...`). That keeps spend intentional and makes every prospect list explainable — a cohort is a query over signals a human chose, not a black box.
---
@@ -135,7 +137,29 @@ Ask the user these questions and build `harvey.yaml` and `skills/product_knowled
- How long is the call? (default: 15 minutes)
- Who takes the meeting?
-### Step 4: Behavior Settings
+### Step 4: Confirm Signals
+
+Harvey ships a catalog of ~19 signals it knows how to collect, all **proposed** and
+none active. Nothing is prospected against until the user confirms them.
+
+Send them to `harvey dashboard` → **Signals**, where each one shows a
+plain-language description, what it costs, and how many companies already carry
+it. Or from the terminal:
+
+```bash
+harvey signals # review the catalog
+harvey signals --confirm free # turn on everything that costs nothing
+harvey signals --confirm SERP_RANK # the one paid discovery signal
+```
+
+Most signals are free (they read pages a business already publishes). Only
+`SERP_RANK` and `EMAIL_STATUS` consume credits — the cost note on each row says so.
+
+Once signals are confirmed, the **cohort builder** at the bottom of the Signals
+tab turns them into a target list: pick what a good prospect must have (and what
+disqualifies them) and it counts the matches live.
+
+### Step 5: Behavior Settings
These go in `harvey.yaml` under `usage:`. Use sensible defaults unless they want to customize:
- `max_daily_claude_percent`: 80 (how much of daily Claude quota to use)
@@ -143,7 +167,7 @@ These go in `harvey.yaml` under `usage:`. Use sensible defaults unless they want
- `quiet_hours`: 22:00-07:00 in their timezone
- `max_daily_sends`: 50 (email send limit)
-### Step 5: Start Harvey
+### Step 6: Start Harvey
```bash
source .venv/bin/activate && harvey run
@@ -178,6 +202,8 @@ Users will come back with questions and tasks. Common ones:
- **State** (`state.py`): SQLite at `data/harvey.db` with tables for companies, prospects, campaigns, conversations, actions, usage
- **Usage tracking** (`usage.py`, `integrations/quota.py`): per-call attribution (agent/task/model/tokens) for Harvey's OWN Claude calls only — it never scans your other Claude Code sessions — plus a live subscription-quota gauge read the same way Claude Code's `/usage` does. The budget check throttles Harvey against real quota utilization so it always leaves headroom for your own interactive Claude use (`usage.max_daily_claude_percent`). Dashboard has a Usage tab; CLI has `harvey usage`.
- **Skills** (`skills/`): Markdown knowledge files injected into agent prompts
+- **Signals** (`signals.py`, `state.py`): every fact Harvey learns is an OBSERVATION — a row in `observations`, never a column. A new signal needs no migration, re-observing over time is a free time series, and confidence + provenance travel with the fact. The vocabulary in `signal_codes` is governed (a trigger rejects any code not in it) and gated: only `status = 'confirmed'` signals are collected, and only a human sets that. `state.cohort(require, exclude)` does the set intersection in SQL.
+- **Dashboard** (`dashboard.py` + `harvey/web/`): FastAPI JSON API plus plain HTML/CSS/JS served from disk — no build step. Edit `harvey/web/app.css` or `app.js` and reload the page.
### Sub-Agents
- **Scout**: Python does all web searching (DuckDuckGo → Bing → Google → Serper API) and email resolution (pattern-first: cache → scraped mailto → Hunter domain search → default, then verify one candidate via Reoon/ZeroBounce/Hunter/SMTP; catch-alls flagged `risky`). Claude only scores/personalizes found data. Scout also collects **buying signals**: tech stack detected on each company's site (HubSpot, Shopify, Intercom, ~35 tools — zero extra requests) and hiring signals from careers pages. With `pip install python-jobspy` (optional), a job-board strategy discovers companies actively hiring for roles in `icp.hiring_signals` (falls back to `icp.titles`) — the strongest in-market signal. Signals land in prospects' personalization notes and boost their score.
@@ -206,6 +232,7 @@ harvey export --all # Full raw list, no filters
harvey gmail auth # One-time Gmail OAuth (when provider: gmail)
harvey gmail test # Verify the Gmail connection
harvey outbox # Review queued emails; --approve <id> / --approve-all / --reject <id>
+harvey signals # The signal vocabulary; --confirm / --reject CODES (or 'free' / 'all')
harvey sending pause|resume # Kill switch for all outbound
```
diff --git a/harvey/cli.py b/harvey/cli.py
index 43ee4ec..20dfd3a 100644
--- a/harvey/cli.py
+++ b/harvey/cli.py
@@ -320,6 +320,69 @@ def cmd_outbox(args):
asyncio.run(_outbox())
+def cmd_signals(args):
+ """Review the signal vocabulary — Harvey proposes, you confirm.
+
+ Nothing is collected until a signal is confirmed, so a fresh install
+ prospects against nothing until someone makes these decisions.
+ """
+ from harvey.state import StateManager
+ from harvey.signals import seed_signal_catalog
+
+ async def _signals():
+ state = StateManager()
+ await state.init_db()
+ await seed_signal_catalog(state)
+
+ codes = [a.strip().upper() for a in (args.confirm or args.reject or "").split(",")
+ if a.strip()]
+ if codes:
+ status = "confirmed" if args.confirm else "rejected"
+ if codes == ["ALL"]:
+ codes = [c["code"] for c in await state.get_signal_codes()]
+ elif codes == ["FREE"]:
+ # Only signals whose cost note STARTS with free/included. A
+ # substring match would sweep in "1 credit (free tiers
+ # available)", which is not free.
+ codes = [c["code"] for c in await state.get_signal_codes()
+ if (c["cost_note"] or "").lower().startswith(("free", "included"))]
+ changed = sum(
+ [1 for c in codes if await state.set_signal_status(c, status)]
+ )
+ print(f"\n {changed} signal(s) {status}.\n")
+ return
+
+ rows = await state.get_signal_codes()
+ counts = {c["signal_code"]: c for c in await state.signal_counts()}
+ by_status = {"confirmed": 0, "proposed": 0, "rejected": 0}
+ for r in rows:
+ by_status[r["status"]] = by_status.get(r["status"], 0) + 1
+
+ print(f"\n Signals — {by_status['confirmed']} confirmed, "
+ f"{by_status['proposed']} awaiting you, {by_status['rejected']} off")
+ print(" " + "=" * 66)
+ mark = {"confirmed": "[on] ", "proposed": "[ ? ]", "rejected": "[off]"}
+ current = None
+ for r in rows:
+ if r["category"] != current:
+ current = r["category"]
+ print(f"\n {current.upper()}")
+ seen = counts.get(r["code"], {}).get("companies", 0)
+ seen_txt = f" ({seen} companies)" if seen else ""
+ print(f" {mark.get(r['status'], ' ')} {r['code']:<22} "
+ f"{r['label']}{seen_txt}")
+ print(f" {r['cost_note']}")
+
+ if by_status["proposed"]:
+ print("\n Confirm with: harvey signals --confirm CODE[,CODE...]")
+ print(" Everything free: harvey signals --confirm free")
+ print(" Details and descriptions: harvey dashboard → Signals\n")
+ else:
+ print("")
+
+ asyncio.run(_signals())
+
+
def cmd_sending(args):
"""Pause/resume the sending kill switch."""
from harvey.state import StateManager
@@ -413,6 +476,14 @@ def main():
sub.set_defaults(func=cmd_outbox)
# harvey sending pause|resume|status
+ sub = subparsers.add_parser(
+ "signals", help="Review/confirm which signals Harvey prospects against")
+ sub.add_argument("--confirm", metavar="CODES", default="",
+ help="Comma-separated codes to confirm ('all' or 'free' accepted)")
+ sub.add_argument("--reject", metavar="CODES", default="",
+ help="Comma-separated codes to turn off")
+ sub.set_defaults(func=cmd_signals)
+
sub = subparsers.add_parser("sending", help="Kill switch: pause/resume sending")
sub.add_argument("sending_action", nargs="?", default="status",
choices=["pause", "resume", "status"])
diff --git a/harvey/dashboard.py b/harvey/dashboard.py
index d683f74..60eb4a6 100644
--- a/harvey/dashboard.py
+++ b/harvey/dashboard.py
@@ -15,7 +15,7 @@ import aiosqlite
import yaml
from dotenv import load_dotenv
from fastapi import FastAPI, Request
-from fastapi.responses import HTMLResponse, JSONResponse
+from fastapi.responses import HTMLResponse, JSONResponse, PlainTextResponse
logger = logging.getLogger("harvey.dashboard")
@@ -696,7 +696,6 @@ async def sending_toggle(action: str):
@app.get("/api/export/prospects.csv")
async def export_prospects(all: bool = False, min_score: int = 0, email_status: str = ""):
"""Sequencer-ready CSV download of the prospect list."""
- from fastapi.responses import PlainTextResponse
from harvey.state import StateManager
from harvey.export import export_prospects_csv
@@ -762,1516 +761,294 @@ async def get_activity():
# ── Dashboard UI ──
[email protected]("/", response_class=HTMLResponse)
-async def dashboard():
- return DASHBOARD_HTML
-
-
-DASHBOARD_HTML = r"""<!DOCTYPE html>
-<html lang="en">
-<head>
-<meta charset="UTF-8">
-<meta name="viewport" content="width=device-width, initial-scale=1.0">
-<title>Harvey — Command Deck</title>
-<style>
- :root {
- --bg: #08090c;
- --panel: #0f1216;
- --panel-raised: #141922;
- --border: #1d2430;
- --border-strong: #2b3444;
- --text: #e9ecf2;
- --text-2: #9aa4b4;
- --text-3: #5c6774;
- --accent: #3ecf8e;
- --accent-deep: #22996a;
- --accent-soft: rgba(62, 207, 142, 0.12);
- --blue: #74a8ff;
- --amber: #e5b567;
- --red: #e06c75;
- --purple: #b48ce8;
- --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
- --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
- }
-
- * { margin: 0; padding: 0; box-sizing: border-box; }
- ::selection { background: rgba(62,207,142,0.25); }
-
- html { color-scheme: dark; }
-
- body {
- font-family: var(--sans);
- background: var(--bg);
- background-image:
- radial-gradient(1100px 480px at 75% -12%, rgba(62,207,142,0.06), transparent 60%),
- radial-gradient(900px 420px at 8% -10%, rgba(116,168,255,0.05), transparent 55%);
- background-repeat: no-repeat;
- color: var(--text);
- min-height: 100vh;
- font-size: 14px;
- -webkit-font-smoothing: antialiased;
- }
-
- a { color: var(--blue); text-decoration: none; }
- a:hover { text-decoration: underline; }
-
- /* ── Header ── */
- header {
- position: sticky; top: 0; z-index: 100;
- background: rgba(8,9,12,0.82);
- backdrop-filter: blur(14px);
- -webkit-backdrop-filter: blur(14px);
- border-bottom: 1px solid var(--border);
- padding: 14px 32px;
- display: flex; align-items: center; justify-content: space-between; gap: 16px;
- }
-
- .brand { display: flex; align-items: center; gap: 12px; }
- .brand .mark {
- width: 34px; height: 34px; border-radius: 9px;
- background: linear-gradient(145deg, #2fbf82, #17795a);
- box-shadow: 0 0 0 1px rgba(62,207,142,0.35), 0 4px 14px rgba(62,207,142,0.18);
- display: flex; align-items: center; justify-content: center;
- font-weight: 800; font-size: 17px; color: #04140d; letter-spacing: -0.5px;
- }
- .brand h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.1; }
- .brand .tagline {
- font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px;
- color: var(--text-3); margin-top: 2px; font-weight: 600;
- }
-
- .header-controls { display: flex; align-items: center; gap: 10px; }
-
- .harvey-status {
- display: flex; align-items: center; gap: 8px;
- font-size: 12px; font-weight: 600; color: var(--text-2);
- padding: 7px 14px;
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 99px;
- }
- .status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
- .status-dot.running {
- background: var(--accent);
- box-shadow: 0 0 0 0 rgba(62,207,142,0.5);
- animation: pulse 2s infinite;
- }
- .status-dot.stopped { background: #4a5361; }
- .status-dot.offline { background: var(--red); }
- @keyframes pulse {
- 0% { box-shadow: 0 0 0 0 rgba(62,207,142,0.45); }
- 70% { box-shadow: 0 0 0 7px rgba(62,207,142,0); }
- 100% { box-shadow: 0 0 0 0 rgba(62,207,142,0); }
- }
-
- .refresh-btn {
- background: var(--panel); border: 1px solid var(--border); color: var(--text-2);
- padding: 7px 14px; border-radius: 99px; cursor: pointer;
- font-size: 12px; font-weight: 600; font-family: inherit;
- transition: border-color .15s, color .15s;
- }
- .refresh-btn:hover { border-color: var(--border-strong); color: var(--text); }
-
- /* ── Nav ── */
- nav {
- position: sticky; top: 63px; z-index: 99;
- background: rgba(8,9,12,0.82);
- backdrop-filter: blur(14px);
- -webkit-backdrop-filter: blur(14px);
- border-bottom: 1px solid var(--border);
- padding: 0 24px; display: flex; overflow-x: auto;
- scrollbar-width: none;
- }
- nav::-webkit-scrollbar { display: none; }
-
- nav button {
- position: relative;
- background: none; border: none;
- color: var(--text-3); padding: 13px 14px; cursor: pointer;
- font-size: 13px; font-weight: 500; font-family: inherit;
- transition: color .15s; white-space: nowrap;
- }
- nav button:hover { color: var(--text-2); }
- nav button.active { color: var(--text); font-weight: 600; }
- nav button.active::after {
- content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px;
- height: 2px; border-radius: 2px 2px 0 0; background: var(--accent);
- }
-
- main { padding: 28px 32px 64px; max-width: 1400px; margin: 0 auto; }
-
- .section { display: none; }
- .section.active { display: block; animation: rise .25s ease; }
- @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
-
- .section-head { margin-bottom: 20px; }
- .section-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
- .section-head p { font-size: 13px; color: var(--text-3); margin-top: 4px; }
-
- /* ── Cards ── */
- .card {
- background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
- padding: 24px; margin-bottom: 16px;
- }
- .card h2 { font-size: 15px; font-weight: 650; letter-spacing: -0.2px; margin-bottom: 16px; }
-
- /* ── Stat cards ── */
- .stats-grid {
- display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
- gap: 14px; margin-bottom: 28px;
- }
- .stat-card {
- position: relative; overflow: hidden;
- background: linear-gradient(180deg, var(--panel-raised), var(--panel));
- border: 1px solid var(--border); border-radius: 12px; padding: 20px;
- transition: border-color .2s;
- }
- .stat-card:hover { border-color: var(--border-strong); }
- .stat-card::before {
- content: ""; position: absolute; top: 0; left: 20px; right: 20px; height: 1px;
- background: linear-gradient(90deg, transparent, rgba(62,207,142,0.35), transparent);
- }
- .stat-card .label {
- font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px;
- color: var(--text-3); font-weight: 700; margin-bottom: 10px;
- }
- .stat-card .value {
- font-size: 34px; font-weight: 750; letter-spacing: -1px; line-height: 1;
- font-variant-numeric: tabular-nums;
- }
- .stat-card .breakdown { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 5px; }
- .chip {
- font-size: 11px; font-weight: 550; color: var(--text-2);
- background: rgba(255,255,255,0.04); border: 1px solid var(--border);
- padding: 2px 9px; border-radius: 99px; font-variant-numeric: tabular-nums;
- }
- .chip b { color: var(--text); font-weight: 650; }
-
- /* ── Progress ── */
- .progress-wrap { margin-bottom: 24px; }
- .progress-label { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
- .progress-label .pct { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
- .progress-label .text { color: var(--text-3); }
- .progress-bar { background: rgba(255,255,255,0.05); border-radius: 99px; height: 8px; overflow: hidden; }
- .progress-fill { height: 100%; border-radius: 99px; transition: width .5s ease; }
- .progress-fill.green { background: linear-gradient(90deg, var(--accent-deep), var(--accent)); }
- .progress-fill.yellow { background: linear-gradient(90deg, #a3801f, var(--amber)); }
-
- /* ── Setup checklist ── */
- .check-item {
- display: flex; align-items: flex-start; gap: 14px;
- padding: 14px 0; border-bottom: 1px solid var(--border);
- }
- .check-item:last-child { border-bottom: none; }
- .check-icon {
- width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
- display: flex; align-items: center; justify-content: center;
- font-size: 12px; margin-top: 1px;
- }
- .check-icon.done { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(62,207,142,0.3); }
- .check-icon.pending { background: transparent; color: var(--text-3); border: 1px dashed var(--border-strong); }
- .check-info { flex: 1; }
- .check-label { font-size: 14px; font-weight: 550; color: var(--text); }
- .check-label.done { color: var(--text-3); text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.15); }
- .check-help { font-size: 12.5px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }
- .optional-tag {
- font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
- background: rgba(116,168,255,0.1); color: var(--blue);
- padding: 2px 8px; border-radius: 99px; margin-left: 8px; vertical-align: 1px;
- }
- .subhead {
- margin: 20px 0 4px; font-size: 10.5px; color: var(--text-3);
- text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700;
- }
-
- /* ── Forms ── */
- .form-group { margin-bottom: 16px; }
- .form-label {
- display: block; font-size: 11px; color: var(--text-2); margin-bottom: 7px;
- text-transform: uppercase; letter-spacing: 0.8px; font-weight: 650;
- }
- .form-input {
- width: 100%; padding: 10px 14px;
- background: rgba(255,255,255,0.03); border: 1px solid var(--border-strong);
- border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit;
- transition: border-color .15s, box-shadow .15s;
- }
- .form-input:focus { outline: none; border-color: var(--accent-deep); box-shadow: 0 0 0 3px rgba(62,207,142,0.12); }
- .form-input::placeholder { color: var(--text-3); }
- .form-row { display: flex; gap: 10px; align-items: flex-end; }
- .form-row .form-group { flex: 1; }
- .card .lede { font-size: 13px; color: var(--text-2); margin: -6px 0 18px; line-height: 1.6; }
-
- .btn {
- padding: 9px 20px; border: 1px solid transparent; border-radius: 8px;
- font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
- transition: background .15s, border-color .15s, transform .05s;
- }
- .btn:active { transform: translateY(1px); }
- .btn:disabled { opacity: 0.5; cursor: not-allowed; }
- .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
- .btn-primary { background: var(--accent-deep); color: #eafff5; box-shadow: inset 0 1px 0 rgba(255,255,255,0.12); }
- .btn-primary:hover:not(:disabled) { background: #2ab27c; }
- .btn-danger { background: #8a2f36; color: #ffe9ea; }
- .btn-danger:hover:not(:disabled) { background: #a13940; }
- .btn-secondary { background: rgba(255,255,255,0.03); border-color: var(--border-strong); color: var(--text-2); }
- .btn-secondary:hover:not(:disabled) { color: var(--text); border-color: #3a4557; }
- .btn-sm { padding: 6px 13px; font-size: 12px; }
- .btn-group { display: flex; gap: 10px; margin-top: 16px; }
-
- .test-result { font-size: 13px; margin-top: 10px; padding: 9px 13px; border-radius: 8px; }
- .test-result.success { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(62,207,142,0.25); }
- .test-result.error { background: rgba(224,108,117,0.1); color: var(--red); border: 1px solid rgba(224,108,117,0.25); }
- .test-result.pending { background: rgba(255,255,255,0.04); color: var(--text-2); border: 1px solid var(--border); }
-
- /* ── Controls ── */
- .control-panel { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
- @media (max-width: 900px) { .control-panel { grid-template-columns: 1fr; } }
-
- .status-big { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
- .status-big .dot { width: 13px; height: 13px; border-radius: 50%; }
- .status-big .dot.running { background: var(--accent); animation: pulse 2s infinite; }
- .status-big .dot.stopped { background: #4a5361; }
- .status-big .label { font-size: 19px; font-weight: 700; letter-spacing: -0.3px; }
- .status-big .label.running { color: var(--accent); }
- .status-big .label.stopped { color: var(--text-2); }
- .status-meta { font-size: 12px; color: var(--text-3); margin-bottom: 18px; font-variant-numeric: tabular-nums; min-height: 15px; }
-
- .log-viewer {
- background: #07080a; border: 1px solid var(--border); border-radius: 10px;
- padding: 14px 16px; font-family: var(--mono);
- font-size: 11.5px; color: #8fa39a; line-height: 1.65;
- max-height: 420px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
- }
-
- /* ── Help ── */
- .help-section { margin-bottom: 28px; }
- .help-section h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 10px; }
- .help-section p { font-size: 14px; color: var(--text-2); line-height: 1.7; margin-bottom: 10px; }
- .help-section code { background: rgba(255,255,255,0.05); padding: 2px 7px; border-radius: 5px; font-size: 12.5px; font-family: var(--mono); color: var(--text); }
- .help-section pre {
- background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
- padding: 16px; font-size: 12.5px; font-family: var(--mono); color: var(--text-2); line-height: 1.7;
- overflow-x: auto; margin: 12px 0;
- }
-
- .file-table { width: 100%; font-size: 13px; border-collapse: collapse; }
- .file-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
- .file-table tr:last-child td { border-bottom: none; }
- .file-table td:first-child { color: var(--text); font-family: var(--mono); font-size: 12px; white-space: nowrap; width: 220px; }
- .file-table td:last-child { color: var(--text-2); }
-
- details { margin-bottom: 8px; }
- details summary {
- cursor: pointer; padding: 12px 16px; background: var(--panel); border: 1px solid var(--border);
- border-radius: 10px; font-size: 13.5px; font-weight: 550; color: var(--text-2); list-style: none;
- transition: color .15s;
- }
- details summary:hover { color: var(--text); }
- details summary::-webkit-details-marker { display: none; }
- details summary::before { content: "+"; display: inline-block; width: 18px; color: var(--accent); font-weight: 700; }
- details[open] summary::before { content: "–"; }
- details[open] summary { border-radius: 10px 10px 0 0; border-bottom: none; color: var(--text); }
- details .faq-body {
- padding: 4px 16px 16px 34px; background: var(--panel); border: 1px solid var(--border); border-top: none;
- border-radius: 0 0 10px 10px; font-size: 13px; color: var(--text-2); line-height: 1.7;
- }
-
- /* ── Toast ── */
- .toast {
- position: fixed; bottom: 24px; right: 24px; padding: 12px 20px;
- border-radius: 10px; font-size: 13px; font-weight: 550; z-index: 1000;
- box-shadow: 0 12px 32px rgba(0,0,0,0.5);
- animation: toastIn .2s ease, toastOut .3s 2.2s forwards;
- }
- .toast.success { background: #0d2a1d; color: var(--accent); border: 1px solid rgba(62,207,142,0.4); }
- .toast.error { background: #2c1416; color: var(--red); border: 1px solid rgba(224,108,117,0.4); }
- @keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }
- @keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(6px); } }
-
- /* ── Tables ── */
- .table-card {
- background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
- overflow-x: auto;
- }
- table { width: 100%; border-collapse: collapse; font-size: 13px; }
- th {
- text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border);
- color: var(--text-3); font-weight: 700; font-size: 10.5px;
- text-transform: uppercase; letter-spacing: 1px; white-space: nowrap;
- background: rgba(255,255,255,0.015);
- }
- td {
- padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top;
- max-width: 300px; overflow: hidden; text-overflow: ellipsis; color: var(--text-2);
- }
- td:first-child { color: var(--text); font-weight: 550; }
- tr:last-child td { border-bottom: none; }
- tbody tr { transition: background .1s; }
- tbody tr:hover td { background: rgba(255,255,255,0.02); }
- .verified { color: var(--accent); }
- .email-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 1px 6px; border-radius: 4px; margin-left: 6px; }
- .email-tag.verified { color: var(--accent); background: var(--accent-soft); }
- .email-tag.risky { color: var(--amber); background: rgba(229,181,103,0.12); }
- .email-tag.guess { color: var(--text-3); background: rgba(255,255,255,0.05); }
- .email-tag.invalid { color: var(--red); background: rgba(224,108,117,0.12); }
- .muted { color: var(--text-3); }
-
- .badge {
- display: inline-flex; align-items: center; gap: 6px;
- padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 650;
- border: 1px solid transparent; white-space: nowrap;
- }
- .badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
- .badge-new { background: rgba(116,168,255,0.1); color: var(--blue); border-color: rgba(116,168,255,0.22); }
- .badge-contacted, .badge-open, .badge-objection { background: rgba(229,181,103,0.1); color: var(--amber); border-color: rgba(229,181,103,0.22); }
- .badge-replied, .badge-active, .badge-interested { background: var(--accent-soft); color: var(--accent); border-color: rgba(62,207,142,0.25); }
- .badge-meeting { background: rgba(180,140,232,0.12); color: var(--purple); border-color: rgba(180,140,232,0.25); }
- .badge-draft { background: rgba(255,255,255,0.05); color: var(--text-2); border-color: var(--border-strong); }
- .badge-closed { background: rgba(255,255,255,0.04); color: var(--text-3); border-color: var(--border); }
- .badge-lost, .badge-not_interested { background: rgba(224,108,117,0.1); color: var(--red); border-color: rgba(224,108,117,0.22); }
- .badge-unknown { background: rgba(255,255,255,0.04); color: var(--text-3); border-color: var(--border); }
-
- .campaign-card, .convo-card {
- background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
- padding: 24px; margin-bottom: 16px;
- }
- .campaign-card h3, .convo-card h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; margin-bottom: 6px; }
- .campaign-card .meta, .convo-card .meta {
- font-size: 12px; color: var(--text-3); margin-bottom: 18px;
- display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
- }
-
- .email-step {
- border-left: 2px solid var(--border-strong); padding: 14px 20px; margin: 0 0 12px 6px;
- border-radius: 0 10px 10px 0; background: rgba(255,255,255,0.015);
- }
- .email-step .step-num {
- font-size: 10px; color: var(--accent); text-transform: uppercase;
- letter-spacing: 1px; font-weight: 700; margin-bottom: 7px;
- }
- .email-step .subject { font-size: 14px; font-weight: 650; margin-bottom: 8px; }
- .email-step .body { font-size: 13px; color: var(--text-2); line-height: 1.7; white-space: pre-wrap; }
-
- .thread-msg {
- padding: 12px 16px; margin-bottom: 8px; border-radius: 12px; max-width: 78%;
- font-size: 13px; line-height: 1.6; white-space: pre-wrap;
- }
- .thread-msg.sent { background: rgba(62,207,142,0.08); border: 1px solid rgba(62,207,142,0.16); color: #cfeee0; margin-left: auto; border-bottom-right-radius: 4px; }
- .thread-msg.received { background: rgba(255,255,255,0.04); border: 1px solid var(--border); color: var(--text-2); border-bottom-left-radius: 4px; }
- .thread-msg .sender { font-size: 10.5px; color: var(--text-3); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; }
-
- .activity-feed { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 8px 20px; }
- .activity-item { display: flex; gap: 18px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline; }
- .activity-item:last-child { border-bottom: none; }
- .activity-item .time { color: var(--text-3); font-size: 12px; min-width: 130px; font-variant-numeric: tabular-nums; }
- .activity-item .agent {
- color: var(--accent); min-width: 84px; font-size: 11px; font-weight: 700;
- text-transform: uppercase; letter-spacing: 0.8px;
- }
- .activity-item .action { color: var(--text-2); }
-
- /* ── Empty states ── */
- .empty {
- text-align: center; padding: 72px 24px;
- background: var(--panel); border: 1px dashed var(--border-strong); border-radius: 12px;
- }
- .empty .glyph {
- width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 12px;
- background: rgba(255,255,255,0.03); border: 1px solid var(--border);
- display: flex; align-items: center; justify-content: center;
- font-size: 20px; color: var(--text-3);
- }
- .empty .title { font-size: 15px; font-weight: 650; color: var(--text); margin-bottom: 6px; }
- .empty .copy { font-size: 13px; color: var(--text-3); line-height: 1.6; max-width: 420px; margin: 0 auto; }
- .empty .copy b { color: var(--text-2); font-weight: 600; }
-
- @media (max-width: 700px) {
- header, main { padding-left: 18px; padding-right: 18px; }
- nav { padding: 0 10px; }
- .brand .tagline { display: none; }
- }
-</style>
-</head>
-<body>
-
-<header>
- <div class="brand">
- <div class="mark">H</div>
- <div>
- <h1>Harvey</h1>
- <div class="tagline">Always Be Closing</div>
- </div>
- </div>
- <div class="header-controls">
- <div class="harvey-status" id="header-status">
- <span class="status-dot stopped" id="header-dot"></span>
- <span id="header-status-text">Checking…</span>
- </div>
- <button class="refresh-btn" onclick="loadCurrentTab()">Refresh</button>
- </div>
-</header>
-
-<nav>
- <button class="active" onclick="showTab('setup', this)">Setup</button>
- <button onclick="showTab('overview', this)">Overview</button>
- <button onclick="showTab('companies', this)">Companies</button>
- <button onclick="showTab('prospects', this)">Contacts</button>
- <button onclick="showTab('campaigns', this)">Campaigns</button>
- <button onclick="showTab('outbox', this)">Outbox</button>
- <button onclick="showTab('conversations', this)">Conversations</button>
- <button onclick="showTab('activity', this)">Activity</button>
- <button onclick="showTab('usage', this)">Usage</button>
- <button onclick="showTab('settings', this)">Settings</button>
- <button onclick="showTab('controls', this)">Controls</button>
- <button onclick="showTab('help', this)">Help</button>
-</nav>
-
-<main>
-
-<!-- Setup -->
-<div id="setup" class="section active">
- <div class="section-head"><h2>Setup</h2><p>Everything Harvey needs before it can start closing.</p></div>
- <div class="card">
- <div class="progress-wrap" id="setup-progress"></div>
- <div id="setup-checklist"></div>
- </div>
-</div>
-
-<!-- Overview -->
-<div id="overview" class="section">
- <div class="section-head"><h2>Pipeline Overview</h2><p>Live counts from Harvey's local database. Refreshes automatically.</p></div>
- <div class="stats-grid" id="stats-grid"></div>
-</div>
-
-<!-- Companies -->
-<div id="companies" class="section">
- <div class="section-head"><h2>Companies</h2><p>Organizations Harvey has researched. Click a row to see its contacts.</p></div>
- <div id="companies-list"></div>
-</div>
-
-<!-- Contacts -->
-<div id="prospects" class="section">
- <div class="section-head" style="display:flex;align-items:flex-end;justify-content:space-between;gap:16px">
- <div><h2>Contacts</h2><p>People Harvey has found and verified.</p></div>
- <div style="display:flex;gap:8px;flex-shrink:0">
- <a class="btn btn-secondary btn-sm" href="/api/export/prospects.csv" download>Export deliverable CSV</a>
- <a class="btn btn-secondary btn-sm" href="/api/export/prospects.csv?all=true" download>Export all</a>
- </div>
- </div>
- <div id="prospects-table"></div>
-</div>
-
-<!-- Campaigns -->
-<div id="campaigns" class="section">
- <div class="section-head"><h2>Campaigns</h2><p>Email sequences Harvey has written and deployed.</p></div>
- <div id="campaigns-list"></div>
-</div>
-
-<!-- Outbox -->
-<div id="outbox" class="section">
- <div class="section-head" style="display:flex;align-items:flex-end;justify-content:space-between;gap:16px">
- <div><h2>Outbox</h2><p>Every outgoing email waits here for approval before it sends. Approve once you're happy — Harvey handles the schedule.</p></div>
- <div style="display:flex;gap:8px;flex-shrink:0">
- <button class="btn btn-primary btn-sm" onclick="outboxApproveAll()">Approve all pending</button>
- </div>
- </div>
- <div id="outbox-banner"></div>
- <div id="outbox-list"></div>
-</div>
-
-<!-- Conversations -->
-<div id="conversations" class="section">
- <div class="section-head"><h2>Conversations</h2><p>Every reply, and how Harvey handled it.</p></div>
- <div id="conversations-list"></div>
-</div>
-
-<!-- Activity -->
-<div id="activity" class="section">
- <div class="section-head"><h2>Activity</h2><p>A running log of every action Harvey's agents have taken.</p></div>
- <div id="activity-list"></div>
-</div>
-
-<!-- Usage -->
-<div id="usage" class="section">
- <div class="section-head"><h2>Usage</h2><p>Actual Claude usage — your subscription quota, calls, and tokens per agent and task. Subscription plans aren't billed per token, so no dollar costs here.</p></div>
- <div id="usage-quota" class="card" style="display:none"></div>
- <div class="stats-grid" id="usage-stats"></div>
- <div class="card" id="usage-daily" style="display:none"></div>
- <div id="usage-tables"></div>
-</div>
-
-<!-- Settings -->
-<div id="settings" class="section">
- <div class="section-head"><h2>Settings</h2><p>Credentials are stored locally in <span style="font-family:var(--mono);font-size:12px">.env</span> — never sent anywhere except the services themselves.</p></div>
- <div class="card">
- <h2>Email Provider</h2>
- <p class="lede">How Harvey sends and reads replies. Active provider: <b id="active-provider">…</b> — change it by setting <span style="font-family:var(--mono);font-size:12px">channels.email.provider</span> in <span style="font-family:var(--mono);font-size:12px">harvey.yaml</span> to <span style="font-family:var(--mono);font-size:12px">gmail</span>, <span style="font-family:var(--mono);font-size:12px">smtp</span>, or <span style="font-family:var(--mono);font-size:12px">instantly</span>.</p>
-
- <div style="border:1px solid var(--border);border-radius:10px;padding:16px;margin-bottom:12px">
- <div style="font-weight:650;margin-bottom:4px">Gmail / Google Workspace <span class="optional-tag">recommended</span> <span id="gmail-status" class="email-tag"></span></div>
- <p class="lede" style="margin-top:4px">Use a mailbox on a dedicated secondary domain. Create an OAuth client (type "Desktop app") in Google Cloud Console → Gmail API, paste the id/secret, save, then run <span style="font-family:var(--mono);font-size:12px">harvey gmail auth</span> in your terminal.</p>
- <div class="form-group"><label class="form-label" for="gmail-id">Client ID</label>
- <input type="text" class="form-input" id="gmail-id" placeholder="xxxx.apps.googleusercontent.com" autocomplete="off"></div>
- <div class="form-group"><label class="form-label" for="gmail-secret">Client Secret</label>
- <div class="form-row"><div class="form-group" style="margin-bottom:0">
- <input type="password" class="form-input" id="gmail-secret" placeholder="Enter client secret" autocomplete="off"></div>
- <button class="btn btn-secondary btn-sm" onclick="toggleVisibility('gmail-secret')">Show</button></div></div>
- <button class="btn btn-primary btn-sm" onclick="saveGmail()">Save Gmail</button>
- </div>
-
- <div style="border:1px solid var(--border);border-radius:10px;padding:16px;margin-bottom:12px">
- <div style="font-weight:650;margin-bottom:4px">SMTP + IMAP mailbox</div>
- <p class="lede" style="margin-top:4px">Any real mailbox (AgentMail, Fastmail, a Workspace app password). IMAP defaults to the SMTP host/login if left blank.</p>
- <div class="form-row">
- <div class="form-group"><label class="form-label" for="smtp-host">SMTP host</label>
- <input type="text" class="form-input" id="smtp-host" placeholder="smtp.example.com" autocomplete="off"></div>
- <div class="form-group" style="max-width:120px"><label class="form-label" for="smtp-port">Port</label>
- <input type="text" class="form-input" id="smtp-port" placeholder="587" autocomplete="off"></div>
- </div>
- <div class="form-group"><label class="form-label" for="smtp-user">Username</label>
- <input type="text" class="form-input" id="smtp-user" placeholder="[email protected]" autocomplete="off"></div>
- <div class="form-group"><label class="form-label" for="smtp-pass">Password</label>
- <div class="form-row"><div class="form-group" style="margin-bottom:0">
- <input type="password" class="form-input" id="smtp-pass" placeholder="Enter password / app password" autocomplete="off"></div>
- <button class="btn btn-secondary btn-sm" onclick="toggleVisibility('smtp-pass')">Show</button></div></div>
- <button class="btn btn-primary btn-sm" onclick="saveSmtp()">Save SMTP</button>
- </div>
-
- <div style="border:1px solid var(--border);border-radius:10px;padding:16px">
- <div style="font-weight:650;margin-bottom:4px">Instantly <span class="optional-tag">legacy</span></div>
- <p class="lede" style="margin-top:4px">Get your API key from <a href="https://app.instantly.ai/app/settings/integrations" target="_blank" rel="noopener">Instantly Settings → Integrations</a> (Growth plan+ for API).</p>
- <div class="form-group"><div class="form-row"><div class="form-group" style="margin-bottom:0">
- <input type="password" class="form-input" id="instantly-key" placeholder="Enter your Instantly API key" autocomplete="off"></div>
- <button class="btn btn-secondary btn-sm" onclick="toggleVisibility('instantly-key')">Show</button>
- <button class="btn btn-secondary btn-sm" onclick="testInstantly()">Test</button></div>
- <div id="instantly-test-result"></div></div>
- <button class="btn btn-primary btn-sm" onclick="saveInstantly()">Save Instantly</button>
- </div>
- </div>
-
- <div class="card">
- <h2>Email Verification <span class="optional-tag">strongly recommended</span></h2>
- <p class="lede">Add at least one so found emails get verified. Without any, addresses stay <span class="email-tag guess">guess</span> and are never sent. Reoon has the best free tier (600/mo).</p>
- <div class="form-group"><label class="form-label" for="reoon-key">Reoon API key <span id="reoon-status" class="email-tag"></span></label>
- <div class="form-row"><div class="form-group" style="margin-bottom:0">
- <input type="password" class="form-input" id="reoon-key" placeholder="600 free/mo — reoon.com/email-verifier" autocomplete="off"></div>
- <button class="btn btn-secondary btn-sm" onclick="toggleVisibility('reoon-key')">Show</button></div></div>
- <div class="form-group"><label class="form-label" for="zerobounce-key">ZeroBounce API key <span id="zerobounce-status" class="email-tag"></span></label>
- <input type="password" class="form-input" id="zerobounce-key" placeholder="100 free/mo — best for M365/Workspace catch-alls" autocomplete="off"></div>
- <div class="form-group"><label class="form-label" for="hunter-key">Hunter API key <span id="hunter-status" class="email-tag"></span></label>
- <input type="password" class="form-input" id="hunter-key" placeholder="50 free/mo + email-pattern lookup" autocomplete="off"></div>
- <button class="btn btn-primary btn-sm" onclick="saveVerifiers()">Save verification keys</button>
- </div>
-
- <div class="card">
- <h2>LinkedIn <span class="optional-tag">optional</span></h2>
- <p class="lede">For automated LinkedIn prospecting. Harvey logs in and searches like a human.</p>
- <div class="form-group">
- <label class="form-label" for="linkedin-email">Email / Username</label>
- <input type="text" class="form-input" id="linkedin-email" placeholder="[email protected]" autocomplete="off">
- </div>
- <div class="form-group">
- <label class="form-label" for="linkedin-password">Password</label>
- <input type="password" class="form-input" id="linkedin-password" placeholder="Enter password" autocomplete="new-password">
- </div>
- <button class="btn btn-primary" onclick="saveLinkedIn()">Save</button>
- </div>
-
- <div class="card">
- <h2>Cloudflare <span class="optional-tag">optional</span></h2>
- <p class="lede">For deep website crawling with JavaScript rendering during product training. ~$5/month.</p>
- <div class="form-group">
- <label class="form-label" for="cf-account-id">Account ID</label>
- <input type="text" class="form-input" id="cf-account-id" placeholder="Your Cloudflare Account ID" autocomplete="off">
- </div>
- <div class="form-group">
- <label class="form-label" for="cf-api-token">API Token</label>
- <input type="password" class="form-input" id="cf-api-token" placeholder="Your Cloudflare API Token" autocomplete="off">
- </div>
- <button class="btn btn-primary" onclick="saveCloudflare()">Save</button>
- </div>
-</div>
-
-<!-- Controls -->
-<div id="controls" class="section">
- <div class="section-head"><h2>Controls</h2><p>Start and stop Harvey's heartbeat loop, and watch what it's doing.</p></div>
- <div class="control-panel">
- <div class="card">
- <h2>Agent</h2>
- <div class="status-big" id="control-status">
- <div class="dot stopped" id="control-dot"></div>
- <span class="label stopped" id="control-label">Stopped</span>
- </div>
- <div class="status-meta" id="control-meta"></div>
- <div class="btn-group">
- <button class="btn btn-primary" id="btn-start" onclick="startHarvey()">Start Harvey</button>
- <button class="btn btn-danger" id="btn-stop" onclick="stopHarvey()" style="display:none">Stop Harvey</button>
- </div>
- </div>
- <div class="card">
- <h2>Recent Logs</h2>
- <div class="log-viewer" id="log-viewer">No logs yet. Start Harvey to see activity.</div>
- <div class="btn-group">
- <button class="btn btn-secondary btn-sm" onclick="loadLogs()">Refresh Logs</button>
- </div>
- </div>
- </div>
-</div>
-
-<!-- Help -->
-<div id="help" class="section">
- <div class="section-head"><h2>Help</h2><p>What Harvey is, how it works, and how to fix the usual problems.</p></div>
-
- <div class="help-section">
- <h2>What is Harvey?</h2>
- <p>Harvey is an autonomous AI sales agent. Once set up, Harvey runs on its own: finds people who match your ideal customer, writes personalized cold emails, sends them through your email platform, reads every reply, handles objections, and works toward booking a meeting. You review everything through this dashboard.</p>
- <p>Harvey runs on your Claude Max subscription, so there are no extra AI costs. Everything stays on your machine in one folder.</p>
- </div>
-
- <div class="help-section">
- <h2>Getting Started</h2>
- <p>There are three things to do:</p>
- <pre>1. Go to the Settings tab and enter your Instantly API key
-2. Train Harvey on your product (through Claude or the command line)
-3. Go to the Controls tab and click Start</pre>
- <p>The Setup tab shows you exactly what's done and what still needs to happen.</p>
- </div>
-
- <div class="help-section">
- <h2>Where Everything Lives</h2>
- <p>Everything Harvey needs is inside this one project folder. Nothing is stored elsewhere.</p>
- <div class="table-card" style="padding:6px 4px">
- <table class="file-table">
- <tr><td>.env</td><td>Your API keys and credentials (never shared or committed)</td></tr>
- <tr><td>harvey.yaml</td><td>Your product info, target customers, and behavior settings</td></tr>
- <tr><td>skills/</td><td>Sales knowledge files. Edit these to change how Harvey writes and sells.</td></tr>
- <tr><td>skills/product_knowledge.md</td><td>Everything Harvey knows about your product (auto-generated from training)</td></tr>
- <tr><td>prompts/</td><td>Prompt templates for each agent. Advanced customization.</td></tr>
- <tr><td>data/harvey.db</td><td>Database with all prospects, campaigns, and conversations</td></tr>
- <tr><td>data/harvey.log</td><td>Log file showing what Harvey is doing</td></tr>
- </table>
- </div>
- </div>
-
- <div class="help-section">
- <h2>Getting Your API Keys</h2>
-
- <details>
- <summary>Instantly API Key (required)</summary>
- <div class="faq-body">
- <p>Instantly is the email platform Harvey uses to send campaigns.</p>
- <p>1. Sign up at <a href="https://instantly.ai" target="_blank" rel="noopener">instantly.ai</a> (you need the Growth plan for API access)</p>
- <p>2. Go to Settings &gt; Integrations</p>
- <p>3. Copy your API key</p>
- <p>4. Paste it in the Settings tab here</p>
- </div>
- </details>
-
- <details>
- <summary>LinkedIn Credentials (optional)</summary>
- <div class="faq-body">
- <p>If you want Harvey to find prospects on LinkedIn, enter your LinkedIn email and password. Harvey uses a real browser to search LinkedIn like a human would, with random delays and rate limits to avoid detection.</p>
- <p>If you skip this, Harvey will find prospects through Google searches and company website scraping instead.</p>
- </div>
- </details>
-
- <details>
- <summary>Cloudflare Browser Rendering (optional)</summary>
- <div class="faq-body">
- <p>This is only used during product training (when Harvey crawls your website to learn about your product). It handles JavaScript-heavy websites that a basic crawler can't read.</p>
- <p>1. Sign up at <a href="https://dash.cloudflare.com" target="_blank" rel="noopener">Cloudflare</a> (paid Workers plan, ~$5/month)</p>
- <p>2. Go to Workers &amp; Pages &gt; Browser Rendering</p>
- <p>3. Create an API token with Browser Rendering Edit permissions</p>
- <p>4. Enter your Account ID and API Token in the Settings tab</p>
- <p>Without this, Harvey uses a built-in crawler that works fine for most websites but can't render JavaScript.</p>
- </div>
- </details>
- </div>
-
- <div class="help-section">
- <h2>Common Issues</h2>
-
- <details>
- <summary>"command not found: harvey"</summary>
- <div class="faq-body">You need to activate the virtual environment first: <code>source .venv/bin/activate</code></div>
- </details>
-
- <details>
- <summary>Instantly API returns 401</summary>
- <div class="faq-body">Your API key is wrong, or you need the Growth plan (the free plan doesn't include API access). Double-check the key in Settings &gt; Integrations in your Instantly dashboard.</div>
- </details>
-
- <details>
- <summary>Claude headless mode fails</summary>
- <div class="faq-body">Make sure you've run <code>claude login</code> in your terminal and have an active Claude Max subscription. Harvey uses your existing subscription, not a separate API key.</div>
- </details>
-
- <details>
- <summary>Harvey isn't finding prospects</summary>
- <div class="faq-body">Check that your ICP (ideal customer profile) in harvey.yaml has realistic titles, industries, and geography. If LinkedIn is set up, check that the credentials are correct. Check the Activity tab to see what Harvey has been trying to do.</div>
- </details>
- </div>
-</div>
-
-</main>
-
-<script>
-let currentTab = 'setup';
-let companyDrill = false; // true while viewing a single company's contacts
-let _companies = [], _prospects = [], _campaigns = [];
-
-// ── Utilities ──
-
-function escHtml(s) {
- if (s === null || s === undefined || s === '') return '';
- return String(s).replace(/[&<>"']/g, ch => (
- {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[ch]
- ));
-}
-
-function badge(status) {
- const safe = String(status || 'unknown');
- const cls = 'badge-' + safe.toLowerCase().replace(/[^a-z0-9]+/g, '_');
- return '<span class="badge ' + escHtml(cls) + '">' + escHtml(safe) + '</span>';
-}
-
-function formatDate(d) {
- if (!d) return '';
- try {
- const dt = new Date(d);
- if (isNaN(dt)) return escHtml(d);
- return dt.toLocaleString('en-US', {month:'short',day:'numeric',hour:'numeric',minute:'2-digit'});
- } catch { return escHtml(d); }
-}
-
-function emptyState(glyph, title, copy) {
- return '<div class="empty"><div class="glyph">' + glyph + '</div>' +
- '<div class="title">' + title + '</div>' +
- '<div class="copy">' + copy + '</div></div>';
-}
-
-function offlineState() {
- return emptyState('&#9888;', 'Dashboard can\'t reach the server',
- 'The dashboard process may have stopped. Restart it with <b>harvey dashboard</b> and refresh this page.');
-}
-
-async function api(path, opts) {
- try {
- const r = await fetch(path, opts);
- if (!r.ok) return null;
- return await r.json();
- } catch {
- return null;
- }
-}
-
-function showToast(msg, type) {
- const t = document.createElement('div');
- t.className = 'toast ' + type;
- t.textContent = msg;
- document.body.appendChild(t);
- setTimeout(() => t.remove(), 2600);
-}
-
-function toggleVisibility(inputId) {
- const el = document.getElementById(inputId);
- el.type = el.type === 'password' ? 'text' : 'password';
-}
-
-// ── Tabs ──
-
-function showTab(id, btn) {
- currentTab = id;
- if (id === 'companies') companyDrill = false;
- document.querySelectorAll('.section').forEach(s => s.classList.remove('active'));
- document.querySelectorAll('nav button').forEach(b => b.classList.remove('active'));
- document.getElementById(id).classList.add('active');
- if (btn) btn.classList.add('active');
- loadCurrentTab();
-}
-
-function loadCurrentTab() {
- switch (currentTab) {
- case 'setup': loadSetupStatus(); break;
- case 'overview': loadStats(); break;
- case 'companies': if (!companyDrill) loadCompanies(); break;
- case 'prospects': loadProspects(); break;
- case 'campaigns': loadCampaigns(); break;
- case 'outbox': loadOutbox(); break;
- case 'conversations': loadConversations(); break;
- case 'activity': loadActivity(); break;
- case 'usage': loadUsage(); break;
- case 'settings': loadSettings(); break;
- case 'controls': loadHarveyStatus(); loadLogs(); break;
- }
-}
-
-// ── Setup ──
-
-async function loadSetupStatus() {
- const data = await api('/api/setup-status');
- if (!data || !data.checks) {
- document.getElementById('setup-progress').innerHTML = '';
- document.getElementById('setup-checklist').innerHTML = offlineState();
- return;
- }
- const pct = data.percent || 0;
- const color = pct === 100 ? 'green' : 'yellow';
-
- document.getElementById('setup-progress').innerHTML =
- '<div class="progress-label">' +
- '<span class="pct">' + pct + '% complete</span>' +
- '<span class="text">' + data.completed + ' of ' + data.total_required + ' required steps done</span>' +
- '</div>' +
- '<div class="progress-bar"><div class="progress-fill ' + color + '" style="width:' + pct + '%"></div></div>';
-
- const renderCheck = (c, optional) => {
- const icon = c.done
- ? '<span class="check-icon done">&#10003;</span>'
- : '<span class="check-icon pending">&#9679;</span>';
- return '<div class="check-item">' + icon +
- '<div class="check-info">' +
- '<div class="check-label ' + (c.done ? 'done' : '') + '">' + escHtml(c.label) +
- (optional ? ' <span class="optional-tag">optional</span>' : '') + '</div>' +
- (!c.done ? '<div class="check-help">' + escHtml(c.help) + '</div>' : '') +
- '</div></div>';
- };
-
- let html = data.checks.filter(c => c.required).map(c => renderCheck(c, false)).join('');
- const optional = data.checks.filter(c => !c.required);
- if (optional.length) {
- html += '<div class="subhead">Optional</div>';
- html += optional.map(c => renderCheck(c, true)).join('');
- }
- document.getElementById('setup-checklist').innerHTML = html;
-}
-
-// ── Settings ──
-
-async function loadSettings() {
- const data = await api('/api/settings');
- if (!data) return;
-
- // Active provider indicator
- const prov = data.provider || 'instantly';
- const provEl = document.getElementById('active-provider');
- if (provEl) provEl.textContent = prov;
-
- // Secret fields never echo a value — show a "saved" placeholder instead.
- const savedPh = (id, isSet, base) => {
- const el = document.getElementById(id);
- if (!el) return;
- el.value = '';
- el.placeholder = isSet ? 'Saved — enter new value to change' : base;
- };
- const tag = (id, ok, okLabel) => {
- const el = document.getElementById(id);
- if (!el) return;
- el.className = 'email-tag ' + (ok ? 'verified' : 'guess');
- el.textContent = ok ? okLabel : 'not set';
- };
-
- // Non-secret values repopulate
- document.getElementById('gmail-id').value = data.gmail_client_id || '';
- document.getElementById('smtp-host').value = data.smtp_host || '';
- document.getElementById('smtp-port').value = data.smtp_port || '';
- document.getElementById('smtp-user').value = data.smtp_username || '';
- document.getElementById('linkedin-email').value = data.linkedin_email || '';
- document.getElementById('cf-account-id').value = data.cloudflare_account_id || '';
-
- savedPh('gmail-secret', data.gmail_client_secret_set, 'Enter client secret');
- savedPh('smtp-pass', data.smtp_password_set, 'Enter password / app password');
- savedPh('instantly-key', data.instantly_api_key_set, 'Enter your Instantly API key');
- savedPh('reoon-key', data.reoon_api_key_set, '600 free/mo — reoon.com/email-verifier');
- savedPh('zerobounce-key', data.zerobounce_api_key_set, '100 free/mo — best for M365/Workspace catch-alls');
- savedPh('hunter-key', data.hunter_api_key_set, '50 free/mo + email-pattern lookup');
- savedPh('linkedin-password', data.linkedin_password_set, 'Enter password');
- savedPh('cf-api-token', data.cloudflare_api_token_set, 'Your Cloudflare API Token');
-
- // Gmail auth status chip
- const g = document.getElementById('gmail-status');
- if (g) {
- if (data.gmail_authorized) { g.className = 'email-tag verified'; g.textContent = 'authorized'; }
- else if (data.gmail_client_secret_set) { g.className = 'email-tag risky'; g.textContent = 'run: harvey gmail auth'; }
- else { g.className = 'email-tag guess'; g.textContent = 'not set up'; }
- }
- tag('reoon-status', data.reoon_api_key_set, 'set');
- tag('zerobounce-status', data.zerobounce_api_key_set, 'set');
- tag('hunter-status', data.hunter_api_key_set, 'set');
-}
-
-function saveGmail() {
- const payload = {GMAIL_CLIENT_ID: document.getElementById('gmail-id').value.trim()};
- const sec = document.getElementById('gmail-secret').value;
- if (sec) payload.GMAIL_CLIENT_SECRET = sec;
- saveEnv(payload, 'Gmail OAuth saved. Now run "harvey gmail auth" in your terminal.').then(loadSettings);
-}
-
-function saveSmtp() {
- const payload = {
- SMTP_HOST: document.getElementById('smtp-host').value.trim(),
- SMTP_PORT: document.getElementById('smtp-port').value.trim(),
- SMTP_USERNAME: document.getElementById('smtp-user').value.trim(),
- };
- const pass = document.getElementById('smtp-pass').value;
- if (pass) payload.SMTP_PASSWORD = pass;
- saveEnv(payload, 'SMTP settings saved.').then(loadSettings);
-}
-
-function saveVerifiers() {
- const payload = {};
- const r = document.getElementById('reoon-key').value;
- const z = document.getElementById('zerobounce-key').value;
- const h = document.getElementById('hunter-key').value;
- if (r) payload.REOON_API_KEY = r;
- if (z) payload.ZEROBOUNCE_API_KEY = z;
- if (h) payload.HUNTER_API_KEY = h;
- if (!Object.keys(payload).length) { showToast('Enter at least one key first.', 'error'); return; }
- saveEnv(payload, 'Verification keys saved.').then(loadSettings);
-}
-
-async function saveEnv(payload, okMsg) {
- const data = await api('/api/settings/env', {
- method: 'POST', headers: {'Content-Type': 'application/json'},
- body: JSON.stringify(payload)
- });
- if (data && data.success) showToast(okMsg, 'success');
- else showToast((data && data.message) || 'Save failed — is the dashboard still running?', 'error');
-}
[email protected]("/api/today")
+async def get_today():
+ """What needs a human, right now.
-function saveInstantly() {
- saveEnv({INSTANTLY_API_KEY: document.getElementById('instantly-key').value.trim()}, 'Instantly API key saved.');
-}
-
-function saveLinkedIn() {
- const payload = {LINKEDIN_EMAIL: document.getElementById('linkedin-email').value.trim()};
- const pass = document.getElementById('linkedin-password').value;
- if (pass) payload.LINKEDIN_PASSWORD = pass;
- saveEnv(payload, 'LinkedIn credentials saved.');
-}
-
-function saveCloudflare() {
- saveEnv({
- CLOUDFLARE_ACCOUNT_ID: document.getElementById('cf-account-id').value.trim(),
- CLOUDFLARE_API_TOKEN: document.getElementById('cf-api-token').value.trim()
- }, 'Cloudflare credentials saved.');
-}
-
-async function testInstantly() {
- const key = document.getElementById('instantly-key').value.trim();
- const el = document.getElementById('instantly-test-result');
- el.innerHTML = '<div class="test-result pending">Testing&hellip;</div>';
- const data = await api('/api/settings/test-instantly', {
- method: 'POST', headers: {'Content-Type': 'application/json'},
- body: JSON.stringify({api_key: key})
- });
- if (!data) {
- el.innerHTML = '<div class="test-result error">Could not reach the dashboard server.</div>';
- return;
- }
- el.innerHTML = '<div class="test-result ' + (data.success ? 'success' : 'error') + '">' + escHtml(data.message) + '</div>';
-}
+ The dashboard opens here rather than on a setup checklist: the question a
+ returning user actually has is "is anything waiting on me?", and the
+ answer is usually a short list or nothing at all.
+ """
+ items: list[dict] = []
+ stats: dict = {}
+ try:
+ from harvey.signals import seed_signal_catalog
-// ── Controls ──
-
-async function loadHarveyStatus() {
- const data = await api('/api/harvey/status');
- const headerDot = document.getElementById('header-dot');
- const headerText = document.getElementById('header-status-text');
-
- if (!data) {
- headerDot.className = 'status-dot offline';
- headerText.textContent = 'Offline';
- return;
- }
- const running = !!data.running;
-
- headerDot.className = 'status-dot ' + (running ? 'running' : 'stopped');
- headerText.textContent = running ? 'Harvey is running' : 'Harvey is stopped';
- document.getElementById('control-dot').className = 'dot ' + (running ? 'running' : 'stopped');
- const label = document.getElementById('control-label');
- label.className = 'label ' + (running ? 'running' : 'stopped');
- label.textContent = running ? 'Running' : 'Stopped';
-
- const meta = document.getElementById('control-meta');
- if (running && data.pid) {
- let info = 'PID ' + escHtml(String(data.pid));
- if (data.started_at) info += ' &middot; started ' + formatDate(data.started_at);
- meta.innerHTML = info;
- } else {
- meta.innerHTML = 'Harvey wakes every few minutes, does what needs doing, and sleeps.';
- }
-
- document.getElementById('btn-start').style.display = running ? 'none' : '';
- document.getElementById('btn-stop').style.display = running ? '' : 'none';
-}
+ state = _state()
+ await state.init_db()
+ await seed_signal_catalog(state)
+
+ codes = await state.get_signal_codes()
+ proposed = [c for c in codes if c.get("status") == "proposed"]
+ confirmed = [c for c in codes if c.get("status") == "confirmed"]
+ pending = await state.get_outbox(status="pending_review", limit=200)
+ approved = await state.get_outbox(status="approved", limit=200)
+ paused = await state.get_setting("sending_paused")
+ counts = await state.count_prospects_by_status()
+
+ convos = await query_db(
+ "SELECT COUNT(*) AS n FROM conversations WHERE status = 'open'"
+ )
+ open_convos = convos[0]["n"] if convos else 0
+ companies = await query_db("SELECT COUNT(*) AS n FROM companies")
+ n_companies = companies[0]["n"] if companies else 0
+
+ stats = {
+ "companies": n_companies,
+ "prospects": sum(counts.values()),
+ "signals_confirmed": len(confirmed),
+ "outbox_pending": len(pending),
+ "outbox_approved": len(approved),
+ "open_conversations": open_convos,
+ }
-async function startHarvey() {
- const btn = document.getElementById('btn-start');
- btn.disabled = true;
- const data = await api('/api/harvey/start', {method: 'POST'});
- if (data && data.success) showToast('Harvey started.', 'success');
- else showToast((data && data.message) || 'Failed to start.', 'error');
- btn.disabled = false;
- loadHarveyStatus();
+ # Ordered by how much it blocks Harvey from doing anything at all.
+ if paused:
+ items.append({
+ "key": "paused", "tone": "bad",
+ "title": "Sending is paused",
+ "detail": str(paused) + ". Nothing will go out until you resume it.",
+ "action": "Review and resume", "tab": "outbox",
+ })
+
+ setup = await get_setup_status()
+ if isinstance(setup, dict) and setup.get("percent", 100) < 100:
+ missing = [c["label"] for c in setup.get("checks", [])
+ if c.get("required") and not c.get("done")]
+ items.append({
+ "key": "setup", "tone": "warn",
+ "title": "Finish setting Harvey up",
+ "detail": ", ".join(missing[:3]) or "Some required steps are incomplete.",
+ "action": "Open setup", "tab": "settings",
+ })
+
+ if proposed:
+ items.append({
+ "key": "signals", "tone": "warn",
+ "title": (f"{len(proposed)} signal waiting for your confirmation"
+ if len(proposed) == 1
+ else f"{len(proposed)} signals waiting for your confirmation"),
+ "detail": ("Harvey won't collect anything you haven't approved. "
+ "Confirm which signals define a good prospect for you."),
+ "action": "Review signals", "tab": "signals",
+ })
+ elif not confirmed:
+ items.append({
+ "key": "signals-none", "tone": "warn",
+ "title": "No signals confirmed",
+ "detail": "Every signal is rejected, so prospecting has nothing to collect.",
+ "action": "Review signals", "tab": "signals",
+ })
+
+ if pending:
+ items.append({
+ "key": "outbox", "tone": "warn",
+ "title": (f"{len(pending)} email waiting for approval" if len(pending) == 1
+ else f"{len(pending)} emails waiting for approval"),
+ "detail": "Nothing sends until you approve it. Read them one at a time.",
+ "action": "Open the decisions desk", "tab": "outbox",
+ })
+
+ if open_convos:
+ items.append({
+ "key": "replies", "tone": "good",
+ "title": (f"{open_convos} live conversation" if open_convos == 1
+ else f"{open_convos} live conversations"),
+ "detail": "People replied. Check how Harvey is handling them.",
+ "action": "Read conversations", "tab": "conversations",
+ })
+
+ return {"items": items, "stats": stats}
+ except Exception as e:
+ logger.exception("today load failed")
+ return {"items": [], "stats": stats, "error": str(e)}
+
+
+# ── Signals: Harvey proposes, the user confirms ──
+#
+# Nothing is collected until a human has said yes to it. This is the gate the
+# whole prospecting pipeline hangs off: collectors ask `state.confirmed_signal_codes()`
+# and skip anything that isn't in the set.
+
+CATEGORY_META = {
+ "discovery": {
+ "label": "Discovery — who exists",
+ "blurb": "How Harvey finds businesses at all, and how visible they are. "
+ "This is the only stage that costs money.",
+ },
+ "profile": {
+ "label": "Profile — what they are",
+ "blurb": "Read from the pages a business already publishes. Free, no AI "
+ "tokens, three HTTP requests per company. These are the signals "
+ "that make an email specific.",
+ },
+ "people": {
+ "label": "People — who decides",
+ "blurb": "Named humans and whether they're the one who can say yes.",
+ },
+ "verification": {
+ "label": "Contactability — can you reach them",
+ "blurb": "Whether the address will actually deliver, and what to do when "
+ "it won't.",
+ },
}
+CATEGORY_ORDER = ["discovery", "profile", "people", "verification"]
-async function stopHarvey() {
- const btn = document.getElementById('btn-stop');
- btn.disabled = true;
- const data = await api('/api/harvey/stop', {method: 'POST'});
- if (data && data.success) showToast('Harvey stopped.', 'success');
- else showToast((data && data.message) || 'Failed to stop.', 'error');
- btn.disabled = false;
- loadHarveyStatus();
-}
-async function loadLogs() {
- const data = await api('/api/harvey/logs');
- const el = document.getElementById('log-viewer');
- if (data && data.lines && data.lines.length) {
- const stick = el.scrollTop + el.clientHeight >= el.scrollHeight - 30;
- el.textContent = data.lines.join('\n');
- if (stick) el.scrollTop = el.scrollHeight;
- } else {
- el.textContent = 'No logs yet. Start Harvey to see activity.';
- }
-}
[email protected]("/api/signals")
+async def get_signals():
+ """The signal vocabulary, grouped for review, with live cohort sizes."""
+ try:
+ from harvey.signals import seed_signal_catalog
-// ── Pipeline data ──
-
-async function loadStats() {
- const grid = document.getElementById('stats-grid');
- const data = await api('/api/stats');
- if (!data) { grid.innerHTML = offlineState(); return; }
- if (data.error) {
- grid.innerHTML = emptyState('&#9670;', 'No pipeline data yet',
- 'Start Harvey from the <b>Controls</b> tab and it will begin prospecting, writing, and sending on its own.');
- return;
- }
- const p = data.prospects || {}, c = data.campaigns || {}, v = data.conversations || {};
- const chips = (map) => {
- const entries = Object.entries(map || {});
- if (!entries.length) return '<span class="chip muted">none yet</span>';
- return entries.map(([k, n]) =>
- '<span class="chip">' + escHtml(k) + ' <b>' + escHtml(String(n)) + '</b></span>'
- ).join('');
- };
- const card = (label, value, breakdown) =>
- '<div class="stat-card"><div class="label">' + label + '</div>' +
- '<div class="value">' + value + '</div>' +
- '<div class="breakdown">' + breakdown + '</div></div>';
-
- grid.innerHTML =
- card('Prospects', p.total || 0, chips(p.by_status)) +
- card('Campaigns', c.total || 0, chips(c.by_status)) +
- card('Conversations', v.total || 0, chips(v.by_status)) +
- card('Actions Logged', data.actions_total || 0,
- '<span class="chip">Claude calls today <b>' + escHtml(String(data.claude_calls_today || 0)) + '</b></span>');
-}
+ state = _state()
+ await state.init_db()
+ # Seeding is idempotent and never overrides a decision the user made,
+ # so it is safe to run on every load — new signals shipped in an
+ # upgrade show up as `proposed` without any migration step.
+ await seed_signal_catalog(state)
+
+ codes = await state.get_signal_codes()
+ counts = {c["signal_code"]: c for c in await state.signal_counts()}
+
+ groups, summary = [], {"proposed": 0, "confirmed": 0, "rejected": 0}
+ for cat in CATEGORY_ORDER:
+ rows = []
+ for sig in codes:
+ if sig.get("category") != cat:
+ continue
+ seen = counts.get(sig["code"], {})
+ rows.append({
+ **sig,
+ "companies": seen.get("companies", 0),
+ "observations": seen.get("observations", 0),
+ })
+ if rows:
+ meta = CATEGORY_META.get(cat, {})
+ groups.append({
+ "key": cat,
+ "label": meta.get("label", cat.title()),
+ "blurb": meta.get("blurb", ""),
+ "signals": rows,
+ })
+ for sig in codes:
+ summary[sig.get("status", "proposed")] = (
+ summary.get(sig.get("status", "proposed"), 0) + 1
+ )
-function fmtTokens(n) {
- n = n || 0;
- if (n >= 1e9) return (n / 1e9).toFixed(1) + 'B';
- if (n >= 1e6) return (n / 1e6).toFixed(1) + 'M';
- if (n >= 1e3) return (n / 1e3).toFixed(1) + 'k';
- return String(n);
-}
+ return {"summary": summary, "groups": groups, "total": len(codes)}
+ except Exception as e:
+ logger.exception("signals load failed")
+ return {"error": str(e), "groups": [], "summary": {}}
-function emailTag(p) {
- if (!p.email) return '';
- // Fall back to the legacy boolean for rows predating email_status.
- const status = p.email_status || (p.email_verified ? 'verified' : 'guess');
- const labels = {verified: 'verified', risky: 'catch-all', guess: 'guess', invalid: 'invalid'};
- if (!labels[status]) return '';
- return ' <span class="email-tag ' + status + '">' + labels[status] + '</span>';
-}
[email protected]("/api/signals/status")
+async def set_signals_status(request: Request):
+ """Confirm or reject one signal, or a whole category at once."""
+ try:
+ body = await request.json()
+ status = (body.get("status") or "").strip()
+ codes = body.get("codes") or ([body["code"]] if body.get("code") else [])
+ if status not in ("proposed", "confirmed", "rejected"):
+ return JSONResponse(
+ {"success": False, "message": f"invalid status: {status!r}"},
+ status_code=400,
+ )
+ if not codes:
+ return JSONResponse(
+ {"success": False, "message": "no signal codes given"}, status_code=400
+ )
-async function loadUsage() {
- const data = await api('/api/usage');
- const statsEl = document.getElementById('usage-stats');
- if (!data) { statsEl.innerHTML = offlineState(); return; }
-
- // Quota gauges — the same numbers `/usage` shows in Claude Code.
- const quotaEl = document.getElementById('usage-quota');
- if (data.quota && Object.keys(data.quota).length) {
- const labels = {five_hour: '5-hour window', seven_day: 'Weekly'};
- let qHtml = '<h2>Claude Subscription Quota</h2>';
- for (const [key, w] of Object.entries(data.quota)) {
- const pct = Math.min(100, Math.max(0, w.utilization || 0));
- const color = pct >= 80 ? 'yellow' : 'green';
- const resets = w.resets_at ? 'resets ' + formatDate(w.resets_at) : '';
- qHtml += '<div class="progress-wrap">' +
- '<div class="progress-label">' +
- '<span class="text">' + escHtml(labels[key] || key) + (resets ? ' &middot; ' + escHtml(resets) : '') + '</span>' +
- '<span class="pct">' + pct.toFixed(0) + '%</span>' +
- '</div>' +
- '<div class="progress-bar"><div class="progress-fill ' + color + '" style="width:' + pct + '%"></div></div>' +
- '</div>';
- }
- quotaEl.innerHTML = qHtml;
- quotaEl.style.display = 'block';
- } else {
- quotaEl.style.display = 'none';
- }
-
- // Totals cards — usage-first (calls is the headline; tokens as chips).
- // No dollars: on a subscription plan usage isn't billed per token.
- const t = data.totals || {};
- const card = (label, p) => {
- p = p || {};
- return '<div class="stat-card"><div class="label">' + label + '</div>' +
- '<div class="value">' + (p.calls || 0) + '</div>' +
- '<div class="breakdown">' +
- '<span class="chip">calls</span>' +
- '<span class="chip">out <b>' + fmtTokens(p.output_tokens) + '</b></span>' +
- '<span class="chip">in <b>' + fmtTokens(p.input_tokens) + '</b></span>' +
- '<span class="chip">cached <b>' + fmtTokens(p.cache_read_tokens) + '</b></span>' +
- '</div></div>';
- };
- statsEl.innerHTML = card('Today', t.today) + card('Last 7 Days', t.week) + card('Last 30 Days', t.month);
-
- // Daily bars — output tokens per day (the work done)
- const dailyEl = document.getElementById('usage-daily');
- const days = data.by_day || [];
- if (days.length) {
- const maxOut = Math.max(...days.map(d => d.output_tokens || 0), 1);
- let dHtml = '<h2>Daily Output Tokens (30 days)</h2>';
- for (const d of days.slice(-30)) {
- const pct = Math.max(2, (d.output_tokens || 0) / maxOut * 100);
- dHtml += '<div style="display:flex;align-items:center;gap:10px;margin-bottom:6px;font-size:12px">' +
- '<span class="muted" style="width:78px;flex-shrink:0;font-family:var(--mono)">' + escHtml(d.day || '') + '</span>' +
- '<div style="flex:1;background:rgba(255,255,255,0.05);border-radius:99px;height:10px;overflow:hidden">' +
- '<div style="width:' + pct + '%;height:100%;border-radius:99px;background:linear-gradient(90deg,var(--accent-deep),var(--accent))"></div>' +
- '</div>' +
- '<span style="width:130px;text-align:right;font-variant-numeric:tabular-nums">' + fmtTokens(d.output_tokens) + ' out' +
- ' <span class="muted">&middot; ' + (d.calls || 0) + ' calls</span></span>' +
- '</div>';
- }
- dailyEl.innerHTML = dHtml;
- dailyEl.style.display = 'block';
- } else {
- dailyEl.style.display = 'none';
- }
-
- // Breakdown tables — calls + tokens, no cost column
- const tablesEl = document.getElementById('usage-tables');
- const table = (title, rows, keyName) => {
- if (!rows || !rows.length) return '';
- let h = '<div class="card"><h2>' + title + '</h2><div class="table-card"><table><thead><tr>' +
- '<th>' + keyName + '</th><th>Calls</th><th>Input</th><th>Output</th><th>Cache read</th>' +
- '</tr></thead><tbody>';
- for (const r of rows) {
- h += '<tr><td>' + escHtml(String(r[keyName.toLowerCase()] || '')) + '</td>' +
- '<td>' + (r.calls || 0) + '</td>' +
- '<td class="muted">' + fmtTokens(r.input_tokens) + '</td>' +
- '<td>' + fmtTokens(r.output_tokens) + '</td>' +
- '<td class="muted">' + fmtTokens(r.cache_read_tokens) + '</td></tr>';
- }
- return h + '</tbody></table></div></div>';
- };
-
- const anyRows = (data.by_agent || []).length || (data.by_task || []).length;
- if (!anyRows) {
- tablesEl.innerHTML = emptyState('&#9680;', 'No usage recorded yet',
- 'Once Harvey starts making Claude calls, every one is logged here with exact calls and tokens by agent and task. Run <b>harvey usage --reconcile</b> to backfill from Claude Code transcripts.');
- } else {
- tablesEl.innerHTML =
- table('By Agent (30 days)', data.by_agent, 'Agent') +
- table('By Task (30 days)', data.by_task, 'Task') +
- table('By Model (30 days)', data.by_model, 'Model');
- }
-}
+ from harvey.signals import seed_signal_catalog
-async function loadOutbox() {
- const data = await api('/api/outbox');
- const banner = document.getElementById('outbox-banner');
- const list = document.getElementById('outbox-list');
- if (!data) { list.innerHTML = offlineState(); return; }
-
- if (data.paused) {
- banner.innerHTML = '<div class="card" style="border-color:var(--red)">' +
- '<h2 style="color:var(--red)">&#9888; Sending paused</h2>' +
- '<p style="color:var(--text-2);font-size:13px;margin-bottom:12px">' + escHtml(data.paused) + '</p>' +
- '<button class="btn btn-secondary btn-sm" onclick="sendingToggle(\'resume\')">Resume sending</button></div>';
- } else {
- banner.innerHTML = '<div style="display:flex;justify-content:flex-end;margin-bottom:12px">' +
- '<button class="btn btn-secondary btn-sm" onclick="sendingToggle(\'pause\')">Pause all sending</button></div>';
- }
-
- let html = '';
- const pending = data.pending || [];
- if (pending.length) {
- html += '<div class="card"><h2>Awaiting approval (' + pending.length + ')</h2>';
- for (const item of pending) {
- html += '<div style="border:1px solid var(--border);border-radius:10px;padding:14px;margin-bottom:10px">' +
- '<div style="display:flex;justify-content:space-between;gap:10px;align-items:center;margin-bottom:8px">' +
- '<div style="font-size:13px"><b>' + escHtml(item.to_email) + '</b>' +
- ' <span class="muted">&middot; step ' + item.step + ' (' + escHtml(item.kind) + ')' +
- ' &middot; sends ' + formatDate(item.send_at) + '</span></div>' +
- '<div style="display:flex;gap:6px;flex-shrink:0">' +
- '<button class="btn btn-primary btn-sm" onclick="outboxAct(\'' + item.id + '\',\'approve\')">Approve</button>' +
- '<button class="btn btn-secondary btn-sm" onclick="outboxAct(\'' + item.id + '\',\'reject\')">Reject</button>' +
- '</div></div>' +
- '<div style="font-size:13px;font-weight:600;margin-bottom:6px">' + escHtml(item.subject) + '</div>' +
- '<div style="font-size:13px;color:var(--text-2);white-space:pre-wrap">' + escHtml(item.body) + '</div>' +
- '</div>';
- }
- html += '</div>';
- } else {
- html += '<div class="card"><h2>Awaiting approval</h2>' +
- '<p style="color:var(--text-3);font-size:13px">Nothing to review. New drafts land here before they can send.</p></div>';
- }
-
- const table = (title, rows, cols) => {
- if (!rows || !rows.length) return '';
- let h = '<div class="card"><h2>' + title + '</h2><div class="table-card"><table><thead><tr>' +
- cols.map(c => '<th>' + c[0] + '</th>').join('') + '</tr></thead><tbody>';
- for (const r of rows) {
- h += '<tr>' + cols.map(c => '<td' + (c[2] ? ' class="muted"' : '') + '>' +
- escHtml(String(c[1](r) ?? '')) + '</td>').join('') + '</tr>';
- }
- return h + '</tbody></table></div></div>';
- };
-
- html += table('Approved &amp; scheduled', data.approved, [
- ['To', r => r.to_email], ['Step', r => r.step], ['Subject', r => r.subject],
- ['Sends', r => formatDate(r.send_at), true],
- ]);
- html += table('Recently sent', data.sent, [
- ['To', r => r.to_email], ['Step', r => r.step], ['Subject', r => r.subject],
- ['Sent', r => formatDate(r.sent_at), true],
- ]);
- html += table('Failed / rejected / cancelled', data.failed, [
- ['To', r => r.to_email], ['Status', r => r.status],
- ['Reason', r => r.error, true], ['Updated', r => formatDate(r.updated_at), true],
- ]);
-
- list.innerHTML = html;
-}
+ state = _state()
+ await state.init_db()
+ # Seed first: a confirm that arrives before anything has loaded the
+ # catalog would otherwise report success while changing nothing.
+ await seed_signal_catalog(state)
+
+ changed, unknown = 0, []
+ for code in codes:
+ if await state.set_signal_status(code, status):
+ changed += 1
+ else:
+ unknown.append(code)
+ return {
+ "success": True, "changed": changed,
+ "status": status, "unknown": unknown,
+ }
+ except Exception as e:
+ return JSONResponse({"success": False, "message": str(e)}, status_code=500)
-async function outboxAct(id, action) {
- const data = await api('/api/outbox/' + encodeURIComponent(id) + '/' + action, {method: 'POST'});
- if (data && data.success) showToast(action === 'approve' ? 'Approved — will send on schedule.' : 'Rejected.', 'success');
- else showToast('Action failed.', 'error');
- loadOutbox();
-}
-async function outboxApproveAll() {
- const data = await api('/api/outbox/approve-all', {method: 'POST'});
- if (data && data.success) showToast('Approved ' + data.approved + ' email(s).', 'success');
- else showToast('Approve-all failed.', 'error');
- loadOutbox();
-}
[email protected]("/api/cohort")
+async def preview_cohort(request: Request):
+ """How many companies carry ALL these signals and none of those.
-async function sendingToggle(action) {
- const data = await api('/api/sending/' + action, {method: 'POST'});
- if (data && data.success) showToast(action === 'pause' ? 'Sending paused.' : 'Sending resumed.', 'success');
- else showToast('Failed.', 'error');
- loadOutbox();
-}
+ The payoff for confirming signals: a cohort is a query, not a list. Set
+ intersection happens in SQL — intersecting in JS over a capped fetch
+ silently returns the wrong answer.
+ """
+ try:
+ body = await request.json()
+ require = [c for c in (body.get("require") or []) if c]
+ exclude = [c for c in (body.get("exclude") or []) if c]
+ if not require:
+ return {"size": 0, "companies": []}
-async function loadCompanies() {
- companyDrill = false;
- const el = document.getElementById('companies-list');
- const data = await api('/api/companies');
- if (!data) { el.innerHTML = offlineState(); return; }
- _companies = data;
- if (!data.length) {
- el.innerHTML = emptyState('&#9906;', 'No companies yet',
- 'Harvey\'s Scout agent hasn\'t researched any companies. Finish <b>Setup</b>, then start Harvey from the <b>Controls</b> tab.');
- return;
- }
- let html = '<div class="table-card"><table><thead><tr><th>Company</th><th>Domain</th><th>Industry</th><th>Size</th><th>Location</th><th>Contacts</th><th>Source</th><th>Added</th></tr></thead><tbody>';
- data.forEach((c, i) => {
- const website = c.website || (c.domain ? 'https://' + c.domain : '');
- const nameLink = website
- ? '<a href="' + escHtml(website) + '" target="_blank" rel="noopener" onclick="event.stopPropagation()">' + escHtml(c.name) + '</a>'
- : escHtml(c.name);
- html += '<tr style="cursor:pointer" onclick="showCompanyContacts(' + i + ')">' +
- '<td>' + nameLink + '</td><td class="muted">' + escHtml(c.domain) + '</td><td>' + escHtml(c.industry) + '</td>' +
- '<td>' + escHtml(c.company_size) + '</td><td>' + escHtml(c.location) + '</td>' +
- '<td>' + (c.contact_count || 0) + '</td><td class="muted">' + escHtml(c.source) + '</td>' +
- '<td class="muted">' + formatDate(c.created_at) + '</td></tr>';
- });
- el.innerHTML = html + '</tbody></table></div>';
-}
+ state = _state()
+ await state.init_db()
+ ids = await state.cohort(require, exclude, limit=1000)
+ if not ids:
+ return {"size": 0, "companies": []}
+
+ placeholders = ",".join("?" for _ in ids[:200])
+ rows = await query_db(
+ f"SELECT id, name, domain, industry, location FROM companies "
+ f"WHERE id IN ({placeholders})",
+ tuple(ids[:200]),
+ )
+ return {"size": len(ids), "companies": rows}
+ except Exception as e:
+ return JSONResponse({"size": 0, "companies": [], "error": str(e)}, status_code=500)
-async function showCompanyContacts(index) {
- const company = _companies[index];
- if (!company) return;
- companyDrill = true;
- const el = document.getElementById('companies-list');
- const data = await api('/api/companies/' + encodeURIComponent(company.id) + '/contacts');
- let html = '<div class="card"><h2>' + escHtml(company.name) + ' — Contacts</h2>' +
- '<button class="btn btn-secondary btn-sm" onclick="loadCompanies()" style="margin-bottom:16px">&larr; Back to Companies</button>';
- if (!data || !data.length) {
- html += '<p style="color:var(--text-3);font-size:13px">No contacts found at this company yet.</p></div>';
- } else {
- html += '<div class="table-card"><table><thead><tr><th>Name</th><th>Title</th><th>Email</th><th>Phone</th><th>LinkedIn</th><th>Status</th><th>Source</th></tr></thead><tbody>';
- for (const p of data) {
- const emailIcon = emailTag(p);
- const phoneIcon = p.phone_verified ? ' <span class="verified">&#10003;</span>' : '';
- html += '<tr><td>' + escHtml(p.first_name) + ' ' + escHtml(p.last_name) + '</td>' +
- '<td>' + escHtml(p.title) + '</td><td>' + escHtml(p.email) + emailIcon + '</td>' +
- '<td>' + escHtml(p.phone) + phoneIcon + '</td>' +
- '<td>' + (p.linkedin_url ? '<a href="' + escHtml(p.linkedin_url) + '" target="_blank" rel="noopener">Profile</a>' : '') + '</td>' +
- '<td>' + badge(p.status) + '</td><td class="muted">' + escHtml(p.source) + '</td></tr>';
- }
- html += '</tbody></table></div></div>';
- }
- el.innerHTML = html;
-}
-async function submitFeedback(entityType, entityId, promptText) {
- const comment = prompt(promptText || 'Add your feedback:');
- if (!comment) return;
- const data = await api('/api/feedback', {
- method: 'POST', headers: {'Content-Type': 'application/json'},
- body: JSON.stringify({entity_type: entityType, entity_id: entityId, comment: comment})
- });
- if (data && data.success) showToast('Feedback saved. Harvey will take it into account.', 'success');
- else showToast((data && data.message) || 'Could not save feedback.', 'error');
-}
[email protected]("/api/runs")
+async def get_runs_api():
+ """The collector run log — what ran, when, what it produced and cost."""
+ try:
+ state = _state()
+ await state.init_db()
+ await state.sweep_stale_runs()
+ return await state.get_runs(limit=25)
+ except Exception as e:
+ return {"error": str(e)}
-function fbProspect(i) {
- const p = _prospects[i];
- if (p) submitFeedback('contact', p.id, 'Feedback on this contact:');
-}
-function fbCampaign(i) {
- const c = _campaigns[i];
- if (c) submitFeedback('campaign', c.id, 'Leave feedback on this campaign:');
-}
+WEB_DIR = (Path(__file__).resolve().parent / "web")
-async function loadProspects() {
- const el = document.getElementById('prospects-table');
- const data = await api('/api/prospects');
- if (!data) { el.innerHTML = offlineState(); return; }
- _prospects = data;
- if (!data.length) {
- el.innerHTML = emptyState('&#9673;', 'No contacts yet',
- 'Harvey hasn\'t found any prospects. Once it\'s running, the Scout agent searches the web for people matching your ideal customer profile in <b>harvey.yaml</b>.');
- return;
- }
- let html = '<div class="table-card"><table><thead><tr><th>Name</th><th>Title</th><th>Company</th><th>Email</th><th>Phone</th><th>Status</th><th>Source</th><th>Added</th><th></th></tr></thead><tbody>';
- data.forEach((p, i) => {
- const emailV = p.email ? (escHtml(p.email) + emailTag(p)) : '';
- const phoneV = p.phone ? (escHtml(p.phone) + (p.phone_verified ? ' <span class="verified">&#10003;</span>' : '')) : '';
- html += '<tr><td>' + escHtml(p.first_name) + ' ' + escHtml(p.last_name) + '</td>' +
- '<td>' + escHtml(p.title) + '</td><td>' + escHtml(p.company) + '</td>' +
- '<td>' + emailV + '</td><td>' + phoneV + '</td><td>' + badge(p.status) + '</td>' +
- '<td class="muted">' + escHtml(p.source) + '</td><td class="muted">' + formatDate(p.created_at) + '</td>' +
- '<td><button class="btn btn-secondary btn-sm" onclick="fbProspect(' + i + ')">Feedback</button></td></tr>';
- });
- el.innerHTML = html + '</tbody></table></div>';
-}
-async function loadCampaigns() {
- const el = document.getElementById('campaigns-list');
- const data = await api('/api/campaigns');
- if (!data) { el.innerHTML = offlineState(); return; }
- _campaigns = data;
- if (!data.length) {
- el.innerHTML = emptyState('&#9993;', 'No campaigns yet',
- 'The Writer agent hasn\'t drafted any sequences. It kicks in automatically once Harvey has scored prospects to write for.');
- return;
- }
- let html = '';
- data.forEach((c, i) => {
- let stepsHtml = '';
- for (const step of (c.sequence || [])) {
- stepsHtml += '<div class="email-step"><div class="step-num">Email ' + escHtml(String(step.step || '?')) +
- (step.delay_days ? ' &middot; send after ' + escHtml(String(step.delay_days)) + ' days' : '') + '</div>' +
- '<div class="subject">' + escHtml(step.subject) + '</div>' +
- '<div class="body">' + escHtml(step.body) + '</div></div>';
- }
- const pc = (c.prospect_ids || []).length;
- html += '<div class="campaign-card"><h3>' + escHtml(c.name || 'Untitled Campaign') + '</h3>' +
- '<div class="meta">' + badge(c.status) + '<span>' + escHtml(c.channel || 'email') + '</span>' +
- '<span>' + pc + ' prospect' + (pc !== 1 ? 's' : '') + '</span><span>' + formatDate(c.created_at) + '</span>' +
- '<button class="btn btn-secondary btn-sm" onclick="fbCampaign(' + i + ')">Feedback</button></div>' +
- (stepsHtml || '<p style="color:var(--text-3);font-size:13px">No email steps in this campaign.</p>') + '</div>';
- });
- el.innerHTML = html;
-}
[email protected]("/static/{filename}")
+async def static_file(filename: str):
+ """Serve the dashboard's CSS/JS from disk.
-async function loadConversations() {
- const el = document.getElementById('conversations-list');
- const data = await api('/api/conversations');
- if (!data) { el.innerHTML = offlineState(); return; }
- if (!data.length) {
- el.innerHTML = emptyState('&#9737;', 'No conversations yet',
- 'No prospects have replied so far. When they do, the Handler agent classifies each reply and responds — every thread shows up here.');
- return;
- }
- let html = '';
- for (const c of data) {
- let threadHtml = '';
- for (const msg of (c.thread || [])) {
- const cls = msg.sender === 'harvey' ? 'sent' : 'received';
- threadHtml += '<div class="thread-msg ' + cls + '"><div class="sender">' + escHtml(msg.sender) +
- ' &middot; ' + formatDate(msg.timestamp) + '</div>' + escHtml(msg.content) + '</div>';
- }
- const name = [c.first_name, c.last_name].filter(Boolean).join(' ') || 'Unknown';
- html += '<div class="convo-card"><h3>' + escHtml(name) +
- (c.company ? ' <span style="color:var(--text-3);font-weight:500">&mdash; ' + escHtml(c.company) + '</span>' : '') + '</h3>' +
- '<div class="meta">' + badge(c.status) + (c.intent ? badge(c.intent) : '') +
- '<span>' + escHtml(c.prospect_email || '') + '</span><span>' + formatDate(c.updated_at) + '</span></div>' +
- (threadHtml || '<p style="color:var(--text-3);font-size:13px">No messages in this thread yet.</p>') + '</div>';
- }
- el.innerHTML = html;
-}
+ Read per-request rather than cached at import: editing app.css or app.js
+ and hitting reload is the whole point of having them as real files.
+ """
+ path = (WEB_DIR / filename).resolve()
+ if path.parent != WEB_DIR.resolve() or not path.is_file():
+ return PlainTextResponse("not found", status_code=404)
+ types = {".css": "text/css", ".js": "text/javascript", ".svg": "image/svg+xml"}
+ return PlainTextResponse(
+ path.read_text(),
+ media_type=types.get(path.suffix, "text/plain"),
+ headers={"Cache-Control": "no-store"},
+ )
-async function loadActivity() {
- const el = document.getElementById('activity-list');
- const data = await api('/api/activity');
- if (!data) { el.innerHTML = offlineState(); return; }
- if (!data.length) {
- el.innerHTML = emptyState('&#9202;', 'No activity yet',
- 'Harvey hasn\'t taken any actions. Every prospect found, email written, and reply handled will appear here the moment it happens.');
- return;
- }
- let html = '<div class="activity-feed">';
- for (const a of data) {
- html += '<div class="activity-item"><span class="time">' + formatDate(a.created_at) + '</span>' +
- '<span class="agent">' + escHtml(a.agent) + '</span>' +
- '<span class="action">' + escHtml(a.action_type) + '</span></div>';
- }
- el.innerHTML = html + '</div>';
-}
-// ── Init & live refresh ──
-
-loadSetupStatus();
-loadHarveyStatus();
-
-// Agent status: quick poll
-setInterval(loadHarveyStatus, 8000);
-
-// Data tabs: auto-refresh live stats without clobbering form input
-setInterval(() => {
- if (document.hidden) return;
- switch (currentTab) {
- case 'setup': loadSetupStatus(); break;
- case 'overview': loadStats(); break;
- case 'companies': if (!companyDrill) loadCompanies(); break;
- case 'prospects': loadProspects(); break;
- case 'campaigns': loadCampaigns(); break;
- case 'conversations': loadConversations(); break;
- case 'activity': loadActivity(); break;
- case 'usage': loadUsage(); break;
- case 'outbox': loadOutbox(); break;
- case 'controls': loadLogs(); break;
- // settings & help: never auto-refreshed (user may be typing)
- }
-}, 15000);
-</script>
-</body>
-</html>
-"""
[email protected]("/", response_class=HTMLResponse)
+async def dashboard():
+ return (WEB_DIR / "index.html").read_text()
def start_dashboard(host: str = "127.0.0.1", port: int = 5555):
diff --git a/harvey/web/app.css b/harvey/web/app.css
new file mode 100644
index 0000000..c27e3f5
--- /dev/null
+++ b/harvey/web/app.css
@@ -0,0 +1,548 @@
+ :root {
+ --bg: #08090c;
+ --panel: #0f1216;
+ --panel-raised: #141922;
+ --border: #1d2430;
+ --border-strong: #2b3444;
+ --text: #e9ecf2;
+ --text-2: #9aa4b4;
+ --text-3: #5c6774;
+ --accent: #3ecf8e;
+ --accent-deep: #22996a;
+ --accent-soft: rgba(62, 207, 142, 0.12);
+ --blue: #74a8ff;
+ --amber: #e5b567;
+ --red: #e06c75;
+ --purple: #b48ce8;
+ --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
+ --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
+ }
+
+ * { margin: 0; padding: 0; box-sizing: border-box; }
+ ::selection { background: rgba(62,207,142,0.25); }
+
+ html { color-scheme: dark; }
+
+ body {
+ font-family: var(--sans);
+ background: var(--bg);
+ background-image:
+ radial-gradient(1100px 480px at 75% -12%, rgba(62,207,142,0.06), transparent 60%),
+ radial-gradient(900px 420px at 8% -10%, rgba(116,168,255,0.05), transparent 55%);
+ background-repeat: no-repeat;
+ color: var(--text);
+ min-height: 100vh;
+ font-size: 14px;
+ -webkit-font-smoothing: antialiased;
+ }
+
+ a { color: var(--blue); text-decoration: none; }
+ a:hover { text-decoration: underline; }
+
+ /* ── Header ── */
+ header {
+ position: sticky; top: 0; z-index: 100;
+ background: rgba(8,9,12,0.82);
+ backdrop-filter: blur(14px);
+ -webkit-backdrop-filter: blur(14px);
+ border-bottom: 1px solid var(--border);
+ padding: 14px 32px;
+ display: flex; align-items: center; justify-content: space-between; gap: 16px;
+ }
+
+ .brand { display: flex; align-items: center; gap: 12px; }
+ .brand .mark {
+ width: 34px; height: 34px; border-radius: 9px;
+ background: linear-gradient(145deg, #2fbf82, #17795a);
+ box-shadow: 0 0 0 1px rgba(62,207,142,0.35), 0 4px 14px rgba(62,207,142,0.18);
+ display: flex; align-items: center; justify-content: center;
+ font-weight: 800; font-size: 17px; color: #04140d; letter-spacing: -0.5px;
+ }
+ .brand h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; line-height: 1.1; }
+ .brand .tagline {
+ font-size: 10px; text-transform: uppercase; letter-spacing: 1.4px;
+ color: var(--text-3); margin-top: 2px; font-weight: 600;
+ }
+
+ .header-controls { display: flex; align-items: center; gap: 10px; }
+
+ .harvey-status {
+ display: flex; align-items: center; gap: 8px;
+ font-size: 12px; font-weight: 600; color: var(--text-2);
+ padding: 7px 14px;
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 99px;
+ }
+ .status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
+ .status-dot.running {
+ background: var(--accent);
+ box-shadow: 0 0 0 0 rgba(62,207,142,0.5);
+ animation: pulse 2s infinite;
+ }
+ .status-dot.stopped { background: #4a5361; }
+ .status-dot.offline { background: var(--red); }
+ @keyframes pulse {
+ 0% { box-shadow: 0 0 0 0 rgba(62,207,142,0.45); }
+ 70% { box-shadow: 0 0 0 7px rgba(62,207,142,0); }
+ 100% { box-shadow: 0 0 0 0 rgba(62,207,142,0); }
+ }
+
+ .refresh-btn {
+ background: var(--panel); border: 1px solid var(--border); color: var(--text-2);
+ padding: 7px 14px; border-radius: 99px; cursor: pointer;
+ font-size: 12px; font-weight: 600; font-family: inherit;
+ transition: border-color .15s, color .15s;
+ }
+ .refresh-btn:hover { border-color: var(--border-strong); color: var(--text); }
+
+ /* ── Nav ── */
+ nav {
+ position: sticky; top: 63px; z-index: 99;
+ background: rgba(8,9,12,0.82);
+ backdrop-filter: blur(14px);
+ -webkit-backdrop-filter: blur(14px);
+ border-bottom: 1px solid var(--border);
+ padding: 0 24px; display: flex; overflow-x: auto;
+ scrollbar-width: none;
+ }
+ nav::-webkit-scrollbar { display: none; }
+
+ nav button {
+ position: relative;
+ background: none; border: none;
+ color: var(--text-3); padding: 13px 14px; cursor: pointer;
+ font-size: 13px; font-weight: 500; font-family: inherit;
+ transition: color .15s; white-space: nowrap;
+ }
+ nav button:hover { color: var(--text-2); }
+ nav button.active { color: var(--text); font-weight: 600; }
+ nav button.active::after {
+ content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px;
+ height: 2px; border-radius: 2px 2px 0 0; background: var(--accent);
+ }
+
+ main { padding: 28px 32px 64px; max-width: 1400px; margin: 0 auto; }
+
+ .section { display: none; }
+ .section.active { display: block; animation: rise .25s ease; }
+ @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
+
+ .section-head { margin-bottom: 20px; }
+ .section-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.4px; }
+ .section-head p { font-size: 13px; color: var(--text-3); margin-top: 4px; }
+
+ /* ── Cards ── */
+ .card {
+ background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
+ padding: 24px; margin-bottom: 16px;
+ }
+ .card h2 { font-size: 15px; font-weight: 650; letter-spacing: -0.2px; margin-bottom: 16px; }
+
+ /* ── Stat cards ── */
+ .stats-grid {
+ display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
+ gap: 14px; margin-bottom: 28px;
+ }
+ .stat-card {
+ position: relative; overflow: hidden;
+ background: linear-gradient(180deg, var(--panel-raised), var(--panel));
+ border: 1px solid var(--border); border-radius: 12px; padding: 20px;
+ transition: border-color .2s;
+ }
+ .stat-card:hover { border-color: var(--border-strong); }
+ .stat-card::before {
+ content: ""; position: absolute; top: 0; left: 20px; right: 20px; height: 1px;
+ background: linear-gradient(90deg, transparent, rgba(62,207,142,0.35), transparent);
+ }
+ .stat-card .label {
+ font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px;
+ color: var(--text-3); font-weight: 700; margin-bottom: 10px;
+ }
+ .stat-card .value {
+ font-size: 34px; font-weight: 750; letter-spacing: -1px; line-height: 1;
+ font-variant-numeric: tabular-nums;
+ }
+ .stat-card .breakdown { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 5px; }
+ .chip {
+ font-size: 11px; font-weight: 550; color: var(--text-2);
+ background: rgba(255,255,255,0.04); border: 1px solid var(--border);
+ padding: 2px 9px; border-radius: 99px; font-variant-numeric: tabular-nums;
+ }
+ .chip b { color: var(--text); font-weight: 650; }
+
+ /* ── Progress ── */
+ .progress-wrap { margin-bottom: 24px; }
+ .progress-label { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }
+ .progress-label .pct { color: var(--text); font-weight: 700; font-variant-numeric: tabular-nums; }
+ .progress-label .text { color: var(--text-3); }
+ .progress-bar { background: rgba(255,255,255,0.05); border-radius: 99px; height: 8px; overflow: hidden; }
+ .progress-fill { height: 100%; border-radius: 99px; transition: width .5s ease; }
+ .progress-fill.green { background: linear-gradient(90deg, var(--accent-deep), var(--accent)); }
+ .progress-fill.yellow { background: linear-gradient(90deg, #a3801f, var(--amber)); }
+
+ /* ── Setup checklist ── */
+ .check-item {
+ display: flex; align-items: flex-start; gap: 14px;
+ padding: 14px 0; border-bottom: 1px solid var(--border);
+ }
+ .check-item:last-child { border-bottom: none; }
+ .check-icon {
+ width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0;
+ display: flex; align-items: center; justify-content: center;
+ font-size: 12px; margin-top: 1px;
+ }
+ .check-icon.done { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(62,207,142,0.3); }
+ .check-icon.pending { background: transparent; color: var(--text-3); border: 1px dashed var(--border-strong); }
+ .check-info { flex: 1; }
+ .check-label { font-size: 14px; font-weight: 550; color: var(--text); }
+ .check-label.done { color: var(--text-3); text-decoration: line-through; text-decoration-color: rgba(255,255,255,0.15); }
+ .check-help { font-size: 12.5px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }
+ .optional-tag {
+ font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
+ background: rgba(116,168,255,0.1); color: var(--blue);
+ padding: 2px 8px; border-radius: 99px; margin-left: 8px; vertical-align: 1px;
+ }
+ .subhead {
+ margin: 20px 0 4px; font-size: 10.5px; color: var(--text-3);
+ text-transform: uppercase; letter-spacing: 1.2px; font-weight: 700;
+ }
+
+ /* ── Forms ── */
+ .form-group { margin-bottom: 16px; }
+ .form-label {
+ display: block; font-size: 11px; color: var(--text-2); margin-bottom: 7px;
+ text-transform: uppercase; letter-spacing: 0.8px; font-weight: 650;
+ }
+ .form-input {
+ width: 100%; padding: 10px 14px;
+ background: rgba(255,255,255,0.03); border: 1px solid var(--border-strong);
+ border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit;
+ transition: border-color .15s, box-shadow .15s;
+ }
+ .form-input:focus { outline: none; border-color: var(--accent-deep); box-shadow: 0 0 0 3px rgba(62,207,142,0.12); }
+ .form-input::placeholder { color: var(--text-3); }
+ .form-row { display: flex; gap: 10px; align-items: flex-end; }
+ .form-row .form-group { flex: 1; }
+ .card .lede { font-size: 13px; color: var(--text-2); margin: -6px 0 18px; line-height: 1.6; }
+
+ .btn {
+ padding: 9px 20px; border: 1px solid transparent; border-radius: 8px;
+ font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
+ transition: background .15s, border-color .15s, transform .05s;
+ }
+ .btn:active { transform: translateY(1px); }
+ .btn:disabled { opacity: 0.5; cursor: not-allowed; }
+ .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
+ .btn-primary { background: var(--accent-deep); color: #eafff5; box-shadow: inset 0 1px 0 rgba(255,255,255,0.12); }
+ .btn-primary:hover:not(:disabled) { background: #2ab27c; }
+ .btn-danger { background: #8a2f36; color: #ffe9ea; }
+ .btn-danger:hover:not(:disabled) { background: #a13940; }
+ .btn-secondary { background: rgba(255,255,255,0.03); border-color: var(--border-strong); color: var(--text-2); }
+ .btn-secondary:hover:not(:disabled) { color: var(--text); border-color: #3a4557; }
+ .btn-sm { padding: 6px 13px; font-size: 12px; }
+ .btn-group { display: flex; gap: 10px; margin-top: 16px; }
+
+ .test-result { font-size: 13px; margin-top: 10px; padding: 9px 13px; border-radius: 8px; }
+ .test-result.success { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(62,207,142,0.25); }
+ .test-result.error { background: rgba(224,108,117,0.1); color: var(--red); border: 1px solid rgba(224,108,117,0.25); }
+ .test-result.pending { background: rgba(255,255,255,0.04); color: var(--text-2); border: 1px solid var(--border); }
+
+ /* ── Controls ── */
+ .control-panel { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
+ @media (max-width: 900px) { .control-panel { grid-template-columns: 1fr; } }
+
+ .status-big { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
+ .status-big .dot { width: 13px; height: 13px; border-radius: 50%; }
+ .status-big .dot.running { background: var(--accent); animation: pulse 2s infinite; }
+ .status-big .dot.stopped { background: #4a5361; }
+ .status-big .label { font-size: 19px; font-weight: 700; letter-spacing: -0.3px; }
+ .status-big .label.running { color: var(--accent); }
+ .status-big .label.stopped { color: var(--text-2); }
+ .status-meta { font-size: 12px; color: var(--text-3); margin-bottom: 18px; font-variant-numeric: tabular-nums; min-height: 15px; }
+
+ .log-viewer {
+ background: #07080a; border: 1px solid var(--border); border-radius: 10px;
+ padding: 14px 16px; font-family: var(--mono);
+ font-size: 11.5px; color: #8fa39a; line-height: 1.65;
+ max-height: 420px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
+ }
+
+ /* ── Help ── */
+ .help-section { margin-bottom: 28px; }
+ .help-section h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 10px; }
+ .help-section p { font-size: 14px; color: var(--text-2); line-height: 1.7; margin-bottom: 10px; }
+ .help-section code { background: rgba(255,255,255,0.05); padding: 2px 7px; border-radius: 5px; font-size: 12.5px; font-family: var(--mono); color: var(--text); }
+ .help-section pre {
+ background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
+ padding: 16px; font-size: 12.5px; font-family: var(--mono); color: var(--text-2); line-height: 1.7;
+ overflow-x: auto; margin: 12px 0;
+ }
+
+ .file-table { width: 100%; font-size: 13px; border-collapse: collapse; }
+ .file-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); }
+ .file-table tr:last-child td { border-bottom: none; }
+ .file-table td:first-child { color: var(--text); font-family: var(--mono); font-size: 12px; white-space: nowrap; width: 220px; }
+ .file-table td:last-child { color: var(--text-2); }
+
+ details { margin-bottom: 8px; }
+ details summary {
+ cursor: pointer; padding: 12px 16px; background: var(--panel); border: 1px solid var(--border);
+ border-radius: 10px; font-size: 13.5px; font-weight: 550; color: var(--text-2); list-style: none;
+ transition: color .15s;
+ }
+ details summary:hover { color: var(--text); }
+ details summary::-webkit-details-marker { display: none; }
+ details summary::before { content: "+"; display: inline-block; width: 18px; color: var(--accent); font-weight: 700; }
+ details[open] summary::before { content: "–"; }
+ details[open] summary { border-radius: 10px 10px 0 0; border-bottom: none; color: var(--text); }
+ details .faq-body {
+ padding: 4px 16px 16px 34px; background: var(--panel); border: 1px solid var(--border); border-top: none;
+ border-radius: 0 0 10px 10px; font-size: 13px; color: var(--text-2); line-height: 1.7;
+ }
+
+ /* ── Toast ── */
+ .toast {
+ position: fixed; bottom: 24px; right: 24px; padding: 12px 20px;
+ border-radius: 10px; font-size: 13px; font-weight: 550; z-index: 1000;
+ box-shadow: 0 12px 32px rgba(0,0,0,0.5);
+ animation: toastIn .2s ease, toastOut .3s 2.2s forwards;
+ }
+ .toast.success { background: #0d2a1d; color: var(--accent); border: 1px solid rgba(62,207,142,0.4); }
+ .toast.error { background: #2c1416; color: var(--red); border: 1px solid rgba(224,108,117,0.4); }
+ @keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }
+ @keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(6px); } }
+
+ /* ── Tables ── */
+ .table-card {
+ background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
+ overflow-x: auto;
+ }
+ table { width: 100%; border-collapse: collapse; font-size: 13px; }
+ th {
+ text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--border);
+ color: var(--text-3); font-weight: 700; font-size: 10.5px;
+ text-transform: uppercase; letter-spacing: 1px; white-space: nowrap;
+ background: rgba(255,255,255,0.015);
+ }
+ td {
+ padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top;
+ max-width: 300px; overflow: hidden; text-overflow: ellipsis; color: var(--text-2);
+ }
+ td:first-child { color: var(--text); font-weight: 550; }
+ tr:last-child td { border-bottom: none; }
+ tbody tr { transition: background .1s; }
+ tbody tr:hover td { background: rgba(255,255,255,0.02); }
+ .verified { color: var(--accent); }
+ .email-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; padding: 1px 6px; border-radius: 4px; margin-left: 6px; }
+ .email-tag.verified { color: var(--accent); background: var(--accent-soft); }
+ .email-tag.risky { color: var(--amber); background: rgba(229,181,103,0.12); }
+ .email-tag.guess { color: var(--text-3); background: rgba(255,255,255,0.05); }
+ .email-tag.invalid { color: var(--red); background: rgba(224,108,117,0.12); }
+ .muted { color: var(--text-3); }
+
+ .badge {
+ display: inline-flex; align-items: center; gap: 6px;
+ padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 650;
+ border: 1px solid transparent; white-space: nowrap;
+ }
+ .badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
+ .badge-new { background: rgba(116,168,255,0.1); color: var(--blue); border-color: rgba(116,168,255,0.22); }
+ .badge-contacted, .badge-open, .badge-objection { background: rgba(229,181,103,0.1); color: var(--amber); border-color: rgba(229,181,103,0.22); }
+ .badge-replied, .badge-active, .badge-interested { background: var(--accent-soft); color: var(--accent); border-color: rgba(62,207,142,0.25); }
+ .badge-meeting { background: rgba(180,140,232,0.12); color: var(--purple); border-color: rgba(180,140,232,0.25); }
+ .badge-draft { background: rgba(255,255,255,0.05); color: var(--text-2); border-color: var(--border-strong); }
+ .badge-closed { background: rgba(255,255,255,0.04); color: var(--text-3); border-color: var(--border); }
+ .badge-lost, .badge-not_interested { background: rgba(224,108,117,0.1); color: var(--red); border-color: rgba(224,108,117,0.22); }
+ .badge-unknown { background: rgba(255,255,255,0.04); color: var(--text-3); border-color: var(--border); }
+
+ .campaign-card, .convo-card {
+ background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
+ padding: 24px; margin-bottom: 16px;
+ }
+ .campaign-card h3, .convo-card h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; margin-bottom: 6px; }
+ .campaign-card .meta, .convo-card .meta {
+ font-size: 12px; color: var(--text-3); margin-bottom: 18px;
+ display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
+ }
+
+ .email-step {
+ border-left: 2px solid var(--border-strong); padding: 14px 20px; margin: 0 0 12px 6px;
+ border-radius: 0 10px 10px 0; background: rgba(255,255,255,0.015);
+ }
+ .email-step .step-num {
+ font-size: 10px; color: var(--accent); text-transform: uppercase;
+ letter-spacing: 1px; font-weight: 700; margin-bottom: 7px;
+ }
+ .email-step .subject { font-size: 14px; font-weight: 650; margin-bottom: 8px; }
+ .email-step .body { font-size: 13px; color: var(--text-2); line-height: 1.7; white-space: pre-wrap; }
+
+ .thread-msg {
+ padding: 12px 16px; margin-bottom: 8px; border-radius: 12px; max-width: 78%;
+ font-size: 13px; line-height: 1.6; white-space: pre-wrap;
+ }
+ .thread-msg.sent { background: rgba(62,207,142,0.08); border: 1px solid rgba(62,207,142,0.16); color: #cfeee0; margin-left: auto; border-bottom-right-radius: 4px; }
+ .thread-msg.received { background: rgba(255,255,255,0.04); border: 1px solid var(--border); color: var(--text-2); border-bottom-left-radius: 4px; }
+ .thread-msg .sender { font-size: 10.5px; color: var(--text-3); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; }
+
+ .activity-feed { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 8px 20px; }
+ .activity-item { display: flex; gap: 18px; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; align-items: baseline; }
+ .activity-item:last-child { border-bottom: none; }
+ .activity-item .time { color: var(--text-3); font-size: 12px; min-width: 130px; font-variant-numeric: tabular-nums; }
+ .activity-item .agent {
+ color: var(--accent); min-width: 84px; font-size: 11px; font-weight: 700;
+ text-transform: uppercase; letter-spacing: 0.8px;
+ }
+ .activity-item .action { color: var(--text-2); }
+
+ /* ── Empty states ── */
+ .empty {
+ text-align: center; padding: 72px 24px;
+ background: var(--panel); border: 1px dashed var(--border-strong); border-radius: 12px;
+ }
+ .empty .glyph {
+ width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 12px;
+ background: rgba(255,255,255,0.03); border: 1px solid var(--border);
+ display: flex; align-items: center; justify-content: center;
+ font-size: 20px; color: var(--text-3);
+ }
+ .empty .title { font-size: 15px; font-weight: 650; color: var(--text); margin-bottom: 6px; }
+ .empty .copy { font-size: 13px; color: var(--text-3); line-height: 1.6; max-width: 420px; margin: 0 auto; }
+ .empty .copy b { color: var(--text-2); font-weight: 600; }
+
+ @media (max-width: 700px) {
+ header, main { padding-left: 18px; padding-right: 18px; }
+ nav { padding: 0 10px; }
+ .brand .tagline { display: none; }
+ }
+
+ /* ── Nav counts: how much is waiting, without opening the tab ── */
+ .nav-count {
+ display: none; margin-left: 6px; padding: 1px 6px; border-radius: 99px;
+ font-size: 10.5px; font-weight: 700; font-variant-numeric: tabular-nums;
+ background: rgba(229,181,103,0.16); color: var(--amber);
+ }
+ .nav-count.on { display: inline-block; }
+ .nav-count.good { background: var(--accent-soft); color: var(--accent); }
+
+ /* ── Today: the action queue ── */
+ .queue { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
+ .queue-item {
+ display: flex; align-items: center; gap: 16px; padding: 16px 18px;
+ background: var(--panel); border: 1px solid var(--border);
+ border-left: 3px solid var(--border-strong); border-radius: 12px;
+ }
+ .queue-item.warn { border-left-color: var(--amber); }
+ .queue-item.bad { border-left-color: var(--red); }
+ .queue-item.good { border-left-color: var(--accent); }
+ .queue-item .qtext { flex: 1; min-width: 0; }
+ .queue-item .qtitle { font-size: 14.5px; font-weight: 650; letter-spacing: -0.2px; }
+ .queue-item .qdetail { font-size: 12.5px; color: var(--text-3); margin-top: 4px; line-height: 1.5; }
+ .queue-clear {
+ display: flex; align-items: center; gap: 12px; padding: 20px;
+ background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
+ margin-bottom: 26px;
+ }
+ .queue-clear .glyph { font-size: 20px; color: var(--accent); }
+ .queue-clear .qtitle { font-size: 14.5px; font-weight: 650; }
+ .queue-clear .qdetail { font-size: 12.5px; color: var(--text-3); margin-top: 3px; }
+
+ /* ── Signals review ── */
+ .sig-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
+ .sig-stat {
+ background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
+ padding: 12px 18px; min-width: 132px;
+ }
+ .sig-stat .n { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.5px; }
+ .sig-stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px; color: var(--text-3); margin-top: 3px; }
+ .sig-stat.confirmed .n { color: var(--accent); }
+ .sig-stat.proposed .n { color: var(--amber); }
+ .sig-stat.rejected .n { color: var(--text-3); }
+
+ .sig-group { margin-bottom: 22px; }
+ .sig-group-head {
+ display: flex; align-items: flex-start; justify-content: space-between;
+ gap: 16px; margin-bottom: 12px;
+ }
+ .sig-group-head h3 { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; }
+ .sig-group-head p { font-size: 12.5px; color: var(--text-3); margin-top: 4px; max-width: 640px; line-height: 1.55; }
+
+ .sig-row {
+ display: flex; gap: 16px; align-items: flex-start; padding: 15px 18px;
+ border-bottom: 1px solid var(--border);
+ }
+ .sig-row:last-child { border-bottom: none; }
+ .sig-row.rejected { opacity: 0.45; }
+ .sig-row .sig-main { flex: 1; min-width: 0; }
+ .sig-row .sig-label { font-size: 14px; font-weight: 600; }
+ .sig-row .sig-code {
+ font-family: var(--mono); font-size: 10.5px; color: var(--text-3);
+ margin-left: 8px; letter-spacing: 0.3px;
+ }
+ .sig-row .sig-desc { font-size: 12.5px; color: var(--text-2); margin-top: 5px; line-height: 1.6; max-width: 660px; }
+ .sig-row .sig-meta { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
+ .sig-row .sig-decide { display: flex; gap: 6px; flex-shrink: 0; padding-top: 2px; }
+ .cost-chip {
+ font-size: 11px; padding: 2px 8px; border-radius: 5px;
+ background: rgba(255,255,255,0.04); color: var(--text-3); border: 1px solid var(--border);
+ }
+ .cost-chip.free { color: var(--accent); background: var(--accent-soft); border-color: rgba(62,207,142,0.22); }
+ .cost-chip.paid { color: var(--amber); background: rgba(229,181,103,0.1); border-color: rgba(229,181,103,0.22); }
+
+ /* ── Cohort builder ── */
+ .cohort-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px; }
+ .cohort-pick {
+ display: flex; align-items: center; gap: 9px; padding: 9px 12px;
+ border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px;
+ cursor: pointer; user-select: none; background: rgba(255,255,255,0.015);
+ }
+ .cohort-pick:hover { border-color: var(--border-strong); }
+ .cohort-pick input { accent-color: var(--accent); }
+ .cohort-pick .n { margin-left: auto; color: var(--text-3); font-variant-numeric: tabular-nums; font-size: 11.5px; }
+ .cohort-size { font-size: 30px; font-weight: 700; letter-spacing: -0.8px; color: var(--accent); font-variant-numeric: tabular-nums; }
+
+ /* ── Decisions desk ── */
+ .desk { display: grid; grid-template-columns: 260px 1fr; gap: 16px; align-items: start; }
+ .desk-list {
+ background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
+ overflow: hidden; max-height: 640px; overflow-y: auto;
+ }
+ .desk-item {
+ padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer;
+ border-left: 3px solid transparent;
+ }
+ .desk-item:last-child { border-bottom: none; }
+ .desk-item:hover { background: rgba(255,255,255,0.02); }
+ .desk-item.active { background: var(--accent-soft); border-left-color: var(--accent); }
+ .desk-item .to { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+ .desk-item .sub { font-size: 11.5px; color: var(--text-3); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
+ .desk-pane {
+ background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 22px 24px;
+ }
+ .desk-pane .to-line { font-size: 13px; color: var(--text-2); margin-bottom: 4px; }
+ .desk-pane .subject { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; margin: 10px 0 14px; }
+ .desk-pane .body {
+ font-size: 14px; color: var(--text-2); line-height: 1.75; white-space: pre-wrap;
+ padding: 16px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
+ }
+ .desk-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
+ kbd {
+ font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border-radius: 4px;
+ background: rgba(255,255,255,0.06); border: 1px solid var(--border-strong); color: var(--text-2);
+ }
+
+ @media (max-width: 900px) {
+ .desk { grid-template-columns: 1fr; }
+ .desk-list { max-height: 240px; }
+ }
+
+ /* ── One status vocabulary ──
+ Every status in Harvey — prospect, campaign, conversation, outbox,
+ signal, email deliverability — renders through the same five tones, so
+ "waiting on me" looks identical everywhere it appears. */
+ .badge.t-waiting { background: rgba(229,181,103,0.1); color: var(--amber); border-color: rgba(229,181,103,0.22); }
+ .badge.t-active { background: rgba(116,168,255,0.1); color: var(--blue); border-color: rgba(116,168,255,0.22); }
+ .badge.t-good { background: var(--accent-soft); color: var(--accent); border-color: rgba(62,207,142,0.25); }
+ .badge.t-bad { background: rgba(224,108,117,0.1); color: var(--red); border-color: rgba(224,108,117,0.22); }
+ .badge.t-idle { background: rgba(255,255,255,0.04); color: var(--text-3); border-color: var(--border); }
+ .badge.t-note { background: rgba(180,140,232,0.12); color: var(--purple); border-color: rgba(180,140,232,0.25); }
diff --git a/harvey/web/app.js b/harvey/web/app.js
new file mode 100644
index 0000000..1860719
--- /dev/null
+++ b/harvey/web/app.js
@@ -0,0 +1,1117 @@
+let currentTab = 'today';
+let companyDrill = false; // true while viewing a single company's contacts
+let _companies = [], _prospects = [], _campaigns = [];
+let _signals = null; // last /api/signals payload, for the cohort builder
+let _desk = { items: [], i: 0 };
+
+// ── Utilities ──
+
+function escHtml(s) {
+ if (s === null || s === undefined || s === '') return '';
+ return String(s).replace(/[&<>"']/g, ch => (
+ {'&':'&amp;','<':'&lt;','>':'&gt;','"':'&quot;',"'":'&#39;'}[ch]
+ ));
+}
+
+// ── One status vocabulary ──
+//
+// Harvey's tables each carry their own words for state: a prospect is `new`,
+// a campaign is `draft`, an email is `pending_review`, a signal is `proposed`.
+// Five of those mean "waiting on you" and the old dashboard styled every one
+// differently. Everything now resolves through this map, so a status reads the
+// same way no matter which table it came out of.
+//
+// tone: waiting (needs a human) | active (in flight) | good | bad | idle
+const STATUS = {
+ // prospects
+ new: ['New', 'active'],
+ contacted: ['Contacted', 'active'],
+ replied: ['Replied', 'good'],
+ interested: ['Interested', 'good'],
+ meeting: ['Meeting booked', 'note'],
+ not_interested: ['Not interested', 'bad'],
+ bounced: ['Bounced', 'bad'],
+ // campaigns
+ draft: ['Draft', 'waiting'],
+ active: ['Active', 'good'],
+ completed: ['Completed', 'idle'],
+ paused: ['Paused', 'bad'],
+ // conversations
+ open: ['Open', 'active'],
+ closed: ['Closed', 'idle'],
+ closed_won: ['Won', 'good'],
+ closed_lost: ['Lost', 'bad'],
+ objection: ['Objection', 'waiting'],
+ // outbox
+ pending_review: ['Waiting on you', 'waiting'],
+ approved: ['Approved', 'good'],
+ scheduled: ['Scheduled', 'active'],
+ sent: ['Sent', 'good'],
+ failed: ['Failed', 'bad'],
+ rejected: ['Rejected', 'idle'],
+ cancelled: ['Cancelled', 'idle'],
+ // signals
+ proposed: ['Waiting on you', 'waiting'],
+ confirmed: ['Confirmed', 'good'],
+ // email deliverability
+ verified: ['Verified', 'good'],
+ risky: ['Catch-all', 'waiting'],
+ guess: ['Unverified', 'idle'],
+ invalid: ['Invalid', 'bad'],
+ // runs
+ running: ['Running', 'active'],
+ stale: ['Stale', 'bad'],
+};
+
+function statusMeta(status) {
+ const key = String(status || '').toLowerCase().replace(/[^a-z0-9]+/g, '_');
+ const hit = STATUS[key];
+ if (hit) return { label: hit[0], tone: hit[1] };
+ const label = String(status || 'unknown').replace(/_/g, ' ');
+ return { label: label.charAt(0).toUpperCase() + label.slice(1), tone: 'idle' };
+}
+
+function badge(status) {
+ const m = statusMeta(status);
+ return '<span class="badge t-' + m.tone + '">' + escHtml(m.label) + '</span>';
+}
+
+function formatDate(d) {
+ if (!d) return '';
+ try {
+ const dt = new Date(d);
+ if (isNaN(dt)) return escHtml(d);
+ return dt.toLocaleString('en-US', {month:'short',day:'numeric',hour:'numeric',minute:'2-digit'});
+ } catch { return escHtml(d); }
+}
+
+function emptyState(glyph, title, copy) {
+ return '<div class="empty"><div class="glyph">' + glyph + '</div>' +
+ '<div class="title">' + title + '</div>' +
+ '<div class="copy">' + copy + '</div></div>';
+}
+
+function offlineState() {
+ return emptyState('&#9888;', 'Dashboard can\'t reach the server',
+ 'The dashboard process may have stopped. Restart it with <b>harvey dashboard</b> and refresh this page.');
+}
+
+async function api(path, opts) {
+ try {
+ const r = await fetch(path, opts);
+ if (!r.ok) return null;
+ return await r.json();
+ } catch {
+ return null;
+ }
+}
+
+function showToast(msg, type) {
+ const t = document.createElement('div');
+ t.className = 'toast ' + type;
+ t.textContent = msg;
+ document.body.appendChild(t);
+ setTimeout(() => t.remove(), 2600);
+}
+
+function toggleVisibility(inputId) {
+ const el = document.getElementById(inputId);
+ el.type = el.type === 'password' ? 'text' : 'password';
+}
+
+// ── Tabs ──
+
+function showTab(id, btn) {
+ currentTab = id;
+ if (id === 'companies') companyDrill = false;
+ document.querySelectorAll('.section').forEach(s => s.classList.remove('active'));
+ document.querySelectorAll('nav button').forEach(b => b.classList.remove('active'));
+ document.getElementById(id).classList.add('active');
+ if (btn) btn.classList.add('active');
+ loadCurrentTab();
+}
+
+function loadCurrentTab() {
+ switch (currentTab) {
+ case 'today': loadToday(); loadStats(); loadSetupStatus(); loadRuns(); break;
+ case 'signals': loadSignals(); break;
+ case 'companies': if (!companyDrill) loadCompanies(); break;
+ case 'prospects': loadProspects(); break;
+ case 'campaigns': loadCampaigns(); break;
+ case 'outbox': loadOutbox(); break;
+ case 'conversations': loadConversations(); break;
+ case 'activity': loadActivity(); break;
+ case 'usage': loadUsage(); break;
+ case 'settings': loadSettings(); break;
+ case 'controls': loadHarveyStatus(); loadLogs(); break;
+ }
+}
+
+// ── Today: what needs a human ──
+
+async function loadToday() {
+ const data = await api('/api/today');
+ const el = document.getElementById('today-queue');
+ if (!data) { el.innerHTML = offlineState(); return; }
+
+ navCount('nav-today', (data.items || []).filter(i => i.tone !== 'good').length);
+ navCount('nav-outbox', (data.stats || {}).outbox_pending || 0);
+ navCount('nav-signals', 0);
+
+ const items = data.items || [];
+ if (!items.length) {
+ el.innerHTML = '<div class="queue-clear">' +
+ '<div class="glyph">&#10003;</div><div>' +
+ '<div class="qtitle">Nothing needs you</div>' +
+ '<div class="qdetail">Harvey has everything it needs. Anything that requires a ' +
+ 'decision — an email to approve, a signal to confirm — shows up here.</div>' +
+ '</div></div>';
+ return;
+ }
+
+ el.innerHTML = '<div class="queue">' + items.map(it =>
+ '<div class="queue-item ' + escHtml(it.tone || 'warn') + '">' +
+ '<div class="qtext">' +
+ '<div class="qtitle">' + escHtml(it.title) + '</div>' +
+ '<div class="qdetail">' + escHtml(it.detail) + '</div>' +
+ '</div>' +
+ '<button class="btn btn-secondary btn-sm" onclick="goTab(\'' + escHtml(it.tab) + '\')">' +
+ escHtml(it.action) + '</button>' +
+ '</div>'
+ ).join('') + '</div>';
+}
+
+function navCount(id, n) {
+ const el = document.getElementById(id);
+ if (!el) return;
+ el.textContent = n > 0 ? n : '';
+ el.className = 'nav-count' + (n > 0 ? ' on' : '');
+}
+
+// Jump to a tab from a link that isn't itself a nav button.
+function goTab(id) {
+ const btns = [...document.querySelectorAll('nav button')];
+ const btn = btns.find(b => (b.getAttribute('onclick') || '').includes("'" + id + "'"));
+ showTab(id, btn);
+}
+
+async function loadRuns() {
+ const el = document.getElementById('today-runs');
+ if (!el) return;
+ const runs = await api('/api/runs');
+ if (!Array.isArray(runs) || !runs.length) { el.innerHTML = ''; return; }
+ el.innerHTML = '<div class="subhead">Collector runs</div>' +
+ '<div class="table-card"><table><thead><tr><th>Stage</th><th>Status</th>' +
+ '<th>Provider</th><th>Records</th><th>Cost</th><th>Started</th></tr></thead><tbody>' +
+ runs.map(r =>
+ '<tr><td>' + escHtml(r.stage) + '</td><td>' + badge(r.status) + '</td>' +
+ '<td class="muted">' + escHtml(r.provider || '—') + '</td>' +
+ '<td>' + (r.records || 0) + '</td>' +
+ '<td class="muted">' + (r.cost_usd ? '$' + Number(r.cost_usd).toFixed(4) : 'free') + '</td>' +
+ '<td class="muted">' + formatDate(r.started_at) + '</td></tr>'
+ ).join('') + '</tbody></table></div>';
+}
+
+// ── Setup checklist (lives on Today, and disappears once it's done) ──
+
+async function loadSetupStatus() {
+ const el = document.getElementById('today-setup');
+ if (!el) return;
+ const data = await api('/api/setup-status');
+ if (!data || !data.checks) { el.innerHTML = ''; return; }
+
+ const pct = data.percent || 0;
+ const renderCheck = (c, optional) => {
+ const icon = c.done
+ ? '<span class="check-icon done">&#10003;</span>'
+ : '<span class="check-icon pending">&#9679;</span>';
+ return '<div class="check-item">' + icon +
+ '<div class="check-info">' +
+ '<div class="check-label ' + (c.done ? 'done' : '') + '">' + escHtml(c.label) +
+ (optional ? ' <span class="optional-tag">optional</span>' : '') + '</div>' +
+ (!c.done ? '<div class="check-help">' + escHtml(c.help) + '</div>' : '') +
+ '</div></div>';
+ };
+
+ let checks = data.checks.filter(c => c.required).map(c => renderCheck(c, false)).join('');
+ const optional = data.checks.filter(c => !c.required);
+ if (optional.length) {
+ checks += '<div class="subhead">Optional</div>';
+ checks += optional.map(c => renderCheck(c, true)).join('');
+ }
+
+ // Complete setup collapses out of the way rather than greeting you forever.
+ const open = pct < 100 ? ' open' : '';
+ el.innerHTML =
+ '<details class="card"' + open + '>' +
+ '<summary style="cursor:pointer;font-size:14px;font-weight:650">Setup &mdash; ' +
+ pct + '% complete <span class="muted" style="font-weight:400">(' +
+ data.completed + ' of ' + data.total_required + ' required steps)</span></summary>' +
+ '<div style="margin-top:16px">' +
+ '<div class="progress-bar" style="margin-bottom:18px"><div class="progress-fill ' +
+ (pct === 100 ? 'green' : 'yellow') + '" style="width:' + pct + '%"></div></div>' +
+ checks +
+ '</div>' +
+ '</details>';
+}
+
+// ── Signals: Harvey proposes, you confirm ──
+
+async function loadSignals() {
+ const data = await api('/api/signals');
+ const sumEl = document.getElementById('signals-summary');
+ const grpEl = document.getElementById('signals-groups');
+ if (!data || data.error) { grpEl.innerHTML = offlineState(); sumEl.innerHTML = ''; return; }
+ _signals = data;
+
+ const s = data.summary || {};
+ navCount('nav-signals', s.proposed || 0);
+ sumEl.innerHTML = '<div class="sig-summary">' +
+ ['confirmed', 'proposed', 'rejected'].map(k =>
+ '<div class="sig-stat ' + k + '"><div class="n">' + (s[k] || 0) + '</div>' +
+ '<div class="k">' + (k === 'proposed' ? 'awaiting you' : k) + '</div></div>'
+ ).join('') +
+ '</div>';
+
+ grpEl.innerHTML = (data.groups || []).map(g => {
+ const codes = g.signals.map(x => x.code);
+ const undecided = g.signals.filter(x => x.status === 'proposed').length;
+ return '<div class="sig-group">' +
+ '<div class="sig-group-head"><div>' +
+ '<h3>' + escHtml(g.label) + '</h3><p>' + escHtml(g.blurb) + '</p>' +
+ '</div>' +
+ (undecided
+ ? '<div style="display:flex;gap:6px;flex-shrink:0">' +
+ '<button class="btn btn-primary btn-sm" onclick=\'setSignals(' +
+ JSON.stringify(codes) + ", \"confirmed\")'>Confirm all " + undecided + '</button>' +
+ '<button class="btn btn-secondary btn-sm" onclick=\'setSignals(' +
+ JSON.stringify(codes) + ", \"rejected\")'>Skip all</button>" +
+ '</div>'
+ : '') +
+ '</div>' +
+ '<div class="card" style="padding:4px 0">' + g.signals.map(sigRow).join('') + '</div>' +
+ '</div>';
+ }).join('');
+
+ renderCohortBuilder();
+}
+
+function sigRow(sig) {
+ const free = /free|included/i.test(sig.cost_note || '');
+ const costCls = free ? 'free' : (/\$/.test(sig.cost_note || '') ? 'paid' : '');
+ const seen = sig.companies
+ ? '<span class="cost-chip">seen on ' + sig.companies +
+ (sig.companies === 1 ? ' company' : ' companies') + ' so far</span>' : '';
+ const floor = sig.confidence_floor > 0
+ ? '<span class="cost-chip">only recorded above ' +
+ Math.round(sig.confidence_floor * 100) + '% confidence</span>' : '';
+
+ const decide = sig.status === 'confirmed'
+ ? '<button class="btn btn-secondary btn-sm" onclick="setSignals([\'' + sig.code +
+ '\'],\'rejected\')">Turn off</button>'
+ : sig.status === 'rejected'
+ ? '<button class="btn btn-secondary btn-sm" onclick="setSignals([\'' + sig.code +
+ '\'],\'confirmed\')">Turn on</button>'
+ : '<button class="btn btn-primary btn-sm" onclick="setSignals([\'' + sig.code +
+ '\'],\'confirmed\')">Confirm</button>' +
+ '<button class="btn btn-secondary btn-sm" onclick="setSignals([\'' + sig.code +
+ '\'],\'rejected\')">Skip</button>';
+
+ return '<div class="sig-row ' + (sig.status === 'rejected' ? 'rejected' : '') + '">' +
+ '<div class="sig-main">' +
+ '<div class="sig-label">' + escHtml(sig.label || sig.code) +
+ '<span class="sig-code">' + escHtml(sig.code) + '</span></div>' +
+ '<div class="sig-desc">' + escHtml(sig.description) + '</div>' +
+ '<div class="sig-meta">' +
+ '<span class="cost-chip ' + costCls + '">' + escHtml(sig.cost_note || 'cost unknown') + '</span>' +
+ floor + seen + badge(sig.status) +
+ '</div>' +
+ '</div>' +
+ '<div class="sig-decide">' + decide + '</div>' +
+ '</div>';
+}
+
+async function setSignals(codes, status) {
+ const data = await api('/api/signals/status', {
+ method: 'POST',
+ headers: {'Content-Type': 'application/json'},
+ body: JSON.stringify({codes: codes, status: status}),
+ });
+ if (data && data.success) {
+ showToast(
+ status === 'confirmed'
+ ? 'Confirmed ' + data.changed + ' signal' + (data.changed === 1 ? '' : 's') +
+ ' — Harvey will collect ' + (data.changed === 1 ? 'it' : 'them') + ' from now on.'
+ : data.changed + ' signal' + (data.changed === 1 ? '' : 's') + ' turned off.',
+ 'success');
+ } else {
+ showToast('Could not update that signal.', 'error');
+ }
+ loadSignals();
+}
+
+// ── Cohort builder: a prospect list is a query ──
+
+let _cohort = { require: new Set(), exclude: new Set() };
+
+function renderCohortBuilder() {
+ const el = document.getElementById('cohort-builder');
+ if (!el || !_signals) return;
+
+ const confirmed = (_signals.groups || [])
+ .flatMap(g => g.signals)
+ .filter(s => s.status === 'confirmed');
+
+ if (!confirmed.length) {
+ el.innerHTML = '<p class="muted" style="font-size:13px">' +
+ 'Confirm some signals above and they become the building blocks here.</p>';
+ document.getElementById('cohort-result').innerHTML = '';
+ return;
+ }
+
+ const col = (title, key, hint) =>
+ '<div><div class="subhead" style="margin-top:0">' + title +
+ ' <span class="muted" style="font-weight:400;text-transform:none;letter-spacing:0">' +
+ hint + '</span></div><div class="cohort-grid">' +
+ confirmed.map(s =>
+ '<label class="cohort-pick"><input type="checkbox" ' +
+ (_cohort[key].has(s.code) ? 'checked ' : '') +
+ 'onchange="toggleCohort(\'' + key + '\',\'' + s.code + '\',this.checked)">' +
+ '<span>' + escHtml(s.label || s.code) + '</span>' +
+ '<span class="n">' + (s.companies || 0) + '</span></label>'
+ ).join('') + '</div></div>';
+
+ el.innerHTML = col('Must have', 'require', '&mdash; every company in the cohort carries all of these') +
+ '<div style="height:18px"></div>' +
+ col('Must not have', 'exclude', '&mdash; disqualifiers');
+}
+
+function toggleCohort(key, code, on) {
+ if (on) _cohort[key].add(code); else _cohort[key].delete(code);
+ // A company can't be both required and excluded on the same signal.
+ const other = key === 'require' ? 'exclude' : 'require';
+ if (on) _cohort[other].delete(code);
+ runCohort();
+ renderCohortBuilder();
+}
+
+async function runCohort() {
+ const el = document.getElementById('cohort-result');
+ if (!el) return;
+ const require = [..._cohort.require], exclude = [..._cohort.exclude];
+ if (!require.length) { el.innerHTML = ''; return; }
+
+ const data = await api('/api/cohort', {
+ method: 'POST',
+ headers: {'Content-Type': 'application/json'},
+ body: JSON.stringify({require: require, exclude: exclude}),
+ });
+ if (!data) { el.innerHTML = ''; return; }
+
+ let html = '<div style="border-top:1px solid var(--border);margin-top:20px;padding-top:20px">' +
+ '<div class="cohort-size">' + data.size + '</div>' +
+ '<div class="muted" style="font-size:13px;margin-top:2px">compan' +
+ (data.size === 1 ? 'y matches' : 'ies match') + ' this cohort right now</div>';
+
+ if (data.companies && data.companies.length) {
+ html += '<div class="table-card" style="margin-top:16px"><table><thead><tr>' +
+ '<th>Company</th><th>Domain</th><th>Industry</th><th>Location</th>' +
+ '</tr></thead><tbody>' +
+ data.companies.slice(0, 50).map(c =>
+ '<tr><td>' + escHtml(c.name) + '</td><td class="muted">' + escHtml(c.domain) + '</td>' +
+ '<td class="muted">' + escHtml(c.industry) + '</td>' +
+ '<td class="muted">' + escHtml(c.location) + '</td></tr>'
+ ).join('') + '</tbody></table></div>';
+ if (data.size > 50) {
+ html += '<p class="muted" style="font-size:12px;margin-top:10px">Showing the first 50.</p>';
+ }
+ } else if (data.size === 0) {
+ html += '<p class="muted" style="font-size:13px;margin-top:12px">' +
+ 'No company carries all of those yet. Either loosen the cohort, or run ' +
+ 'prospecting to collect more.</p>';
+ }
+ el.innerHTML = html + '</div>';
+}
+
+// ── Settings ──
+
+async function loadSettings() {
+ const data = await api('/api/settings');
+ if (!data) return;
+
+ // Active provider indicator
+ const prov = data.provider || 'instantly';
+ const provEl = document.getElementById('active-provider');
+ if (provEl) provEl.textContent = prov;
+
+ // Secret fields never echo a value — show a "saved" placeholder instead.
+ const savedPh = (id, isSet, base) => {
+ const el = document.getElementById(id);
+ if (!el) return;
+ el.value = '';
+ el.placeholder = isSet ? 'Saved — enter new value to change' : base;
+ };
+ const tag = (id, ok, okLabel) => {
+ const el = document.getElementById(id);
+ if (!el) return;
+ el.className = 'email-tag ' + (ok ? 'verified' : 'guess');
+ el.textContent = ok ? okLabel : 'not set';
+ };
+
+ // Non-secret values repopulate
+ document.getElementById('gmail-id').value = data.gmail_client_id || '';
+ document.getElementById('smtp-host').value = data.smtp_host || '';
+ document.getElementById('smtp-port').value = data.smtp_port || '';
+ document.getElementById('smtp-user').value = data.smtp_username || '';
+ document.getElementById('linkedin-email').value = data.linkedin_email || '';
+ document.getElementById('cf-account-id').value = data.cloudflare_account_id || '';
+
+ savedPh('gmail-secret', data.gmail_client_secret_set, 'Enter client secret');
+ savedPh('smtp-pass', data.smtp_password_set, 'Enter password / app password');
+ savedPh('instantly-key', data.instantly_api_key_set, 'Enter your Instantly API key');
+ savedPh('reoon-key', data.reoon_api_key_set, '600 free/mo — reoon.com/email-verifier');
+ savedPh('zerobounce-key', data.zerobounce_api_key_set, '100 free/mo — best for M365/Workspace catch-alls');
+ savedPh('hunter-key', data.hunter_api_key_set, '50 free/mo + email-pattern lookup');
+ savedPh('linkedin-password', data.linkedin_password_set, 'Enter password');
+ savedPh('cf-api-token', data.cloudflare_api_token_set, 'Your Cloudflare API Token');
+
+ // Gmail auth status chip
+ const g = document.getElementById('gmail-status');
+ if (g) {
+ if (data.gmail_authorized) { g.className = 'email-tag verified'; g.textContent = 'authorized'; }
+ else if (data.gmail_client_secret_set) { g.className = 'email-tag risky'; g.textContent = 'run: harvey gmail auth'; }
+ else { g.className = 'email-tag guess'; g.textContent = 'not set up'; }
+ }
+ tag('reoon-status', data.reoon_api_key_set, 'set');
+ tag('zerobounce-status', data.zerobounce_api_key_set, 'set');
+ tag('hunter-status', data.hunter_api_key_set, 'set');
+}
+
+function saveGmail() {
+ const payload = {GMAIL_CLIENT_ID: document.getElementById('gmail-id').value.trim()};
+ const sec = document.getElementById('gmail-secret').value;
+ if (sec) payload.GMAIL_CLIENT_SECRET = sec;
+ saveEnv(payload, 'Gmail OAuth saved. Now run "harvey gmail auth" in your terminal.').then(loadSettings);
+}
+
+function saveSmtp() {
+ const payload = {
+ SMTP_HOST: document.getElementById('smtp-host').value.trim(),
+ SMTP_PORT: document.getElementById('smtp-port').value.trim(),
+ SMTP_USERNAME: document.getElementById('smtp-user').value.trim(),
+ };
+ const pass = document.getElementById('smtp-pass').value;
+ if (pass) payload.SMTP_PASSWORD = pass;
+ saveEnv(payload, 'SMTP settings saved.').then(loadSettings);
+}
+
+function saveVerifiers() {
+ const payload = {};
+ const r = document.getElementById('reoon-key').value;
+ const z = document.getElementById('zerobounce-key').value;
+ const h = document.getElementById('hunter-key').value;
+ if (r) payload.REOON_API_KEY = r;
+ if (z) payload.ZEROBOUNCE_API_KEY = z;
+ if (h) payload.HUNTER_API_KEY = h;
+ if (!Object.keys(payload).length) { showToast('Enter at least one key first.', 'error'); return; }
+ saveEnv(payload, 'Verification keys saved.').then(loadSettings);
+}
+
+async function saveEnv(payload, okMsg) {
+ const data = await api('/api/settings/env', {
+ method: 'POST', headers: {'Content-Type': 'application/json'},
+ body: JSON.stringify(payload)
+ });
+ if (data && data.success) showToast(okMsg, 'success');
+ else showToast((data && data.message) || 'Save failed — is the dashboard still running?', 'error');
+}
+
+function saveInstantly() {
+ saveEnv({INSTANTLY_API_KEY: document.getElementById('instantly-key').value.trim()}, 'Instantly API key saved.');
+}
+
+function saveLinkedIn() {
+ const payload = {LINKEDIN_EMAIL: document.getElementById('linkedin-email').value.trim()};
+ const pass = document.getElementById('linkedin-password').value;
+ if (pass) payload.LINKEDIN_PASSWORD = pass;
+ saveEnv(payload, 'LinkedIn credentials saved.');
+}
+
+function saveCloudflare() {
+ saveEnv({
+ CLOUDFLARE_ACCOUNT_ID: document.getElementById('cf-account-id').value.trim(),
+ CLOUDFLARE_API_TOKEN: document.getElementById('cf-api-token').value.trim()
+ }, 'Cloudflare credentials saved.');
+}
+
+async function testInstantly() {
+ const key = document.getElementById('instantly-key').value.trim();
+ const el = document.getElementById('instantly-test-result');
+ el.innerHTML = '<div class="test-result pending">Testing&hellip;</div>';
+ const data = await api('/api/settings/test-instantly', {
+ method: 'POST', headers: {'Content-Type': 'application/json'},
+ body: JSON.stringify({api_key: key})
+ });
+ if (!data) {
+ el.innerHTML = '<div class="test-result error">Could not reach the dashboard server.</div>';
+ return;
+ }
+ el.innerHTML = '<div class="test-result ' + (data.success ? 'success' : 'error') + '">' + escHtml(data.message) + '</div>';
+}
+
+// ── Controls ──
+
+async function loadHarveyStatus() {
+ const data = await api('/api/harvey/status');
+ const headerDot = document.getElementById('header-dot');
+ const headerText = document.getElementById('header-status-text');
+
+ if (!data) {
+ headerDot.className = 'status-dot offline';
+ headerText.textContent = 'Offline';
+ return;
+ }
+ const running = !!data.running;
+
+ headerDot.className = 'status-dot ' + (running ? 'running' : 'stopped');
+ headerText.textContent = running ? 'Harvey is running' : 'Harvey is stopped';
+ document.getElementById('control-dot').className = 'dot ' + (running ? 'running' : 'stopped');
+ const label = document.getElementById('control-label');
+ label.className = 'label ' + (running ? 'running' : 'stopped');
+ label.textContent = running ? 'Running' : 'Stopped';
+
+ const meta = document.getElementById('control-meta');
+ if (running && data.pid) {
+ let info = 'PID ' + escHtml(String(data.pid));
+ if (data.started_at) info += ' &middot; started ' + formatDate(data.started_at);
+ meta.innerHTML = info;
+ } else {
+ meta.innerHTML = 'Harvey wakes every few minutes, does what needs doing, and sleeps.';
+ }
+
+ document.getElementById('btn-start').style.display = running ? 'none' : '';
+ document.getElementById('btn-stop').style.display = running ? '' : 'none';
+}
+
+async function startHarvey() {
+ const btn = document.getElementById('btn-start');
+ btn.disabled = true;
+ const data = await api('/api/harvey/start', {method: 'POST'});
+ if (data && data.success) showToast('Harvey started.', 'success');
+ else showToast((data && data.message) || 'Failed to start.', 'error');
+ btn.disabled = false;
+ loadHarveyStatus();
+}
+
+async function stopHarvey() {
+ const btn = document.getElementById('btn-stop');
+ btn.disabled = true;
+ const data = await api('/api/harvey/stop', {method: 'POST'});
+ if (data && data.success) showToast('Harvey stopped.', 'success');
+ else showToast((data && data.message) || 'Failed to stop.', 'error');
+ btn.disabled = false;
+ loadHarveyStatus();
+}
+
+async function loadLogs() {
+ const data = await api('/api/harvey/logs');
+ const el = document.getElementById('log-viewer');
+ if (data && data.lines && data.lines.length) {
+ const stick = el.scrollTop + el.clientHeight >= el.scrollHeight - 30;
+ el.textContent = data.lines.join('\n');
+ if (stick) el.scrollTop = el.scrollHeight;
+ } else {
+ el.textContent = 'No logs yet. Start Harvey to see activity.';
+ }
+}
+
+// ── Pipeline data ──
+
+async function loadStats() {
+ const grid = document.getElementById('stats-grid');
+ const data = await api('/api/stats');
+ if (!data) { grid.innerHTML = offlineState(); return; }
+ if (data.error) {
+ grid.innerHTML = emptyState('&#9670;', 'No pipeline data yet',
+ 'Start Harvey from the <b>Controls</b> tab and it will begin prospecting, writing, and sending on its own.');
+ return;
+ }
+ const p = data.prospects || {}, c = data.campaigns || {}, v = data.conversations || {};
+ const chips = (map) => {
+ const entries = Object.entries(map || {});
+ if (!entries.length) return '<span class="chip muted">none yet</span>';
+ return entries.map(([k, n]) =>
+ '<span class="chip">' + escHtml(k) + ' <b>' + escHtml(String(n)) + '</b></span>'
+ ).join('');
+ };
+ const card = (label, value, breakdown) =>
+ '<div class="stat-card"><div class="label">' + label + '</div>' +
+ '<div class="value">' + value + '</div>' +
+ '<div class="breakdown">' + breakdown + '</div></div>';
+
+ grid.innerHTML =
+ card('Prospects', p.total || 0, chips(p.by_status)) +
+ card('Campaigns', c.total || 0, chips(c.by_status)) +
+ card('Conversations', v.total || 0, chips(v.by_status)) +
+ card('Actions Logged', data.actions_total || 0,
+ '<span class="chip">Claude calls today <b>' + escHtml(String(data.claude_calls_today || 0)) + '</b></span>');
+}
+
+function fmtTokens(n) {
+ n = n || 0;
+ if (n >= 1e9) return (n / 1e9).toFixed(1) + 'B';
+ if (n >= 1e6) return (n / 1e6).toFixed(1) + 'M';
+ if (n >= 1e3) return (n / 1e3).toFixed(1) + 'k';
+ return String(n);
+}
+
+
+function emailTag(p) {
+ if (!p.email) return '';
+ // Fall back to the legacy boolean for rows predating email_status.
+ const status = p.email_status || (p.email_verified ? 'verified' : 'guess');
+ if (!STATUS[status]) return '';
+ const m = statusMeta(status);
+ return ' <span class="badge t-' + m.tone + '" style="margin-left:6px">' + escHtml(m.label) + '</span>';
+}
+
+async function loadUsage() {
+ const data = await api('/api/usage');
+ const statsEl = document.getElementById('usage-stats');
+ if (!data) { statsEl.innerHTML = offlineState(); return; }
+
+ // Quota gauges — the same numbers `/usage` shows in Claude Code.
+ const quotaEl = document.getElementById('usage-quota');
+ if (data.quota && Object.keys(data.quota).length) {
+ const labels = {five_hour: '5-hour window', seven_day: 'Weekly'};
+ let qHtml = '<h2>Claude Subscription Quota</h2>';
+ for (const [key, w] of Object.entries(data.quota)) {
+ const pct = Math.min(100, Math.max(0, w.utilization || 0));
+ const color = pct >= 80 ? 'yellow' : 'green';
+ const resets = w.resets_at ? 'resets ' + formatDate(w.resets_at) : '';
+ qHtml += '<div class="progress-wrap">' +
+ '<div class="progress-label">' +
+ '<span class="text">' + escHtml(labels[key] || key) + (resets ? ' &middot; ' + escHtml(resets) : '') + '</span>' +
+ '<span class="pct">' + pct.toFixed(0) + '%</span>' +
+ '</div>' +
+ '<div class="progress-bar"><div class="progress-fill ' + color + '" style="width:' + pct + '%"></div></div>' +
+ '</div>';
+ }
+ quotaEl.innerHTML = qHtml;
+ quotaEl.style.display = 'block';
+ } else {
+ quotaEl.style.display = 'none';
+ }
+
+ // Totals cards — usage-first (calls is the headline; tokens as chips).
+ // No dollars: on a subscription plan usage isn't billed per token.
+ const t = data.totals || {};
+ const card = (label, p) => {
+ p = p || {};
+ return '<div class="stat-card"><div class="label">' + label + '</div>' +
+ '<div class="value">' + (p.calls || 0) + '</div>' +
+ '<div class="breakdown">' +
+ '<span class="chip">calls</span>' +
+ '<span class="chip">out <b>' + fmtTokens(p.output_tokens) + '</b></span>' +
+ '<span class="chip">in <b>' + fmtTokens(p.input_tokens) + '</b></span>' +
+ '<span class="chip">cached <b>' + fmtTokens(p.cache_read_tokens) + '</b></span>' +
+ '</div></div>';
+ };
+ statsEl.innerHTML = card('Today', t.today) + card('Last 7 Days', t.week) + card('Last 30 Days', t.month);
+
+ // Daily bars — output tokens per day (the work done)
+ const dailyEl = document.getElementById('usage-daily');
+ const days = data.by_day || [];
+ if (days.length) {
+ const maxOut = Math.max(...days.map(d => d.output_tokens || 0), 1);
+ let dHtml = '<h2>Daily Output Tokens (30 days)</h2>';
+ for (const d of days.slice(-30)) {
+ const pct = Math.max(2, (d.output_tokens || 0) / maxOut * 100);
+ dHtml += '<div style="display:flex;align-items:center;gap:10px;margin-bottom:6px;font-size:12px">' +
+ '<span class="muted" style="width:78px;flex-shrink:0;font-family:var(--mono)">' + escHtml(d.day || '') + '</span>' +
+ '<div style="flex:1;background:rgba(255,255,255,0.05);border-radius:99px;height:10px;overflow:hidden">' +
+ '<div style="width:' + pct + '%;height:100%;border-radius:99px;background:linear-gradient(90deg,var(--accent-deep),var(--accent))"></div>' +
+ '</div>' +
+ '<span style="width:130px;text-align:right;font-variant-numeric:tabular-nums">' + fmtTokens(d.output_tokens) + ' out' +
+ ' <span class="muted">&middot; ' + (d.calls || 0) + ' calls</span></span>' +
+ '</div>';
+ }
+ dailyEl.innerHTML = dHtml;
+ dailyEl.style.display = 'block';
+ } else {
+ dailyEl.style.display = 'none';
+ }
+
+ // Breakdown tables — calls + tokens, no cost column
+ const tablesEl = document.getElementById('usage-tables');
+ const table = (title, rows, keyName) => {
+ if (!rows || !rows.length) return '';
+ let h = '<div class="card"><h2>' + title + '</h2><div class="table-card"><table><thead><tr>' +
+ '<th>' + keyName + '</th><th>Calls</th><th>Input</th><th>Output</th><th>Cache read</th>' +
+ '</tr></thead><tbody>';
+ for (const r of rows) {
+ h += '<tr><td>' + escHtml(String(r[keyName.toLowerCase()] || '')) + '</td>' +
+ '<td>' + (r.calls || 0) + '</td>' +
+ '<td class="muted">' + fmtTokens(r.input_tokens) + '</td>' +
+ '<td>' + fmtTokens(r.output_tokens) + '</td>' +
+ '<td class="muted">' + fmtTokens(r.cache_read_tokens) + '</td></tr>';
+ }
+ return h + '</tbody></table></div></div>';
+ };
+
+ const anyRows = (data.by_agent || []).length || (data.by_task || []).length;
+ if (!anyRows) {
+ tablesEl.innerHTML = emptyState('&#9680;', 'No usage recorded yet',
+ 'Once Harvey starts making Claude calls, every one is logged here with exact calls and tokens by agent and task. Run <b>harvey usage --reconcile</b> to backfill from Claude Code transcripts.');
+ } else {
+ tablesEl.innerHTML =
+ table('By Agent (30 days)', data.by_agent, 'Agent') +
+ table('By Task (30 days)', data.by_task, 'Task') +
+ table('By Model (30 days)', data.by_model, 'Model');
+ }
+}
+
+// ── Outbox: a decisions desk, not a wall of drafts ──
+//
+// Approving mail is a queue of one-at-a-time judgements. Showing all of them
+// stacked invites a single "approve all" reflex, which is exactly the review
+// the approval ladder exists to prevent. One email fills the pane; the rest
+// wait in the rail.
+
+async function loadOutbox() {
+ const data = await api('/api/outbox');
+ const banner = document.getElementById('outbox-banner');
+ const desk = document.getElementById('outbox-desk');
+ const list = document.getElementById('outbox-list');
+ const actions = document.getElementById('outbox-actions');
+ if (!data) { desk.innerHTML = offlineState(); list.innerHTML = ''; return; }
+
+ const pending = data.pending || [];
+ _desk.items = pending;
+ if (_desk.i >= pending.length) _desk.i = Math.max(0, pending.length - 1);
+ navCount('nav-outbox', pending.length);
+
+ actions.innerHTML =
+ (pending.length && !data.paused
+ ? '<button class="btn btn-primary btn-sm" onclick="outboxApproveAll()">Approve all ' +
+ pending.length + '</button>' : '') +
+ (data.paused
+ ? '<button class="btn btn-secondary btn-sm" onclick="sendingToggle(\'resume\')">' +
+ 'Resume sending</button>'
+ : '<button class="btn btn-secondary btn-sm" onclick="sendingToggle(\'pause\')">' +
+ 'Pause all sending</button>');
+
+ // The kill switch gets a banner only when it's actually on — a permanent
+ // bar for a thing that isn't happening is just noise.
+ banner.innerHTML = data.paused
+ ? '<div class="card" style="border-color:var(--red);margin-bottom:16px">' +
+ '<h2 style="color:var(--red)">&#9888; Sending is paused</h2>' +
+ '<p style="color:var(--text-2);font-size:13px">' + escHtml(data.paused) +
+ '. Approved mail stays queued until you resume.</p></div>'
+ : '';
+
+ desk.innerHTML = pending.length ? renderDesk(pending, _desk.i) :
+ '<div class="card">' + emptyState('&#10003;', 'Nothing to review',
+ 'Every draft Harvey writes lands here first. Approve one and it sends on schedule.') +
+ '</div>';
+
+ const table = (title, rows, cols) => {
+ if (!rows || !rows.length) return '';
+ let h = '<div class="card"><h2>' + title + '</h2><div class="table-card"><table><thead><tr>' +
+ cols.map(c => '<th>' + c[0] + '</th>').join('') + '</tr></thead><tbody>';
+ for (const r of rows) {
+ h += '<tr>' + cols.map(c => '<td' + (c[2] ? ' class="muted"' : '') + '>' +
+ (c[3] ? c[1](r) : escHtml(String(c[1](r) ?? ''))) + '</td>').join('') + '</tr>';
+ }
+ return h + '</tbody></table></div></div>';
+ };
+
+ list.innerHTML =
+ table('Approved &amp; scheduled', data.approved, [
+ ['To', r => r.to_email], ['Step', r => r.step], ['Subject', r => r.subject],
+ ['Sends', r => formatDate(r.send_at), true],
+ ]) +
+ table('Recently sent', data.sent, [
+ ['To', r => r.to_email], ['Step', r => r.step], ['Subject', r => r.subject],
+ ['Sent', r => formatDate(r.sent_at), true],
+ ]) +
+ table('Didn\'t send', data.failed, [
+ ['To', r => r.to_email], ['Status', r => badge(r.status), false, true],
+ ['Reason', r => r.error, true], ['Updated', r => formatDate(r.updated_at), true],
+ ]);
+}
+
+function renderDesk(items, i) {
+ const cur = items[i];
+ const rail = items.map((it, n) =>
+ '<div class="desk-item ' + (n === i ? 'active' : '') + '" onclick="deskGo(' + n + ')">' +
+ '<div class="to">' + escHtml(it.to_email) + '</div>' +
+ '<div class="sub">' + escHtml(it.subject || '(no subject)') + '</div>' +
+ '</div>').join('');
+
+ return '<div class="desk">' +
+ '<div class="desk-list">' + rail + '</div>' +
+ '<div class="desk-pane">' +
+ '<div class="to-line">To <b>' + escHtml(cur.to_email) + '</b> &middot; step ' +
+ cur.step + ' (' + escHtml(cur.kind) + ') &middot; sends ' +
+ formatDate(cur.send_at) + '</div>' +
+ '<div class="subject">' + escHtml(cur.subject || '(no subject)') + '</div>' +
+ '<div class="body">' + escHtml(cur.body) + '</div>' +
+ '<div class="desk-actions">' +
+ '<button class="btn btn-primary" onclick="outboxAct(\'' + cur.id + '\',\'approve\')">' +
+ 'Approve <kbd>A</kbd></button>' +
+ '<button class="btn btn-secondary" onclick="outboxAct(\'' + cur.id + '\',\'reject\')">' +
+ 'Reject <kbd>R</kbd></button>' +
+ '<span class="muted" style="font-size:12px;margin-left:auto">' +
+ (i + 1) + ' of ' + items.length + '</span>' +
+ '</div>' +
+ '</div></div>';
+}
+
+function deskGo(n) {
+ if (n < 0 || n >= _desk.items.length) return;
+ _desk.i = n;
+ document.getElementById('outbox-desk').innerHTML = renderDesk(_desk.items, n);
+}
+
+// Keyboard review. Ignored while typing into a field, so Settings still works.
+document.addEventListener('keydown', e => {
+ if (currentTab !== 'outbox' || e.metaKey || e.ctrlKey || e.altKey) return;
+ const tag = (e.target.tagName || '').toLowerCase();
+ if (tag === 'input' || tag === 'textarea' || e.target.isContentEditable) return;
+ const cur = _desk.items[_desk.i];
+ const k = e.key.toLowerCase();
+ if (k === 'j') { e.preventDefault(); deskGo(_desk.i + 1); }
+ else if (k === 'k') { e.preventDefault(); deskGo(_desk.i - 1); }
+ else if (k === 'a' && cur) { e.preventDefault(); outboxAct(cur.id, 'approve'); }
+ else if (k === 'r' && cur) { e.preventDefault(); outboxAct(cur.id, 'reject'); }
+});
+
+async function outboxAct(id, action) {
+ const data = await api('/api/outbox/' + encodeURIComponent(id) + '/' + action, {method: 'POST'});
+ if (data && data.success) showToast(action === 'approve' ? 'Approved — will send on schedule.' : 'Rejected.', 'success');
+ else showToast('Action failed.', 'error');
+ loadOutbox();
+}
+
+async function outboxApproveAll() {
+ const data = await api('/api/outbox/approve-all', {method: 'POST'});
+ if (data && data.success) showToast('Approved ' + data.approved + ' email(s).', 'success');
+ else showToast('Approve-all failed.', 'error');
+ loadOutbox();
+}
+
+async function sendingToggle(action) {
+ const data = await api('/api/sending/' + action, {method: 'POST'});
+ if (data && data.success) showToast(action === 'pause' ? 'Sending paused.' : 'Sending resumed.', 'success');
+ else showToast('Failed.', 'error');
+ loadOutbox();
+}
+
+async function loadCompanies() {
+ companyDrill = false;
+ const el = document.getElementById('companies-list');
+ const data = await api('/api/companies');
+ if (!data) { el.innerHTML = offlineState(); return; }
+ _companies = data;
+ if (!data.length) {
+ el.innerHTML = emptyState('&#9906;', 'No companies yet',
+ 'Harvey\'s Scout agent hasn\'t researched any companies. Finish <b>Setup</b>, then start Harvey from the <b>Controls</b> tab.');
+ return;
+ }
+ let html = '<div class="table-card"><table><thead><tr><th>Company</th><th>Domain</th><th>Industry</th><th>Size</th><th>Location</th><th>Contacts</th><th>Source</th><th>Added</th></tr></thead><tbody>';
+ data.forEach((c, i) => {
+ const website = c.website || (c.domain ? 'https://' + c.domain : '');
+ const nameLink = website
+ ? '<a href="' + escHtml(website) + '" target="_blank" rel="noopener" onclick="event.stopPropagation()">' + escHtml(c.name) + '</a>'
+ : escHtml(c.name);
+ html += '<tr style="cursor:pointer" onclick="showCompanyContacts(' + i + ')">' +
+ '<td>' + nameLink + '</td><td class="muted">' + escHtml(c.domain) + '</td><td>' + escHtml(c.industry) + '</td>' +
+ '<td>' + escHtml(c.company_size) + '</td><td>' + escHtml(c.location) + '</td>' +
+ '<td>' + (c.contact_count || 0) + '</td><td class="muted">' + escHtml(c.source) + '</td>' +
+ '<td class="muted">' + formatDate(c.created_at) + '</td></tr>';
+ });
+ el.innerHTML = html + '</tbody></table></div>';
+}
+
+async function showCompanyContacts(index) {
+ const company = _companies[index];
+ if (!company) return;
+ companyDrill = true;
+ const el = document.getElementById('companies-list');
+ const data = await api('/api/companies/' + encodeURIComponent(company.id) + '/contacts');
+ let html = '<div class="card"><h2>' + escHtml(company.name) + ' — Contacts</h2>' +
+ '<button class="btn btn-secondary btn-sm" onclick="loadCompanies()" style="margin-bottom:16px">&larr; Back to Companies</button>';
+ if (!data || !data.length) {
+ html += '<p style="color:var(--text-3);font-size:13px">No contacts found at this company yet.</p></div>';
+ } else {
+ html += '<div class="table-card"><table><thead><tr><th>Name</th><th>Title</th><th>Email</th><th>Phone</th><th>LinkedIn</th><th>Status</th><th>Source</th></tr></thead><tbody>';
+ for (const p of data) {
+ const emailIcon = emailTag(p);
+ const phoneIcon = p.phone_verified ? ' <span class="verified">&#10003;</span>' : '';
+ html += '<tr><td>' + escHtml(p.first_name) + ' ' + escHtml(p.last_name) + '</td>' +
+ '<td>' + escHtml(p.title) + '</td><td>' + escHtml(p.email) + emailIcon + '</td>' +
+ '<td>' + escHtml(p.phone) + phoneIcon + '</td>' +
+ '<td>' + (p.linkedin_url ? '<a href="' + escHtml(p.linkedin_url) + '" target="_blank" rel="noopener">Profile</a>' : '') + '</td>' +
+ '<td>' + badge(p.status) + '</td><td class="muted">' + escHtml(p.source) + '</td></tr>';
+ }
+ html += '</tbody></table></div></div>';
+ }
+ el.innerHTML = html;
+}
+
+async function submitFeedback(entityType, entityId, promptText) {
+ const comment = prompt(promptText || 'Add your feedback:');
+ if (!comment) return;
+ const data = await api('/api/feedback', {
+ method: 'POST', headers: {'Content-Type': 'application/json'},
+ body: JSON.stringify({entity_type: entityType, entity_id: entityId, comment: comment})
+ });
+ if (data && data.success) showToast('Feedback saved. Harvey will take it into account.', 'success');
+ else showToast((data && data.message) || 'Could not save feedback.', 'error');
+}
+
+function fbProspect(i) {
+ const p = _prospects[i];
+ if (p) submitFeedback('contact', p.id, 'Feedback on this contact:');
+}
+
+function fbCampaign(i) {
+ const c = _campaigns[i];
+ if (c) submitFeedback('campaign', c.id, 'Leave feedback on this campaign:');
+}
+
+async function loadProspects() {
+ const el = document.getElementById('prospects-table');
+ const data = await api('/api/prospects');
+ if (!data) { el.innerHTML = offlineState(); return; }
+ _prospects = data;
+ if (!data.length) {
+ el.innerHTML = emptyState('&#9673;', 'No contacts yet',
+ 'Harvey hasn\'t found any prospects. Once it\'s running, the Scout agent searches the web for people matching your ideal customer profile in <b>harvey.yaml</b>.');
+ return;
+ }
+ let html = '<div class="table-card"><table><thead><tr><th>Name</th><th>Title</th><th>Company</th><th>Email</th><th>Phone</th><th>Status</th><th>Source</th><th>Added</th><th></th></tr></thead><tbody>';
+ data.forEach((p, i) => {
+ const emailV = p.email ? (escHtml(p.email) + emailTag(p)) : '';
+ const phoneV = p.phone ? (escHtml(p.phone) + (p.phone_verified ? ' <span class="verified">&#10003;</span>' : '')) : '';
+ html += '<tr><td>' + escHtml(p.first_name) + ' ' + escHtml(p.last_name) + '</td>' +
+ '<td>' + escHtml(p.title) + '</td><td>' + escHtml(p.company) + '</td>' +
+ '<td>' + emailV + '</td><td>' + phoneV + '</td><td>' + badge(p.status) + '</td>' +
+ '<td class="muted">' + escHtml(p.source) + '</td><td class="muted">' + formatDate(p.created_at) + '</td>' +
+ '<td><button class="btn btn-secondary btn-sm" onclick="fbProspect(' + i + ')">Feedback</button></td></tr>';
+ });
+ el.innerHTML = html + '</tbody></table></div>';
+}
+
+async function loadCampaigns() {
+ const el = document.getElementById('campaigns-list');
+ const data = await api('/api/campaigns');
+ if (!data) { el.innerHTML = offlineState(); return; }
+ _campaigns = data;
+ if (!data.length) {
+ el.innerHTML = emptyState('&#9993;', 'No campaigns yet',
+ 'The Writer agent hasn\'t drafted any sequences. It kicks in automatically once Harvey has scored prospects to write for.');
+ return;
+ }
+ let html = '';
+ data.forEach((c, i) => {
+ let stepsHtml = '';
+ for (const step of (c.sequence || [])) {
+ stepsHtml += '<div class="email-step"><div class="step-num">Email ' + escHtml(String(step.step || '?')) +
+ (step.delay_days ? ' &middot; send after ' + escHtml(String(step.delay_days)) + ' days' : '') + '</div>' +
+ '<div class="subject">' + escHtml(step.subject) + '</div>' +
+ '<div class="body">' + escHtml(step.body) + '</div></div>';
+ }
+ const pc = (c.prospect_ids || []).length;
+ html += '<div class="campaign-card"><h3>' + escHtml(c.name || 'Untitled Campaign') + '</h3>' +
+ '<div class="meta">' + badge(c.status) + '<span>' + escHtml(c.channel || 'email') + '</span>' +
+ '<span>' + pc + ' prospect' + (pc !== 1 ? 's' : '') + '</span><span>' + formatDate(c.created_at) + '</span>' +
+ '<button class="btn btn-secondary btn-sm" onclick="fbCampaign(' + i + ')">Feedback</button></div>' +
+ (stepsHtml || '<p style="color:var(--text-3);font-size:13px">No email steps in this campaign.</p>') + '</div>';
+ });
+ el.innerHTML = html;
+}
+
+async function loadConversations() {
+ const el = document.getElementById('conversations-list');
+ const data = await api('/api/conversations');
+ if (!data) { el.innerHTML = offlineState(); return; }
+ if (!data.length) {
+ el.innerHTML = emptyState('&#9737;', 'No conversations yet',
+ 'No prospects have replied so far. When they do, the Handler agent classifies each reply and responds — every thread shows up here.');
+ return;
+ }
+ let html = '';
+ for (const c of data) {
+ let threadHtml = '';
+ for (const msg of (c.thread || [])) {
+ const cls = msg.sender === 'harvey' ? 'sent' : 'received';
+ threadHtml += '<div class="thread-msg ' + cls + '"><div class="sender">' + escHtml(msg.sender) +
+ ' &middot; ' + formatDate(msg.timestamp) + '</div>' + escHtml(msg.content) + '</div>';
+ }
+ const name = [c.first_name, c.last_name].filter(Boolean).join(' ') || 'Unknown';
+ html += '<div class="convo-card"><h3>' + escHtml(name) +
+ (c.company ? ' <span style="color:var(--text-3);font-weight:500">&mdash; ' + escHtml(c.company) + '</span>' : '') + '</h3>' +
+ '<div class="meta">' + badge(c.status) + (c.intent ? badge(c.intent) : '') +
+ '<span>' + escHtml(c.prospect_email || '') + '</span><span>' + formatDate(c.updated_at) + '</span></div>' +
+ (threadHtml || '<p style="color:var(--text-3);font-size:13px">No messages in this thread yet.</p>') + '</div>';
+ }
+ el.innerHTML = html;
+}
+
+async function loadActivity() {
+ const el = document.getElementById('activity-list');
+ const data = await api('/api/activity');
+ if (!data) { el.innerHTML = offlineState(); return; }
+ if (!data.length) {
+ el.innerHTML = emptyState('&#9202;', 'No activity yet',
+ 'Harvey hasn\'t taken any actions. Every prospect found, email written, and reply handled will appear here the moment it happens.');
+ return;
+ }
+ let html = '<div class="activity-feed">';
+ for (const a of data) {
+ html += '<div class="activity-item"><span class="time">' + formatDate(a.created_at) + '</span>' +
+ '<span class="agent">' + escHtml(a.agent) + '</span>' +
+ '<span class="action">' + escHtml(a.action_type) + '</span></div>';
+ }
+ el.innerHTML = html + '</div>';
+}
+
+// ── Init & live refresh ──
+
+loadToday();
+loadStats();
+loadSetupStatus();
+loadRuns();
+loadHarveyStatus();
+
+// Agent status: quick poll
+setInterval(loadHarveyStatus, 8000);
+
+// Nav counts stay live wherever you are, so "something needs me" is visible
+// from any tab without polling that tab's contents.
+setInterval(async () => {
+ if (document.hidden || currentTab === 'today') return;
+ const data = await api('/api/today');
+ if (!data) return;
+ navCount('nav-today', (data.items || []).filter(i => i.tone !== 'good').length);
+ navCount('nav-outbox', (data.stats || {}).outbox_pending || 0);
+}, 20000);
+
+// Data tabs: auto-refresh live views without clobbering anything in progress.
+// Outbox, settings and help are deliberately excluded — re-rendering the desk
+// under someone mid-decision loses their place, and settings may be mid-edit.
+setInterval(() => {
+ if (document.hidden) return;
+ switch (currentTab) {
+ case 'today': loadToday(); loadStats(); loadRuns(); break;
+ case 'companies': if (!companyDrill) loadCompanies(); break;
+ case 'prospects': loadProspects(); break;
+ case 'campaigns': loadCampaigns(); break;
+ case 'conversations': loadConversations(); break;
+ case 'activity': loadActivity(); break;
+ case 'usage': loadUsage(); break;
+ case 'controls': loadLogs(); break;
+ }
+}, 15000);
diff --git a/harvey/web/index.html b/harvey/web/index.html
new file mode 100644
index 0000000..dbef5af
--- /dev/null
+++ b/harvey/web/index.html
@@ -0,0 +1,355 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta charset="UTF-8">
+<meta name="viewport" content="width=device-width, initial-scale=1.0">
+<title>Harvey — Command Deck</title>
+<link rel="stylesheet" href="/static/app.css">
+</head>
+<body>
+
+<header>
+ <div class="brand">
+ <div class="mark">H</div>
+ <div>
+ <h1>Harvey</h1>
+ <div class="tagline">Always Be Closing</div>
+ </div>
+ </div>
+ <div class="header-controls">
+ <div class="harvey-status" id="header-status">
+ <span class="status-dot stopped" id="header-dot"></span>
+ <span id="header-status-text">Checking…</span>
+ </div>
+ <button class="refresh-btn" onclick="loadCurrentTab()">Refresh</button>
+ </div>
+</header>
+
+<nav>
+ <button class="active" onclick="showTab('today', this)">Today<span class="nav-count" id="nav-today"></span></button>
+ <button onclick="showTab('signals', this)">Signals<span class="nav-count" id="nav-signals"></span></button>
+ <button onclick="showTab('companies', this)">Companies</button>
+ <button onclick="showTab('prospects', this)">Contacts</button>
+ <button onclick="showTab('campaigns', this)">Campaigns</button>
+ <button onclick="showTab('outbox', this)">Outbox<span class="nav-count" id="nav-outbox"></span></button>
+ <button onclick="showTab('conversations', this)">Conversations</button>
+ <button onclick="showTab('activity', this)">Activity</button>
+ <button onclick="showTab('usage', this)">Usage</button>
+ <button onclick="showTab('settings', this)">Settings</button>
+ <button onclick="showTab('controls', this)">Controls</button>
+ <button onclick="showTab('help', this)">Help</button>
+</nav>
+
+<main>
+
+<!-- Today: what needs a human -->
+<div id="today" class="section active">
+ <div class="section-head">
+ <h2>Today</h2>
+ <p>Anything waiting on you, then everything Harvey has built so far.</p>
+ </div>
+ <div id="today-queue"></div>
+ <div id="today-setup"></div>
+ <div class="subhead">Pipeline</div>
+ <div class="stats-grid" id="stats-grid"></div>
+ <div id="today-runs"></div>
+</div>
+
+<!-- Signals: the confirmation gate -->
+<div id="signals" class="section">
+ <div class="section-head">
+ <h2>Signals</h2>
+ <p>Harvey proposes what it knows how to look for. You decide what actually
+ defines a good prospect &mdash; nothing is collected until you confirm it.</p>
+ </div>
+ <div id="signals-summary"></div>
+ <div id="signals-groups"></div>
+
+ <div class="subhead">Cohort builder</div>
+ <div class="card">
+ <p class="lede">A prospect list is a query, not a file. Pick the signals a
+ good prospect must have &mdash; and any that disqualify them &mdash; and see
+ how many companies match right now.</p>
+ <div id="cohort-builder"></div>
+ <div id="cohort-result"></div>
+ </div>
+</div>
+
+<!-- Companies -->
+<div id="companies" class="section">
+ <div class="section-head"><h2>Companies</h2><p>Organizations Harvey has researched. Click a row to see its contacts.</p></div>
+ <div id="companies-list"></div>
+</div>
+
+<!-- Contacts -->
+<div id="prospects" class="section">
+ <div class="section-head" style="display:flex;align-items:flex-end;justify-content:space-between;gap:16px">
+ <div><h2>Contacts</h2><p>People Harvey has found and verified.</p></div>
+ <div style="display:flex;gap:8px;flex-shrink:0">
+ <a class="btn btn-secondary btn-sm" href="/api/export/prospects.csv" download>Export deliverable CSV</a>
+ <a class="btn btn-secondary btn-sm" href="/api/export/prospects.csv?all=true" download>Export all</a>
+ </div>
+ </div>
+ <div id="prospects-table"></div>
+</div>
+
+<!-- Campaigns -->
+<div id="campaigns" class="section">
+ <div class="section-head"><h2>Campaigns</h2><p>Email sequences Harvey has written and deployed.</p></div>
+ <div id="campaigns-list"></div>
+</div>
+
+<!-- Outbox: the decisions desk -->
+<div id="outbox" class="section">
+ <div class="section-head" style="display:flex;align-items:flex-end;justify-content:space-between;gap:16px">
+ <div>
+ <h2>Outbox</h2>
+ <p>Every outgoing email stops here. Read one, decide, move on &mdash;
+ <kbd>A</kbd> approve, <kbd>R</kbd> reject, <kbd>J</kbd>/<kbd>K</kbd> to move.</p>
+ </div>
+ <div style="display:flex;gap:8px;flex-shrink:0" id="outbox-actions"></div>
+ </div>
+ <div id="outbox-banner"></div>
+ <div id="outbox-desk"></div>
+ <div id="outbox-list"></div>
+</div>
+
+<!-- Conversations -->
+<div id="conversations" class="section">
+ <div class="section-head"><h2>Conversations</h2><p>Every reply, and how Harvey handled it.</p></div>
+ <div id="conversations-list"></div>
+</div>
+
+<!-- Activity -->
+<div id="activity" class="section">
+ <div class="section-head"><h2>Activity</h2><p>A running log of every action Harvey's agents have taken.</p></div>
+ <div id="activity-list"></div>
+</div>
+
+<!-- Usage -->
+<div id="usage" class="section">
+ <div class="section-head"><h2>Usage</h2><p>Actual Claude usage — your subscription quota, calls, and tokens per agent and task. Subscription plans aren't billed per token, so no dollar costs here.</p></div>
+ <div id="usage-quota" class="card" style="display:none"></div>
+ <div class="stats-grid" id="usage-stats"></div>
+ <div class="card" id="usage-daily" style="display:none"></div>
+ <div id="usage-tables"></div>
+</div>
+
+<!-- Settings -->
+<div id="settings" class="section">
+ <div class="section-head"><h2>Settings</h2><p>Credentials are stored locally in <span style="font-family:var(--mono);font-size:12px">.env</span> — never sent anywhere except the services themselves.</p></div>
+ <div class="card">
+ <h2>Email Provider</h2>
+ <p class="lede">How Harvey sends and reads replies. Active provider: <b id="active-provider">…</b> — change it by setting <span style="font-family:var(--mono);font-size:12px">channels.email.provider</span> in <span style="font-family:var(--mono);font-size:12px">harvey.yaml</span> to <span style="font-family:var(--mono);font-size:12px">gmail</span>, <span style="font-family:var(--mono);font-size:12px">smtp</span>, or <span style="font-family:var(--mono);font-size:12px">instantly</span>.</p>
+
+ <div style="border:1px solid var(--border);border-radius:10px;padding:16px;margin-bottom:12px">
+ <div style="font-weight:650;margin-bottom:4px">Gmail / Google Workspace <span class="optional-tag">recommended</span> <span id="gmail-status" class="email-tag"></span></div>
+ <p class="lede" style="margin-top:4px">Use a mailbox on a dedicated secondary domain. Create an OAuth client (type "Desktop app") in Google Cloud Console → Gmail API, paste the id/secret, save, then run <span style="font-family:var(--mono);font-size:12px">harvey gmail auth</span> in your terminal.</p>
+ <div class="form-group"><label class="form-label" for="gmail-id">Client ID</label>
+ <input type="text" class="form-input" id="gmail-id" placeholder="xxxx.apps.googleusercontent.com" autocomplete="off"></div>
+ <div class="form-group"><label class="form-label" for="gmail-secret">Client Secret</label>
+ <div class="form-row"><div class="form-group" style="margin-bottom:0">
+ <input type="password" class="form-input" id="gmail-secret" placeholder="Enter client secret" autocomplete="off"></div>
+ <button class="btn btn-secondary btn-sm" onclick="toggleVisibility('gmail-secret')">Show</button></div></div>
+ <button class="btn btn-primary btn-sm" onclick="saveGmail()">Save Gmail</button>
+ </div>
+
+ <div style="border:1px solid var(--border);border-radius:10px;padding:16px;margin-bottom:12px">
+ <div style="font-weight:650;margin-bottom:4px">SMTP + IMAP mailbox</div>
+ <p class="lede" style="margin-top:4px">Any real mailbox (AgentMail, Fastmail, a Workspace app password). IMAP defaults to the SMTP host/login if left blank.</p>
+ <div class="form-row">
+ <div class="form-group"><label class="form-label" for="smtp-host">SMTP host</label>
+ <input type="text" class="form-input" id="smtp-host" placeholder="smtp.example.com" autocomplete="off"></div>
+ <div class="form-group" style="max-width:120px"><label class="form-label" for="smtp-port">Port</label>
+ <input type="text" class="form-input" id="smtp-port" placeholder="587" autocomplete="off"></div>
+ </div>
+ <div class="form-group"><label class="form-label" for="smtp-user">Username</label>
+ <input type="text" class="form-input" id="smtp-user" placeholder="[email protected]" autocomplete="off"></div>
+ <div class="form-group"><label class="form-label" for="smtp-pass">Password</label>
+ <div class="form-row"><div class="form-group" style="margin-bottom:0">
+ <input type="password" class="form-input" id="smtp-pass" placeholder="Enter password / app password" autocomplete="off"></div>
+ <button class="btn btn-secondary btn-sm" onclick="toggleVisibility('smtp-pass')">Show</button></div></div>
+ <button class="btn btn-primary btn-sm" onclick="saveSmtp()">Save SMTP</button>
+ </div>
+
+ <div style="border:1px solid var(--border);border-radius:10px;padding:16px">
+ <div style="font-weight:650;margin-bottom:4px">Instantly <span class="optional-tag">legacy</span></div>
+ <p class="lede" style="margin-top:4px">Get your API key from <a href="https://app.instantly.ai/app/settings/integrations" target="_blank" rel="noopener">Instantly Settings → Integrations</a> (Growth plan+ for API).</p>
+ <div class="form-group"><div class="form-row"><div class="form-group" style="margin-bottom:0">
+ <input type="password" class="form-input" id="instantly-key" placeholder="Enter your Instantly API key" autocomplete="off"></div>
+ <button class="btn btn-secondary btn-sm" onclick="toggleVisibility('instantly-key')">Show</button>
+ <button class="btn btn-secondary btn-sm" onclick="testInstantly()">Test</button></div>
+ <div id="instantly-test-result"></div></div>
+ <button class="btn btn-primary btn-sm" onclick="saveInstantly()">Save Instantly</button>
+ </div>
+ </div>
+
+ <div class="card">
+ <h2>Email Verification <span class="optional-tag">strongly recommended</span></h2>
+ <p class="lede">Add at least one so found emails get verified. Without any, addresses stay <span class="email-tag guess">guess</span> and are never sent. Reoon has the best free tier (600/mo).</p>
+ <div class="form-group"><label class="form-label" for="reoon-key">Reoon API key <span id="reoon-status" class="email-tag"></span></label>
+ <div class="form-row"><div class="form-group" style="margin-bottom:0">
+ <input type="password" class="form-input" id="reoon-key" placeholder="600 free/mo — reoon.com/email-verifier" autocomplete="off"></div>
+ <button class="btn btn-secondary btn-sm" onclick="toggleVisibility('reoon-key')">Show</button></div></div>
+ <div class="form-group"><label class="form-label" for="zerobounce-key">ZeroBounce API key <span id="zerobounce-status" class="email-tag"></span></label>
+ <input type="password" class="form-input" id="zerobounce-key" placeholder="100 free/mo — best for M365/Workspace catch-alls" autocomplete="off"></div>
+ <div class="form-group"><label class="form-label" for="hunter-key">Hunter API key <span id="hunter-status" class="email-tag"></span></label>
+ <input type="password" class="form-input" id="hunter-key" placeholder="50 free/mo + email-pattern lookup" autocomplete="off"></div>
+ <button class="btn btn-primary btn-sm" onclick="saveVerifiers()">Save verification keys</button>
+ </div>
+
+ <div class="card">
+ <h2>LinkedIn <span class="optional-tag">optional</span></h2>
+ <p class="lede">For automated LinkedIn prospecting. Harvey logs in and searches like a human.</p>
+ <div class="form-group">
+ <label class="form-label" for="linkedin-email">Email / Username</label>
+ <input type="text" class="form-input" id="linkedin-email" placeholder="[email protected]" autocomplete="off">
+ </div>
+ <div class="form-group">
+ <label class="form-label" for="linkedin-password">Password</label>
+ <input type="password" class="form-input" id="linkedin-password" placeholder="Enter password" autocomplete="new-password">
+ </div>
+ <button class="btn btn-primary" onclick="saveLinkedIn()">Save</button>
+ </div>
+
+ <div class="card">
+ <h2>Cloudflare <span class="optional-tag">optional</span></h2>
+ <p class="lede">For deep website crawling with JavaScript rendering during product training. ~$5/month.</p>
+ <div class="form-group">
+ <label class="form-label" for="cf-account-id">Account ID</label>
+ <input type="text" class="form-input" id="cf-account-id" placeholder="Your Cloudflare Account ID" autocomplete="off">
+ </div>
+ <div class="form-group">
+ <label class="form-label" for="cf-api-token">API Token</label>
+ <input type="password" class="form-input" id="cf-api-token" placeholder="Your Cloudflare API Token" autocomplete="off">
+ </div>
+ <button class="btn btn-primary" onclick="saveCloudflare()">Save</button>
+ </div>
+</div>
+
+<!-- Controls -->
+<div id="controls" class="section">
+ <div class="section-head"><h2>Controls</h2><p>Start and stop Harvey's heartbeat loop, and watch what it's doing.</p></div>
+ <div class="control-panel">
+ <div class="card">
+ <h2>Agent</h2>
+ <div class="status-big" id="control-status">
+ <div class="dot stopped" id="control-dot"></div>
+ <span class="label stopped" id="control-label">Stopped</span>
+ </div>
+ <div class="status-meta" id="control-meta"></div>
+ <div class="btn-group">
+ <button class="btn btn-primary" id="btn-start" onclick="startHarvey()">Start Harvey</button>
+ <button class="btn btn-danger" id="btn-stop" onclick="stopHarvey()" style="display:none">Stop Harvey</button>
+ </div>
+ </div>
+ <div class="card">
+ <h2>Recent Logs</h2>
+ <div class="log-viewer" id="log-viewer">No logs yet. Start Harvey to see activity.</div>
+ <div class="btn-group">
+ <button class="btn btn-secondary btn-sm" onclick="loadLogs()">Refresh Logs</button>
+ </div>
+ </div>
+ </div>
+</div>
+
+<!-- Help -->
+<div id="help" class="section">
+ <div class="section-head"><h2>Help</h2><p>What Harvey is, how it works, and how to fix the usual problems.</p></div>
+
+ <div class="help-section">
+ <h2>What is Harvey?</h2>
+ <p>Harvey is an autonomous AI sales agent. Once set up, Harvey runs on its own: finds people who match your ideal customer, writes personalized cold emails, sends them through your email platform, reads every reply, handles objections, and works toward booking a meeting. You review everything through this dashboard.</p>
+ <p>Harvey runs on your Claude Max subscription, so there are no extra AI costs. Everything stays on your machine in one folder.</p>
+ </div>
+
+ <div class="help-section">
+ <h2>Getting Started</h2>
+ <p>There are three things to do:</p>
+ <pre>1. Go to the Settings tab and enter your Instantly API key
+2. Train Harvey on your product (through Claude or the command line)
+3. Go to the Controls tab and click Start</pre>
+ <p>The Setup tab shows you exactly what's done and what still needs to happen.</p>
+ </div>
+
+ <div class="help-section">
+ <h2>Where Everything Lives</h2>
+ <p>Everything Harvey needs is inside this one project folder. Nothing is stored elsewhere.</p>
+ <div class="table-card" style="padding:6px 4px">
+ <table class="file-table">
+ <tr><td>.env</td><td>Your API keys and credentials (never shared or committed)</td></tr>
+ <tr><td>harvey.yaml</td><td>Your product info, target customers, and behavior settings</td></tr>
+ <tr><td>skills/</td><td>Sales knowledge files. Edit these to change how Harvey writes and sells.</td></tr>
+ <tr><td>skills/product_knowledge.md</td><td>Everything Harvey knows about your product (auto-generated from training)</td></tr>
+ <tr><td>prompts/</td><td>Prompt templates for each agent. Advanced customization.</td></tr>
+ <tr><td>data/harvey.db</td><td>Database with all prospects, campaigns, and conversations</td></tr>
+ <tr><td>data/harvey.log</td><td>Log file showing what Harvey is doing</td></tr>
+ </table>
+ </div>
+ </div>
+
+ <div class="help-section">
+ <h2>Getting Your API Keys</h2>
+
+ <details>
+ <summary>Instantly API Key (required)</summary>
+ <div class="faq-body">
+ <p>Instantly is the email platform Harvey uses to send campaigns.</p>
+ <p>1. Sign up at <a href="https://instantly.ai" target="_blank" rel="noopener">instantly.ai</a> (you need the Growth plan for API access)</p>
+ <p>2. Go to Settings &gt; Integrations</p>
+ <p>3. Copy your API key</p>
+ <p>4. Paste it in the Settings tab here</p>
+ </div>
+ </details>
+
+ <details>
+ <summary>LinkedIn Credentials (optional)</summary>
+ <div class="faq-body">
+ <p>If you want Harvey to find prospects on LinkedIn, enter your LinkedIn email and password. Harvey uses a real browser to search LinkedIn like a human would, with random delays and rate limits to avoid detection.</p>
+ <p>If you skip this, Harvey will find prospects through Google searches and company website scraping instead.</p>
+ </div>
+ </details>
+
+ <details>
+ <summary>Cloudflare Browser Rendering (optional)</summary>
+ <div class="faq-body">
+ <p>This is only used during product training (when Harvey crawls your website to learn about your product). It handles JavaScript-heavy websites that a basic crawler can't read.</p>
+ <p>1. Sign up at <a href="https://dash.cloudflare.com" target="_blank" rel="noopener">Cloudflare</a> (paid Workers plan, ~$5/month)</p>
+ <p>2. Go to Workers &amp; Pages &gt; Browser Rendering</p>
+ <p>3. Create an API token with Browser Rendering Edit permissions</p>
+ <p>4. Enter your Account ID and API Token in the Settings tab</p>
+ <p>Without this, Harvey uses a built-in crawler that works fine for most websites but can't render JavaScript.</p>
+ </div>
+ </details>
+ </div>
+
+ <div class="help-section">
+ <h2>Common Issues</h2>
+
+ <details>
+ <summary>"command not found: harvey"</summary>
+ <div class="faq-body">You need to activate the virtual environment first: <code>source .venv/bin/activate</code></div>
+ </details>
+
+ <details>
+ <summary>Instantly API returns 401</summary>
+ <div class="faq-body">Your API key is wrong, or you need the Growth plan (the free plan doesn't include API access). Double-check the key in Settings &gt; Integrations in your Instantly dashboard.</div>
+ </details>
+
+ <details>
+ <summary>Claude headless mode fails</summary>
+ <div class="faq-body">Make sure you've run <code>claude login</code> in your terminal and have an active Claude Max subscription. Harvey uses your existing subscription, not a separate API key.</div>
+ </details>
+
+ <details>
+ <summary>Harvey isn't finding prospects</summary>
+ <div class="faq-body">Check that your ICP (ideal customer profile) in harvey.yaml has realistic titles, industries, and geography. If LinkedIn is set up, check that the credentials are correct. Check the Activity tab to see what Harvey has been trying to do.</div>
+ </details>
+ </div>
+</div>
+
+</main>
+
+<script src="/static/app.js"></script>
+</body>
+</html>
diff --git a/pyproject.toml b/pyproject.toml
index f04e054..4d91c79 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -49,3 +49,7 @@ harvey = "harvey.cli:main"
[tool.setuptools.packages.find]
include = ["harvey*"]
+
+# The dashboard's HTML/CSS/JS are real files, served from disk.
+[tool.setuptools.package-data]
+harvey = ["web/*"]
diff --git a/tests/test_dashboard_signals.py b/tests/test_dashboard_signals.py
new file mode 100644
index 0000000..9785bd8
--- /dev/null
+++ b/tests/test_dashboard_signals.py
@@ -0,0 +1,229 @@
+"""Dashboard API for the signal-confirmation gate, cohorts, and Today.
+
+These cover the contract the UI depends on: Harvey proposes signals, nothing
+is collected until a human confirms, and a confirmed set becomes a cohort
+query rather than a static list.
+"""
+
+import tempfile
+from pathlib import Path
+
+import pytest
+from fastapi.testclient import TestClient
+
+import harvey.dashboard as dash
+from harvey.signals import SIGNAL_CATALOG
+from harvey.state import StateManager
+
+
+def client(monkeypatch):
+ """A dashboard bound to a throwaway database."""
+ with tempfile.TemporaryDirectory() as tmp:
+ db = Path(tmp) / "harvey.db"
+ monkeypatch.setattr(dash, "DB_PATH", db)
+ monkeypatch.setattr(dash, "WEB_DIR", Path(__file__).resolve().parent.parent / "harvey" / "web")
+ with TestClient(dash.app) as c:
+ c.db_path = db
+ yield c
+
+
+# ── The confirmation gate ──
+
+
+def test_signals_seed_as_proposed_not_confirmed(client):
+ """Harvey proposes. Nothing is live until a human says so."""
+ data = client.get("/api/signals").json()
+ assert data["total"] == len(SIGNAL_CATALOG)
+ assert data["summary"]["proposed"] == len(SIGNAL_CATALOG)
+ assert data["summary"]["confirmed"] == 0
+
+
+def test_signals_grouped_with_plain_language(client):
+ data = client.get("/api/signals").json()
+ keys = [g["key"] for g in data["groups"]]
+ assert keys == ["discovery", "profile", "people", "verification"]
+ for group in data["groups"]:
+ assert group["blurb"] # every category explains itself
+ for sig in group["signals"]:
+ assert sig["description"] and sig["cost_note"]
+
+
+def test_confirm_and_reject_signals(client):
+ r = client.post("/api/signals/status",
+ json={"codes": ["INCUMBENT_AGENCY", "RUNNING_GOOGLE_ADS"],
+ "status": "confirmed"})
+ assert r.json()["changed"] == 2 and r.json()["unknown"] == []
+
+ r = client.post("/api/signals/status",
+ json={"code": "BLOCKS_AI_CRAWLERS", "status": "rejected"})
+ assert r.json()["changed"] == 1
+
+ summary = client.get("/api/signals").json()["summary"]
+ assert summary["confirmed"] == 2
+ assert summary["rejected"] == 1
+
+
+def test_reseeding_never_overrides_a_users_decision(client):
+ """Every /api/signals load re-seeds so upgrades add new signals. It must
+ not quietly re-enable something the user turned off."""
+ client.post("/api/signals/status",
+ json={"code": "RUNNING_META_ADS", "status": "rejected"})
+ client.get("/api/signals") # re-seeds
+ data = client.get("/api/signals").json()
+ meta = next(s for g in data["groups"] for s in g["signals"]
+ if s["code"] == "RUNNING_META_ADS")
+ assert meta["status"] == "rejected"
+
+
+def test_confirming_before_the_catalog_loads_still_works(client):
+ """A confirm can arrive before anything has read /api/signals. It must
+ seed the vocabulary rather than silently changing nothing."""
+ r = client.post("/api/signals/status",
+ json={"codes": ["SERP_RANK"], "status": "confirmed"}).json()
+ assert r["changed"] == 1
+
+
+def test_unknown_codes_are_reported_not_swallowed(client):
+ r = client.post("/api/signals/status",
+ json={"codes": ["SERP_RANK", "NOT_A_SIGNAL"],
+ "status": "confirmed"}).json()
+ assert r["changed"] == 1
+ assert r["unknown"] == ["NOT_A_SIGNAL"]
+
+
+def test_invalid_status_is_rejected(client):
+ r = client.post("/api/signals/status", json={"codes": ["SERP_RANK"], "status": "on"})
+ assert r.status_code == 400
+ r = client.post("/api/signals/status", json={"codes": [], "status": "confirmed"})
+ assert r.status_code == 400
+
+
+# ── Cohorts ──
+
+
+async def _seed_observations(db_path):
+ state = StateManager(str(db_path))
+ await state.init_db()
+ from harvey.signals import seed_signal_catalog
+ await seed_signal_catalog(state)
+ from harvey.models import Company
+
+ ids = []
+ for n, name in enumerate(["Alpha Roofing", "Beta Roofing", "Gamma Roofing"]):
+ ids.append(await state.add_company(
+ Company(name=name, domain=f"{name.split()[0].lower()}.com")))
+ # Alpha: agency + ads. Beta: agency only. Gamma: ads + booking already.
+ await state.add_observations([
+ {"company_id": ids[0], "signal_code": "INCUMBENT_AGENCY", "value_text": "Studio3"},
+ {"company_id": ids[0], "signal_code": "RUNNING_GOOGLE_ADS", "value_num": 1},
+ {"company_id": ids[1], "signal_code": "INCUMBENT_AGENCY", "value_text": "Etna"},
+ {"company_id": ids[2], "signal_code": "RUNNING_GOOGLE_ADS", "value_num": 1},
+ {"company_id": ids[2], "signal_code": "NO_ONLINE_BOOKING", "value_num": 1},
+ ])
+ return ids
+
+
+def test_cohort_is_a_set_intersection(client):
+ import asyncio
+ asyncio.run(_seed_observations(client.db_path))
+
+ both = client.post("/api/cohort", json={
+ "require": ["INCUMBENT_AGENCY", "RUNNING_GOOGLE_ADS"]}).json()
+ assert both["size"] == 1
+ assert both["companies"][0]["name"] == "Alpha Roofing"
+
+ one = client.post("/api/cohort", json={"require": ["RUNNING_GOOGLE_ADS"]}).json()
+ assert one["size"] == 2
+
+ excluded = client.post("/api/cohort", json={
+ "require": ["RUNNING_GOOGLE_ADS"], "exclude": ["NO_ONLINE_BOOKING"]}).json()
+ assert excluded["size"] == 1
+ assert excluded["companies"][0]["name"] == "Alpha Roofing"
+
+
+def test_cohort_with_no_requirements_is_empty_not_everything(client):
+ """An empty cohort must never mean 'select all' — that would silently
+ turn a mis-click into a campaign against the entire database."""
+ assert client.post("/api/cohort", json={"require": []}).json()["size"] == 0
+
+
+def test_signal_counts_surface_in_the_review_ui(client):
+ import asyncio
+ asyncio.run(_seed_observations(client.db_path))
+ data = client.get("/api/signals").json()
+ agency = next(s for g in data["groups"] for s in g["signals"]
+ if s["code"] == "INCUMBENT_AGENCY")
+ assert agency["companies"] == 2
+
+
+# ── Today ──
+
+
+def test_today_leads_with_unconfirmed_signals(client):
+ data = client.get("/api/today").json()
+ keys = [i["key"] for i in data["items"]]
+ assert "signals" in keys
+ item = next(i for i in data["items"] if i["key"] == "signals")
+ assert item["tab"] == "signals"
+ assert "19" in item["title"]
+
+
+def test_today_flags_a_fully_rejected_vocabulary(client):
+ codes = [s["code"] for s in SIGNAL_CATALOG]
+ client.post("/api/signals/status", json={"codes": codes, "status": "rejected"})
+ data = client.get("/api/today").json()
+ keys = [i["key"] for i in data["items"]]
+ assert "signals-none" in keys
+
+
+def test_today_stats_are_present_even_on_an_empty_install(client):
+ stats = client.get("/api/today").json()["stats"]
+ for key in ("companies", "prospects", "signals_confirmed",
+ "outbox_pending", "open_conversations"):
+ assert key in stats
+
+
+# ── Static assets ──
+
+
+def test_dashboard_serves_its_files(client):
+ assert client.get("/").status_code == 200
+ assert "app.css" in client.get("/").text
+ assert client.get("/static/app.css").status_code == 200
+ assert client.get("/static/app.js").status_code == 200
+
+
+def test_static_route_refuses_to_escape_the_web_directory(client):
+ assert client.get("/static/..%2f..%2fharvey.yaml").status_code == 404
+ assert client.get("/static/nope.css").status_code == 404
+
+
+# ── Catalog invariants the UI and CLI both rely on ──
+
+
+def test_cost_notes_are_machine_classifiable():
+ """`harvey signals --confirm free` and the dashboard's green/amber cost
+ chip both key off the cost note. A signal that costs credits must not
+ read as free — that is how someone accidentally turns on paid collection.
+ """
+ paid = {"SERP_RANK", "EMAIL_STATUS", "EMAIL_PATTERN", "FOUND_IN_SERP"}
+ for sig in SIGNAL_CATALOG:
+ free = sig["cost_note"].lower().startswith(("free", "included"))
+ if sig["code"] in paid:
+ continue
+ assert free, f"{sig['code']} has an unclassifiable cost note: {sig['cost_note']!r}"
+
+ serp = next(s for s in SIGNAL_CATALOG if s["code"] == "SERP_RANK")
+ assert not serp["cost_note"].lower().startswith("free")
+ email = next(s for s in SIGNAL_CATALOG if s["code"] == "EMAIL_STATUS")
+ assert not email["cost_note"].lower().startswith("free")
+
+
+def test_every_signal_has_a_category_the_ui_renders():
+ from harvey.dashboard import CATEGORY_ORDER
+ for sig in SIGNAL_CATALOG:
+ assert sig["category"] in CATEGORY_ORDER, (
+ f"{sig['code']} is in category {sig['category']!r}, which the "
+ "dashboard would silently drop")