Skip to content

Agent Zero AI framework

Hide remote skill discovery until the A0 CLI connects

Alessandro03c9d8ccd539
diff --git a/helpers/skills.py b/helpers/skills.py
index 65bd1018c..b3e634f77 100644
--- a/helpers/skills.py
+++ b/helpers/skills.py
@@ -7,6 +7,7 @@ from pathlib import Path
from typing import Any, Dict, Iterable, List, Literal, Optional, Tuple, TYPE_CHECKING, TypedDict
from helpers import files, subagents, projects, file_tree, runtime
+from helpers.extension import extensible
from helpers import plugins as plugin_helpers
if TYPE_CHECKING:
@@ -67,6 +68,7 @@ def get_skills_base_dir() -> Path:
return Path(files.get_abs_path("usr", "skills"))
+@extensible
def get_skill_roots(
agent: Agent|None=None,
) -> List[str]:
diff --git a/helpers/skills.py.dox.md b/helpers/skills.py.dox.md
index 91de81bc7..9c9bb98e4 100644
--- a/helpers/skills.py.dox.md
+++ b/helpers/skills.py.dox.md
@@ -57,6 +57,8 @@
## Runtime Contracts
+- `get_skill_roots` is extensible. Plugin end hooks may filter agent-scoped roots from current runtime state; do not mutate cached path lists. Global discovery without an agent retains installed roots. Listing, search, lookup, and skill reattachment use this resolver.
+
- Helper modules own reusable framework APIs and must preserve public callers unless all callers, tests, and docs are updated together.
- Update this file whenever public functions, classes, persistence behavior, path/security assumptions, side effects, or cross-module contracts change.
- Loaded skill names are chat-wide context data under `CONTEXT_DATA_NAME_LOADED_SKILLS`; legacy agent-local `loaded_skills` lists are migrated into context data and cleared when read.
diff --git a/plugins/_a0_connector/AGENTS.md b/plugins/_a0_connector/AGENTS.md
index a11f8568c..5dc630a52 100644
--- a/plugins/_a0_connector/AGENTS.md
+++ b/plugins/_a0_connector/AGENTS.md
@@ -22,6 +22,7 @@
prompts, remote file metadata enables `text_editor_remote`, F4-enabled remote
execution metadata enables `code_execution_remote`, and supported enabled
Computer Use that does not need re-arming enables `computer_use_remote`.
+- Agent-scoped skill discovery includes this plugin's `skills/` root only when a routed connected socket has connector capability metadata. WebUI-only sockets do not qualify; disabled capabilities still count as a connected CLI. Filter roots on each discovery without mutating cached paths or persisting visibility settings. `setup-a0-cli` lives in root `skills/` and stays discoverable while disconnected.
- Never re-add a connector prompt that the effective project/profile tool policy
blocks.
- Do not bypass WebSocket authentication or leak connector session data.
diff --git a/plugins/_a0_connector/extensions/python/_functions/helpers/skills/get_skill_roots/end/_70_gate_remote_skills.py b/plugins/_a0_connector/extensions/python/_functions/helpers/skills/get_skill_roots/end/_70_gate_remote_skills.py
new file mode 100644
index 000000000..f10b422ff
--- /dev/null
+++ b/plugins/_a0_connector/extensions/python/_functions/helpers/skills/get_skill_roots/end/_70_gate_remote_skills.py
@@ -0,0 +1,25 @@
+from helpers import files
+from helpers.extension import Extension
+from plugins._a0_connector.helpers import ws_runtime
+
+
+class GateRemoteSkills(Extension):
+ def execute(self, data: dict, **kwargs):
+ if not self.agent or not isinstance(data.get("result"), list):
+ return
+
+ candidates = ws_runtime.remote_tool_sids_for_context(self.agent.context.id)
+ if any(
+ metadata(sid) is not None
+ for sid in candidates
+ for metadata in (
+ ws_runtime.remote_file_metadata_for_sid,
+ ws_runtime.remote_exec_metadata_for_sid,
+ ws_runtime.computer_use_metadata_for_sid,
+ ws_runtime.host_browser_metadata_for_sid,
+ )
+ ):
+ return
+
+ root = files.get_abs_path("plugins", "_a0_connector", "skills")
+ data["result"] = [path for path in data["result"] if path != root]
diff --git a/plugins/_browser/AGENTS.md b/plugins/_browser/AGENTS.md
index 071bc3a00..554c9b458 100644
--- a/plugins/_browser/AGENTS.md
+++ b/plugins/_browser/AGENTS.md
@@ -60,7 +60,7 @@
- Coordinate tool, helper, and panel changes so browser state shown in the UI matches tool behavior.
- Do not depend on nested Electron `<webview>` support or launcher-specific preload bridges unless the launcher exposes that bridge as an explicit contract.
-- Keep `prompts/agent.system.tool.browser.md` as a compact callable contract; move detailed browser workflows into `skills/browser-automation/SKILL.md`.
+- Keep `prompts/agent.system.tool.browser.md` as a compact callable contract; move detailed browser workflows and host setup/remote-tool fallback guidance into `skills/browser-automation/SKILL.md` so the default system prompt does not name unavailable remote tools.
- Keep `skills/browser-automation/SKILL.md` frontmatter triggers current with rendered browsing, host-browser, screenshot, and web-interaction user phrasing so relevant-skill recall can surface the skill before the full browser workflow is needed.
- Keep fragile form guidance progressively disclosed through `skills/browser-form-workflows/SKILL.md`, linked from the browser prompt through `browser-automation`.
diff --git a/plugins/_browser/prompts/agent.system.tool.browser.md b/plugins/_browser/prompts/agent.system.tool.browser.md
index 402ef6efa..980d18580 100644
--- a/plugins/_browser/prompts/agent.system.tool.browser.md
+++ b/plugins/_browser/prompts/agent.system.tool.browser.md
@@ -3,8 +3,6 @@ Rendered browser automation for pages that need interaction, JavaScript, forms,
Prefer `search_engine` or `document_query` for plain text research. The tool must not open a Browser surface automatically. Use the tool headlessly unless the user opens the Browser surface or asks for the optional visible WebUI viewer.
-When the user asks for "my browser", "host browser", "local browser", a local Chromium browser, or opening a URL in their host browser, use this `browser` tool. Do not substitute `computer_use_remote`, `code_execution_remote`, `xdg-open`, `sensible-browser`, or Python `webbrowser.open`. If setup fails and mentions remote debugging, tell the user to open the browser inspect page, such as `chrome://inspect/#remote-debugging` or `opera://inspect/#remote-debugging`, enable "Allow remote debugging for this browser instance", run `/browser host on`, and retry.
-
For rendered browsing workflows, multi-step interaction, screenshots, downloads, uploads, forms, or host/container mode decisions, first load `browser-automation` with `skills_tool:load`, then call this tool using the loaded instructions. For fragile forms, `browser-automation` links to `browser-form-workflows`; load it when selects, checkboxes, radios, uploads, contenteditable fields, validation, or submission state are central.
Actions: tabs `open`, `list`, `state`, `set_active`, `navigate`, `back`, `forward`, `reload`, `close`, `close_all`; inspect `content`, `detail`, `screenshot`; interact `click`, `hover`, `double_click`, `right_click`, `drag`, `type`, `submit`, `type_submit`, `scroll`, `select_option`, `set_checked`, `upload_file`; advanced `evaluate`, `key_chord`, `mouse`, `wheel`, `keyboard`, `clipboard`, `set_viewport`, `multi`.
diff --git a/plugins/_browser/skills/browser-automation/SKILL.md b/plugins/_browser/skills/browser-automation/SKILL.md
index 6a09f56a6..9efd61708 100644
--- a/plugins/_browser/skills/browser-automation/SKILL.md
+++ b/plugins/_browser/skills/browser-automation/SKILL.md
@@ -37,6 +37,8 @@ For fragile forms, load `browser-form-workflows` with `skills_tool:load` before
## Modes
+When the user asks for "my browser", "host browser", "local browser", a local Chromium browser, or opening a URL in their host browser, use this `browser` tool. Do not substitute `computer_use_remote`, `code_execution_remote`, `xdg-open`, `sensible-browser`, or Python `webbrowser.open`. If setup fails and mentions remote debugging, tell the user to open the browser inspect page, such as `chrome://inspect/#remote-debugging` or `opera://inspect/#remote-debugging`, enable "Allow remote debugging for this browser instance", run `/browser host on`, and retry.
+
The same tool may run in Docker container mode or A0 CLI host-browser mode, depending on project/plugin settings.
- Container mode: browser and upload paths resolve inside the Agent Zero container.
diff --git a/skills/AGENTS.md b/skills/AGENTS.md
index 28cc26b15..f247d2592 100644
--- a/skills/AGENTS.md
+++ b/skills/AGENTS.md
@@ -9,6 +9,7 @@
- Each direct skill directory owns its `SKILL.md` and any local supporting files.
- Plugin-distributed skills belong under the relevant plugin directory.
+- `setup-a0-cli/` owns primary host-connector setup guidance and remains discoverable without a connected CLI.
- User-local skills belong under `usr/skills/`.
## Local Contracts
diff --git a/plugins/_a0_connector/skills/setup-a0-cli/SKILL.md b/skills/setup-a0-cli/SKILL.md
similarity index 100%
rename from plugins/_a0_connector/skills/setup-a0-cli/SKILL.md
rename to skills/setup-a0-cli/SKILL.md
diff --git a/tests/test_a0_connector_prompt_gating.py b/tests/test_a0_connector_prompt_gating.py
index 659acdeb3..b92617cc6 100644
--- a/tests/test_a0_connector_prompt_gating.py
+++ b/tests/test_a0_connector_prompt_gating.py
@@ -5,6 +5,7 @@ import uuid
from pathlib import Path
from types import SimpleNamespace
+import pytest
import yaml
PROJECT_ROOT = Path(__file__).resolve().parents[1]
@@ -66,6 +67,15 @@ def _load_gate_class():
IncludeRemoteToolStubs = _load_gate_class()
[email protected](autouse=True)
+def isolate_tool_policy(monkeypatch):
+ monkeypatch.setitem(
+ IncludeRemoteToolStubs.execute.__globals__,
+ "resolve_tool",
+ lambda _agent, _name: SimpleNamespace(allowed=True),
+ )
+
+
class FakeContext:
def __init__(self, context_id: str):
self.id = context_id
@@ -660,12 +670,17 @@ def test_host_browser_requests_route_to_browser_tool_not_desktop_or_shell_fallba
/ "SKILL.md"
).read_text(encoding="utf-8")
- assert 'When the user asks for "my browser"' in browser_prompt
- assert "Do not substitute `computer_use_remote`" in browser_prompt
- assert "code_execution_remote" in browser_prompt
- assert "Python `webbrowser.open`" in browser_prompt
- assert "chrome://inspect/#remote-debugging" in browser_prompt
- assert "opera://inspect/#remote-debugging" in browser_prompt
+ browser_skill = (
+ PROJECT_ROOT / "plugins" / "_browser" / "skills" / "browser-automation" / "SKILL.md"
+ ).read_text(encoding="utf-8")
+ assert "computer_use_remote" not in browser_prompt
+ assert "code_execution_remote" not in browser_prompt
+ assert 'When the user asks for "my browser"' in browser_skill
+ assert "Do not substitute `computer_use_remote`" in browser_skill
+ assert "code_execution_remote" in browser_skill
+ assert "Python `webbrowser.open`" in browser_skill
+ assert "chrome://inspect/#remote-debugging" in browser_skill
+ assert "opera://inspect/#remote-debugging" in browser_skill
assert "Do not start `computer_use_remote` for web-page navigation" in computer_skill
assert (
"Do not fall back to `code_execution_remote`, `xdg-open`, `sensible-browser`, "
@@ -711,3 +726,45 @@ def test_host_computer_use_does_not_fall_back_to_linux_desktop_skill():
assert "use the OS" not in linux_frontmatter["triggers"]
assert "terminal app" not in linux_frontmatter["triggers"]
assert any("Xpra" in trigger for trigger in linux_frontmatter["triggers"])
+
+
+def test_connector_skill_root_follows_connection_without_mutating_cached_paths(monkeypatch):
+ from agent import Agent
+ from helpers import skills, subagents
+
+ agent = object.__new__(Agent)
+ agent.context = FakeContext(_context_id())
+ agent.config = SimpleNamespace(profile="default")
+ connector = PROJECT_ROOT / "plugins" / "_a0_connector"
+ roots = [str(connector / "skills"), str(PROJECT_ROOT / "skills")]
+
+ def get_paths(_agent, *parts, **kwargs):
+ if parts == ("skills",):
+ return roots
+ return [str(connector.joinpath(*parts))]
+
+ monkeypatch.setattr(subagents, "get_paths", get_paths)
+ monkeypatch.setattr(skills, "get_hidden_skills", lambda agent: [])
+ monkeypatch.setattr(skills, "get_visibility_policy", lambda agent: {"mode": "inherit"})
+ remote_names = {path.parent.name for path in (connector / "skills").glob("*/SKILL.md")}
+ sid = _sid()
+ try:
+ for state in ("offline", "webui_only", "cli_disabled", "cli_enabled", "disconnected"):
+ if state == "webui_only":
+ ws_runtime.register_sid(sid)
+ elif state.startswith("cli_"):
+ ws_runtime.store_sid_remote_file_metadata(sid, {"enabled": state == "cli_enabled"})
+ elif state == "disconnected":
+ ws_runtime.unregister_sid(sid)
+
+ connected = state.startswith("cli_")
+ names = {skill.name for skill in skills.list_skills(agent)}
+ assert "setup-a0-cli" in names
+ assert (remote_names <= names) if connected else names.isdisjoint(remote_names)
+ assert bool(skills.find_skill("host-file-editing", agent)) == connected
+ matches = {skill.name for skill in skills.search_skills("host", agent=agent)}
+ assert ("host-file-editing" in matches) == connected
+ assert len(roots) == 2
+ assert str(connector / "skills") in skills.get_skill_roots()
+ finally:
+ ws_runtime.unregister_sid(sid)
diff --git a/tests/test_default_prompt_budget.py b/tests/test_default_prompt_budget.py
index 3b1847ecf..d5f23a64d 100644
--- a/tests/test_default_prompt_budget.py
+++ b/tests/test_default_prompt_budget.py
@@ -98,12 +98,11 @@ async def test_default_agent0_prompt_contracts():
assert "~~~json" in communication_prompt
assert "~~~json" not in rendered_system_text
assert "```json" not in rendered_system_text
- assert "# code_execution_remote tool" not in system_text
- assert "# text_editor_remote tool" not in system_text
- assert "### computer_use_remote" not in system_text
- assert '"tool_name": "code_execution_remote"' not in system_text
- assert '"tool_name": "text_editor_remote"' not in system_text
- assert '"tool_name": "computer_use_remote"' not in system_text
+ for name in ("code_execution_remote", "text_editor_remote", "computer_use_remote"):
+ assert name not in system_text
+ assert name not in rendered_system_text
+ assert "- host-" not in system_text
+ assert "- setup-a0-cli:" in system_text
assert "Computer Use enablement is scoped to the current CLI session" not in system_text
diff --git a/tests/test_skills_runtime.py b/tests/test_skills_runtime.py
index e7dd26ac8..bb0dacd39 100644
--- a/tests/test_skills_runtime.py
+++ b/tests/test_skills_runtime.py
@@ -16,6 +16,7 @@ HELPER_STUB_MODULES = (
"helpers.subagents",
"helpers.file_tree",
"helpers.runtime",
+ "helpers.extension",
)
@@ -50,6 +51,9 @@ def _register_helpers_stubs():
file_tree = types.ModuleType("helpers.file_tree")
file_tree.file_tree = lambda *args, **kwargs: ""
+ extension = types.ModuleType("helpers.extension")
+ extension.extensible = lambda func: func
+
runtime = types.ModuleType("helpers.runtime")
runtime.is_development = lambda: False
@@ -67,6 +71,7 @@ def _register_helpers_stubs():
sys.modules["helpers.subagents"] = subagents
sys.modules["helpers.file_tree"] = file_tree
sys.modules["helpers.runtime"] = runtime
+ sys.modules["helpers.extension"] = extension
def _load_skills_helper_module():
@@ -417,7 +422,7 @@ def test_renamed_skills_use_standard_frontmatter_only():
PROJECT_ROOT / "plugins" / "_a0_connector" / "skills" / "host-computer-use-macos" / "SKILL.md",
PROJECT_ROOT / "plugins" / "_a0_connector" / "skills" / "host-computer-use-windows" / "SKILL.md",
PROJECT_ROOT / "plugins" / "_a0_connector" / "skills" / "host-file-editing" / "SKILL.md",
- PROJECT_ROOT / "plugins" / "_a0_connector" / "skills" / "setup-a0-cli" / "SKILL.md",
+ PROJECT_ROOT / "skills" / "setup-a0-cli" / "SKILL.md",
PROJECT_ROOT / "plugins" / "_browser" / "skills" / "browser-automation" / "SKILL.md",
PROJECT_ROOT / "plugins" / "_browser" / "skills" / "browser-extension-control" / "SKILL.md",
PROJECT_ROOT / "plugins" / "_browser" / "skills" / "browser-form-workflows" / "SKILL.md",