AI Update: {label}: {tool_name} {tool_emoji} ({action}) ↳ {target}
This commit is contained in:
@@ -218,86 +218,79 @@ def format_tool_call(tool_name: str, tool_args: Any, lang: str = "fa") -> str:
|
||||
# Tool specific highlights
|
||||
if tool_name == "run_command":
|
||||
cmd = params.get("CommandLine", "")
|
||||
target = f"💻 <code>{escape_html(cmd[:120])}</code>" if cmd else ""
|
||||
elif tool_name == "write_to_file":
|
||||
target = escape_html(cmd[:120]) if cmd else ""
|
||||
elif tool_name in ("write_to_file", "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:
|
||||
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>"
|
||||
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 in ("view_file", "view_image"):
|
||||
file_p = params.get("AbsolutePath", "")
|
||||
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":
|
||||
dir_p = params.get("DirectoryPath", "")
|
||||
if dir_p:
|
||||
target = f"📂 <code>{escape_html(dir_p[:80])}</code>"
|
||||
target = escape_html(dir_p[:80])
|
||||
elif tool_name == "grep_search":
|
||||
q = params.get("Query", "")
|
||||
if q:
|
||||
target = f"🔍 <code>{escape_html(q[:80])}</code>"
|
||||
target = escape_html(q[:80])
|
||||
elif tool_name == "find_by_name":
|
||||
pat = params.get("Pattern", "")
|
||||
if pat:
|
||||
target = f"📁 <code>{escape_html(pat[:80])}</code>"
|
||||
target = escape_html(pat[:80])
|
||||
elif tool_name == "search_web":
|
||||
q = params.get("query", "")
|
||||
if q:
|
||||
target = f"🌐 <code>{escape_html(q[:80])}</code>"
|
||||
target = escape_html(q[:80])
|
||||
elif tool_name == "read_url_content":
|
||||
u = params.get("Url", "")
|
||||
if u:
|
||||
target = f"🔗 <code>{escape_html(u[:80])}</code>"
|
||||
target = escape_html(u[:80])
|
||||
elif tool_name == "generate_image":
|
||||
p = params.get("Prompt", "")
|
||||
if p:
|
||||
target = f"🎨 <code>{escape_html(p[:80])}</code>"
|
||||
target = escape_html(p[:80])
|
||||
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>"
|
||||
target = escape_html(str(timing)[:80])
|
||||
elif tool_name == "manage_task":
|
||||
act = params.get("Action", "")
|
||||
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":
|
||||
subagents = params.get("Subagents", [])
|
||||
roles = [s.get("Role", s.get("TypeName", "Agent")) for s in subagents if isinstance(s, dict)]
|
||||
if roles:
|
||||
target = f"🤖 <code>{escape_html(', '.join(roles)[:80])}</code>"
|
||||
target = escape_html(", ".join(roles)[:80])
|
||||
elif tool_name == "define_subagent":
|
||||
name = params.get("name", "")
|
||||
if name:
|
||||
target = f"🧠 <code>{escape_html(name[:80])}</code>"
|
||||
target = escape_html(name[:80])
|
||||
elif tool_name == "manage_subagents":
|
||||
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":
|
||||
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":
|
||||
target = "❓ <code>درخواست تایید / سوال</code>"
|
||||
target = "درخواست تایید / سوال"
|
||||
|
||||
if not action and not target and isinstance(tool_args, str) and tool_args.strip():
|
||||
# Fallback short string preview
|
||||
short_args = tool_args.strip().replace("\n", " ")
|
||||
if len(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 ""
|
||||
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:
|
||||
out += f"\n ↳ {target}"
|
||||
out += f"\n ↳ <code>{target}</code>"
|
||||
return out + "\n"
|
||||
|
||||
def markdown_to_telegram_html(text: str) -> str:
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user