system-prompts-and-models-o.../salesflow-saas/backend/app/api/v1/router.py
Claude c398bd31ce
feat(dealix): Full OS orchestrator — unified deal lifecycle automation
The missing brain that connects ALL existing services into one system:

1. full_os_orchestrator.py — Deal lifecycle state machine:
   12 stages: new_lead → qualifying → qualified → nurturing →
   meeting_booked → meeting_done → proposal_sent → negotiating →
   payment_requested → pilot_active → closed_won/lost/opted_out.

   Each stage has: auto-transitions based on intent, auto-actions
   (send_whatsapp, book_meeting, sync_crm, etc.), Arabic response
   templates, qualification questions.

2. full_os.py API — 4 endpoints:
   - POST /os/process — classify event + determine next stage + actions
   - POST /os/process-and-act — same + auto-execute (WhatsApp send
     via Ultramsg if safe, or create draft if human approval needed)
   - POST /os/bulk-process — batch event processing
   - GET /os/stages — list all stages with transitions

3. How it works:
   Inbound WhatsApp → /os/process-and-act →
   classify intent → transition stage →
   if auto_send_allowed: send WhatsApp response immediately
   if human_approval_required: create draft for Sami to review
   Always: log activity + suggest next actions

4. Safety:
   - Negotiation/payment/pilot stages = human_approval_required
   - Opt-out = immediate stop, no further contact
   - All sends via existing Ultramsg (rate limited, logged)
   - Draft queue for anything needing review

Connects to existing infrastructure:
- outreach_engine._send_via_ultramsg() for WhatsApp
- OutreachDraft model for draft queue
- Reply classifier for intent detection

https://claude.ai/code/session_01W1rJthWDkasijTdXCfxVHs
2026-04-25 18:04:12 +00:00

155 lines
8.5 KiB
Python

