Skip to content

The agent that grows with you

fix(webapp): report the commit an inspection read, and share the detection cases

unsupportedpastels26ba38a098d8
diff --git a/apps/desktop/electron/desktop-plugin-install.test.ts b/apps/desktop/electron/desktop-plugin-install.test.ts
index c9e4db48185..1149522f94a 100644
--- a/apps/desktop/electron/desktop-plugin-install.test.ts
+++ b/apps/desktop/electron/desktop-plugin-install.test.ts
@@ -124,6 +124,46 @@ describe('detectPluginComponents', () => {
})
})
+interface DetectionCase {
+ name: string
+ root: string
+ files: Record<string, string>
+ expect: { agent: boolean; desktop: boolean; agent_name: null | string }
+}
+
+// Shared with the gateway's detector (tests/hermes_cli/test_plugins_cmd_inspect.py).
+const DETECTION_CASES = (
+ JSON.parse(
+ fs.readFileSync(path.resolve(here, '..', '..', '..', 'tests', 'fixtures', 'plugin_component_detection.json'), 'utf8')
+ ) as { cases: DetectionCase[] }
+).cases
+
+describe('detectPluginComponents on the shared detection cases', () => {
+ const roots: string[] = []
+
+ afterEach(() => {
+ for (const root of roots.splice(0)) {
+ fs.rmSync(root, { recursive: true, force: true })
+ }
+ })
+
+ it.each(DETECTION_CASES)('$name', async ({ root, files, expect: expected }) => {
+ const parent = mkdtemp('hermes-detect-')
+ roots.push(parent)
+ const pluginRoot = path.join(parent, root)
+ fs.mkdirSync(pluginRoot)
+
+ for (const [rel, text] of Object.entries(files)) {
+ fs.mkdirSync(path.dirname(path.join(pluginRoot, rel)), { recursive: true })
+ fs.writeFileSync(path.join(pluginRoot, rel), text)
+ }
+
+ const detected = await detectPluginComponents(pluginRoot)
+
+ expect({ agent: detected.agent, desktop: detected.desktop, agent_name: detected.agentName }).toEqual(expected)
+ })
+})
+
describe('probePluginRepo', () => {
const roots: string[] = []
diff --git a/apps/desktop/src/global.d.ts b/apps/desktop/src/global.d.ts
index 2080d78ab69..bf713933189 100644
--- a/apps/desktop/src/global.d.ts
+++ b/apps/desktop/src/global.d.ts
@@ -656,6 +656,8 @@ declare global {
desktopName?: string | null
warnings?: string[]
insecure?: boolean
+ /** The commit that was inspected; an install of this source is held to it. */
+ sha?: string
/** Inspection itself is missing here (not a failed read): Retry cannot help. */
unavailable?: boolean
error?: string
diff --git a/apps/desktop/src/store/agent-plugins.test.ts b/apps/desktop/src/store/agent-plugins.test.ts
index b1576ce9eb9..0e190938c65 100644
--- a/apps/desktop/src/store/agent-plugins.test.ts
+++ b/apps/desktop/src/store/agent-plugins.test.ts
@@ -1,9 +1,11 @@
+import { JsonRpcGatewayError } from '@hermes/shared'
import { afterEach, describe, expect, it, vi } from 'vitest'
import {
$agentPlugins,
$agentPluginsProfile,
type AgentPluginRow,
+ inspectAgentPlugin,
installAgentPlugin,
isDesktopRelevantPlugin,
normalizeAgentPluginRow,
@@ -61,6 +63,52 @@ describe('installAgentPlugin', () => {
})
})
+describe('inspectAgentPlugin', () => {
+ const answering = (sha: unknown) =>
+ vi.fn(async () => ({ ok: true, agent: true, agent_name: 'demo', desktop: false, warnings: [], sha }))
+
+ it('carries the commit the backend read, lower-cased, so the install can be held to it', async () => {
+ const sha = 'ABCDEF0123456789abcdef0123456789abcdef01'
+ const request = answering(sha)
+
+ expect(await inspectAgentPlugin(request as never, { identifier: 'owner/repo', profile: 'research' })).toMatchObject({
+ ok: true,
+ agentName: 'demo',
+ sha: sha.toLowerCase()
+ })
+ expect(request).toHaveBeenCalledWith(
+ 'plugins.manage',
+ { action: 'inspect', identifier: 'owner/repo', profile: 'research' },
+ expect.any(Number)
+ )
+ })
+
+ it('drops a commit that is not a full SHA', async () => {
+ for (const sha of ['main', 'abcdef0', null, undefined]) {
+ expect(await inspectAgentPlugin(answering(sha) as never, { identifier: 'owner/repo' })).not.toHaveProperty('sha')
+ }
+ })
+
+ it('marks a backend without the inspect action unavailable, and a transport failure retryable', async () => {
+ const refusing = vi.fn(async () => {
+ throw new JsonRpcGatewayError('unknown plugins action: inspect', { code: 4017 })
+ })
+
+ const timingOut = vi.fn(async () => {
+ throw new Error('request timed out after 120s: plugins.manage')
+ })
+
+ expect(await inspectAgentPlugin(refusing as never, { identifier: 'owner/repo' })).toMatchObject({
+ ok: false,
+ unavailable: true
+ })
+ expect(await inspectAgentPlugin(timingOut as never, { identifier: 'owner/repo' })).toMatchObject({
+ ok: false,
+ unavailable: false
+ })
+ })
+})
+
describe('normalizeAgentPluginRow', () => {
it('treats an absent servers field as an empty full snapshot', () => {
const previous = normalizeAgentPluginRow(
diff --git a/apps/desktop/src/store/agent-plugins.ts b/apps/desktop/src/store/agent-plugins.ts
index c98a8750ff8..e7a4fa9fdae 100644
--- a/apps/desktop/src/store/agent-plugins.ts
+++ b/apps/desktop/src/store/agent-plugins.ts
@@ -375,6 +375,8 @@ export interface AgentPluginInspection {
desktopName?: string | null
warnings: string[]
insecure?: boolean
+ /** The commit the backend read; absent when it reported none or not a full SHA. */
+ sha?: string
unavailable?: boolean
error?: string
}
@@ -396,6 +398,7 @@ export async function inspectAgentPlugin(
desktop?: boolean
agent_name?: string | null
desktop_name?: string | null
+ sha?: string | null
warnings?: string[]
insecure?: boolean
error?: string
@@ -424,6 +427,7 @@ export async function inspectAgentPlugin(
desktopName: result?.desktop_name ?? null,
warnings: result?.warnings ?? [],
insecure: Boolean(result?.insecure),
+ ...(ok && typeof result.sha === 'string' && COMMIT_SHA_RE.test(result.sha) ? { sha: result.sha.toLowerCase() } : {}),
...(ok ? {} : { error: result?.error || 'Inspection failed' })
}
} catch (e) {
diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.ts
index 8707810d3ff..b5bd758c6b5 100644
--- a/apps/shared/src/gateway-contract.generated.ts
+++ b/apps/shared/src/gateway-contract.generated.ts
@@ -4404,7 +4404,7 @@ export interface PluginsManageParams {
names?: string[] | null
}
export type PluginsAction = 'list' | 'toggle' | 'install' | 'inspect' | 'update' | 'remove' | 'settings' | 'onboarding' | 'presence'
-/** ``list`` → ``plugins`` + counts; ``toggle`` → ``ok``/``unchanged``/``restart_required``/``name`` (the canonical key written)/``plugin``; ``install`` → ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s ok payload; ``inspect`` → ``ok``/``agent``/``desktop``/``agent_name``/``desktop_name``/``warnings``/``insecure`` or ``ok=false`` + ``error``; ``toggle``/``install``/``update`` that loaded a plugin also carry ``gateway_reloaded`` (the running gateway picked it up and re-wired its handlers) and ``activation`` — the honest split of what is live now vs deferred, so ``restart_required`` is True only when no gateway answered or the running gateway/backend cannot import the plugin's Python dependencies (``activation.missing_dependencies``); ``update`` → ``ok``/``unchanged``/``sha``, or ``ok=false`` + ``consent_required`` with the ``delta`` (``{surface: [added...]}``) / ``delta_lines`` a widened pin adds — nothing changed until the client retries with ``accept_capabilities`` — or ``ok=false`` + ``scan_blocked`` with ``scan_verdict`` / ``scan_findings`` (retry a caution verdict with ``force``); ``remove`` → ``ok``/``name`` plus ``cleared_memory_provider`` when the removed plugin was the live ``memory.provider``. */
+/** ``list`` → ``plugins`` + counts; ``toggle`` → ``ok``/``unchanged``/``restart_required``/``name`` (the canonical key written)/``plugin``; ``install`` → ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s ok payload; ``inspect`` → ``ok``/``agent``/``desktop``/``agent_name``/``desktop_name``/``sha`` (the commit read)/``warnings``/``insecure`` or ``ok=false`` + ``error``; ``toggle``/``install``/``update`` that loaded a plugin also carry ``gateway_reloaded`` (the running gateway picked it up and re-wired its handlers) and ``activation`` — the honest split of what is live now vs deferred, so ``restart_required`` is True only when no gateway answered or the running gateway/backend cannot import the plugin's Python dependencies (``activation.missing_dependencies``); ``update`` → ``ok``/``unchanged``/``sha``, or ``ok=false`` + ``consent_required`` with the ``delta`` (``{surface: [added...]}``) / ``delta_lines`` a widened pin adds — nothing changed until the client retries with ``accept_capabilities`` — or ``ok=false`` + ``scan_blocked`` with ``scan_verdict`` / ``scan_findings`` (retry a caution verdict with ``force``); ``remove`` → ``ok``/``name`` plus ``cleared_memory_provider`` when the removed plugin was the live ``memory.provider``. */
export interface PluginsManageResult {
plugins?: AgentPluginRow[] | null
user_count?: number | null
diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.json
index f2ad3c83ac0..9987c36464e 100644
--- a/apps/shared/src/gateway-contract.openrpc.json
+++ b/apps/shared/src/gateway-contract.openrpc.json
@@ -27879,7 +27879,7 @@
},
"PluginsManageResult": {
"additionalProperties": false,
- "description": "``list`` \u2192 ``plugins`` + counts; ``toggle`` \u2192 ``ok``/``unchanged``/``restart_required``/``name``\n(the canonical key written)/``plugin``; ``install`` \u2192 ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s\nok payload; ``inspect`` \u2192 ``ok``/``agent``/``desktop``/``agent_name``/``desktop_name``/``warnings``/``insecure``\nor ``ok=false`` + ``error``; ``toggle``/``install``/``update`` that loaded a plugin also carry ``gateway_reloaded`` (the\nrunning gateway picked it up and re-wired its handlers) and ``activation`` \u2014 the honest split of what is\nlive now vs deferred, so ``restart_required`` is True only when no gateway answered or the running\ngateway/backend cannot import the plugin's Python dependencies (``activation.missing_dependencies``); ``update`` \u2192 ``ok``/``unchanged``/``sha``, or ``ok=false`` + ``consent_required`` with the\n``delta`` (``{surface: [added...]}``) / ``delta_lines`` a widened pin adds \u2014 nothing changed until the\nclient retries with ``accept_capabilities`` \u2014 or ``ok=false`` + ``scan_blocked`` with ``scan_verdict`` /\n``scan_findings`` (retry a caution verdict with ``force``); ``remove`` \u2192 ``ok``/``name`` plus\n``cleared_memory_provider`` when the removed plugin was the live ``memory.provider``.",
+ "description": "``list`` \u2192 ``plugins`` + counts; ``toggle`` \u2192 ``ok``/``unchanged``/``restart_required``/``name``\n(the canonical key written)/``plugin``; ``install`` \u2192 ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s\nok payload; ``inspect`` \u2192 ``ok``/``agent``/``desktop``/``agent_name``/``desktop_name``/``sha`` (the commit\nread)/``warnings``/``insecure`` or ``ok=false`` + ``error``; ``toggle``/``install``/``update`` that loaded a plugin also carry ``gateway_reloaded`` (the\nrunning gateway picked it up and re-wired its handlers) and ``activation`` \u2014 the honest split of what is\nlive now vs deferred, so ``restart_required`` is True only when no gateway answered or the running\ngateway/backend cannot import the plugin's Python dependencies (``activation.missing_dependencies``); ``update`` \u2192 ``ok``/``unchanged``/``sha``, or ``ok=false`` + ``consent_required`` with the\n``delta`` (``{surface: [added...]}``) / ``delta_lines`` a widened pin adds \u2014 nothing changed until the\nclient retries with ``accept_capabilities`` \u2014 or ``ok=false`` + ``scan_blocked`` with ``scan_verdict`` /\n``scan_findings`` (retry a caution verdict with ``force``); ``remove`` \u2192 ``ok``/``name`` plus\n``cleared_memory_provider`` when the removed plugin was the live ``memory.provider``.",
"properties": {
"plugins": {
"anyOf": [
diff --git a/hermes_cli/plugins_cmd_inspect.py b/hermes_cli/plugins_cmd_inspect.py
index 6ef29077023..bb7dcb16d7a 100644
--- a/hermes_cli/plugins_cmd_inspect.py
+++ b/hermes_cli/plugins_cmd_inspect.py
@@ -75,9 +75,11 @@ def _failure(error: str, warnings: list[str], insecure: bool) -> dict[str, Any]:
def inspect_plugin_source(identifier: str, *, catalog_name: Optional[str] = None) -> dict[str, Any]:
- """``{ok, agent, desktop, agent_name, desktop_name, warnings, insecure}``, or ``ok: False`` with
+ """``{ok, agent, desktop, agent_name, desktop_name, sha, warnings, insecure}``, or ``ok: False`` with
``error``. *catalog_name* inspects the curated entry at its reviewed pin (its repo replaces
- *identifier*), so the dialog shows exactly what the catalog install will put down.
+ *identifier*), so the dialog shows exactly what the catalog install will put down. ``sha`` is the
+ commit that was read: a source that moves after review must not install a tree nobody inspected,
+ so the install is held to it, as native Desktop's probe is.
A repeat of a request (same profile home, catalog name and source) joins the clone still running
for it, or reads a successful answer it produced within :data:`_RESULT_TTL_SECONDS`. The browser
@@ -141,7 +143,7 @@ def _inspect(identifier: str, catalog_name: Optional[str]) -> dict[str, Any]:
raise_if_removed(identifier, git_url, *names)
with tempfile.TemporaryDirectory(prefix="hermes-plugin-inspect-") as tmp:
clone = Path(tmp) / "plugin"
- pc._clone_plugin_repo(clone, git_url, revision, subdir)
+ sha = pc._clone_plugin_repo(clone, git_url, revision, subdir)
root = pc._resolve_subdir_within(clone, subdir) if subdir else clone
fallback = subdir.rstrip("/").rsplit("/", 1)[-1] if subdir else pc._repo_name_from_url(git_url)
found = detect_components(root, fallback)
@@ -150,4 +152,4 @@ def _inspect(identifier: str, catalog_name: Optional[str]) -> dict[str, Any]:
if not found["agent"] and not found["desktop"]:
return _failure("No agent or desktop plugin artifacts found in this repository.", warnings, insecure)
return {"ok": True, **found, "desktop_name": _desktop_folder_name(git_url, subdir) if found["desktop"] else None,
- "warnings": warnings, "insecure": insecure}
+ "sha": sha, "warnings": warnings, "insecure": insecure}
diff --git a/scripts/ci/classify_changes.py b/scripts/ci/classify_changes.py
index 9f1a45c54c7..6481b7fd8a6 100644
--- a/scripts/ci/classify_changes.py
+++ b/scripts/ci/classify_changes.py
@@ -80,7 +80,8 @@ must never skip one a change could break:
``tests/website/test_generate_llms_txt.py`` asserts every page reaches it.
* A cross-language fixture (``_SHARED_FIXTURE_CONSUMERS``) selects the test
lanes of every consumer that reads it: the update-marker corpus runs pytest,
- cargo, vitest and the Windows hand-off tests, not only ``python``.
+ cargo, vitest and the Windows hand-off tests, not only ``python``; the plugin
+ component-detection cases run pytest and vitest.
"""
from __future__ import annotations
@@ -186,6 +187,11 @@ _SHARED_FIXTURE_CONSUMERS: dict[str, tuple[str, ...]] = {
"apps/desktop/electron/remote-update-marker-programs.test.ts", # SSH remote judge
"apps/desktop/electron/remote-lifecycle-v2-marker.test.ts", # SSH relaunch/spawn gate
),
+ # Which halves a plugin folder ships: the gateway's and native Desktop's inspectors.
+ "tests/fixtures/plugin_component_detection.json": (
+ "tests/hermes_cli/test_plugins_cmd_inspect.py", # Python: detect_components
+ "apps/desktop/electron/desktop-plugin-install.test.ts", # Electron: detectPluginComponents
+ ),
}
# What a fixture inherits from its consumers: the lanes that run them as tests.
# Not the slow suites a consumer's path also matches (an Electron test file under
diff --git a/tests/fixtures/plugin_component_detection.json b/tests/fixtures/plugin_component_detection.json
new file mode 100644
index 00000000000..90aa05a5f7e
--- /dev/null
+++ b/tests/fixtures/plugin_component_detection.json
@@ -0,0 +1,78 @@
+{
+ "schema": 1,
+ "doc": "Which halves a plugin folder ships. Both inspectors read these cases: the gateway's (hermes_cli/plugins_cmd_inspect.py detect_components) and native Desktop's (apps/desktop/electron/desktop-plugin-install.ts detectPluginComponents). A rule changed in one must change in both, and here. Each case is a folder named 'root' holding 'files'; agent_name falls back to that folder's name.",
+ "cases": [
+ {
+ "name": "yaml manifest with a package is an agent half named by the manifest",
+ "root": "folder-name",
+ "files": { "plugin.yaml": "name: from-manifest\nversion: 1.0.0\n", "__init__.py": "" },
+ "expect": { "agent": true, "desktop": false, "agent_name": "from-manifest" }
+ },
+ {
+ "name": "plugin.yml counts as the yaml manifest",
+ "root": "yml-plugin",
+ "files": { "plugin.yml": "name: yml-name\n", "__init__.py": "" },
+ "expect": { "agent": true, "desktop": false, "agent_name": "yml-name" }
+ },
+ {
+ "name": "a quoted manifest name is read without its quotes",
+ "root": "quoted",
+ "files": { "plugin.yaml": "name: \"quoted-name\"\n", "__init__.py": "" },
+ "expect": { "agent": true, "desktop": false, "agent_name": "quoted-name" }
+ },
+ {
+ "name": "a yaml manifest without a name falls back to the folder name",
+ "root": "unnamed-plugin",
+ "files": { "plugin.yaml": "version: 1.0.0\n", "__init__.py": "" },
+ "expect": { "agent": true, "desktop": false, "agent_name": "unnamed-plugin" }
+ },
+ {
+ "name": "a yaml manifest without __init__.py is not an agent half",
+ "root": "manifest-only",
+ "files": { "plugin.yaml": "name: manifest-only\n" },
+ "expect": { "agent": false, "desktop": false, "agent_name": null }
+ },
+ {
+ "name": "a portable plugin.json is an agent half named by it",
+ "root": "portable",
+ "files": { "plugin.json": "{\"name\": \"portable-one\"}" },
+ "expect": { "agent": true, "desktop": false, "agent_name": "portable-one" }
+ },
+ {
+ "name": "a portable plugin.json without a name falls back to the folder name",
+ "root": "portable-unnamed",
+ "files": { "plugin.json": "{}" },
+ "expect": { "agent": true, "desktop": false, "agent_name": "portable-unnamed" }
+ },
+ {
+ "name": "the yaml manifest names the plugin when a plugin.json is present too",
+ "root": "both-manifests",
+ "files": { "plugin.yaml": "name: yaml-wins\n", "__init__.py": "", "plugin.json": "{\"name\": \"json-loses\"}" },
+ "expect": { "agent": true, "desktop": false, "agent_name": "yaml-wins" }
+ },
+ {
+ "name": "plugin.js at the root is a desktop half",
+ "root": "ui-plugin",
+ "files": { "plugin.js": "export default {}\n" },
+ "expect": { "agent": false, "desktop": true, "agent_name": null }
+ },
+ {
+ "name": "desktop/plugin.js beside an agent half makes a mixed package",
+ "root": "mixed",
+ "files": { "plugin.yaml": "name: mixed\n", "__init__.py": "", "desktop/plugin.js": "export default {}\n" },
+ "expect": { "agent": true, "desktop": true, "agent_name": "mixed" }
+ },
+ {
+ "name": "plugin.js in any other folder is not a desktop half",
+ "root": "elsewhere",
+ "files": { "ui/plugin.js": "export default {}\n" },
+ "expect": { "agent": false, "desktop": false, "agent_name": null }
+ },
+ {
+ "name": "a folder with neither half ships nothing",
+ "root": "readme-only",
+ "files": { "README.md": "nothing here\n" },
+ "expect": { "agent": false, "desktop": false, "agent_name": null }
+ }
+ ]
+}
diff --git a/tests/hermes_cli/test_plugins_cmd_inspect.py b/tests/hermes_cli/test_plugins_cmd_inspect.py
index eb7b900b574..ded8255ffc1 100644
--- a/tests/hermes_cli/test_plugins_cmd_inspect.py
+++ b/tests/hermes_cli/test_plugins_cmd_inspect.py
@@ -4,6 +4,7 @@ Every case clones a real local Git repository through the installer's clone path
but the catalog lookup and the kill list.
"""
+import json
import subprocess
import threading
from pathlib import Path
@@ -13,7 +14,11 @@ import pytest
from hermes_cli import plugins_cmd, plugins_cmd_catalog, plugins_cmd_inspect
from hermes_cli.plugins_cmd import PluginOperationError
-from hermes_cli.plugins_cmd_inspect import inspect_plugin_source
+from hermes_cli.plugins_cmd_inspect import detect_components, inspect_plugin_source
+
+# Shared with native Desktop's detector (apps/desktop/electron/desktop-plugin-install.test.ts).
+_DETECTION_CASES = json.loads((Path(__file__).resolve().parents[1] / "fixtures/plugin_component_detection.json")
+ .read_text(encoding="utf-8-sig"))["cases"]
def _git(repo: Path, *args: str) -> str:
@@ -82,7 +87,7 @@ def test_agent_only_package_is_read_without_running_its_code(tmp_path, sentinel)
result = inspect_plugin_source(repo.as_uri())
assert result == {"ok": True, "agent": True, "desktop": False, "agent_name": "demo-agent", "desktop_name": None,
- "warnings": [result["warnings"][0]], "insecure": True}
+ "sha": _git(repo, "rev-parse", "HEAD"), "warnings": [result["warnings"][0]], "insecure": True}
assert "insecure or local scheme" in result["warnings"][0]
assert not sentinel.exists()
@@ -107,7 +112,7 @@ def test_desktop_only_and_portable_packages(tmp_path):
assert inspect_plugin_source(desktop.as_uri()) | {"warnings": []} == {
"ok": True, "agent": False, "desktop": True, "agent_name": None, "desktop_name": "ui-plugin",
- "warnings": [], "insecure": True}
+ "sha": _git(desktop, "rev-parse", "HEAD"), "warnings": [], "insecure": True}
assert inspect_plugin_source(portable.as_uri())["agent_name"] == "portable-one"
@@ -164,10 +169,35 @@ def test_catalog_entry_is_inspected_at_its_reviewed_pin(tmp_path, sentinel, monk
unknown = inspect_plugin_source("", catalog_name="missing")
assert (pinned["ok"], pinned["agent"], pinned["desktop"]) == (True, True, False)
+ assert pinned["sha"] == pin
assert unknown == {"ok": False, "agent": False, "desktop": False, "warnings": [], "insecure": False,
"error": "'missing' is not in the Hermes plugin catalog."}
+def test_the_reported_sha_is_the_commit_read_even_after_the_source_moves(tmp_path, sentinel, monkeypatch):
+ # The install is held to the reviewed commit, so a push after review must not change what is reported.
+ repo = _repo(tmp_path, _agent_files(sentinel))
+ reviewed = _git(repo, "rev-parse", "HEAD")
+
+ assert inspect_plugin_source(repo.as_uri())["sha"] == reviewed
+ moved = _commit(repo, {"desktop/plugin.js": "export default {}\n"})
+ assert inspect_plugin_source(repo.as_uri())["sha"] == reviewed # a repeat reads the same review
+
+ monkeypatch.setattr(plugins_cmd_inspect, "_RESULT_TTL_SECONDS", -1)
+ assert inspect_plugin_source(repo.as_uri())["sha"] == moved
+
+
[email protected]("case", _DETECTION_CASES, ids=lambda case: case["name"])
+def test_detection_matches_the_shared_cases(tmp_path, case):
+ root = tmp_path / case["root"]
+ root.mkdir()
+ for rel, text in case["files"].items():
+ (root / rel).parent.mkdir(parents=True, exist_ok=True)
+ (root / rel).write_text(text, encoding="utf-8")
+
+ assert detect_components(root, case["root"]) == case["expect"]
+
+
def test_inspection_writes_nothing_into_the_profile(tmp_path, sentinel, monkeypatch):
home = tmp_path / "home"
home.mkdir()
@@ -197,6 +227,7 @@ def test_retry_during_a_slow_clone_joins_it_instead_of_cloning_again(tmp_path, s
assert clones.count == 1
assert [a["agent_name"] for a in answers] == ["demo-agent", "demo-agent"]
+ assert answers[0]["sha"] == answers[1]["sha"] == _git(repo, "rev-parse", "HEAD")
assert answers[0] is not answers[1] and answers[0]["warnings"] is not answers[1]["warnings"]
diff --git a/tests/tui_gateway/test_plugins_manage_inspect.py b/tests/tui_gateway/test_plugins_manage_inspect.py
index 8150df52c70..225d6a83e65 100644
--- a/tests/tui_gateway/test_plugins_manage_inspect.py
+++ b/tests/tui_gateway/test_plugins_manage_inspect.py
@@ -35,6 +35,9 @@ def test_inspect_reports_halves_and_installs_nothing(tmp_path, monkeypatch):
assert {k: result[k] for k in ("ok", "agent", "desktop", "agent_name", "desktop_name", "insecure")} == {
"ok": True, "agent": True, "desktop": True, "agent_name": "pkg", "desktop_name": "pkg", "insecure": True}
+ head = subprocess.run(["git", "rev-parse", "HEAD"], cwd=repo, check=True, capture_output=True, text=True,
+ encoding="utf-8").stdout.strip()
+ assert result["sha"] == head
assert not (home / "plugins" / "pkg").exists()
listed = _manage(action="list")["result"]["plugins"]
assert all(row["name"] != "pkg" for row in listed)
diff --git a/tui_gateway/contracts/tools_mcp_plugins.py b/tui_gateway/contracts/tools_mcp_plugins.py
index 2bbdef6601a..14736c2a180 100644
--- a/tui_gateway/contracts/tools_mcp_plugins.py
+++ b/tui_gateway/contracts/tools_mcp_plugins.py
@@ -806,8 +806,8 @@ class PluginScanFinding(Result):
class PluginsManageResult(Result):
"""``list`` → ``plugins`` + counts; ``toggle`` → ``ok``/``unchanged``/``restart_required``/``name``
(the canonical key written)/``plugin``; ``install`` → ``hermes_cli.plugins_cmd.dashboard_install_plugin``'s
- ok payload; ``inspect`` → ``ok``/``agent``/``desktop``/``agent_name``/``desktop_name``/``warnings``/``insecure``
- or ``ok=false`` + ``error``; ``toggle``/``install``/``update`` that loaded a plugin also carry ``gateway_reloaded`` (the
+ ok payload; ``inspect`` → ``ok``/``agent``/``desktop``/``agent_name``/``desktop_name``/``sha`` (the commit
+ read)/``warnings``/``insecure`` or ``ok=false`` + ``error``; ``toggle``/``install``/``update`` that loaded a plugin also carry ``gateway_reloaded`` (the
running gateway picked it up and re-wired its handlers) and ``activation`` — the honest split of what is
live now vs deferred, so ``restart_required`` is True only when no gateway answered or the running
gateway/backend cannot import the plugin's Python dependencies (``activation.missing_dependencies``); ``update`` → ``ok``/``unchanged``/``sha``, or ``ok=false`` + ``consent_required`` with the
@@ -851,8 +851,9 @@ class PluginsManageResult(Result):
onboarding: list[OnboardingCatalogPlugin] | None = None
# ``presence`` → the named catalog plugins this OS runs, in the order asked; unknown names dropped.
presence: list[CatalogPluginPresence] | None = None
- # ``inspect`` → which halves the source ships (``ok`` + ``warnings``, or ``ok=false`` + ``error``) and
- # whether its URL scheme is insecure; nothing was installed (``hermes_cli.plugins_cmd_inspect``).
+ # ``inspect`` → which halves the source ships (``ok`` + ``warnings``, or ``ok=false`` + ``error``),
+ # the commit it read (``sha``) and whether its URL scheme is insecure; nothing was installed
+ # (``hermes_cli.plugins_cmd_inspect``).
agent: bool | None = None
desktop: bool | None = None
agent_name: str | None = None