mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-18 15:29:36 +00:00
Platform Services Layer (10 modules) — برج التحكم بالنمو - event_bus: 27 typed events (whatsapp/email/calendar/lead/payment/review/social/partner/sheet/crm/action) - identity_resolution: cross-channel merge (phone+email+CRM+social) with confidence scoring - channel_registry: 11 channels (WA, Gmail, Calendar, Moyasar, LinkedIn, X, IG, GBP, Sheets, CRM, Forms) with capabilities/risk/PDPL notes - action_policy: 9 rules (block_cold_whatsapp, block_payment_no_confirm, block_secrets, external_send_needs_approval, calendar_insert_needs_approval, social_dm_needs_explicit, unknown_source_review, high_value_deal_review, draft_only_safe) - tool_gateway: single execution chokepoint, env-flag-gated live actions (default OFF) - unified_inbox: 8 card types, ≤3 buttons enforced, Arabic - action_ledger: requested→approved→executed audit trail - proof_ledger: leads/meetings/drafts/sends/payments/revenue/risks_blocked/time_saved per channel - service_catalog: 12 sellable services - router api/routers/platform_services.py — 13 endpoints under /api/v1/platform/ Intelligence Layer (10 modules) — الشبكة العصبية للنمو - growth_brain: per-customer Brain + is_ready_for_autopilot() (≥30 signals + ≥40% accept) - command_feed: 9 daily card types (opportunity/revenue_leak/partner_suggestion/meeting_prep/review_response/competitive_move/customer_reactivation/ai_visibility_alert/action_required) - action_graph: 10 typed edges (signal→action→outcome) with what_works_summary - mission_engine: 7 missions, KILL FEATURE first_10_opportunities (10 فرص في 10 دقائق) - decision_memory: learns from accept/skip/edit/block, returns preferences (channels, tones, sectors, rejected actions, accept_rate) - trust_score: composite 0-100 (source+opt_in+channel+content+freq+approval) → safe/needs_review/blocked - revenue_dna: best_channel/segment/angle + common_objection + avg_cycle_days - opportunity_simulator: 9 Saudi sectors, expected_replies/meetings/deals/pipeline_sar + risk_score - competitive_moves: 8 move types with Arabic recommended_action_ar - board_brief: weekly Founder Shadow Board (3 decisions + 3 opportunities + 3 risks + relationship + experiment + metric) - router api/routers/intelligence_layer.py — 12 endpoints under /api/v1/intelligence/ Tests - tests/unit/test_platform_services.py — 31 tests covering catalog/channels/events/policy/gateway/identity/inbox/ledger/proof - tests/unit/test_intelligence_layer.py — 29 tests covering brain/feed/graph/missions/memory/trust/dna/simulator/competitive/brief - 60/60 new tests pass; full suite 587 passed, 2 skipped Docs - docs/PLATFORM_SERVICES_STRATEGY.md (Arabic) - docs/INTELLIGENCE_LAYER_STRATEGY.md (Arabic) - docs/DEALIX_100_PERCENT_LAUNCH_PLAN.md — added §32 Platform Services + §33 Intelligence Layer Safety - No live send by default (all WA/Gmail/Calendar/Moyasar guarded by env flags, all OFF) - All external actions go through Tool Gateway → Action Policy → draft/approval_required - No secrets allowed in payloads (block_secrets policy) - PDPL-aware: cold WhatsApp without consent is hard-blocked - Existing 477+ tests untouched (no breaking changes) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
115 lines
5.0 KiB
Python
115 lines
5.0 KiB
Python
"""Intelligence Mission Engine — 7 outcome-shaped growth missions."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from auto_client_acquisition.intelligence_layer.growth_brain import GrowthBrain
|
|
|
|
|
|
INTEL_MISSIONS: tuple[dict[str, Any], ...] = (
|
|
{
|
|
"id": "first_10_opportunities",
|
|
"title_ar": "10 فرص في 10 دقائق",
|
|
"goal_ar": "اكتشاف 10 شركات سعودية + رسائل عربية + موافقة + متابعة أسبوع.",
|
|
"kill_metric": "ten_drafts_approved",
|
|
"required_integrations": ("whatsapp",),
|
|
"safety_rules_ar": ("لا cold WhatsApp بدون lawful basis",),
|
|
"success_metrics": ("approve_rate ≥ 50%", "first_reply ≤ 24h"),
|
|
},
|
|
{
|
|
"id": "revenue_leak_rescue",
|
|
"title_ar": "أنقذ الإيراد الضائع",
|
|
"goal_ar": "اقرأ Email/CRM/WhatsApp → استخرج leads ضائعة → drafts متابعة.",
|
|
"kill_metric": "leads_revived",
|
|
"required_integrations": ("gmail", "crm"),
|
|
"safety_rules_ar": ("approval لكل follow-up",),
|
|
"success_metrics": ("rescued_leads ≥ 5", "rescued_pipeline_sar ≥ 30000"),
|
|
},
|
|
{
|
|
"id": "partnership_sprint",
|
|
"title_ar": "ابدأ قناة شراكات",
|
|
"goal_ar": "تحديد + التواصل مع 5 شركاء محتملين خلال 14 يوم.",
|
|
"kill_metric": "partner_intros_replied",
|
|
"required_integrations": ("gmail", "google_calendar"),
|
|
"safety_rules_ar": ("لا outreach شخصي بدون warm context",),
|
|
"success_metrics": ("intros_replied ≥ 2", "first_partner_meeting ≤ 14d"),
|
|
},
|
|
{
|
|
"id": "customer_reactivation",
|
|
"title_ar": "استرجع العملاء الخاملين",
|
|
"goal_ar": "ارفع قائمة قدامى → صنّفهم → رسائل عودة بـ payment link.",
|
|
"kill_metric": "reactivated_customers",
|
|
"required_integrations": ("whatsapp", "moyasar"),
|
|
"safety_rules_ar": ("Opt-in موثق فقط",),
|
|
"success_metrics": ("reactivated ≥ 10", "revenue_sar ≥ 25000"),
|
|
},
|
|
{
|
|
"id": "meeting_booking_sprint",
|
|
"title_ar": "احجز 3 اجتماعات",
|
|
"goal_ar": "Top-10 leads → agenda → موافقة → calendar drafts.",
|
|
"kill_metric": "meetings_confirmed",
|
|
"required_integrations": ("google_calendar", "whatsapp"),
|
|
"safety_rules_ar": ("لا insert بدون OAuth + ضغطة المستخدم",),
|
|
"success_metrics": ("meetings_confirmed ≥ 3 / 5d",),
|
|
},
|
|
{
|
|
"id": "ai_visibility_sprint",
|
|
"title_ar": "AEO Sprint — اظهر في إجابات AI",
|
|
"goal_ar": "تحليل ظهور الشركة + خطة محتوى 30 يوم لـ ChatGPT/Gemini/Perplexity.",
|
|
"kill_metric": "questions_visible",
|
|
"required_integrations": ("google_business_profile",),
|
|
"safety_rules_ar": ("لا scraping خارج المسموح",),
|
|
"success_metrics": ("question_visibility_lift ≥ 30%",),
|
|
},
|
|
{
|
|
"id": "competitive_response",
|
|
"title_ar": "الرد على حركة منافس",
|
|
"goal_ar": "رصد price change/offer/hiring → ردود + حملات + ROI breakdown.",
|
|
"kill_metric": "competitor_signals_resolved",
|
|
"required_integrations": (),
|
|
"safety_rules_ar": ("لا تشهير", "لا اتهام عام",),
|
|
"success_metrics": ("retention_lift", "win_rate_lift"),
|
|
},
|
|
)
|
|
|
|
|
|
def list_intel_missions() -> dict[str, Any]:
|
|
return {
|
|
"count": len(INTEL_MISSIONS),
|
|
"missions": list(INTEL_MISSIONS),
|
|
"kill_feature_id": "first_10_opportunities",
|
|
}
|
|
|
|
|
|
def recommend_missions(brain: GrowthBrain | None = None, *, limit: int = 3) -> dict[str, Any]:
|
|
"""Pick top-N missions for this customer based on brain state."""
|
|
if brain is None:
|
|
recommended = list(INTEL_MISSIONS)[:limit]
|
|
else:
|
|
# Simple heuristic: kill feature first, then prioritize by integrations
|
|
ranked: list[tuple[dict, float]] = []
|
|
for m in INTEL_MISSIONS:
|
|
score = 50.0
|
|
if m["id"] == "first_10_opportunities":
|
|
score += 50 # always priority for new customers
|
|
req = set(m["required_integrations"])
|
|
connected = set(brain.channels_connected)
|
|
if req.issubset(connected):
|
|
score += 20
|
|
else:
|
|
score -= 10 * (len(req - connected))
|
|
if "fill_pipeline" in brain.growth_priorities and m["id"] in (
|
|
"first_10_opportunities", "revenue_leak_rescue"
|
|
):
|
|
score += 15
|
|
if "build_partner_channel" in brain.growth_priorities and m["id"] == "partnership_sprint":
|
|
score += 15
|
|
ranked.append((m, score))
|
|
ranked.sort(key=lambda x: x[1], reverse=True)
|
|
recommended = [m for m, _ in ranked[:limit]]
|
|
return {
|
|
"recommended": recommended,
|
|
"rationale_ar": "تم الترتيب حسب priorities العميل + القنوات المربوطة.",
|
|
}
|