The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): the catalog lookup falls back only for a backend without the method
alt-glitch97c5f5b59062
diff --git a/apps/desktop/src/lib/plugin-catalog.test.ts b/apps/desktop/src/lib/plugin-catalog.test.tsindex d08f862bb5b..0d0bf02005d 100644--- a/apps/desktop/src/lib/plugin-catalog.test.ts+++ b/apps/desktop/src/lib/plugin-catalog.test.ts@@ -1,34 +1,29 @@+import { JSON_RPC_METHOD_NOT_FOUND, JsonRpcGatewayError } from '@hermes/shared'import { describe, expect, it, vi } from 'vitest'-import { type CatalogRequest, lookupPluginCatalogEntry } from './plugin-catalog'+import { type CatalogLookupReply, type CatalogRequest, lookupPluginCatalogEntry } from './plugin-catalog'const SHA = 'a'.repeat(40)const replying =- (reply: unknown): CatalogRequest =>- async <T>() =>- reply as T+ (reply: CatalogLookupReply | null | undefined): CatalogRequest =>+ async () =>+ reply-const noFetch = vi.fn(async () => {+const noFetch = vi.fn<typeof fetch>(async () => {throw new Error('the renderer must not fetch the docs host when the backend answers')-}) as unknown as typeof fetch+})describe('lookupPluginCatalogEntry', () => {- it('asks the backend, not the docs host (its 301 has no CORS header)', async () => {- const calls: [string, Record<string, unknown>][] = []+ it('asks the backend for the entry, not the docs host', async () => {const found = { name: 'aihubmix', repo: 'https://github.com/AIhubmix/mono', sha: SHA, subdir: 'aihubmix' }-- const request: CatalogRequest = async <T>(method: string, params: Record<string, unknown>) => {- calls.push([method, params])-- return { status: 'found', entry: found } as T- }+ const request = vi.fn<CatalogRequest>(async () => ({ status: 'found', entry: found }))await expect(lookupPluginCatalogEntry(' aihubmix ', { fetchImpl: noFetch, request })).resolves.toEqual({ok: true,- entry: { name: 'aihubmix', repo: 'https://github.com/AIhubmix/mono', sha: SHA, subdir: 'aihubmix' }+ entry: found})- expect(calls).toEqual([['plugins.catalog.lookup', { name: 'aihubmix' }]])+ expect(request.mock.calls).toEqual([['plugins.catalog.lookup', { name: 'aihubmix' }]])expect(noFetch).not.toHaveBeenCalled()})@@ -50,27 +45,21 @@ describe('lookupPluginCatalogEntry', () => {})it('refuses a non-catalog name before asking anyone', async () => {- const asked: string[] = []-- const request: CatalogRequest = async <T>(method: string) => {- asked.push(method)-- return { status: 'found' } as T- }+ const request = vi.fn<CatalogRequest>(async () => ({ status: 'found' }))await expect(lookupPluginCatalogEntry('../etc', { fetchImpl: noFetch, request })).resolves.toEqual({ok: false,error: 'invalid_name'})- expect(asked).toEqual([])+ expect(request).not.toHaveBeenCalled()})- it('falls back to the direct feed only when the backend cannot answer', async () => {+ it('falls back to the direct feed only when the backend predates the lookup', async () => {const feed = [{ name: 'weather', repo: 'https://github.com/x/weather', sha: SHA, subdir: '' }]- const fetchImpl = vi.fn(async () => new Response(JSON.stringify(feed))) as unknown as typeof fetch+ const fetchImpl = vi.fn<typeof fetch>(async () => new Response(JSON.stringify(feed)))const request: CatalogRequest = async () => {- throw new Error('method not found: plugins.catalog.lookup')+ throw new JsonRpcGatewayError('method not found: plugins.catalog.lookup', { code: JSON_RPC_METHOD_NOT_FOUND })}await expect(lookupPluginCatalogEntry('weather', { fetchImpl, request })).resolves.toMatchObject({@@ -79,4 +68,16 @@ describe('lookupPluginCatalogEntry', () => {})expect(fetchImpl).toHaveBeenCalledTimes(1)})++ it('reads an unreachable backend as unavailable, without fetching', async () => {+ const request: CatalogRequest = async () => {+ throw new Error('Hermes gateway unavailable for profile "default"')+ }++ await expect(lookupPluginCatalogEntry('weather', { fetchImpl: noFetch, request })).resolves.toEqual({+ ok: false,+ error: 'unavailable'+ })+ expect(noFetch).not.toHaveBeenCalled()+ })})diff --git a/apps/desktop/src/lib/plugin-catalog.ts b/apps/desktop/src/lib/plugin-catalog.tsindex 409ade35869..5d25d468be3 100644--- a/apps/desktop/src/lib/plugin-catalog.ts+++ b/apps/desktop/src/lib/plugin-catalog.ts@@ -9,15 +9,17 @@* always agree on the repo, subdir and reviewed pin for a name.** The lookup asks the backend (`plugins.catalog.lookup`), which reads the live- * catalog with its cache, kill list and in-tree fallback. The renderer can't- * fetch the JSON itself: the docs host answers with a cross-origin 301 that- * carries no CORS header, so the browser rejects it (hermes-agent 136483). Only- * a backend that predates the method falls back to the direct fetch.+ * catalog with its cache, kill list and in-tree fallback: the same catalog the+ * install resolves its pin from. A renderer fetch of the JSON also depends on+ * the docs host's cross-origin redirect carrying a CORS header, which it did+ * not until 2026-10-13 (hermes-agent 136483). Only a backend that predates the+ * method falls back to the direct fetch.** Everything here only classifies — nothing installs. Callers open the Install* Plugin dialog, which still requires the user's explicit confirmation.*/+import { isMissingRpcMethod } from '@/lib/gateway-rpc'import { activeGatewayProfileKey, requestGatewayForProfile } from '@/store/gateway'export const CATALOG_ORIGIN = 'https://hermes-agent.nousresearch.com'@@ -64,16 +66,20 @@ function asEntry(raw: unknown): null | PluginCatalogEntry {}}-/** A gateway RPC, as `requestGatewayForProfile` sends it for the active profile. */-export type CatalogRequest = <T>(method: string, params: Record<string, unknown>) => Promise<T>--interface CatalogLookupReply {+/** What `plugins.catalog.lookup` answers; `entry` is parsed by `asEntry`, so a malformed one degrades. */+export interface CatalogLookupReply {entry?: unknownstatus?: string}+/** The lookup RPC for one name, as `requestGatewayForProfile` sends it for the active profile. */+export type CatalogRequest = (+ method: 'plugins.catalog.lookup',+ params: { name: string }+) => Promise<CatalogLookupReply | null | undefined>+const activeProfileRequest: CatalogRequest = (method, params) =>- requestGatewayForProfile(activeGatewayProfileKey(), method, params, LOOKUP_TIMEOUT_MS)+ requestGatewayForProfile<CatalogLookupReply>(activeGatewayProfileKey(), method, params, LOOKUP_TIMEOUT_MS)async function lookupFromFeed(name: string, fetchImpl: typeof fetch): Promise<PluginCatalogLookup> {let rows: unknown@@ -106,8 +112,8 @@ async function lookupFromFeed(name: string, fetchImpl: typeof fetch): Promise<Pl/*** Look one name up in the live catalog. Unknown names are a hard `unknown`,* never a guess: the deep link must not turn an arbitrary string into a git- * identifier the dialog would then clone. The backend answers; a backend that- * can't (older than the method, or unreachable) falls back to the direct fetch.+ * identifier the dialog would then clone. The backend answers; only a backend+ * older than the method falls back to the direct fetch.*/export async function lookupPluginCatalogEntry(name: string,@@ -125,9 +131,10 @@ export async function lookupPluginCatalogEntry(let reply: CatalogLookupReply | null | undefinedtry {- reply = await request<CatalogLookupReply>('plugins.catalog.lookup', { name: trimmed })- } catch {- return lookupFromFeed(trimmed, fetchImpl)+ reply = await request('plugins.catalog.lookup', { name: trimmed })+ } catch (error) {+ // Only a backend that predates the method falls back; an unreachable one can't run the install either.+ return isMissingRpcMethod(error) ? lookupFromFeed(trimmed, fetchImpl) : { ok: false, error: 'unavailable' }}// A malformed success reply (null, no status) degrades like every other failure.diff --git a/tui_gateway/methods_plugin_catalog.py b/tui_gateway/methods_plugin_catalog.pyindex f9b09f61aef..5400beec4cb 100644--- a/tui_gateway/methods_plugin_catalog.py+++ b/tui_gateway/methods_plugin_catalog.py@@ -21,7 +21,7 @@ _profile_scoped = _registry.profile_scoped@method("plugins.catalog.lookup")@_profile_scopeddef _(rid, params: dict) -> dict:- from hermes_cli.plugin_catalog import find_removed, load_catalog_live+ from hermes_cli.plugin_catalog import load_catalog_live, match_removed, resolved_removed_entriesfrom hermes_cli.plugins_cmd_catalog import looks_like_catalog_namename = str(params.get("name") or "").strip()@@ -34,7 +34,8 @@ def _(rid, params: dict) -> dict:return _ok(rid, {"status": "unavailable"})entry = next((e for e in entries if e.name == name), None)# A removed name or repo is never offered: install would refuse it anyway.- if entry is None or find_removed(entry.name) or find_removed(entry.repo):+ removed = resolved_removed_entries() if entry else []+ if entry is None or match_removed(entry.name, removed) or match_removed(entry.repo, removed):return _ok(rid, {"status": "unknown"})return _ok(rid, {"status": "found", "entry": {"name": entry.name, "repo": entry.repo, "sha": entry.sha,"subdir": entry.subdir}})