from fastapi import APIRouter
from app.api.v1 import (
auth, leads, deals, dashboard, tenants, users, affiliates, ai_agents,
companies, contacts, calls, meetings, commissions, payouts, disputes,
guarantees, consents, complaints, knowledge, sectors, presentations,
supervisor, admin, health, analytics, webhooks, prospecting,
inbox, sequences,
)
from app.api.v1 import compliance as compliance_router
from app.api.v1 import agents as agents_router
from app.api.v1 import intelligence as intelligence_router
from app.api.v1 import master as master_router
from app.api.v1 import revenue_room as revenue_room_router
from app.api.v1 import outreach_engine as outreach_router
from app.api.v1 import lead_prospector as prospector_router
from app.api.v1 import pipeline as pipeline_router
from app.api.v1 import agent_system as agent_system_router
from app.api.v1 import autonomous_foundation as autonomous_foundation_router
from app.api.v1 import hermes as hermes_router
from app.api.v1 import strategic_deals as strategic_deals_router
from app.api.v1 import marketing_hub as marketing_hub_router
from app.api.v1 import strategy_summary as strategy_summary_router
from app.api.v1 import value_proposition as value_proposition_router
from app.api.v1 import customer_onboarding as customer_onboarding_router
from app.api.v1 import sales_os as sales_os_router
from app.api.v1 import operations as operations_router
from app.api.v1 import proposals as proposals_router
from app.api.v1 import contradiction as contradiction_router
from app.api.v1 import evidence_packs as evidence_packs_router
from app.api.v1 import executive_room as executive_room_router
from app.api.v1 import connector_governance as connector_governance_router
from app.api.v1 import model_routing as model_routing_router
from app.api.v1 import saudi_compliance as saudi_compliance_router
from app.api.v1 import forecast_control as forecast_control_router
from app.api.v1 import approval_center as approval_center_router
api_router = APIRouter()
api_router.include_router(auth.router, prefix="/auth", tags=["Authentication"])
api_router.include_router(tenants.router, prefix="/tenant", tags=["Tenant"])
api_router.include_router(users.router, prefix="/users", tags=["Users"])
api_router.include_router(leads.router, prefix="/leads", tags=["Leads"])
api_router.include_router(deals.router, prefix="/deals", tags=["Deals"])
api_router.include_router(dashboard.router, prefix="/dashboard", tags=["Dashboard"])
api_router.include_router(affiliates.router)
api_router.include_router(ai_agents.router)
api_router.include_router(companies.router, prefix="/companies", tags=["Companies"])
api_router.include_router(contacts.router, prefix="/contacts", tags=["Contacts"])
api_router.include_router(calls.router, prefix="/calls", tags=["Calls"])
api_router.include_router(meetings.router, prefix="/meetings", tags=["Meetings"])
api_router.include_router(commissions.router, prefix="/commissions", tags=["Commissions"])
api_router.include_router(payouts.router, prefix="/payouts", tags=["Payouts"])
api_router.include_router(disputes.router, prefix="/disputes", tags=["Disputes"])
api_router.include_router(guarantees.router, prefix="/guarantees", tags=["Guarantees"])
api_router.include_router(consents.router, prefix="/consents", tags=["Consents"])
api_router.include_router(complaints.router, prefix="/complaints", tags=["Complaints"])
api_router.include_router(knowledge.router, prefix="/knowledge", tags=["Knowledge"])
api_router.include_router(sectors.router, prefix="/sectors", tags=["Sectors"])
api_router.include_router(presentations.router, prefix="/presentations", tags=["Presentations"])
api_router.include_router(supervisor.router, prefix="/supervisor", tags=["Supervisor"])
api_router.include_router(admin.router, prefix="/admin", tags=["Admin"])
api_router.include_router(health.router, tags=["Health"])
api_router.include_router(marketing_hub_router.router)
api_router.include_router(strategy_summary_router.router)
api_router.include_router(value_proposition_router.router)
api_router.include_router(customer_onboarding_router.router)
api_router.include_router(sales_os_router.router)
api_router.include_router(operations_router.router)
api_router.include_router(analytics.router, tags=["Analytics & AI"])
api_router.include_router(webhooks.router, tags=["Webhooks"])
api_router.include_router(prospecting.router, prefix="/prospecting", tags=["Prospecting"])
api_router.include_router(inbox.router)
api_router.include_router(sequences.router)
api_router.include_router(compliance_router.router)
# ── CPQ — Proposals & Quotes ────────────────────────────────
api_router.include_router(proposals_router.router)
# ── Manus Multi-Agent + Autonomous Intelligence ─────────────
api_router.include_router(agents_router.router)
api_router.include_router(intelligence_router.router)
api_router.include_router(master_router.router)
# ── Revenue Room — Saudi AI Sales Engine ─────────────────────
api_router.include_router(revenue_room_router.router)
# ── Outreach Engine — Auto Client Acquisition ────────────────
api_router.include_router(outreach_router.router)
# ── Lead Prospector — AI-Powered Lead Generation ─────────────
api_router.include_router(prospector_router.router)
# ── Autonomous Pipeline — Self-Running Sales Machine ─────────
api_router.include_router(pipeline_router.router)
# ── 22-Agent AI System — Full Empire Control ─────────────────
api_router.include_router(agent_system_router.router)
api_router.include_router(autonomous_foundation_router.router)
# ── Hermes Fusion — Orchestration Layer ──────────────────────
api_router.include_router(hermes_router.router)
# ── Strategic Deals — B2B Deal Discovery & Negotiation ───────
api_router.include_router(strategic_deals_router.router)
# ── WhatsApp Webhook — Incoming messages & status ────────────
from app.api.v1 import whatsapp_webhook as whatsapp_webhook_router
api_router.include_router(whatsapp_webhook_router.router)
# ── Tier-1 Governance & Trust Surfaces ───────────────────────
api_router.include_router(contradiction_router.router)
api_router.include_router(evidence_packs_router.router)
api_router.include_router(executive_room_router.router)
api_router.include_router(connector_governance_router.router)
api_router.include_router(model_routing_router.router)
api_router.include_router(saudi_compliance_router.router)
api_router.include_router(forecast_control_router.router)
api_router.include_router(approval_center_router.router)
# ── Golden Path — Tier-1 Verification Flow ───────────────────
from app.api.v1 import golden_path as golden_path_router
api_router.include_router(golden_path_router.router)
# ── Structured Outputs — Schema-Bound Decision Artifacts ─────
from app.api.v1 import structured_outputs as structured_outputs_router
api_router.include_router(structured_outputs_router.router)
# ── Saudi Sensitive Workflow — PDPL-Controlled Data Sharing ──
from app.api.v1 import saudi_workflow as saudi_workflow_router
api_router.include_router(saudi_workflow_router.router)
# ── Omnichannel — Unified channel management ─────────────────
from app.api.v1 import channels as channels_router
api_router.include_router(channels_router.router)
# ── Pricing & Checkout — Moyasar-powered payment flow ────────
from app.api.v1 import pricing as pricing_router
api_router.include_router(pricing_router.router)
# ── Automation — Daily targeting + email + reply classification ─
from app.api.v1 import automation as automation_router
api_router.include_router(automation_router.router)
# ── Draft Queue — review, approve, send outreach drafts ────────
from app.api.v1 import drafts as drafts_router
api_router.include_router(drafts_router.router)
# ── Follow-ups — auto-generate follow-up drafts for unreplied ──
from app.api.v1 import followups as followups_router
api_router.include_router(followups_router.router)
# ── Full OS — unified deal lifecycle orchestration ─────────────
from app.api.v1 import full_os as full_os_router
api_router.include_router(full_os_router.router)