* refactor(plugins): remove the Sep 2026 decomposition compat layer on schedule The PLUGIN-COMPAT layer (2776813df3+d63e380324+0a5164cebe) kept pre-#102117 import paths alive for external plugins until 2026-09-14. That window closed two weeks ago; since then the loader has already been skipping plugins that use the old paths. This removes the layer itself: - 328 appended `PLUGIN-COMPAT` blocks (lazy `__getattr__` pointer tables, re-exported third-party names, restored dead definitions) and the three re-export stub modules (gateway/startup_watchdog, hermes_cli/observability/relay_runtime, tools/environments/modal_utils) - COMPAT_MANIFEST.md, compat_manifest.json, scripts/check_compat_pointers.py and its lint step - the reporting surfaces: CLI banner notice, `hermes plugins compat`, the `hermes doctor` section, the post-update notice, the Desktop one-time dialog, the loader's pre-import skip and the `plugins.allow_deprecated_imports` escape hatch An external plugin that still imports an old path now fails to load with its ImportError as the reason in `hermes plugins list`, the same path as any broken plugin. hermes_cli/plugin_compat.py stays as three inert stubs (compat_report, removal_in_effect, summary_lines): an already-running pre-removal `hermes update` lazy-imports them after the checkout swap (tests/compat/old_updater_surface.json). In-tree fallout, both already dead: hermes_cli/setup.py::_check_espeak_ng (no callers; its `shutil` came from a compat block) and gateway/config.py::SessionResetPolicy ("retained solely for the scheduled plugin-compat window"). Two test_run_agent patches targeted the removed `run_agent.handle_function_call` pointer; they now patch `model_tools.handle_function_call`, the seam production reads, like every sibling test in that file. * chore: retrigger CI (zero-job startup_failure phantom) * test: drop resolution allowlist rows for the two deleted which() sites hermes_cli/setup.py::_check_espeak_ng (dead) and tools/skillevaluator_scan.py::scanner_available (a restored definition inside a PLUGIN-COMPAT block) no longer exist; the stale-row gate requires their allowlist entries go with them.
110 lines
4.5 KiB
Python
110 lines
4.5 KiB
Python
"""Agent-facing tool: respond to a native JS dialog captured by the CDP supervisor.
|
|
|
|
Response-only: the agent reads ``pending_dialogs`` from ``browser_snapshot``,
|
|
then calls ``browser_dialog(action=...)``. Gated on ``_browser_cdp_check`` so it
|
|
appears together with ``browser_cdp``. Design: ``website/docs/developer-guide/browser-supervisor.md``.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
from typing import Any, Dict, Optional
|
|
|
|
from tools.browser_supervisor import SUPERVISOR_REGISTRY
|
|
from tools.registry import registry
|
|
|
|
BROWSER_DIALOG_SCHEMA: Dict[str, Any] = {
|
|
"name": "browser_dialog",
|
|
"description": (
|
|
"Respond to a native JavaScript dialog (alert / confirm / prompt / "
|
|
"beforeunload) that is currently blocking the page.\n\n"
|
|
"**Workflow:** call ``browser_snapshot`` first — if a dialog is open, "
|
|
"it appears in the ``pending_dialogs`` field with ``id``, ``type``, "
|
|
"and ``message``. Then call this tool with ``action='accept'`` or "
|
|
"``action='dismiss'``.\n\n"
|
|
"**Prompt dialogs:** pass ``prompt_text`` to supply the response "
|
|
"string. Ignored for alert/confirm/beforeunload.\n\n"
|
|
"**Multiple dialogs:** if more than one dialog is queued (rare — "
|
|
"happens when a second dialog fires while the first is still open), "
|
|
"pass ``dialog_id`` from the snapshot to disambiguate.\n\n"
|
|
"**Availability:** only present when a CDP-capable backend is "
|
|
"attached — Browserbase sessions, local Chromium-family browser via "
|
|
"``/browser connect``, or ``browser.cdp_url`` in config.yaml. "
|
|
"Not available on Camofox (REST-only) or the default Playwright "
|
|
"local browser (CDP port is hidden)."
|
|
),
|
|
"parameters": {
|
|
"type": "object",
|
|
"properties": {
|
|
"action": {
|
|
"type": "string",
|
|
"enum": ["accept", "dismiss"],
|
|
"description": (
|
|
"'accept' clicks OK / returns the prompt text. "
|
|
"'dismiss' clicks Cancel / returns null from prompt(). "
|
|
"For ``beforeunload`` dialogs: 'accept' allows the "
|
|
"navigation, 'dismiss' keeps the page."
|
|
),
|
|
},
|
|
"prompt_text": {
|
|
"type": "string",
|
|
"description": (
|
|
"Response string for a ``prompt()`` dialog. Ignored for "
|
|
"other dialog types. Defaults to empty string."
|
|
),
|
|
},
|
|
"dialog_id": {
|
|
"type": "string",
|
|
"description": (
|
|
"Specific dialog to respond to, from "
|
|
"``browser_snapshot.pending_dialogs[].id``. Required "
|
|
"only when multiple dialogs are queued."
|
|
),
|
|
},
|
|
},
|
|
"required": ["action"],
|
|
},
|
|
}
|
|
|
|
|
|
def browser_dialog(
|
|
action: str,
|
|
prompt_text: Optional[str] = None,
|
|
dialog_id: Optional[str] = None,
|
|
task_id: Optional[str] = None,
|
|
) -> str:
|
|
"""Respond to a pending dialog on the active task's CDP supervisor."""
|
|
supervisor = SUPERVISOR_REGISTRY.get(task_id or "default")
|
|
if supervisor is None:
|
|
return json.dumps({
|
|
"success": False,
|
|
"error": (
|
|
"No CDP supervisor is attached to this task. Either the "
|
|
"browser backend doesn't expose CDP (Camofox, default "
|
|
"Playwright) or no browser session has been started yet. "
|
|
"Call browser_navigate or /browser connect first."
|
|
),
|
|
})
|
|
result = supervisor.respond_to_dialog(action=action, prompt_text=prompt_text, dialog_id=dialog_id)
|
|
if result.get("ok"):
|
|
return json.dumps({"success": True, "action": action, "dialog": result.get("dialog", {})})
|
|
return json.dumps({"success": False, "error": result.get("error", "unknown error")})
|
|
|
|
|
|
def _browser_dialog_check() -> bool:
|
|
"""Gate: same as ``browser_cdp`` so the two tools appear/disappear together."""
|
|
from tools.browser_cdp_tool import _browser_cdp_check
|
|
|
|
return _browser_cdp_check()
|
|
|
|
|
|
registry.register(
|
|
name="browser_dialog",
|
|
toolset="browser-cdp",
|
|
schema=BROWSER_DIALOG_SCHEMA,
|
|
handler=lambda args, **kw: browser_dialog(action=args.get("action", ""), prompt_text=args.get("prompt_text"),
|
|
dialog_id=args.get("dialog_id"), task_id=kw.get("task_id")),
|
|
check_fn=_browser_dialog_check,
|
|
emoji="💬",
|
|
)
|