mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-30 11:52:04 +00:00
fix: redact browser typed text surfaces
This commit is contained in:
parent
5add283ec8
commit
8ff426e53b
8 changed files with 272 additions and 25 deletions
|
|
@ -2758,19 +2758,34 @@ def browser_type(ref: str, text: str, task_id: Optional[str] = None) -> str:
|
|||
# Use fill command (clears then types)
|
||||
result = _run_browser_command(effective_task_id, "fill", [ref, text])
|
||||
|
||||
from agent.display import (
|
||||
redact_browser_typed_text_for_display,
|
||||
redact_tool_args_for_display,
|
||||
)
|
||||
|
||||
display_text = (redact_tool_args_for_display("browser_type", {"text": text}) or {})["text"]
|
||||
|
||||
if result.get("success"):
|
||||
response = {
|
||||
"success": True,
|
||||
"typed": text,
|
||||
# Never echo raw typed text back to tool progress/log surfaces: it
|
||||
# is commonly a password, API key, or other credential. Redact
|
||||
# only the returned display value; the original text was already
|
||||
# sent to the browser command above.
|
||||
"typed": display_text,
|
||||
"element": ref
|
||||
}
|
||||
return json.dumps(_copy_fallback_warning(response, result), ensure_ascii=False)
|
||||
response = _copy_fallback_warning(response, result)
|
||||
response = redact_browser_typed_text_for_display(response, text)
|
||||
return json.dumps(response, ensure_ascii=False)
|
||||
else:
|
||||
response = {
|
||||
"success": False,
|
||||
"error": result.get("error", f"Failed to type into {ref}")
|
||||
}
|
||||
return json.dumps(_copy_fallback_warning(response, result), ensure_ascii=False)
|
||||
response = _copy_fallback_warning(response, result)
|
||||
response = redact_browser_typed_text_for_display(response, text)
|
||||
return json.dumps(response, ensure_ascii=False)
|
||||
|
||||
|
||||
def browser_scroll(direction: str, task_id: Optional[str] = None) -> str:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue