{ "project_name": "Web3CyberAgent", "metadata": { "version": "2.1.0", "environment": "Hybrid Kernel Architecture (FastAPI + Dynamic Exec)", "target_platform": "FastAPI Asynchronous Webhook Container" }, "strict_rules": { "imports": { "local_scope_only": true, "reason": "Prevent NameError and memory leaks during dynamic kernel execution via exec() in index.py. All modules must be imported inside the function body.", "forbidden_packages": [ "groq", "openai", "telethon", "pyrogram" ], "forbidden_packages_reason": "External SDKs maintain persistent socket connections that break or hang under dynamic exec() context. Use raw HTTP protocols instead.", "preferred_packages": { "httpx": "Mandatory for all asynchronous core operations and external API integrations. Ensures zero event loop blocking.", "requests": "Allowed strictly inside synchronous isolated child contexts or legacy dynamic exec() statements where loop management is absent.", "json": "Used for payload serialization.", "os": "Used for secure environment variables extraction." } }, "async_concurrency": { "safe_fastapi_loop": "Always wrap asynchronous user_client (Telethon) operations inside sync functions strictly using this isolated block: loop = asyncio.new_event_loop(); try: result = loop.run_until_complete(...); finally: loop.close(). This prevents Event Loop cross-contamination in the FastAPI main thread." }, "dynamic_execution_security": { "injection_protection": "Never allow unverified raw user strings to modify Python statements. Enforce strict type casting (e.g., int(chat_id)) and strip control characters to mitigate remote code execution (RCE).", "memory_isolated_scope": "Ensure all internal local variables are cleanly written and do not pollute the global dictionary namespace of the exec() supervisor." }, "error_handling": { "http_failover": "Implement a mandatory fallback loop over the models array (llama-3.3-70b-versatile -> llama-3.1-70b-versatile -> llama-3.1-8b-instant -> mixtral-8x7b-32768) to dynamically handle HTTP 404, 429, or 503 errors without crashing the webhook container.", "timeouts": "Enforce strict HTTP timeouts: max 3 seconds for Telegram chat meta-data, max 15 seconds for Groq LLM inference, and max 20 seconds for Telegram outbound messages.", "logs": "Never expose raw Python tracebacks to the end-user. Catch all exceptions inside try-except blocks and return formatted technical diagnostic strings prefixed with error emoji." }, "persona": { "system_prompt_requirement": "Strictly include inside the system role: 'Ты — Cyber-Agent, высокотехнологичный ИИ-помощник, разработанный в рамках контура Web3CyberServices. Твоя задача — помогать разработчику в OSINT и автоматизации. Обращайся к пользователю естественно, по имени (user_name). Строго запрещено использовать любые устаревшие официальные титулы, приставки или обращения вроде Господин или Gospodin.'", "formatting": "Always return outputs using clean, well-formed Markdown syntax. Ensure all asterisks and underscores are properly paired to avoid parsing errors on the Telegram edge. Never use nested formatting inside code blocks." } } }