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.
Merge branch 'pr40' into fix/pr40-gmail-compose-live-status
Ethanea44cd13371d
diff --cc harvey/dashboard.pyindex 7612aac,51398ca..7ddee94--- a/harvey/dashboard.py+++ b/harvey/dashboard.py@@@ -882,60 -800,40 +882,92 @@@ async def outbox_approve(item_id: str)return {"success": bool(n)}except Exception as e:return JSONResponse({"success": False, "message": str(e)}, status_code=500)++[email protected]("/api/outbox/{item_id}/edit")+async def outbox_edit(item_id: str, request: Request):+ """Rewrite a draft awaiting review. Never approves it."""+ try:+ body = await request.json()+ except Exception:+ body = {}+ if not isinstance(body, dict):+ body = {}+ subject = str(body.get("subject") or "").strip()+ text = str(body.get("body") or "").strip()+ try:+ state = _state()+ await state.init_db()+ item = await state.get_outbox_item(item_id)+ if not item or item.get("status") != "pending_review":+ return JSONResponse({"success": False,+ "message": "Only drafts awaiting review can be edited."},+ status_code=409)+ if item.get("kind") == "reply":+ # Gmail threads a reply by its subject: a new one would land as a+ # fresh, unthreaded email to someone who wrote in. Only the body+ # of a reply is editable; its stored subject is kept exactly.+ subject = item.get("subject") or ""+ if not subject.strip() or not text:+ return JSONResponse({"success": False,+ "message": "Subject and body are both required."},+ status_code=400)+ # The sender re-checks every email before it goes out; an edit it+ # would block is refused now, while the reviewer can still fix it,+ # instead of failing quietly at send time. Content rules only: the+ # recipient isn't something an edit can change.+ from harvey.gate import pre_send_check+ gate = pre_send_check("[email protected]", subject, text)+ if not gate:+ return JSONResponse({"success": False,+ "message": "The sender would have blocked this: "+ + "; ".join(gate.reasons)},+ status_code=400)+ if not await state.edit_outbox_draft(item_id, subject, text):+ return JSONResponse({"success": False,+ "message": "Only drafts awaiting review can be edited."},+ status_code=409)+ await state.log_action("outbox_edited", "dashboard", {+ "outbox_id": item_id, "to_email": item.get("to_email", ""),+ "old_subject": item.get("subject", ""), "old_body": item.get("body", ""),+ })+ return {"success": True}+ except Exception as e:+ return JSONResponse({"success": False, "message": str(e)}, status_code=500)+ @app.post("/api/prospects/{prospect_id}/sent")+ async def mark_prospect_sent(prospect_id: str, request: Request):+ """The user sent this email by hand (e.g. from Gmail): record it, or undo it."""+ try:+ try:+ body = await request.json()+ except ValueError:+ body = {}+ sent = bool((body or {}).get("sent", True))+ rows = await query_db("SELECT status FROM prospects WHERE id = ?", (prospect_id,))+ if not rows:+ return JSONResponse({"success": False, "message": "unknown prospect"},+ status_code=404)+ current = rows[0].get("status") or "new"+ # Only toggle between "not sent" and "sent". A prospect who already+ # replied, booked or closed keeps that status — unticking a box must+ # never erase a reply.+ if current not in ("new", "queued", "contacted"):+ return {"success": True, "sent": True, "status": current}+ state = _state()+ await state.init_db()+ await state.update_prospect_status(prospect_id, "contacted" if sent else "new")+ await state.log_action(+ action_type="manual_send" if sent else "manual_send_undone",+ agent="user",+ details={"prospect_id": prospect_id},+ )+ return {"success": True, "sent": sent}+ except Exception as e:+ return JSONResponse({"success": False, "message": str(e)}, status_code=500)++@app.post("/api/outbox/{item_id}/reject")async def outbox_reject(item_id: str):try: