AI Update: {label}: {tool_name} {tool_emoji} ({action}) ↳ {target}

This commit is contained in:
Antigravity Bot
2026-08-30 16:54:28 +03:30
parent 82089f74af
commit 463908dd1b
2 changed files with 28 additions and 35 deletions
+20 -27
View File
@@ -218,86 +218,79 @@ 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 = escape_html(cmd[:120]) if cmd else ""
elif tool_name == "write_to_file": elif tool_name in ("write_to_file", "replace_file_content"):
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 = escape_html(Path(file_p).name if "/" in file_p else file_p)
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 = escape_html(Path(file_p).name if "/" in file_p else file_p)
elif tool_name == "list_dir": elif tool_name == "list_dir":
dir_p = params.get("DirectoryPath", "") dir_p = params.get("DirectoryPath", "")
if dir_p: if dir_p:
target = f"📂 <code>{escape_html(dir_p[:80])}</code>" target = escape_html(dir_p[:80])
elif tool_name == "grep_search": elif tool_name == "grep_search":
q = params.get("Query", "") q = params.get("Query", "")
if q: if q:
target = f"🔍 <code>{escape_html(q[:80])}</code>" target = escape_html(q[:80])
elif tool_name == "find_by_name": elif tool_name == "find_by_name":
pat = params.get("Pattern", "") pat = params.get("Pattern", "")
if pat: if pat:
target = f"📁 <code>{escape_html(pat[:80])}</code>" target = escape_html(pat[:80])
elif tool_name == "search_web": elif tool_name == "search_web":
q = params.get("query", "") q = params.get("query", "")
if q: if q:
target = f"🌐 <code>{escape_html(q[:80])}</code>" target = escape_html(q[:80])
elif tool_name == "read_url_content": elif tool_name == "read_url_content":
u = params.get("Url", "") u = params.get("Url", "")
if u: if u:
target = f"🔗 <code>{escape_html(u[:80])}</code>" target = escape_html(u[:80])
elif tool_name == "generate_image": elif tool_name == "generate_image":
p = params.get("Prompt", "") p = params.get("Prompt", "")
if p: if p:
target = f"🎨 <code>{escape_html(p[:80])}</code>" target = escape_html(p[:80])
elif tool_name == "schedule": elif tool_name == "schedule":
timing = params.get("CronExpression") or (f"{params.get('DurationSeconds')}s" if params.get("DurationSeconds") else "") or params.get("Prompt", "") timing = params.get("CronExpression") or (f"{params.get('DurationSeconds')}s" if params.get("DurationSeconds") else "") or params.get("Prompt", "")
if timing: if timing:
target = f"⏰ <code>{escape_html(str(timing)[:80])}</code>" target = escape_html(str(timing)[:80])
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", "")
target = f"⚙️ <code>{escape_html(act)} {escape_html(tid)}</code>" target = f"{escape_html(act)} {escape_html(tid)}".strip()
elif tool_name == "invoke_subagent": elif tool_name == "invoke_subagent":
subagents = params.get("Subagents", []) subagents = params.get("Subagents", [])
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 = escape_html(", ".join(roles)[:80])
elif tool_name == "define_subagent": elif tool_name == "define_subagent":
name = params.get("name", "") name = params.get("name", "")
if name: if name:
target = f"🧠 <code>{escape_html(name[:80])}</code>" target = escape_html(name[:80])
elif tool_name == "manage_subagents": elif tool_name == "manage_subagents":
act = params.get("Action", "") act = params.get("Action", "")
target = f"👥 <code>{escape_html(act)}</code>" if act else "" target = escape_html(act) if act else ""
elif tool_name == "send_message": elif tool_name == "send_message":
msg = params.get("Message", "") msg = params.get("Message", "")
target = f"💬 <code>{escape_html(msg[:80])}</code>" if msg else "" target = escape_html(msg[:80]) if msg else ""
elif tool_name == "ask_question": elif tool_name == "ask_question":
target = "❓ <code>درخواست تایید / سوال</code>" target = "درخواست تایید / سوال"
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
short_args = tool_args.strip().replace("\n", " ") short_args = tool_args.strip().replace("\n", " ")
if len(short_args) > 100: if len(short_args) > 100:
short_args = short_args[:100] + "..." short_args = short_args[:100] + "..."
target = f"<code>{escape_html(short_args)}</code>" target = escape_html(short_args)
action_text = f" ({escape_html(action)})" if action else "" action_text = f" ({escape_html(action)})" if action else ""
out = f"{tool_emoji} <b>{label}:</b> <code>{escape_html(tool_name)}</code>{action_text}" out = f"<b>{label}:</b> <code>{escape_html(tool_name)} {tool_emoji}</code>{action_text}"
if target: if target:
out += f"\n{target}" out += f"\n<code>{target}</code>"
return out + "\n" return out + "\n"
def markdown_to_telegram_html(text: str) -> str: def markdown_to_telegram_html(text: str) -> str:
File diff suppressed because one or more lines are too long