hermes-web-provider-plugin
Use when building a Hermes web-search provider plugin.
- License 许可
- MIT
- 最近更新
- 2026-10-20
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- hermes-web-provider-plugin
- author
- Masia
- license
- MIT
- version
- 1.1.0
- metadata
- { "hermes": { "tags": [ "hermes", "plugins", "web-search", "camofox", "provider" ], "related_skills": [ "hermes-agent", "authoring-hermes-skills", "safe-extension-deployment" ] } }
- description
- Use when building a Hermes web-search provider plugin.
02 资源文件 1
03 SKILL.md 正文
Building a Hermes web-search provider plugin
When to Use
- Building or extending a Hermes plugin that services
web_search/web_extract(a new backend provider, or changes to camofox-search / ai-search). - Debugging why a configured web provider is not registered, not selected, or not loading.
- Needing plugin-side LLM calls (
ctx.llm) or a child agent session (ctx.subagent_lifecycle) — see thehermes-plugin-developmentskill.
Reference implementations on this machine: ~/projects/camofox-search (Camofox browser backend),
~/projects/ai-search (Crawl4AI backend). Full docs: hermes-agent repo
website/docs/developer-guide/web-search-provider-plugin.md + .../plugins/index.md.
Repo layout that works
<repo>/
plugin/<pkg>/ # __init__.py (register), plugin.yaml, provider.py,
# client.py, engines.py, settings.py
scripts/install_dev_plugin.py # copy installer -> $HERMES_HOME/plugins/web/<pkg>
scripts/smoke_live.py # live daemon smoke (run with Hermes venv python)
tests/ # offline pytest (conftest stubs agent.* outside Hermes)
pyproject.toml # [project.entry-points."hermes_agent.plugins"]
Contracts (verified against hermes-agent source)
- ABC:
agent.web_search_provider.WebSearchProvider— implementname,is_available()(cheap, NO network — runs on everyhermes toolspaint),supports_search()/supports_extract(),search()/extract(),get_setup_schema(). - Return shapes, and they are NOT the same.
search()returns the legacy envelope{"success": True, "data": {"web": [{title,url,description,position}]}}, or{"success": False, "error": str}on failure.extract()returns a bare list[{url,title,content,raw_content,metadata}, ...]witherroron a per-URL failure — never an envelope.tools/web_tools_extract.py::_dispatch_extractiterates the value directly, so an envelope makes it iterate the dict's KEYS and the whole call dies with'str' object has no attribute 'get'.search/extractmay beasync def. agent/web_search_provider.py's MODULE docstring still describes the envelope for extract; that line is stale. The truth is theextract()method docstring, the bundled providers (plugins/web/{tavily,exa,firecrawl,parallel,keenable,perplexity}all annotate-> list[dict]), and the dispatcher that consumes the value.plugin.yaml:kind: backend+provides_web_providers: [<provider-name>]; manifestnamelikeweb-<slug>;requires_envdriveshermes plugins installprompts.- User plugin dirs:
$HERMES_HOME/plugins/<category>/<dir>/→ loader key<category>/<dir>, module namespacehermes_plugins.<cat>__<dir>(/→__,-→_). USE RELATIVE IMPORTS in the package. - User plugins are opt-in:
hermes plugins enable web/<dir>; bundled backends auto-load. - Install: copy to
$HERMES_HOME/plugins/web/<dir>→hermes plugins enable web/<dir>. The enable soft-reloads a running Gateway (tools/skills land in the NEXT session) but re-imports no provider code — a changedprovider.pytakes effect only after a gateway restart (deploy sequence below). Validate withhermes plugins validate <plugin_dir>(runs register() in isolation). - Config/env: resolve via
hermes_cli.config.get_env_value(secret-scope aware) thenos.environ; re-raiseUnscopedSecretErrorinstead of falling back across profiles. - Live smoke needs the Hermes venv python (that python can import
agent.*).
camofox REST (live-verified camofox-browser 2.4.8, engine camoufox)
- Auth:
Authorization: Bearer <CAMOFOX_API_KEY>(Hermes.env); baseCAMOFOX_URL, defaulthttp://localhost:9377. Container:docker start camofox-browser. POST /tabs {userId, sessionKey, url}→{tabId}—sessionKeyis REQUIRED here (coretools/browser_camofox.pysendslistItemId; the daemon version rejects less).POST /tabs/{id}/evaluate {userId, expression}→{ok, result, resultType, truncated}; normalizeresult(decoded JSON on 2.4.8, JSON string on other versions).DELETE /sessions/{userId}closes the browser context and clears the daemon's in-memory per-user state; the on-disk profile dir (and its cookies) PERSISTS — it is not a wipe.- Bing SERP (cn.bing verified):
#b_results > li.b_algo,h2 a,.b_caption p. - Tab creation rejects non-http(s) URLs (
Blocked URL scheme: about:); blank tabs must OMITurl.
Plugin-owned profile + cookies (verified on camofox-browser 2.4.8 / Edge 155)
- Browse with ONE stable userId (
CAMOFOX_SEARCH_USER_ID, defaultcamofox_search): a cookie import only reaches sessions of the SAME userId, so per-call random userIds silently discard every import. Per call: open a work tab → do the work → close only that tab. - Camoufox destroys its browser WINDOW when a context's last tab closes; every later
Browser.newPagethen fails (500,delayedStartupPromise, window is null). Keep one idle blank HOLDER tab in the profile, and heal a broken context once: close session → ensure holder → retry the tab create. A live smoke that opens/closes tabs repeatedly is the probe for this — a single-tab check will not catch it. - Cookie endpoints:
POST /sessions/{userId}/cookies {cookies, tabId?}(Playwright format; each cookie needs name+value+domain; max 500 per request; needs a live tab — passingtabIdskips the canonical-profile checks) andGET /tabs/{tabId}/cookies?userId=for round-trip verification. Tool output carries counts only — never cookie values. - Reading the USER's own browser cookies (Windows): a running Chromium-family browser holds its
Cookies DB locked (persistent WinError 32, retries do not help). Fall back to a CDP export
from a browser started with
--remote-debugging-port(probe a configurable port list), and report what to close/restart — never kill the user's browser. Chromium values: DPAPI key fromLocal State+ AES-GCM, and modern builds prepend a 32-byte binding prefix to the plaintext (strip it); app-boundv20is undecryptable — skip. Firefoxcookies.sqliteis plaintext. - Depth — session/profile model, exact decrypt formats, CDP recipe, scheduled-job pattern,
testing recipe:
references/camofox-profile-and-cookies.md.
Provider plugin + agent tool + bundled skill (one plugin, three surfaces)
A web-provider plugin can also register agent tools and a bundled skill (proven in camofox-search v0.2):
ctx.register_tool(name, toolset, schema, handler, emoji=...): handler signaturehandler(args, **kwargs)must return a JSON string (the registry rejects plain dicts; only the multimodal envelope passes).- The manifest must declare the tool:
provides_tools: [<name>]— otherwisehermes plugins validatefails with "undeclared tools registered (not in provides_tools)". ctx.register_skill(<name>, Path(SKILL.md), description=..., frontmatter=...): read-only, resolvable as<manifest name>:<skill>(load withskill_view), listed in<available_skills>while enabled; no manifest field needed. Pass the parsed frontmatter explicitly: the<available_skills>row comes from register-time metadata (list_plugin_skill_metadata), NOT from re-reading the file — a skill registered bare shows an empty description and no future agent can see its triggers. Parse SKILL.md inregister()with a small self-containedkey: value+ block-scalar parser; do NOT importagent.skill_utilsor other agent internals for it (hermes plugins validateflags private core imports, and those seams move between releases).- Bundled skill conventions (user preference): write SKILL.md in ENGLISH — committed artifacts are
English-first even when the session language is Chinese — and put the trigger conditions in the
frontmatter
description, since that text is all a future agent sees in the skills index before deciding to load it. - Per-plugin SQLite store: resolve data dir from
hermes_constants.get_hermes_home()(profile-aware; fall back toHERMES_HOMEenv → platform default for standalone/tests), open connections withPRAGMA journal_mode=WAL+busy_timeout, and catch store errors in the provider so search/extract degrade to built-ins instead of failing. - Verify Hermes-side without pytest:
hermes plugins validate <plugin_dir>(runsregister()with a real ctx — catches undeclared tools, collisions, import errors) andhermes plugins doctor <plugin_dir>(discovery + import + registration in a temp HERMES_HOME). The Hermes venv ships no pytest: run the repo suite under the repo venv (PYTHONPATH=<hermes-agent repo>to exercise the real ABC), and run a small probe script with the Hermes venv python for runtime checks.
Deploy to the live Hermes home and prove it (verified sequence)
Treat "deploy the plugin" as full activation, not a file copy: install, enable, live smoke, backend switch, evidence, revert path.
- Install the copy from the repo venv python:
scripts/install_dev_plugin.py --target-hermes-home "$HERMES_HOME"(dry-run first;--replacewhen a copy exists — it backs up and hash-verifies). hermes plugins enable web/<dir>— output confirms enablement plusGateway reloaded plugins — deferred: tools (next session). The first enable's soft reload re-registers tools/skills metadata; it does NOT re-import provider code, so a changedprovider.pyreaches the live gateway only after a restart.hermes gateway restartWORKS from an external CLI session: it drains, starts a new PID and the platforms reconnect. Verifyhermes gateway statusreports the new PID andgateway.logshows✓ <platform> connected; a transient127.0.0.1:8642 still accepting connectionswarning is the old socket draining, not a fault.- It is refused only when the shell IS inside the gateway's own process tree (a gateway-hosted session driving the terminal tool) — there, use the control-socket reload (step 8).
- Ship the fix with a
plugin.yaml+pyproject.tomlversion bump in the same commit, so the installed copy is identifiable against a later--replace.
- Prove the LIVE gateway loaded it:
grep -i "<plugin-dir>" "$HERMES_HOME/logs/agent.log"— expectRegistered web provider '<name>',registered tool: ...,registered skill: ...lines. - Live smoke with the Hermes venv python against the real daemon — this is also what creates the real data dir / rule DB for the first time.
- Point the profile at the provider:
hermes config set web.search_backend <name>andweb.extract_backend <name>. Selection re-reads config per call, so no restart is needed. - Prove selection with a probe under the Hermes venv python:
discover_plugins()→agent.web_search_registry._configured_backend("search")→_resolve(configured, capability="search").name(same for"extract"). - A configured backend may be DANGLING:
web.search_backendcan name a plugin installed only in a different profile and resolution falls back silently. Checkhermes plugins list --plainbefore believing a configured value is active; switch it only when it is broken or the user asked. - Updating an already-enabled plugin:
hermes plugins enable web/<dir>on an enabled plugin is a NO-OP — it does not reload the gateway, so changed skill registration metadata (name/description) stays stale in the running process. Force the reload over the gateway control socket (Hermes venv python):from gateway.control_socket import reload_gateway_plugins; reload_gateway_plugins(Path("<hermes home>"))→{reloaded: True, plugins: [...], adapters_rewired: N}. Skill FILE content is path-served (a deployed SKILL.md edit is live on the nextskill_view) — only registration metadata needs the reload. - Verifying a just-deployed tool: a
hermes chat -qspawned from the agent shell routes through the RUNNING gateway (platform=local) and reflects its IN-MEMORY plugin state — before the reload lands it reports "'<tool>' is not a known tool name" even though the disk copy is new. Verify the on-disk copy in a fresh python instead:discover_plugins()thenmodel_tools.get_tool_definitions(skip_tool_search_assembly=True)and check the tool names; then reload over the control socket and re-runhermes chat -qto prove the live path. - After installing a provider fix, prove the INSTALLED copy, not the repo: load it as a synthetic
package (
spec_from_file_location(name, <installed>/__init__.py, submodule_search_locations=[<installed>])) and run the host dispatcher against it with a stubbed client. Then run the installer's backup copy through the same probe — the old tree must reproduce the logged failure and the new one must return entries. That A/B is the only causal proof that the deployed bytes changed behaviour.
Pitfalls
- Parallel work from a provider MUST run worker threads inside a copy of the caller's context:
the gateway's per-turn secret scope (
agent.secret_scope._SECRET_SCOPE) is aContextVarthat fresh threads do NOT inherit, andget_env_valueon a multiplexed gateway FAILS CLOSED for any env read in an unscoped thread (UnscopedSecretError— "could not read this profile's <VAR> ... Runhermes gateway restart"). The web_search call then errors and Hermes silently rescues it with a keyless fallback (served_by/rescued_fromin the response) — broken, but it looks like a result. Pattern:context = contextvars.copy_context()once, thenpool.submit(context.copy().run, fn, ...)per task — each task needs its OWN copy (a shared Context cannot be entered concurrently). Regression-test by setting a probe ContextVar beforesearch()and asserting it inside the worker. - A provider's own test suite asserts whatever shape its author assumed, so it cannot catch a
contract mismatch — a green suite says nothing about the host. Verify every provider return value
against the real dispatcher with a stubbed client:
asyncio.run(_dispatch_extract(Provider(), ["https://example.com/"], None))must return a list of entries and must not raise; do the same for_memoized_search's envelope expectations. - After deploying/reloading a provider plugin, verify the LIVE gateway path with a real
web_searchcall and read the envelope: aserved_by/rescued_from/backend_errorrescue is a FAILED call even though results come back. Direct probe scripts (Hermes venv python, no gateway) never exercise the multiplex scope, so scope bugs surface only through the gateway. - Write
.gitignoreFIRST. For any full-file rewrite go straight torm+write_file: the stale-read guard blockswrite_fileon an existing file even after a fresh full read (a single earlier paginated read poisons it) and re-reading does not reliably clear it. - Tests must pass outside Hermes: conftest installs a stub
agent.web_search_providerwhen the real runtime isn't importable. Runcompileallunder BOTH pythons (Hermes venv 3.14 + repo venv). - Clamp
limitwith try/exceptmax(1, min(int(limit), 20));limit or 5turns 0 into 5. - Repo venv:
uv venv && uv pip install -p .venv/Scripts/python.exe pytest requests; tests:.venv/Scripts/python.exe -m pytest. - After a live smoke, check tabs PER USER:
GET /tabs?userId=<user>— the unfilteredGET /tabsmisleadingly returns[]and hides everything. The plugin's stable profile should show exactly one idle blank holder tab and no leftover work tabs.
04 同仓库更多 Skills
web-retrieval-resilience
Web tools fail or search rules break: repair or fall back.
blocked-page-recovery
Use when a fetch fails: 403/429, paywall, WAF, bot wall.
verification-loop
Run a six-phase verification of a Claude Code session's work — build, type check, lint, tests with coverage, security grep, and diff review — then produce a PASS/FAIL verification report. Use when verifying work after completing a feature or refactor, before creating a PR, or when quality gates must pass.
unreal-world-builder
开放世界与环境专家——精通 UE5 World Partition、Landscape、程序化植被、HLOD 和大规模关卡流式加载,打造无缝开放世界体验
unreal-technical-artist
Unreal Engine 视觉管线专家——精通材质编辑器、Niagara 特效、程序化内容生成和 UE5 项目的美术到引擎管线
unreal-systems-engineer
性能与混合架构专家——精通 C++/Blueprint 边界、Nanite 几何体、Lumen GI 和 Gameplay Ability System,面向 AAA 级 Unreal Engine 项目