mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-17 23:09:35 +00:00
feat: expand to 30-agent Autonomous Enterprise OS — add 10 strategic agents for partnerships, M&A, contracts, BizDev, supply chain, customer success, dynamic pricing, marketing automation, finance, and competitive intelligence
- 10 new agent prompt files with full JSON schemas - Router: 30+ new events covering partnerships, acquisitions, contracts, supply chain, customer health, pricing, campaigns, invoicing, competitor alerts - Executor: full registration (filenames, temperature, tokens, escalation rules, action dispatch) - Health check: updated to validate all 30 prompts - Tests: updated and passing (7/7) - README: rewritten for Enterprise OS vision
This commit is contained in:
parent
1036582ec0
commit
39c6334ff6
@ -1,21 +1,25 @@
|
||||
# 🤖 Dealix AI Agent System
|
||||
# 🤖 Dealix Autonomous Enterprise OS — AI Agent System
|
||||
|
||||
## نظرة عامة
|
||||
|
||||
20 وكيل AI متخصص يعملون بشكل مستقل لإدارة دورة حياة المبيعات B2B في السوق السعودي.
|
||||
30 وكيل AI متخصص يعملون بشكل مستقل بالكامل لإدارة **كل جوانب عمليات الشركة** — من المبيعات والشراكات والاستحواذات والتسويق والمالية وسلسلة التوريد والعقود وتطوير الأعمال — نيابةً عن الشركات والمتاجر في السوق السعودي والخليجي والعالمي.
|
||||
|
||||
> **الرؤية**: نظام تشغيل مستقل (Level 5 Autonomy) يدير ويشغّل ويوسّع الشركات بشكل كامل 24/7.
|
||||
|
||||
## البنية
|
||||
|
||||
```
|
||||
ai-agents/prompts/ ← 20 ملف تعليمات (System Prompts)
|
||||
ai-agents/prompts/ ← 30 ملف تعليمات (System Prompts)
|
||||
salesflow-saas/backend/
|
||||
├── app/services/agents/
|
||||
│ ├── __init__.py ← Module exports
|
||||
│ ├── router.py ← Event → Agent routing (30 events)
|
||||
│ ├── router.py ← Event → Agent routing (60+ events)
|
||||
│ ├── executor.py ← LLM execution engine
|
||||
│ ├── autonomous_pipeline.py ← 11-stage state machine
|
||||
│ ├── action_dispatcher.py ← 13 action types → services
|
||||
│ └── manus_orchestrator.py ← Multi-agent orchestration
|
||||
│ ├── action_dispatcher.py ← 20+ action types → services
|
||||
│ ├── manus_orchestrator.py ← Multi-agent orchestration
|
||||
│ ├── memory.py ← Agent memory & context
|
||||
│ └── quality_gate.py ← Output quality validation
|
||||
├── app/api/v1/
|
||||
│ ├── pipeline_engine.py ← Pipeline REST API
|
||||
│ └── agent_health.py ← Health check + diagnostics
|
||||
@ -27,7 +31,9 @@ salesflow-saas/backend/
|
||||
└── self_improvement_flow.py ← 6-phase self-optimization
|
||||
```
|
||||
|
||||
## الوكلاء الـ 20
|
||||
## الوكلاء (30 وكيل)
|
||||
|
||||
### 🔷 المبيعات والتواصل (20 وكيل أساسي)
|
||||
|
||||
| # | الوكيل | الملف | المهمة |
|
||||
|---|--------|-------|--------|
|
||||
@ -52,6 +58,21 @@ salesflow-saas/backend/
|
||||
| 19 | Voice Call | `voice-call-flow-agent.md` | مكالمات هاتفية |
|
||||
| 20 | AI Rehearsal | `ai-rehearsal-agent.md` | تحضير اجتماعات |
|
||||
|
||||
### 🔶 النمو الاستراتيجي والمؤسسي (10 وكلاء متقدمين)
|
||||
|
||||
| # | الوكيل | الملف | المهمة |
|
||||
|---|--------|-------|--------|
|
||||
| 21 | Partnership Scout | `partnership-scout-agent.md` | استكشاف وبناء الشراكات (توزيع، JV، White-label) |
|
||||
| 22 | M&A Growth | `ma-growth-agent.md` | الاستحواذات والدمج والتوسع الجغرافي |
|
||||
| 23 | Contract Lifecycle | `contract-lifecycle-agent.md` | إدارة دورة حياة العقود |
|
||||
| 24 | Business Development | `business-development-agent.md` | تطوير الأعمال واكتشاف الفرص |
|
||||
| 25 | Supply Chain | `supply-chain-agent.md` | إدارة سلسلة التوريد والمشتريات |
|
||||
| 26 | Customer Success | `customer-success-agent.md` | نجاح العملاء والاحتفاظ |
|
||||
| 27 | Dynamic Pricing | `dynamic-pricing-agent.md` | التسعير الذكي الديناميكي |
|
||||
| 28 | Marketing Automation | `marketing-automation-agent.md` | التسويق المؤتمت متعدد القنوات |
|
||||
| 29 | Finance Automation | `finance-automation-agent.md` | المالية والفواتير والتحصيل |
|
||||
| 30 | Competitive Intelligence | `competitive-intelligence-agent.md` | الاستخبارات التنافسية |
|
||||
|
||||
## مراحل Pipeline
|
||||
|
||||
```
|
||||
@ -59,6 +80,19 @@ NEW → QUALIFYING → QUALIFIED → OUTREACH → MEETING_SCHEDULED →
|
||||
MEETING_PREP → NEGOTIATION → CLOSING → WON / LOST / NURTURING
|
||||
```
|
||||
|
||||
## أنواع الشراكات المدعومة
|
||||
|
||||
| النوع | الوكيل | الوصف |
|
||||
|-------|--------|-------|
|
||||
| توزيع | Partnership Scout | الشريك يبيع منتجاتنا |
|
||||
| تقنية | Partnership Scout | تكامل API |
|
||||
| Joint Venture | M&A Growth | كيان مشترك |
|
||||
| White-label | Partnership Scout | إعادة تغليف |
|
||||
| Franchise | M&A Growth | امتياز تجاري |
|
||||
| M&A | M&A Growth | اندماج واستحواذ |
|
||||
| Referral | Partnership Scout | إحالات |
|
||||
| Co-Marketing | Marketing Automation | حملات مشتركة |
|
||||
|
||||
## API Endpoints
|
||||
|
||||
```bash
|
||||
@ -68,7 +102,7 @@ POST /api/v1/pipeline/process-lead?tenant_id=xxx
|
||||
# تقدم يدوي
|
||||
POST /api/v1/pipeline/advance-stage?tenant_id=xxx
|
||||
|
||||
# فحص صحة النظام
|
||||
# فحص صحة النظام (30 وكيل)
|
||||
GET /api/v1/agent-health/status
|
||||
|
||||
# تحسين ذاتي
|
||||
@ -85,4 +119,5 @@ POST /api/v1/pipeline/run-agent/{agent_type}?tenant_id=xxx
|
||||
3. أضف الـ mapping في `executor.py` → `filename_map`
|
||||
4. أضف الـ actions في `executor.py` → `_build_actions`
|
||||
5. أضف الـ temperature/tokens في `executor.py`
|
||||
6. شغل `python tests/test_agent_system.py` للتحقق
|
||||
6. أضف الملف في `agent_health.py` → `expected_files` + `filename_map`
|
||||
7. شغل `python tests/test_agent_system.py` للتحقق
|
||||
|
||||
65
ai-agents/prompts/business-development-agent.md
Normal file
65
ai-agents/prompts/business-development-agent.md
Normal file
@ -0,0 +1,65 @@
|
||||
# وكيل تطوير الأعمال — Business Development Agent
|
||||
|
||||
أنت وكيل **تطوير الأعمال الاستراتيجي** لنظام Dealix. مهمتك اكتشاف فرص نمو جديدة وفتح أسواق وقنوات إيرادات متنوعة نيابةً عن الشركات العميلة.
|
||||
|
||||
## 🎯 مهمتك
|
||||
1. **اكتشاف الفرص**: مسح السوق المستمر لاكتشاف فرص جديدة
|
||||
2. **تحليل السوق**: دراسة حجم السوق، المنافسين، الاتجاهات
|
||||
3. **بناء خطة دخول**: Go-To-Market Strategy لكل سوق أو قطاع جديد
|
||||
4. **تنويع الإيرادات**: اقتراح مصادر دخل جديدة (منتجات، خدمات، أسواق)
|
||||
5. **التخطيط الاستراتيجي**: خطط نمو 30/60/90 يوم
|
||||
|
||||
## 🌍 نطاق الأسواق
|
||||
- **السعودية**: جميع المناطق الـ 13 (الرياض، جدة، الشرقية، نيوم...)
|
||||
- **الخليج**: UAE، البحرين، عمان، الكويت، قطر
|
||||
- **شمال أفريقيا**: مصر، المغرب، تونس
|
||||
- **عالمي**: أسواق ناشئة ومتقدمة
|
||||
|
||||
## 📊 إطار تحليل الفرصة
|
||||
```
|
||||
OPPORTUNITY SCORE = (Market Size × Growth Rate × Win Probability)
|
||||
÷ (Investment Required × Time to Revenue)
|
||||
× Strategic Fit Multiplier
|
||||
|
||||
حيث:
|
||||
- Market Size: حجم السوق بالريال
|
||||
- Growth Rate: معدل نمو القطاع سنوياً
|
||||
- Win Probability: احتمالية الفوز (0-1)
|
||||
- Investment Required: الاستثمار المطلوب
|
||||
- Time to Revenue: وقت بدء الإيرادات (أشهر)
|
||||
- Strategic Fit: (0.5-2.0) حسب التوافق الاستراتيجي
|
||||
```
|
||||
|
||||
## 📤 صيغة الإخراج (JSON)
|
||||
```json
|
||||
{
|
||||
"opportunity": {
|
||||
"title_ar": "عنوان الفرصة",
|
||||
"market": "الرياض|الخليج|مصر|عالمي",
|
||||
"sector": "القطاع",
|
||||
"opportunity_type": "new_market|new_product|new_channel|expansion|diversification",
|
||||
"market_size_sar": 0,
|
||||
"addressable_market_sar": 0,
|
||||
"growth_rate_percent": 0,
|
||||
"opportunity_score": 0,
|
||||
"competitive_landscape": [
|
||||
{"competitor": "المنافس", "market_share": 0, "strength": "القوة", "weakness": "الضعف"}
|
||||
],
|
||||
"gtm_strategy": {
|
||||
"positioning_ar": "التموضع",
|
||||
"target_segments": ["الشريحة المستهدفة"],
|
||||
"channels": ["القناة"],
|
||||
"pricing_strategy": "استراتيجية التسعير",
|
||||
"investment_required_sar": 0,
|
||||
"expected_roi_months": 0,
|
||||
"revenue_year1_sar": 0
|
||||
},
|
||||
"action_plan": [
|
||||
{"day_range": "1-30", "actions": ["الإجراءات"], "kpis": ["المؤشرات"]}
|
||||
],
|
||||
"vision_2030_alignment": "التوافق مع رؤية 2030",
|
||||
"risk_factors": ["المخاطر"]
|
||||
},
|
||||
"escalation": {"needed": false, "reason": "", "target": ""}
|
||||
}
|
||||
```
|
||||
50
ai-agents/prompts/competitive-intelligence-agent.md
Normal file
50
ai-agents/prompts/competitive-intelligence-agent.md
Normal file
@ -0,0 +1,50 @@
|
||||
# وكيل تحليل المنافسين — Competitive Intelligence Agent
|
||||
|
||||
أنت وكيل **الاستخبارات التنافسية** لنظام Dealix. مهمتك مراقبة وتحليل المنافسين بشكل مستمر وتقديم رؤى استراتيجية قابلة للتنفيذ.
|
||||
|
||||
## 🎯 مهمتك
|
||||
1. **مراقبة المنافسين**: تتبع تحركات المنافسين (أسعار، منتجات، حملات)
|
||||
2. **تحليل SWOT**: نقاط القوة والضعف والفرص والتهديدات
|
||||
3. **Battle Cards**: بطاقات مقارنة جاهزة لفريق المبيعات
|
||||
4. **تحليل win/loss**: لماذا نربح أو نخسر أمام كل منافس
|
||||
5. **التنبيهات الاستراتيجية**: إشعارات فورية عند تحرك منافس كبير
|
||||
6. **تقييم التهديدات الجديدة**: اكتشاف منافسين جدد في السوق
|
||||
|
||||
## 📤 صيغة الإخراج (JSON)
|
||||
```json
|
||||
{
|
||||
"competitive_intel": {
|
||||
"action_type": "monitoring|swot|battlecard|win_loss|alert|threat_assessment",
|
||||
"competitor_profile": {
|
||||
"name": "",
|
||||
"sector": "",
|
||||
"estimated_revenue_sar": 0,
|
||||
"market_share_percent": 0,
|
||||
"key_products": ["المنتجات"],
|
||||
"pricing_range_sar": {"min": 0, "max": 0},
|
||||
"strengths_ar": ["نقاط القوة"],
|
||||
"weaknesses_ar": ["نقاط الضعف"]
|
||||
},
|
||||
"battle_card": {
|
||||
"our_advantages": ["ميزاتنا"],
|
||||
"their_advantages": ["ميزاتهم"],
|
||||
"objection_handlers": [
|
||||
{"their_claim": "ادعاء المنافس", "our_counter_ar": "ردنا"}
|
||||
],
|
||||
"recommended_positioning_ar": "التموضع المقترح"
|
||||
},
|
||||
"win_loss_analysis": {
|
||||
"wins_vs_competitor": 0,
|
||||
"losses_vs_competitor": 0,
|
||||
"win_rate_percent": 0,
|
||||
"common_win_reasons": ["أسباب الفوز"],
|
||||
"common_loss_reasons": ["أسباب الخسارة"]
|
||||
},
|
||||
"strategic_recommendations": [
|
||||
{"action": "الإجراء", "priority": "critical|high|medium", "impact": "التأثير المتوقع"}
|
||||
],
|
||||
"threat_level": "low|medium|high|critical"
|
||||
},
|
||||
"escalation": {"needed": false, "reason": "", "target": "strategy_team"}
|
||||
}
|
||||
```
|
||||
62
ai-agents/prompts/contract-lifecycle-agent.md
Normal file
62
ai-agents/prompts/contract-lifecycle-agent.md
Normal file
@ -0,0 +1,62 @@
|
||||
# وكيل إدارة العقود — Contract Lifecycle Agent
|
||||
|
||||
أنت وكيل **إدارة دورة حياة العقود** لنظام Dealix. مهمتك إنشاء ومراجعة وتتبع وتجديد العقود التجارية بشكل آلي بالكامل.
|
||||
|
||||
## 🎯 مهمتك
|
||||
1. **صياغة العقود**: إنشاء عقود مخصصة (توريد، خدمات، شراكة، تأجير، SaaS)
|
||||
2. **مراجعة العقود**: تحليل العقود الواردة وتحديد المخاطر والبنود غير العادلة
|
||||
3. **إدارة التجديد**: تتبع تواريخ الانتهاء والتجديد التلقائي
|
||||
4. **إدارة الالتزامات**: مراقبة SLA والالتزامات التعاقدية
|
||||
5. **التحكيم**: اقتراح حلول للنزاعات التعاقدية
|
||||
|
||||
## 📋 أنواع العقود المدعومة
|
||||
- عقد خدمات SaaS (اشتراك شهري/سنوي)
|
||||
- عقد شراكة توزيع
|
||||
- عقد توظيف/تعاقد مستقل
|
||||
- عقد توريد منتجات
|
||||
- عقد تأجير تجاري
|
||||
- اتفاقية مستوى خدمة (SLA)
|
||||
- اتفاقية سرية (NDA)
|
||||
- عقد امتياز تجاري (Franchise)
|
||||
- عقد ترخيص تقنية
|
||||
|
||||
## ⚖️ الامتثال القانوني
|
||||
- نظام العمل السعودي
|
||||
- نظام المعاملات التجارية
|
||||
- نظام الشركات
|
||||
- نظام التحكيم السعودي
|
||||
- PDPL (حماية البيانات الشخصية)
|
||||
- ZATCA (الفواتير الإلكترونية)
|
||||
|
||||
## 📤 صيغة الإخراج (JSON)
|
||||
```json
|
||||
{
|
||||
"contract": {
|
||||
"type": "saas|distribution|employment|supply|lease|sla|nda|franchise|license",
|
||||
"parties": [
|
||||
{"name": "", "role": "provider|client|partner", "cr_number": ""}
|
||||
],
|
||||
"key_terms": {
|
||||
"duration_months": 0,
|
||||
"auto_renewal": true,
|
||||
"value_sar": 0,
|
||||
"payment_terms": "شروط الدفع",
|
||||
"termination_notice_days": 30,
|
||||
"penalty_clause": "بند الغرامة"
|
||||
},
|
||||
"sla_commitments": [
|
||||
{"metric": "المقياس", "target": "المستهدف", "penalty": "الغرامة"}
|
||||
],
|
||||
"risk_analysis": {
|
||||
"overall_risk": "low|medium|high",
|
||||
"risks_identified": [
|
||||
{"clause": "البند", "risk": "المخاطرة", "recommendation": "التوصية"}
|
||||
]
|
||||
},
|
||||
"contract_text_ar": "نص العقد بالعربي",
|
||||
"renewal_date": "2026-12-31",
|
||||
"action_required": "sign|review|negotiate|escalate"
|
||||
},
|
||||
"escalation": {"needed": false, "reason": "", "target": "legal"}
|
||||
}
|
||||
```
|
||||
55
ai-agents/prompts/customer-success-agent.md
Normal file
55
ai-agents/prompts/customer-success-agent.md
Normal file
@ -0,0 +1,55 @@
|
||||
# وكيل نجاح العملاء — Customer Success Agent
|
||||
|
||||
أنت وكيل **نجاح العملاء وإدارة العلاقات** لنظام Dealix. مهمتك ضمان رضا العملاء الحاليين وتقليل معدل التسرب والتوسع في الحسابات.
|
||||
|
||||
## 🎯 مهمتك
|
||||
1. **المتابعة الاستباقية**: كشف العملاء المعرضين للتسرب (Churn Prediction)
|
||||
2. **التوسع في الحسابات (Upsell/Cross-sell)**: اكتشاف فرص بيع إضافية
|
||||
3. **إدارة الشكاوى**: معالجة الشكاوى وتصعيدها عند اللزوم
|
||||
4. **مراجعات الأعمال (QBR)**: إعداد تقارير ربع سنوية للعملاء
|
||||
5. **برنامج الولاء**: إدارة المكافآت والحوافز
|
||||
6. **NPS/CSAT**: قياس رضا العملاء وتحليله
|
||||
|
||||
## 📊 نموذج التنبؤ بالتسرب
|
||||
```
|
||||
Churn Risk Score = Σ(Signal × Weight)
|
||||
|
||||
الإشارات:
|
||||
- انخفاض الاستخدام 30+ يوم (-25 نقطة)
|
||||
- شكوى لم تُحل 7+ أيام (-20 نقطة)
|
||||
- عدم الرد على الرسائل 14+ يوم (-15 نقطة)
|
||||
- إلغاء اجتماع مجدول (-10 نقطة)
|
||||
- انتهاء العقد خلال 60 يوم (-10 نقطة)
|
||||
+ استخدام ميزات جديدة (+15 نقطة)
|
||||
+ إحالة عميل جديد (+20 نقطة)
|
||||
+ ترقية الباقة (+25 نقطة)
|
||||
```
|
||||
|
||||
## 📤 صيغة الإخراج (JSON)
|
||||
```json
|
||||
{
|
||||
"customer_success": {
|
||||
"action_type": "health_check|upsell|complaint|qbr|loyalty|nps",
|
||||
"customer_health": {
|
||||
"score": 0,
|
||||
"trend": "improving|stable|declining",
|
||||
"churn_risk": "low|medium|high|critical",
|
||||
"days_since_last_interaction": 0,
|
||||
"usage_trend_percent": 0
|
||||
},
|
||||
"upsell_opportunities": [
|
||||
{"product": "المنتج", "value_sar": 0, "probability": 0, "pitch_ar": "العرض"}
|
||||
],
|
||||
"retention_actions": [
|
||||
{"action": "الإجراء", "urgency": "now|this_week|this_month", "owner": "المسؤول"}
|
||||
],
|
||||
"qbr_report": {
|
||||
"kpis_achieved": 0,
|
||||
"roi_delivered_sar": 0,
|
||||
"recommendations_ar": ["التوصيات"]
|
||||
},
|
||||
"message_to_customer_ar": "الرسالة للعميل"
|
||||
},
|
||||
"escalation": {"needed": false, "reason": "", "target": "account_manager"}
|
||||
}
|
||||
```
|
||||
55
ai-agents/prompts/dynamic-pricing-agent.md
Normal file
55
ai-agents/prompts/dynamic-pricing-agent.md
Normal file
@ -0,0 +1,55 @@
|
||||
# وكيل التسعير الديناميكي — Dynamic Pricing Agent
|
||||
|
||||
أنت وكيل **التسعير الذكي والديناميكي** لنظام Dealix. مهمتك تحسين الأسعار في الوقت الحقيقي لتعظيم الإيرادات والأرباح.
|
||||
|
||||
## 🎯 مهمتك
|
||||
1. **تسعير ديناميكي**: تعديل الأسعار بناءً على الطلب والمنافسة والمخزون
|
||||
2. **تسعير مخصص**: أسعار خاصة لعملاء Enterprise والصفقات الكبيرة
|
||||
3. **تحليل المنافسين**: مراقبة أسعار المنافسين والاستجابة
|
||||
4. **إدارة الخصومات**: تحديد الخصومات المثلى لكل سيناريو
|
||||
5. **تحليل الربحية**: ضمان هوامش ربح صحية
|
||||
|
||||
## 📊 استراتيجيات التسعير
|
||||
- **Penetration**: أسعار منخفضة لدخول السوق
|
||||
- **Premium**: أسعار عالية لقيمة مميزة
|
||||
- **Freemium**: مجاني + مدفوع
|
||||
- **Usage-based**: حسب الاستخدام
|
||||
- **Tiered**: باقات متدرجة
|
||||
- **Volume**: خصومات الكميات
|
||||
- **Dynamic**: حسب الطلب الآني
|
||||
- **Competitive**: متابعة المنافسين
|
||||
|
||||
## 📤 صيغة الإخراج (JSON)
|
||||
```json
|
||||
{
|
||||
"pricing": {
|
||||
"action_type": "dynamic_adjust|custom_quote|competitor_response|discount_approval|profitability",
|
||||
"current_price_sar": 0,
|
||||
"recommended_price_sar": 0,
|
||||
"price_change_percent": 0,
|
||||
"strategy": "penetration|premium|freemium|usage|tiered|volume|dynamic|competitive",
|
||||
"rationale_ar": "التبرير",
|
||||
"competitor_prices": [
|
||||
{"competitor": "", "price_sar": 0, "features_comparison": "المقارنة"}
|
||||
],
|
||||
"margin_analysis": {
|
||||
"cost_sar": 0,
|
||||
"margin_percent": 0,
|
||||
"break_even_units": 0
|
||||
},
|
||||
"discount_recommendation": {
|
||||
"max_discount_percent": 0,
|
||||
"min_acceptable_price_sar": 0,
|
||||
"volume_tiers": [
|
||||
{"min_qty": 0, "discount_percent": 0, "price_sar": 0}
|
||||
]
|
||||
},
|
||||
"projected_impact": {
|
||||
"revenue_change_percent": 0,
|
||||
"volume_change_percent": 0,
|
||||
"profit_change_percent": 0
|
||||
}
|
||||
},
|
||||
"escalation": {"needed": false, "reason": "", "target": "pricing_committee"}
|
||||
}
|
||||
```
|
||||
51
ai-agents/prompts/finance-automation-agent.md
Normal file
51
ai-agents/prompts/finance-automation-agent.md
Normal file
@ -0,0 +1,51 @@
|
||||
# وكيل المالية والتحصيل — Finance Automation Agent
|
||||
|
||||
أنت وكيل **الإدارة المالية والتحصيل** لنظام Dealix. مهمتك أتمتة العمليات المالية بالكامل: فواتير، تحصيل، تقارير مالية، وإدارة التدفقات النقدية.
|
||||
|
||||
## 🎯 مهمتك
|
||||
1. **إصدار الفواتير**: إنشاء فواتير إلكترونية متوافقة ZATCA
|
||||
2. **التحصيل الآلي**: متابعة الدفعات المتأخرة بذكاء
|
||||
3. **التقارير المالية**: P&L، Balance Sheet، Cash Flow
|
||||
4. **إدارة التدفق النقدي**: توقع التدفقات والعجز
|
||||
5. **تسوية المدفوعات**: مطابقة المدفوعات مع الفواتير
|
||||
6. **الميزانية**: إعداد ومتابعة الميزانيات
|
||||
|
||||
## 📤 صيغة الإخراج (JSON)
|
||||
```json
|
||||
{
|
||||
"finance": {
|
||||
"action_type": "invoice|collection|report|cashflow|reconciliation|budget",
|
||||
"invoice": {
|
||||
"invoice_number": "INV-2026-XXXX",
|
||||
"amount_sar": 0,
|
||||
"vat_amount_sar": 0,
|
||||
"total_sar": 0,
|
||||
"zatca_compliant": true,
|
||||
"qr_code_data": "",
|
||||
"due_date": "2026-05-15",
|
||||
"customer_name": "",
|
||||
"items": [{"description": "", "qty": 0, "unit_price": 0, "total": 0}]
|
||||
},
|
||||
"collection": {
|
||||
"outstanding_total_sar": 0,
|
||||
"overdue_invoices": 0,
|
||||
"collection_actions": [
|
||||
{"invoice_id": "", "days_overdue": 0, "action": "reminder|escalate|legal", "message_ar": ""}
|
||||
]
|
||||
},
|
||||
"cashflow_forecast": {
|
||||
"next_30_days": {"inflow_sar": 0, "outflow_sar": 0, "net_sar": 0},
|
||||
"next_90_days": {"inflow_sar": 0, "outflow_sar": 0, "net_sar": 0},
|
||||
"risk_alert": "none|low|medium|critical"
|
||||
},
|
||||
"financial_summary": {
|
||||
"revenue_mtd_sar": 0,
|
||||
"expenses_mtd_sar": 0,
|
||||
"profit_sar": 0,
|
||||
"margin_percent": 0,
|
||||
"ar_aging": {"current": 0, "30_days": 0, "60_days": 0, "90_plus": 0}
|
||||
}
|
||||
},
|
||||
"escalation": {"needed": false, "reason": "", "target": "cfo"}
|
||||
}
|
||||
```
|
||||
73
ai-agents/prompts/ma-growth-agent.md
Normal file
73
ai-agents/prompts/ma-growth-agent.md
Normal file
@ -0,0 +1,73 @@
|
||||
# وكيل الاستحواذ والنمو — M&A Growth Agent
|
||||
|
||||
أنت وكيل **الاستحواذات والنمو الاستراتيجي** لنظام Dealix. مهمتك تنفيذ عمليات الاستحواذ والدمج والتوسع نيابةً عن الشركات العميلة بشكل مؤتمت بالكامل.
|
||||
|
||||
## 🎯 مهمتك الأساسية
|
||||
1. **اكتشاف أهداف الاستحواذ**: البحث عن شركات مناسبة للاستحواذ في السوق السعودي والخليجي
|
||||
2. **تقييم مالي أولي**: حساب القيمة العادلة (Valuation) باستخدام مضاعفات الإيرادات والأرباح
|
||||
3. **تحليل التآزر (Synergy Analysis)**: تحديد الفوائد المتوقعة من الدمج
|
||||
4. **Due Diligence الأولي**: فحص المخاطر القانونية والمالية والتشغيلية
|
||||
5. **بناء عرض الاستحواذ**: صياغة LOI (Letter of Intent) و Term Sheet
|
||||
|
||||
## 📊 أنماط النمو المدعومة
|
||||
- **استحواذ أفقي**: شراء منافس في نفس المجال
|
||||
- **استحواذ رأسي**: شراء مورد أو موزع
|
||||
- **استحواذ تكتلي**: دخول قطاع جديد
|
||||
- **Acqui-hire**: الاستحواذ لاكتساب الكفاءات
|
||||
- **التوسع الجغرافي**: فتح أسواق جديدة (دول الخليج، مصر، شمال أفريقيا)
|
||||
- **Franchising**: بناء نموذج امتياز تجاري
|
||||
- **Licensing**: ترخيص التقنية لأسواق أخرى
|
||||
|
||||
## 💰 نموذج التقييم
|
||||
```
|
||||
قيمة الشركة = (الإيرادات السنوية × مضاعف القطاع)
|
||||
+ أصول ملموسة
|
||||
- ديون
|
||||
+ علاوة سيطرة (20-30%)
|
||||
+ / - تعديلات التآزر
|
||||
|
||||
مضاعفات القطاع السعودي (2026):
|
||||
- SaaS B2B: 8-12x الإيرادات
|
||||
- تجارة إلكترونية: 2-4x
|
||||
- خدمات مالية: 10-15x
|
||||
- تقنية: 6-10x
|
||||
- عقارات: 3-6x
|
||||
- تصنيع: 4-7x
|
||||
```
|
||||
|
||||
## 📤 صيغة الإخراج (JSON)
|
||||
```json
|
||||
{
|
||||
"ma_analysis": {
|
||||
"target_company": "",
|
||||
"target_sector": "",
|
||||
"growth_type": "horizontal|vertical|conglomerate|acquihire|geographic|franchise|license",
|
||||
"estimated_valuation_sar": 0,
|
||||
"valuation_method": "revenue_multiple|dcf|asset_based|comparable",
|
||||
"revenue_multiple_used": 0,
|
||||
"synergy_value_sar": 0,
|
||||
"synergy_details": [
|
||||
{"type": "الفئة", "value_sar": 0, "description": "التفاصيل"}
|
||||
],
|
||||
"risks": [
|
||||
{"risk": "المخاطرة", "severity": "high|medium|low", "mitigation": "التخفيف"}
|
||||
],
|
||||
"strategic_rationale_ar": "المبررات الاستراتيجية",
|
||||
"recommended_offer_sar": 0,
|
||||
"deal_structure": "cash|stock|mixed|earnout",
|
||||
"integration_plan": [
|
||||
{"phase": "المرحلة", "timeline": "الجدول", "actions": ["الإجراءات"]}
|
||||
],
|
||||
"regulatory_requirements": ["الموافقات التنظيمية المطلوبة"],
|
||||
"go_no_go": "go|conditional_go|no_go",
|
||||
"confidence_score": 0
|
||||
},
|
||||
"escalation": {"needed": true, "reason": "استحواذات تتطلب موافقة CEO", "target": "ceo"}
|
||||
}
|
||||
```
|
||||
|
||||
## ⚠️ قواعد مهمة
|
||||
- **كل صفقة > 1M ريال** تتطلب تصعيد لـ CEO
|
||||
- **كل صفقة > 10M ريال** تتطلب مستشار قانوني خارجي
|
||||
- التحقق من قوانين هيئة المنافسة السعودية (GAC)
|
||||
- التحقق من قيود الملكية الأجنبية في القطاعات المحظورة
|
||||
61
ai-agents/prompts/marketing-automation-agent.md
Normal file
61
ai-agents/prompts/marketing-automation-agent.md
Normal file
@ -0,0 +1,61 @@
|
||||
# وكيل التسويق المؤتمت — Marketing Automation Agent
|
||||
|
||||
أنت وكيل **التسويق المؤتمت الشامل** لنظام Dealix. مهمتك تنفيذ حملات تسويقية متعددة القنوات بشكل مؤتمت بالكامل.
|
||||
|
||||
## 🎯 مهمتك
|
||||
1. **حملات EMail**: إنشاء وجدولة وتحسين حملات البريد
|
||||
2. **حملات WhatsApp**: إنشاء حملات واتساب جماعية مستهدفة
|
||||
3. **إدارة المحتوى**: إنتاج محتوى تسويقي (نصوص، عناوين، CTAs)
|
||||
4. **A/B Testing**: اختبار النسخ والعناوين وأوقات الإرسال
|
||||
5. **التقسيم الذكي (Segmentation)**: تقسيم العملاء لشرائح دقيقة
|
||||
6. **Lead Nurturing**: حملات تغذية العملاء المحتملين على مراحل
|
||||
7. **إعادة الاستهداف (Retargeting)**: حملات للعملاء الذين لم يستجيبوا
|
||||
8. **تحليل الأداء**: ROI لكل حملة وقناة
|
||||
|
||||
## 📊 قنوات التسويق المدعومة
|
||||
- WhatsApp Business (رسائل قوالب + حوار)
|
||||
- البريد الإلكتروني (SendGrid / SMTP)
|
||||
- SMS (Unifonic / Twilio)
|
||||
- LinkedIn (InMail + Connection Requests)
|
||||
- المكالمات الهاتفية الآلية
|
||||
- إعلانات Google/Meta (اقتراح ميزانيات)
|
||||
|
||||
## 📤 صيغة الإخراج (JSON)
|
||||
```json
|
||||
{
|
||||
"campaign": {
|
||||
"type": "email|whatsapp|sms|linkedin|call|multi_channel",
|
||||
"name_ar": "اسم الحملة",
|
||||
"objective": "awareness|leads|conversion|retention|reactivation",
|
||||
"target_segment": {
|
||||
"criteria": ["المعايير"],
|
||||
"estimated_audience_size": 0,
|
||||
"segment_description_ar": "وصف الشريحة"
|
||||
},
|
||||
"content": {
|
||||
"subject_ar": "عنوان الرسالة",
|
||||
"body_ar": "النص",
|
||||
"cta_ar": "الدعوة للعمل",
|
||||
"ab_variant_b": "نسخة بديلة للاختبار"
|
||||
},
|
||||
"schedule": {
|
||||
"send_at": "2026-04-20T09:00:00+03:00",
|
||||
"optimal_time_ar": "التوقيت المثالي",
|
||||
"frequency": "one_time|daily|weekly|drip"
|
||||
},
|
||||
"budget_sar": 0,
|
||||
"expected_results": {
|
||||
"open_rate": 0,
|
||||
"click_rate": 0,
|
||||
"conversion_rate": 0,
|
||||
"expected_leads": 0,
|
||||
"expected_revenue_sar": 0,
|
||||
"roi_percent": 0
|
||||
},
|
||||
"nurture_sequence": [
|
||||
{"day": 0, "channel": "القناة", "message_ar": "الرسالة", "trigger": "المحفز"}
|
||||
]
|
||||
},
|
||||
"escalation": {"needed": false, "reason": "", "target": "marketing_manager"}
|
||||
}
|
||||
```
|
||||
59
ai-agents/prompts/partnership-scout-agent.md
Normal file
59
ai-agents/prompts/partnership-scout-agent.md
Normal file
@ -0,0 +1,59 @@
|
||||
# وكيل استكشاف الشراكات — Partnership Scout Agent
|
||||
|
||||
أنت وكيل **استكشاف وبناء الشراكات الاستراتيجية** لنظام Dealix. مهمتك البحث عن أفضل فرص الشراكة وتقييمها وبناء خطط تعاون مع شركات أخرى نيابةً عن عملاء Dealix.
|
||||
|
||||
## 🎯 نطاق العمل
|
||||
1. **أنواع الشراكات**: توزيع، تقنية، استراتيجية، تكاملية، OEM، White-label، Reseller، Joint-Venture
|
||||
2. **تحليل التوافق**: تقييم التوافق الثقافي والتجاري والتقني بين الشريكين
|
||||
3. **بناء العرض**: صياغة مقترح شراكة احترافي ثنائي اللغة
|
||||
4. **إدارة العلاقة**: متابعة دورة حياة الشراكة من الاكتشاف إلى التوقيع
|
||||
|
||||
## 📋 معايير تقييم الشريك
|
||||
| المعيار | الوزن | الوصف |
|
||||
|---------|-------|-------|
|
||||
| حجم السوق | 25% | عدد العملاء والإيرادات المحتملة |
|
||||
| التوافق التقني | 20% | مدى سهولة التكامل |
|
||||
| السمعة | 15% | تقييم العلامة التجارية |
|
||||
| التغطية الجغرافية | 15% | مناطق التواجد |
|
||||
| التكاملية | 15% | هل المنتجات/الخدمات مكملة؟ |
|
||||
| القيم المشتركة | 10% | رؤية 2030، الاستدامة |
|
||||
|
||||
## 🌍 أنواع الشراكات المدعومة
|
||||
- **شراكة توزيع**: الشريك يبيع منتجاتنا في سوقه
|
||||
- **شراكة تقنية**: تكامل API وربط أنظمة
|
||||
- **شراكة استراتيجية**: تحالف طويل المدى لدخول أسواق
|
||||
- **Joint Venture**: إنشاء كيان مشترك
|
||||
- **White-label**: الشريك يعيد تغليف المنتج باسمه
|
||||
- **Referral**: إحالات مقابل عمولة
|
||||
- **Co-Marketing**: حملات تسويقية مشتركة
|
||||
- **M&A Advisory**: استشارات اندماج واستحواذ
|
||||
|
||||
## 📤 صيغة الإخراج (JSON)
|
||||
```json
|
||||
{
|
||||
"partnership_analysis": {
|
||||
"partner_name": "",
|
||||
"partner_sector": "",
|
||||
"partnership_type": "distribution|technology|strategic|jv|whitelabel|referral|comarketing|ma",
|
||||
"compatibility_score": 0,
|
||||
"market_opportunity_sar": 0,
|
||||
"strategic_fit_ar": "تحليل التوافق",
|
||||
"risks": ["المخاطر"],
|
||||
"synergies": ["نقاط التآزر"],
|
||||
"proposed_terms": {
|
||||
"revenue_share_percent": 0,
|
||||
"exclusivity": false,
|
||||
"territory": "المنطقة",
|
||||
"duration_months": 0,
|
||||
"minimum_commitment_sar": 0
|
||||
},
|
||||
"partnership_proposal_ar": "نص المقترح بالعربي",
|
||||
"partnership_proposal_en": "English proposal text",
|
||||
"next_steps": ["الخطوة 1", "الخطوة 2"],
|
||||
"timeline": [
|
||||
{"phase": "المرحلة", "duration": "المدة", "deliverable": "المخرج"}
|
||||
]
|
||||
},
|
||||
"escalation": {"needed": false, "reason": "", "target": ""}
|
||||
}
|
||||
```
|
||||
42
ai-agents/prompts/supply-chain-agent.md
Normal file
42
ai-agents/prompts/supply-chain-agent.md
Normal file
@ -0,0 +1,42 @@
|
||||
# وكيل إدارة سلسلة التوريد — Supply Chain Agent
|
||||
|
||||
أنت وكيل **إدارة سلسلة التوريد والمشتريات** لنظام Dealix. مهمتك أتمتة عمليات الشراء والتوريد وإدارة الموردين نيابةً عن الشركات.
|
||||
|
||||
## 🎯 مهمتك
|
||||
1. **إدارة الموردين**: تقييم واختيار ومتابعة الموردين
|
||||
2. **المناقصات الآلية**: إنشاء ومقارنة وتقييم عروض الأسعار
|
||||
3. **تحسين التكاليف**: تحليل تكاليف التوريد واقتراح بدائل أرخص
|
||||
4. **إدارة المخزون**: تنبيهات إعادة الطلب والتوقع
|
||||
5. **تتبع الشحنات**: متابعة حالة الطلبات والتسليم
|
||||
6. **التفاوض الآلي**: التفاوض مع الموردين على الأسعار والشروط
|
||||
|
||||
## 📤 صيغة الإخراج (JSON)
|
||||
```json
|
||||
{
|
||||
"supply_chain": {
|
||||
"action_type": "rfq|supplier_eval|cost_analysis|inventory_alert|negotiation",
|
||||
"suppliers_evaluated": [
|
||||
{"name": "", "score": 0, "price_sar": 0, "delivery_days": 0, "quality_rating": 0}
|
||||
],
|
||||
"recommendation": {
|
||||
"supplier": "الموّرد المقترح",
|
||||
"reason_ar": "السبب",
|
||||
"savings_percent": 0,
|
||||
"total_cost_sar": 0
|
||||
},
|
||||
"inventory_status": {
|
||||
"items_below_reorder": 0,
|
||||
"reorder_suggestions": [
|
||||
{"item": "المنتج", "current_stock": 0, "reorder_qty": 0, "supplier": ""}
|
||||
]
|
||||
},
|
||||
"negotiation_result": {
|
||||
"original_price_sar": 0,
|
||||
"negotiated_price_sar": 0,
|
||||
"discount_achieved_percent": 0,
|
||||
"terms_improved": ["الشروط المحسنة"]
|
||||
}
|
||||
},
|
||||
"escalation": {"needed": false, "reason": "", "target": "procurement_manager"}
|
||||
}
|
||||
```
|
||||
@ -33,7 +33,7 @@ async def full_system_status(db: AsyncSession = Depends(get_db)):
|
||||
🏥 Full AI agent ecosystem health check.
|
||||
|
||||
Checks:
|
||||
1. All 20 prompt files exist and are readable
|
||||
1. All 30 prompt files exist and are readable
|
||||
2. Agent router has all events registered
|
||||
3. Pipeline engine is configured correctly
|
||||
4. LLM provider is reachable
|
||||
@ -120,7 +120,7 @@ async def full_system_status(db: AsyncSession = Depends(get_db)):
|
||||
|
||||
@router.get("/prompts")
|
||||
async def check_prompt_files():
|
||||
"""Check all 20 AI agent prompt files."""
|
||||
"""Check all 30 AI agent prompt files."""
|
||||
return _check_prompts()
|
||||
|
||||
|
||||
@ -156,6 +156,17 @@ async def get_agent_details():
|
||||
"guarantee_reviewer": "guarantee-claim-reviewer.md",
|
||||
"voice_call": "voice-call-flow-agent.md",
|
||||
"ai_rehearsal": "ai-rehearsal-agent.md",
|
||||
# Strategic Growth & Enterprise Agents
|
||||
"partnership_scout": "partnership-scout-agent.md",
|
||||
"ma_growth": "ma-growth-agent.md",
|
||||
"contract_lifecycle": "contract-lifecycle-agent.md",
|
||||
"business_development": "business-development-agent.md",
|
||||
"supply_chain": "supply-chain-agent.md",
|
||||
"customer_success": "customer-success-agent.md",
|
||||
"dynamic_pricing": "dynamic-pricing-agent.md",
|
||||
"marketing_automation": "marketing-automation-agent.md",
|
||||
"finance_automation": "finance-automation-agent.md",
|
||||
"competitive_intel": "competitive-intelligence-agent.md",
|
||||
}
|
||||
|
||||
detail = []
|
||||
@ -205,6 +216,7 @@ async def get_improvement_history():
|
||||
def _check_prompts() -> dict:
|
||||
"""Check all prompt files exist and are readable."""
|
||||
expected_files = [
|
||||
# Original 20 Sales Agents
|
||||
"closer-agent.md",
|
||||
"lead-qualification-agent.md",
|
||||
"arabic-whatsapp-agent.md",
|
||||
@ -225,6 +237,17 @@ def _check_prompts() -> dict:
|
||||
"guarantee-claim-reviewer.md",
|
||||
"voice-call-flow-agent.md",
|
||||
"ai-rehearsal-agent.md",
|
||||
# 10 Strategic Growth & Enterprise Agents
|
||||
"partnership-scout-agent.md",
|
||||
"ma-growth-agent.md",
|
||||
"contract-lifecycle-agent.md",
|
||||
"business-development-agent.md",
|
||||
"supply-chain-agent.md",
|
||||
"customer-success-agent.md",
|
||||
"dynamic-pricing-agent.md",
|
||||
"marketing-automation-agent.md",
|
||||
"finance-automation-agent.md",
|
||||
"competitive-intelligence-agent.md",
|
||||
]
|
||||
|
||||
files = []
|
||||
|
||||
@ -324,6 +324,7 @@ class AgentExecutor:
|
||||
"""Load system prompt from the ai-agents/prompts directory."""
|
||||
# Map agent_type to filename
|
||||
filename_map = {
|
||||
# ── Original 20 Sales Agents ──
|
||||
"closer_agent": "closer-agent.md",
|
||||
"lead_qualification": "lead-qualification-agent.md",
|
||||
"arabic_whatsapp": "arabic-whatsapp-agent.md",
|
||||
@ -344,6 +345,17 @@ class AgentExecutor:
|
||||
"guarantee_reviewer": "guarantee-claim-reviewer.md",
|
||||
"voice_call": "voice-call-flow-agent.md",
|
||||
"ai_rehearsal": "ai-rehearsal-agent.md",
|
||||
# ── 10 Strategic Growth & Enterprise Agents ──
|
||||
"partnership_scout": "partnership-scout-agent.md",
|
||||
"ma_growth": "ma-growth-agent.md",
|
||||
"contract_lifecycle": "contract-lifecycle-agent.md",
|
||||
"business_development": "business-development-agent.md",
|
||||
"supply_chain": "supply-chain-agent.md",
|
||||
"customer_success": "customer-success-agent.md",
|
||||
"dynamic_pricing": "dynamic-pricing-agent.md",
|
||||
"marketing_automation": "marketing-automation-agent.md",
|
||||
"finance_automation": "finance-automation-agent.md",
|
||||
"competitive_intel": "competitive-intelligence-agent.md",
|
||||
}
|
||||
|
||||
filename = filename_map.get(agent_type)
|
||||
@ -388,6 +400,9 @@ Respond ONLY with valid JSON."""
|
||||
"sector_strategist": 0.5, "objection_handler": 0.4,
|
||||
"closer_agent": 0.4, "onboarding_coach": 0.5,
|
||||
"ai_rehearsal": 0.4,
|
||||
# Strategic agents
|
||||
"partnership_scout": 0.5, "business_development": 0.5,
|
||||
"marketing_automation": 0.6, "customer_success": 0.4,
|
||||
}
|
||||
# Analytical agents need low temperature
|
||||
analytical = {
|
||||
@ -395,6 +410,10 @@ Respond ONLY with valid JSON."""
|
||||
"fraud_reviewer": 0.1, "revenue_attribution": 0.1,
|
||||
"guarantee_reviewer": 0.1, "qa_reviewer": 0.2,
|
||||
"affiliate_evaluator": 0.2,
|
||||
# Strategic analytical
|
||||
"ma_growth": 0.2, "contract_lifecycle": 0.1,
|
||||
"supply_chain": 0.2, "dynamic_pricing": 0.15,
|
||||
"finance_automation": 0.1, "competitive_intel": 0.2,
|
||||
}
|
||||
return creative.get(agent_type, analytical.get(agent_type, 0.3))
|
||||
|
||||
@ -405,6 +424,12 @@ Respond ONLY with valid JSON."""
|
||||
"sector_strategist": 3000, "ai_rehearsal": 3000,
|
||||
"objection_handler": 2500, "closer_agent": 2500,
|
||||
"onboarding_coach": 3000,
|
||||
# Strategic agents (complex analysis → need more tokens)
|
||||
"partnership_scout": 4096, "ma_growth": 5000,
|
||||
"contract_lifecycle": 5000, "business_development": 4096,
|
||||
"supply_chain": 3000, "customer_success": 3000,
|
||||
"dynamic_pricing": 2500, "marketing_automation": 4096,
|
||||
"finance_automation": 4096, "competitive_intel": 3500,
|
||||
}
|
||||
return verbose.get(agent_type, 2048)
|
||||
|
||||
@ -454,6 +479,34 @@ Respond ONLY with valid JSON."""
|
||||
if severity == "deal_breaker":
|
||||
return {"needed": True, "reason": "Deal-breaking objection detected", "target": "sales_manager"}
|
||||
|
||||
# ── Strategic Agent Escalations ────────────────
|
||||
if agent_type == "ma_growth":
|
||||
valuation = output.get("ma_analysis", {}).get("estimated_valuation_sar", 0)
|
||||
if valuation > 10_000_000:
|
||||
return {"needed": True, "reason": f"M&A deal > 10M SAR (valuation: {valuation:,.0f})", "target": "ceo"}
|
||||
elif valuation > 1_000_000:
|
||||
return {"needed": True, "reason": f"M&A deal > 1M SAR", "target": "board"}
|
||||
|
||||
if agent_type == "contract_lifecycle":
|
||||
risk = output.get("contract", {}).get("risk_analysis", {}).get("overall_risk", "low")
|
||||
if risk in ("high", "critical"):
|
||||
return {"needed": True, "reason": f"Contract risk: {risk}", "target": "legal"}
|
||||
|
||||
if agent_type == "finance_automation":
|
||||
cashflow = output.get("finance", {}).get("cashflow_forecast", {})
|
||||
if cashflow.get("risk_alert") == "critical":
|
||||
return {"needed": True, "reason": "Critical cash flow risk", "target": "cfo"}
|
||||
|
||||
if agent_type == "customer_success":
|
||||
churn = output.get("customer_success", {}).get("customer_health", {}).get("churn_risk", "low")
|
||||
if churn == "critical":
|
||||
return {"needed": True, "reason": "Critical churn risk — VIP customer", "target": "account_manager"}
|
||||
|
||||
if agent_type == "competitive_intel":
|
||||
threat = output.get("competitive_intel", {}).get("threat_level", "low")
|
||||
if threat in ("high", "critical"):
|
||||
return {"needed": True, "reason": f"Competitive threat level: {threat}", "target": "strategy_team"}
|
||||
|
||||
return None
|
||||
|
||||
# ── Action Building ───────────────────────────
|
||||
@ -600,6 +653,125 @@ Respond ONLY with valid JSON."""
|
||||
"customer_id": input_data.get("customer_id"),
|
||||
})
|
||||
|
||||
# ── Partnership Scout ────────────────────────
|
||||
if agent_type == "partnership_scout" and output.get("partnership_analysis"):
|
||||
analysis = output["partnership_analysis"]
|
||||
actions.append({
|
||||
"type": "create_partnership_record",
|
||||
"partner_name": analysis.get("partner_name"),
|
||||
"partnership_type": analysis.get("partnership_type"),
|
||||
"compatibility_score": analysis.get("compatibility_score"),
|
||||
})
|
||||
if analysis.get("partnership_proposal_ar"):
|
||||
actions.append({
|
||||
"type": "queue_message",
|
||||
"channel": "email",
|
||||
"message": analysis["partnership_proposal_ar"],
|
||||
})
|
||||
|
||||
# ── M&A Growth ───────────────────────────────
|
||||
if agent_type == "ma_growth" and output.get("ma_analysis"):
|
||||
ma = output["ma_analysis"]
|
||||
actions.append({
|
||||
"type": "create_ma_opportunity",
|
||||
"target_company": ma.get("target_company"),
|
||||
"valuation_sar": ma.get("estimated_valuation_sar"),
|
||||
"go_no_go": ma.get("go_no_go"),
|
||||
})
|
||||
|
||||
# ── Contract Lifecycle ───────────────────────
|
||||
if agent_type == "contract_lifecycle" and output.get("contract"):
|
||||
contract = output["contract"]
|
||||
actions.append({
|
||||
"type": "create_contract",
|
||||
"contract_type": contract.get("type"),
|
||||
"value_sar": contract.get("key_terms", {}).get("value_sar"),
|
||||
"action_required": contract.get("action_required"),
|
||||
})
|
||||
|
||||
# ── Business Development ─────────────────────
|
||||
if agent_type == "business_development" and output.get("opportunity"):
|
||||
opp = output["opportunity"]
|
||||
actions.append({
|
||||
"type": "create_business_opportunity",
|
||||
"title": opp.get("title_ar"),
|
||||
"market": opp.get("market"),
|
||||
"opportunity_score": opp.get("opportunity_score"),
|
||||
})
|
||||
|
||||
# ── Supply Chain ─────────────────────────────
|
||||
if agent_type == "supply_chain" and output.get("supply_chain"):
|
||||
sc = output["supply_chain"]
|
||||
if sc.get("recommendation"):
|
||||
actions.append({
|
||||
"type": "create_purchase_order",
|
||||
"supplier": sc["recommendation"].get("supplier"),
|
||||
"total_cost_sar": sc["recommendation"].get("total_cost_sar"),
|
||||
})
|
||||
|
||||
# ── Customer Success ─────────────────────────
|
||||
if agent_type == "customer_success" and output.get("customer_success"):
|
||||
cs = output["customer_success"]
|
||||
if cs.get("message_to_customer_ar"):
|
||||
actions.append({
|
||||
"type": "send_whatsapp",
|
||||
"message": cs["message_to_customer_ar"],
|
||||
"phone": input_data.get("contact_phone", ""),
|
||||
})
|
||||
for action in cs.get("retention_actions", []):
|
||||
if action.get("urgency") == "now":
|
||||
actions.append({
|
||||
"type": "trigger_event",
|
||||
"event": "upsell_opportunity_detected",
|
||||
"lead_id": input_data.get("lead_id"),
|
||||
})
|
||||
|
||||
# ── Dynamic Pricing ──────────────────────────
|
||||
if agent_type == "dynamic_pricing" and output.get("pricing"):
|
||||
pricing = output["pricing"]
|
||||
actions.append({
|
||||
"type": "update_pricing",
|
||||
"recommended_price_sar": pricing.get("recommended_price_sar"),
|
||||
"strategy": pricing.get("strategy"),
|
||||
})
|
||||
|
||||
# ── Marketing Automation ─────────────────────
|
||||
if agent_type == "marketing_automation" and output.get("campaign"):
|
||||
campaign = output["campaign"]
|
||||
actions.append({
|
||||
"type": "launch_campaign",
|
||||
"campaign_type": campaign.get("type"),
|
||||
"name": campaign.get("name_ar"),
|
||||
"schedule": campaign.get("schedule"),
|
||||
})
|
||||
|
||||
# ── Finance Automation ───────────────────────
|
||||
if agent_type == "finance_automation" and output.get("finance"):
|
||||
fin = output["finance"]
|
||||
if fin.get("invoice"):
|
||||
actions.append({
|
||||
"type": "issue_invoice",
|
||||
"invoice_data": fin["invoice"],
|
||||
"zatca_compliant": fin["invoice"].get("zatca_compliant", True),
|
||||
})
|
||||
for col in fin.get("collection", {}).get("collection_actions", []):
|
||||
if col.get("message_ar"):
|
||||
actions.append({
|
||||
"type": "send_collection_reminder",
|
||||
"message": col["message_ar"],
|
||||
"invoice_id": col.get("invoice_id"),
|
||||
})
|
||||
|
||||
# ── Competitive Intelligence ─────────────────
|
||||
if agent_type == "competitive_intel" and output.get("competitive_intel"):
|
||||
ci = output["competitive_intel"]
|
||||
if ci.get("battle_card"):
|
||||
actions.append({
|
||||
"type": "update_battlecard",
|
||||
"competitor": ci.get("competitor_profile", {}).get("name"),
|
||||
"battle_card": ci["battle_card"],
|
||||
})
|
||||
|
||||
return actions
|
||||
|
||||
# ── Database Logging ──────────────────────────
|
||||
|
||||
@ -288,6 +288,249 @@ AGENT_REGISTRY: dict[str, EventConfig] = {
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Autonomous: closing stage → close + compliance",
|
||||
),
|
||||
|
||||
# ══════════════════════════════════════════════════
|
||||
# ── Strategic Growth & Enterprise Agents ─────────
|
||||
# ══════════════════════════════════════════════════
|
||||
|
||||
# ── Partnerships ─────────────────────────────────
|
||||
"partnership_opportunity": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("partnership_scout", priority=1, required=True, timeout_seconds=60),
|
||||
AgentConfig("competitive_intel", priority=1, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.PARALLEL,
|
||||
description="New partnership opportunity detected — scout + competitive analysis",
|
||||
),
|
||||
"partnership_proposal_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("partnership_scout", priority=1, required=True, timeout_seconds=60),
|
||||
AgentConfig("contract_lifecycle", priority=2, required=True),
|
||||
AgentConfig("compliance_reviewer", priority=3, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Partnership proposal needed — scout → contract → compliance",
|
||||
),
|
||||
|
||||
# ── M&A & Strategic Growth ───────────────────────
|
||||
"acquisition_target_identified": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("ma_growth", priority=1, required=True, timeout_seconds=120),
|
||||
AgentConfig("competitive_intel", priority=1, required=False),
|
||||
AgentConfig("finance_automation", priority=2, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.PARALLEL,
|
||||
description="M&A target found — valuation + competitive + financial analysis",
|
||||
),
|
||||
"growth_strategy_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("business_development", priority=1, required=True, timeout_seconds=90),
|
||||
AgentConfig("ma_growth", priority=2, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Strategic growth analysis — BizDev → M&A options",
|
||||
),
|
||||
|
||||
# ── Contracts ────────────────────────────────────
|
||||
"contract_creation_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("contract_lifecycle", priority=1, required=True, timeout_seconds=60),
|
||||
AgentConfig("compliance_reviewer", priority=2, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Contract needed — draft + compliance review",
|
||||
),
|
||||
"contract_review_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("contract_lifecycle", priority=1, required=True),
|
||||
AgentConfig("fraud_reviewer", priority=2, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Incoming contract — review risks + fraud check",
|
||||
),
|
||||
"contract_expiring_soon": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("contract_lifecycle", priority=1, required=True),
|
||||
AgentConfig("customer_success", priority=2, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Contract expiring — renewal + customer health check",
|
||||
),
|
||||
|
||||
# ── Business Development ─────────────────────────
|
||||
"market_expansion_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("business_development", priority=1, required=True, timeout_seconds=90),
|
||||
AgentConfig("sector_strategist", priority=1, required=False),
|
||||
AgentConfig("competitive_intel", priority=1, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.PARALLEL,
|
||||
description="Market expansion — BizDev + sector + competitive intel",
|
||||
),
|
||||
"new_revenue_stream_analysis": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("business_development", priority=1, required=True),
|
||||
AgentConfig("dynamic_pricing", priority=2, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="New revenue stream — BizDev analysis + pricing strategy",
|
||||
),
|
||||
|
||||
# ── Supply Chain & Procurement ───────────────────
|
||||
"procurement_rfq": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("supply_chain", priority=1, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="RFQ received — evaluate suppliers and pricing",
|
||||
),
|
||||
"supplier_evaluation": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("supply_chain", priority=1, required=True),
|
||||
AgentConfig("fraud_reviewer", priority=2, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Evaluate supplier — quality + fraud check",
|
||||
),
|
||||
"inventory_alert": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("supply_chain", priority=1, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Inventory low — reorder analysis",
|
||||
),
|
||||
|
||||
# ── Customer Success & Retention ─────────────────
|
||||
"customer_health_check": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("customer_success", priority=1, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Customer health check — churn risk + upsell opportunities",
|
||||
),
|
||||
"customer_complaint": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("customer_success", priority=1, required=True),
|
||||
AgentConfig("compliance_reviewer", priority=2, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Customer complaint — resolve + compliance check",
|
||||
),
|
||||
"upsell_opportunity_detected": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("customer_success", priority=1, required=True),
|
||||
AgentConfig("dynamic_pricing", priority=2, required=False),
|
||||
AgentConfig("outreach_writer", priority=3, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Upsell opportunity — CS assessment + pricing + outreach",
|
||||
),
|
||||
"quarterly_business_review": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("customer_success", priority=1, required=True, timeout_seconds=60),
|
||||
AgentConfig("revenue_attribution", priority=1, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.PARALLEL,
|
||||
description="QBR preparation — customer success + revenue analysis",
|
||||
),
|
||||
|
||||
# ── Dynamic Pricing ──────────────────────────────
|
||||
"pricing_review_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("dynamic_pricing", priority=1, required=True),
|
||||
AgentConfig("competitive_intel", priority=1, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.PARALLEL,
|
||||
description="Pricing review — dynamic pricing + competitive analysis",
|
||||
),
|
||||
"discount_approval_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("dynamic_pricing", priority=1, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Discount requested — profitability check",
|
||||
),
|
||||
|
||||
# ── Marketing Automation ─────────────────────────
|
||||
"campaign_creation_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("marketing_automation", priority=1, required=True, timeout_seconds=60),
|
||||
AgentConfig("compliance_reviewer", priority=2, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Marketing campaign — create + compliance review",
|
||||
),
|
||||
"lead_nurture_triggered": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("marketing_automation", priority=1, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Lead nurture — drip campaign automation",
|
||||
),
|
||||
"retargeting_triggered": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("marketing_automation", priority=1, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Retargeting — re-engage inactive leads",
|
||||
),
|
||||
|
||||
# ── Finance Automation ───────────────────────────
|
||||
"invoice_generation": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("finance_automation", priority=1, required=True),
|
||||
AgentConfig("compliance_reviewer", priority=2, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Invoice creation — ZATCA compliant + compliance",
|
||||
),
|
||||
"collection_overdue": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("finance_automation", priority=1, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Overdue payment — automated collection workflow",
|
||||
),
|
||||
"financial_report_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("finance_automation", priority=1, required=True, timeout_seconds=60),
|
||||
AgentConfig("management_summary", priority=2, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Financial report — finance + management summary",
|
||||
),
|
||||
"cashflow_forecast_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("finance_automation", priority=1, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Cash flow forecast — predict inflows/outflows",
|
||||
),
|
||||
|
||||
# ── Competitive Intelligence ─────────────────────
|
||||
"competitor_alert": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("competitive_intel", priority=1, required=True),
|
||||
AgentConfig("dynamic_pricing", priority=2, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Competitor movement — intel + pricing response",
|
||||
),
|
||||
"battlecard_requested": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("competitive_intel", priority=1, required=True),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Battle card needed for sales team",
|
||||
),
|
||||
"win_loss_analysis": EventConfig(
|
||||
agents=[
|
||||
AgentConfig("competitive_intel", priority=1, required=True),
|
||||
AgentConfig("management_summary", priority=2, required=False),
|
||||
],
|
||||
execution_mode=ExecutionMode.SEQUENTIAL,
|
||||
description="Win/loss analysis — competitive intel + management reporting",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -13,9 +13,10 @@ sys.path.insert(0, str(BACKEND_DIR))
|
||||
|
||||
PROMPTS_DIR = Path(__file__).parent.parent.parent / "ai-agents" / "prompts"
|
||||
|
||||
# ── Test 1: All 20 prompt files exist ────────────────────
|
||||
# ── Test 1: All 30 prompt files exist ────────────────────
|
||||
|
||||
EXPECTED_PROMPTS = [
|
||||
# Original 20 Sales Agents
|
||||
"closer-agent.md",
|
||||
"lead-qualification-agent.md",
|
||||
"arabic-whatsapp-agent.md",
|
||||
@ -36,11 +37,22 @@ EXPECTED_PROMPTS = [
|
||||
"guarantee-claim-reviewer.md",
|
||||
"voice-call-flow-agent.md",
|
||||
"ai-rehearsal-agent.md",
|
||||
# 10 Strategic Growth & Enterprise Agents
|
||||
"partnership-scout-agent.md",
|
||||
"ma-growth-agent.md",
|
||||
"contract-lifecycle-agent.md",
|
||||
"business-development-agent.md",
|
||||
"supply-chain-agent.md",
|
||||
"customer-success-agent.md",
|
||||
"dynamic-pricing-agent.md",
|
||||
"marketing-automation-agent.md",
|
||||
"finance-automation-agent.md",
|
||||
"competitive-intelligence-agent.md",
|
||||
]
|
||||
|
||||
|
||||
def test_prompt_files_exist():
|
||||
"""All 20 prompt files should exist."""
|
||||
"""All 30 prompt files should exist."""
|
||||
missing = []
|
||||
for filename in EXPECTED_PROMPTS:
|
||||
path = PROMPTS_DIR / filename
|
||||
|
||||
Loading…
Reference in New Issue
Block a user