mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-06 05:17:15 +00:00
browser_vault reached pages only through the task's CDP supervisor. Camofox (now a plugin) has no CDP endpoint, so every fill on a Camofox tab ended with "Could not determine the current page origin": the username from browser_vault list worked, the password never filled. ctx.register_browser_page_backend lets a plugin browser carry the vault's origin read, form inspection and fill script to its own page. Core keeps the secret contract: the exact-origin pre-check and in-page re-check, the Bot Desktop takeover check, an in-page try/catch around the secret script, and fixed failure text on that path. Registration follows the login-backend provenance rule (bundled, or catalog verified/official at its pin) and is refused under plugins.isolation: host. Consolidates the core half of #127179 and #135204 (the Camofox halves already shipped in the official plugin); the in-page wrapper follows #114414. Co-authored-by: Jonathan Bruce <jonathan.bruce369@gmail.com> Co-authored-by: clsferguson <cferguson@live.ca> Co-authored-by: Benjamin PERRY <benjaminperry6@yahoo.fr>
30 lines
1.1 KiB
Python
30 lines
1.1 KiB
Python
"""Browser page backends registered by plugins via :meth:`PluginContext.register_browser_page_backend`,
|
|
consumed by ``tools.browser_vault_tool``. The backend holding the task's live page wins over the CDP
|
|
session; with none, the vault uses the CDP supervisor as before."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import logging
|
|
from typing import Optional
|
|
|
|
from agent.browser_page_backend import BrowserPageBackend
|
|
from agent.provider_registry import ProviderRegistry
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
_registry: ProviderRegistry[BrowserPageBackend] = ProviderRegistry(
|
|
label="Browser page backend", provider_cls=BrowserPageBackend, logger=logger,
|
|
)
|
|
_registry.export(globals())
|
|
|
|
|
|
def backend_for_task(task_id: str) -> Optional[BrowserPageBackend]:
|
|
"""The registered backend holding ``task_id``'s live page, or ``None``."""
|
|
for backend in _registry.list_providers():
|
|
try:
|
|
if backend.has_page(task_id):
|
|
return backend
|
|
except Exception as exc: # health: allow BLE001 -- a probing failure means "no page here"
|
|
logger.debug("browser page backend %s.has_page raised %s", backend.name, exc)
|
|
return None
|