AI Update: این متن رو ببین که برام فرستادی 📜 مدیریت و تاریخچه گفتگوها (

This commit is contained in:
Antigravity Bot
2026-08-30 16:49:39 +03:30
parent 2a8669fb90
commit 1d0c2e25d8
3 changed files with 84 additions and 24 deletions
Binary file not shown.
+65 -8
View File
@@ -172,10 +172,32 @@ def format_thought(
header = "💭 <b>تفکر و استدلال:</b>" if is_fa else "💭 <b>Reasoning / Thinking:</b>" header = "💭 <b>تفکر و استدلال:</b>" if is_fa else "💭 <b>Reasoning / Thinking:</b>"
return f"<blockquote expandable>{header}\n{escaped}</blockquote>\n" return f"<blockquote expandable>{header}\n{escaped}</blockquote>\n"
TOOL_EMOJI_MAP: Dict[str, str] = {
"run_command": "💻",
"manage_task": "⚙️",
"view_file": "👁️",
"view_image": "👁️",
"replace_file_content": "✏️",
"write_to_file": "📝",
"list_dir": "📂",
"grep_search": "🔍",
"find_by_name": "📁",
"search_web": "🌐",
"read_url_content": "🔗",
"generate_image": "🎨",
"schedule": "",
"invoke_subagent": "🤖",
"define_subagent": "🧠",
"manage_subagents": "👥",
"send_message": "💬",
"ask_question": "",
}
def format_tool_call(tool_name: str, tool_args: Any, lang: str = "fa") -> str: def format_tool_call(tool_name: str, tool_args: Any, lang: str = "fa") -> str:
"""Formats an active tool execution notification into a clean, concise badge.""" """Formats an active tool execution notification into a clean, concise badge."""
is_fa = (lang or "").lower() in ("fa", "farsi", "persian", "🇮🇷 persian / farsi (فارسی)") is_fa = (lang or "").lower() in ("fa", "farsi", "persian", "🇮🇷 persian / farsi (فارسی)")
label = "ابزار" if is_fa else "Tool" label = "ابزار" if is_fa else "Tool"
tool_emoji = TOOL_EMOJI_MAP.get(tool_name, "🔧")
# Parse tool arguments if passed as JSON string or dict # Parse tool arguments if passed as JSON string or dict
params = {} params = {}
@@ -196,18 +218,29 @@ def format_tool_call(tool_name: str, tool_args: Any, lang: str = "fa") -> str:
# Tool specific highlights # Tool specific highlights
if tool_name == "run_command": if tool_name == "run_command":
cmd = params.get("CommandLine", "") cmd = params.get("CommandLine", "")
target = f"<code>{escape_html(cmd[:120])}</code>" if cmd else "" target = f"💻 <code>{escape_html(cmd[:120])}</code>" if cmd else ""
elif tool_name in ("write_to_file", "replace_file_content"): elif tool_name == "write_to_file":
file_p = params.get("TargetFile", "") file_p = params.get("TargetFile", "")
instr = params.get("Instruction", "") instr = params.get("Instruction", "")
if file_p: if file_p:
target = f"📄 <code>{escape_html(Path(file_p).name if '/' in file_p else file_p)}</code>" target = f"📝 <code>{escape_html(Path(file_p).name if '/' in file_p else file_p)}</code>"
if instr and not action:
action = instr[:100]
elif tool_name == "replace_file_content":
file_p = params.get("TargetFile", "")
instr = params.get("Instruction", "")
if file_p:
target = f"✏️ <code>{escape_html(Path(file_p).name if '/' in file_p else file_p)}</code>"
if instr and not action: if instr and not action:
action = instr[:100] action = instr[:100]
elif tool_name in ("view_file", "view_image"): elif tool_name in ("view_file", "view_image"):
file_p = params.get("AbsolutePath", "") file_p = params.get("AbsolutePath", "")
if file_p: if file_p:
target = f"🔍 <code>{escape_html(Path(file_p).name if '/' in file_p else file_p)}</code>" target = f"👁️ <code>{escape_html(Path(file_p).name if '/' in file_p else file_p)}</code>"
elif tool_name == "list_dir":
dir_p = params.get("DirectoryPath", "")
if dir_p:
target = f"📂 <code>{escape_html(dir_p[:80])}</code>"
elif tool_name == "grep_search": elif tool_name == "grep_search":
q = params.get("Query", "") q = params.get("Query", "")
if q: if q:
@@ -216,10 +249,22 @@ def format_tool_call(tool_name: str, tool_args: Any, lang: str = "fa") -> str:
pat = params.get("Pattern", "") pat = params.get("Pattern", "")
if pat: if pat:
target = f"📁 <code>{escape_html(pat[:80])}</code>" target = f"📁 <code>{escape_html(pat[:80])}</code>"
elif tool_name in ("read_url_content", "search_web"): elif tool_name == "search_web":
u = params.get("Url") or params.get("query", "") q = params.get("query", "")
if q:
target = f"🌐 <code>{escape_html(q[:80])}</code>"
elif tool_name == "read_url_content":
u = params.get("Url", "")
if u: if u:
target = f"🌐 <code>{escape_html(u[:80])}</code>" target = f"🔗 <code>{escape_html(u[:80])}</code>"
elif tool_name == "generate_image":
p = params.get("Prompt", "")
if p:
target = f"🎨 <code>{escape_html(p[:80])}</code>"
elif tool_name == "schedule":
timing = params.get("CronExpression") or (f"{params.get('DurationSeconds')}s" if params.get("DurationSeconds") else "") or params.get("Prompt", "")
if timing:
target = f"⏰ <code>{escape_html(str(timing)[:80])}</code>"
elif tool_name == "manage_task": elif tool_name == "manage_task":
act = params.get("Action", "") act = params.get("Action", "")
tid = params.get("TaskId", "") tid = params.get("TaskId", "")
@@ -229,6 +274,18 @@ def format_tool_call(tool_name: str, tool_args: Any, lang: str = "fa") -> str:
roles = [s.get("Role", s.get("TypeName", "Agent")) for s in subagents if isinstance(s, dict)] roles = [s.get("Role", s.get("TypeName", "Agent")) for s in subagents if isinstance(s, dict)]
if roles: if roles:
target = f"🤖 <code>{escape_html(', '.join(roles)[:80])}</code>" target = f"🤖 <code>{escape_html(', '.join(roles)[:80])}</code>"
elif tool_name == "define_subagent":
name = params.get("name", "")
if name:
target = f"🧠 <code>{escape_html(name[:80])}</code>"
elif tool_name == "manage_subagents":
act = params.get("Action", "")
target = f"👥 <code>{escape_html(act)}</code>" if act else ""
elif tool_name == "send_message":
msg = params.get("Message", "")
target = f"💬 <code>{escape_html(msg[:80])}</code>" if msg else ""
elif tool_name == "ask_question":
target = "❓ <code>درخواست تایید / سوال</code>"
if not action and not target and isinstance(tool_args, str) and tool_args.strip(): if not action and not target and isinstance(tool_args, str) and tool_args.strip():
# Fallback short string preview # Fallback short string preview
@@ -238,7 +295,7 @@ def format_tool_call(tool_name: str, tool_args: Any, lang: str = "fa") -> str:
target = f"<code>{escape_html(short_args)}</code>" target = f"<code>{escape_html(short_args)}</code>"
action_text = f" ({escape_html(action)})" if action else "" action_text = f" ({escape_html(action)})" if action else ""
out = f"🔧 <b>{label}:</b> <code>{escape_html(tool_name)}</code>{action_text}" out = f"{tool_emoji} <b>{label}:</b> <code>{escape_html(tool_name)}</code>{action_text}"
if target: if target:
out += f"\n{target}" out += f"\n{target}"
return out + "\n" return out + "\n"
File diff suppressed because one or more lines are too long