mirror of
https://github.com/x1xhlol/system-prompts-and-models-of-ai-tools.git
synced 2026-06-17 23:09:35 +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>
87 lines
2.8 KiB
Python
87 lines
2.8 KiB
Python
"""Competitive Move Detector — analyze competitor activity → suggest action."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
|
|
MOVE_TYPES: tuple[str, ...] = (
|
|
"price_change",
|
|
"new_offer",
|
|
"hiring",
|
|
"event",
|
|
"content_campaign",
|
|
"rebrand",
|
|
"funding",
|
|
"expansion",
|
|
)
|
|
|
|
|
|
def analyze_competitive_move(
|
|
*,
|
|
competitor_name: str,
|
|
move_type: str,
|
|
payload: dict[str, Any] | None = None,
|
|
) -> dict[str, Any]:
|
|
"""
|
|
Take one observed competitor signal → return Arabic recommended action.
|
|
|
|
Pure deterministic; no live competitor scraping.
|
|
"""
|
|
p = payload or {}
|
|
if move_type not in MOVE_TYPES:
|
|
return {
|
|
"error": f"unknown move_type: {move_type}",
|
|
"valid_types": list(MOVE_TYPES),
|
|
}
|
|
|
|
if move_type == "price_change":
|
|
delta_pct = float(p.get("price_delta_pct", -10))
|
|
action_ar = (
|
|
"حملة مضادة + ROI breakdown مقارن — لا تخفّض السعر."
|
|
if delta_pct < 0 else
|
|
"ميزة تنافسية: عرضنا أرخص — اطلق ROI proof."
|
|
)
|
|
urgency = "high" if abs(delta_pct) >= 15 else "medium"
|
|
elif move_type == "new_offer":
|
|
action_ar = (
|
|
"حلّل العرض الجديد + اقتباس مزاياك المختلفة + offer comparison."
|
|
)
|
|
urgency = "medium"
|
|
elif move_type == "hiring":
|
|
action_ar = (
|
|
"إشارة توسع — استهدف نفس عملائهم بعرضك المختلف."
|
|
)
|
|
urgency = "low"
|
|
elif move_type == "event":
|
|
action_ar = (
|
|
"حضّر أنت محتوى/ندوة في نفس الفترة — استفد من اهتمام السوق."
|
|
)
|
|
urgency = "medium"
|
|
elif move_type == "content_campaign":
|
|
action_ar = (
|
|
"اقرأ زاويتهم + اطلق رد منشور / dialog بحجة مدعومة بأرقام."
|
|
)
|
|
urgency = "low"
|
|
elif move_type == "rebrand":
|
|
action_ar = "احتفظ بهويتك — أعلن استمرار وعدك للعملاء."
|
|
urgency = "low"
|
|
elif move_type == "funding":
|
|
action_ar = (
|
|
"إشارة سرعة في السوق — ركّز على retention + speed-to-value."
|
|
)
|
|
urgency = "medium"
|
|
else: # expansion
|
|
action_ar = "نبّه فريق المبيعات + رسالة احتفاظ للعملاء الكبار."
|
|
urgency = "medium"
|
|
|
|
return {
|
|
"competitor_name": competitor_name,
|
|
"move_type": move_type,
|
|
"urgency": urgency,
|
|
"recommended_action_ar": action_ar,
|
|
"next_step_ar": "جهّز draft رد + موافقة المشغّل قبل الإطلاق.",
|
|
"approval_required": True,
|
|
"payload_received": p,
|
|
}
|