mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-18 15:29:36 +00:00
Builds the full Saudi Autonomous Revenue OS surface as 10 deterministic
modules + a 16-endpoint router under /api/v1/growth-operator/.
Approval-first: every outbound is draft. No live send / charge / calendar
insert from this layer.
MODULES (auto_client_acquisition/growth_operator/)
1. client_profile.py — ClientGrowthProfile + Saudi-default approval
+ compliance rules (no cold WhatsApp, blocked keywords, weekly cap,
quiet_hours_riyadh)
2. contact_importer.py — normalize_phone (Saudi E.164),
dedupe_contacts (richer-record-wins), classify_contact_source
(existing/inbound/event/referral/old_lead/cold/unknown), detect_opt_out
(Arabic + English markers), summarize_import (dashboard report)
3. contactability.py — score_contactability returns
safe/needs_review/blocked with Arabic reasons; default policy:
no cold WhatsApp without lawful basis (PDPL Art.5)
4. targeting.py — segment_contacts, rank_targets (filters unsafe),
recommend_top_10, why_now_stub (deterministic, sector-aware)
5. message_planner.py — draft_arabic_message (Saudi tone, 4-sector
opener bank, no overhyped phrases, always pending_approval),
draft_followup (4 outcome modes), draft_objection_response
(6 indexed Saudi B2B objections with score_delta + next_action)
6. partnership_planner.py — 6 partner types catalog
(agency / consultant / integrator / crm / community / influencer)
+ suggest_partner_types (size/sector aware) + draft_partner_outreach
+ partner_scorecard (platinum/gold/silver/bronze)
7. meeting_planner.py — build_meeting_agenda (15/20-30/45+ min slot
plans), build_calendar_draft (Google Calendar shape, live_inserted=False,
conferenceData for Meet, Asia/Riyadh timezone), build_post_meeting_followup
8. payment_offer.py — sar_to_halalas, build_moyasar_payment_link_draft
(full payload + in-chat message + 4-plan catalog, live_charged=False)
9. proof_pack.py — build_weekly_proof_pack with grade A+/A/B/C/D,
activity/money/quality/best-of sections, dynamic next_week_plan_ar,
markdown export
10. mission_planner.py — 6 GROWTH_MISSIONS (first_10_opportunities ⭐
kill feature, recover_stalled_deals, partnership_sprint,
safe_whatsapp_campaign, meeting_booking_sprint, list_cleanup);
list_missions() + run_mission()
ROUTER (api/routers/growth_operator.py) — 16 endpoints
POST /contacts/import-preview · POST /contactability/score
POST /targets/top-10 · POST /messages/draft · POST /messages/followup
POST /messages/objection-response · POST /partners/suggest
POST /partners/outreach · POST /partners/scorecard
POST /meetings/draft · POST /meetings/post-followup
POST /payment-offer/draft · GET /missions · POST /missions/{id}/run
GET /proof-pack/demo · POST /profile
WIRING: api/main.py adds growth_operator import + router include
(positioned after personal_operator, before public).
DOCS
- docs/ARABIC_GROWTH_OPERATOR_FULL_SPEC.md (NEW): 20-section vision +
customer-type table + upload flow + contactability rules +
WhatsApp/Gmail/Calendar/Moyasar drafts + 6 missions + 16-endpoint
catalog + competitive comparison + beta readiness checklist
TESTS — 50 passing on Python 3.10 venv
tests/unit/test_growth_operator.py covers:
- Phone normalization across 5 input formats including invalid
- Dedupe richer-record invariant
- Source classification (existing/inbound/event/cold/unknown)
- Opt-out detection (Arabic + English notes + status)
- Import summary aggregation
- Contactability: opt-out blocked, cold WhatsApp blocked,
unknown→needs_review, existing→safe, inbound→safe
- Bulk contactability summary
- Top-10 filtering (unsafe excluded), max-cap enforcement
- Segment buckets
- Arabic message: pending_approval invariant + Arabic content
+ no overhyped phrases (banned list)
- Followup approval invariant
- Objection response: known + unknown→diagnostic
- Partner suggestions size-aware (SMB→agency/consultant/community)
- Partner outreach approval invariant
- Partner unknown type returns error
- Partner scorecard tier ordering
- Meeting agenda + calendar draft (live_inserted=False) +
Asia/Riyadh timezone + post-followup pending
- Payment: halalas conversion (1 SAR=100), negative raises,
draft NEVER charges (live_charged=False), unknown plan→error
- Proof pack: grade range + structure + markdown export
- Missions: first_10_opportunities present + kill feature ID
+ run mission known/unknown
- Profile: demo specialized + partial not specialized
+ default compliance blocks 'ضمان 100' + no_cold_whatsapp_without_lawful_basis
VERIFICATION
- 527 unit tests pass (was 477; +50 growth_operator)
- 2 skipped (provider smoke needs API keys)
- AST green on all 13 new files
- Approval invariant holds across every drafting function
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
155 lines
6.8 KiB
Python
155 lines
6.8 KiB
Python
"""
|
|
Growth Missions — outcome-shaped tasks instead of features.
|
|
|
|
Each mission has: id, title_ar, goal_ar, steps (ordered, approval-gated),
|
|
expected_duration_days, kill_metric (the ONE number that proves success).
|
|
|
|
Pure deterministic. Production wires each step to the relevant agent.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
|
|
GROWTH_MISSIONS: tuple[dict[str, Any], ...] = (
|
|
{
|
|
"id": "first_10_opportunities",
|
|
"title_ar": "اطلع لي 10 فرص",
|
|
"goal_ar": "اكتشاف 10 شركات سعودية مناسبة + رسائل عربية + موافقة + متابعة أسبوع.",
|
|
"expected_duration_days": 7,
|
|
"kill_metric": "ten_drafts_approved",
|
|
"steps_ar": [
|
|
"تحديد القطاع والمدينة + المعايير الأساسية.",
|
|
"اكتشاف 30 شركة مرشحة من المصادر المسموحة.",
|
|
"فلترة لـ 10 بأعلى Why-Now score.",
|
|
"كتابة 10 رسائل عربية بحالة pending_approval.",
|
|
"موافقة المشغّل على عينة → إرسال آمن.",
|
|
"تصنيف الردود + اقتراح متابعة لكل واحدة.",
|
|
"Proof Pack أسبوعي عند الإغلاق.",
|
|
],
|
|
"primary_endpoint": "/api/v1/innovation/opportunities/ten-in-ten",
|
|
"approval_required": True,
|
|
},
|
|
{
|
|
"id": "recover_stalled_deals",
|
|
"title_ar": "أنقذ الصفقات المتوقفة",
|
|
"goal_ar": "اكتشف الصفقات بدون نشاط 14+ يوم + اقترح متابعات multi-thread.",
|
|
"expected_duration_days": 5,
|
|
"kill_metric": "stalled_deals_revived",
|
|
"steps_ar": [
|
|
"قراءة pipeline الحالي + revenue_graph.leak_detector.",
|
|
"تصنيف الصفقات: stalled / single-threaded / no-proposal.",
|
|
"اقتراح multi-thread (DM إضافي داخل الحساب).",
|
|
"كتابة drafts متابعة pending_approval لكل صفقة.",
|
|
"موافقة المشغّل → إرسال + جدولة re-check بعد 7 أيام.",
|
|
],
|
|
"primary_endpoint": "/api/v1/revenue-os/leaks",
|
|
"approval_required": True,
|
|
},
|
|
{
|
|
"id": "partnership_sprint",
|
|
"title_ar": "ابدأ شراكات",
|
|
"goal_ar": "تحديد + التواصل مع 5 شركاء محتملين خلال أسبوعين.",
|
|
"expected_duration_days": 14,
|
|
"kill_metric": "partner_intros_replied",
|
|
"steps_ar": [
|
|
"تحديد قطاع العميل + حجمه → اقتراح أنواع شركاء مناسبة.",
|
|
"ترشيح 5 شركاء محتملين بأعلى strategic_value.",
|
|
"كتابة outreach warm لكل واحد.",
|
|
"موافقة المشغّل → إرسال على email.",
|
|
"متابعة الردود + جدولة 20 دقيقة لكل ردّ إيجابي.",
|
|
"Partner scorecard أولي بعد المكالمات.",
|
|
],
|
|
"primary_endpoint": "/api/v1/growth-operator/partners/suggest",
|
|
"approval_required": True,
|
|
},
|
|
{
|
|
"id": "safe_whatsapp_campaign",
|
|
"title_ar": "جهز حملة واتساب آمنة",
|
|
"goal_ar": "تحويل قائمة العميل إلى حملة WhatsApp يحترم PDPL + opt-in.",
|
|
"expected_duration_days": 3,
|
|
"kill_metric": "safe_messages_drafted",
|
|
"steps_ar": [
|
|
"رفع قائمة الأرقام عبر contact_importer.",
|
|
"تنظيف + dedupe + classify_source.",
|
|
"فحص contactability — إخراج blocked/needs_review.",
|
|
"كتابة رسائل عربية لكل segment آمن.",
|
|
"موافقة المشغّل لكل segment على حدة.",
|
|
"إرسال آمن مع opt-out في كل رسالة.",
|
|
],
|
|
"primary_endpoint": "/api/v1/growth-operator/contacts/import-preview",
|
|
"approval_required": True,
|
|
},
|
|
{
|
|
"id": "meeting_booking_sprint",
|
|
"title_ar": "احجز لي 3 اجتماعات",
|
|
"goal_ar": "حجز 3 اجتماعات مع leads أعلى Why-Now خلال 5 أيام عمل.",
|
|
"expected_duration_days": 5,
|
|
"kill_metric": "meetings_confirmed",
|
|
"steps_ar": [
|
|
"اختيار أعلى 10 leads من Top-10 السابق.",
|
|
"إعداد agenda + calendar draft لكل واحد.",
|
|
"كتابة intro + ask مكالمة 15 دقيقة.",
|
|
"موافقة + إرسال WhatsApp/email.",
|
|
"تأكيد الحضور قبل الاجتماع بـ 24 ساعة.",
|
|
"post-meeting follow-up draft.",
|
|
],
|
|
"primary_endpoint": "/api/v1/growth-operator/meetings/draft",
|
|
"approval_required": True,
|
|
},
|
|
{
|
|
"id": "list_cleanup",
|
|
"title_ar": "ارفع قائمتي ونظفها",
|
|
"goal_ar": "تحويل ملف غير منظم إلى قائمة contactability-classified جاهزة.",
|
|
"expected_duration_days": 1,
|
|
"kill_metric": "safe_contacts_extracted",
|
|
"steps_ar": [
|
|
"رفع CSV/Excel.",
|
|
"normalize_phone + dedupe.",
|
|
"classify_contact_source لكل سطر.",
|
|
"score_contactability لكل سطر.",
|
|
"تقرير: safe / needs_review / blocked + عدد + عينة.",
|
|
"اقتراح: ابدأ بالـ safe فقط، مع plan لـ needs_review.",
|
|
],
|
|
"primary_endpoint": "/api/v1/growth-operator/contacts/import-preview",
|
|
"approval_required": True,
|
|
},
|
|
)
|
|
|
|
|
|
def list_missions() -> dict[str, Any]:
|
|
"""Return the canonical mission catalog."""
|
|
return {
|
|
"count": len(GROWTH_MISSIONS),
|
|
"missions": list(GROWTH_MISSIONS),
|
|
"kill_feature_id": "first_10_opportunities",
|
|
}
|
|
|
|
|
|
def run_mission(mission_id: str, *, payload: dict[str, Any] | None = None) -> dict[str, Any]:
|
|
"""
|
|
Plan a mission run — returns the execution outline + first-step
|
|
prompt for the operator. Does NOT actually execute steps; that's
|
|
done by routing each step to its primary endpoint.
|
|
"""
|
|
mission = next((m for m in GROWTH_MISSIONS if m["id"] == mission_id), None)
|
|
if mission is None:
|
|
return {
|
|
"error": f"unknown_mission: {mission_id}",
|
|
"available_ids": [m["id"] for m in GROWTH_MISSIONS],
|
|
}
|
|
return {
|
|
"mission_id": mission_id,
|
|
"title_ar": mission["title_ar"],
|
|
"goal_ar": mission["goal_ar"],
|
|
"kill_metric": mission["kill_metric"],
|
|
"expected_duration_days": mission["expected_duration_days"],
|
|
"current_step_index": 0,
|
|
"next_step_ar": mission["steps_ar"][0],
|
|
"primary_endpoint": mission["primary_endpoint"],
|
|
"payload_received": payload or {},
|
|
"approval_required": True,
|
|
"approval_status": "pending_approval",
|
|
}
|