Skip to content

The agent that grows with you

fix(bot-mode): every @hermes reader follows the real-'hermes'-profile claim

Tekniuma3c7d4a5661d
diff --git a/apps/desktop/src/plugins/hermes-bots/bot-row.tsx b/apps/desktop/src/plugins/hermes-bots/bot-row.tsx
index f0c7a2864ca..7c220f713e2 100644
--- a/apps/desktop/src/plugins/hermes-bots/bot-row.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/bot-row.tsx
@@ -187,7 +187,7 @@ export function BotRow({ bot, onDelete, onEdit, onGroup, onNewSection, showHandl
// resolved the pinned canonical chat, preview THAT session β€” not the
// profile's most recent (but unrelated) activity. Liveness checks above
// keep last_session semantics: any recent activity means the bot is alive.
- const { fromBot } = previewKind(previewSession?.preview)
+ const { fromBot } = previewKind(previewSession?.preview, $lastRoster.get(), bot.connectionId)
// DM previews read like DMs: strip the delivery prefix, keep the message.
const displayPreview = stripPreviewMarkdown(
diff --git a/apps/desktop/src/plugins/hermes-bots/cron.tsx b/apps/desktop/src/plugins/hermes-bots/cron.tsx
index 166aac1a0b9..40b0ec9981e 100644
--- a/apps/desktop/src/plugins/hermes-bots/cron.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/cron.tsx
@@ -55,7 +55,7 @@ const ROUTINES_KEY = [ID, 'routines']
/** Last good cron list, same idea as the roster snapshot. */
const $lastJobs = atom<RoutineJob[]>([])
-function showsHandle(name: string, meta: BotMeta | null | undefined, bot?: RosterRow) {
+function showsHandle(name: string, meta: BotMeta | null | undefined, bot?: RosterRow | null) {
const display = displayName(
{
name
@@ -1270,8 +1270,8 @@ export function RoutinesPane() {
meta
)}
</div>
- {showsHandle(bot, meta) ? (
- <span className="shrink-0 font-mono text-[0.65rem] text-(--ui-text-quaternary)">{`@${botHandle(bot)}`}</span>
+ {showsHandle(bot, meta, owner) ? (
+ <span className="shrink-0 font-mono text-[0.65rem] text-(--ui-text-quaternary)">{`@${botHandle(bot, owner)}`}</span>
) : null}
</div>
<div className="text-[0.65rem] uppercase tracking-wider text-(--ui-text-quaternary)">{c.title}</div>
diff --git a/apps/desktop/src/plugins/hermes-bots/data.hermes-handle.test.ts b/apps/desktop/src/plugins/hermes-bots/data.hermes-handle.test.ts
index 7927afe8051..c9f1d0900cd 100644
--- a/apps/desktop/src/plugins/hermes-bots/data.hermes-handle.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/data.hermes-handle.test.ts
@@ -8,6 +8,7 @@
import { describe, expect, it, vi } from 'vitest'
import { botHandle, botMentionTag, claimDefaultHandles, mergeMultiSourceRoster, resolveRosterMentions } from './data'
+import { previewKind } from './row-helpers'
import type { RosterRow } from './types'
vi.mock('@hermes/plugin-sdk', async () => {
@@ -67,4 +68,30 @@ describe('the @hermes handle', () => {
expect(rows.map(row => botHandle(String(row.name), row))).toEqual(['hermes', 'default', 'hermes'])
})
+
+ it("never lets a source's stale 'hermes' handle on its default answer @hermes", () => {
+ // An older backend labels its default @hermes even beside a real hermes profile.
+ const rows = claimDefaultHandles<RosterRow>([
+ { connectionId: 'mini', handle: 'hermes', name: 'default', remoteSource: true },
+ { connectionId: 'mini', handle: 'hermes', name: 'hermes', remoteSource: true },
+ { connectionId: 'local', name: 'researcher' }
+ ])
+
+ expect(resolveRosterMentions('@hermes ping', rows, { name: 'researcher' }).map(row => row.name)).toEqual(['hermes'])
+ })
+
+ it('names a DM sender in a row preview by its roster handle', () => {
+ const rows = claimDefaultHandles<RosterRow>(
+ ['default', 'hermes', 'researcher'].map(name => ({ connectionId: 'local', name }))
+ )
+
+ const sender = (name: string, list: RosterRow[]) =>
+ previewKind(`Message from πŸ€– ${name} (@x): hi`, list, 'local').fromBot
+
+ expect([sender('default', rows), sender('hermes', rows)]).toEqual(['default', 'hermes'])
+ // No real hermes profile: the default is still @hermes (#89484).
+ expect(sender('default', claimDefaultHandles<RosterRow>([{ connectionId: 'local', name: 'default' }]))).toBe(
+ 'hermes'
+ )
+ })
})
diff --git a/apps/desktop/src/plugins/hermes-bots/data.ts b/apps/desktop/src/plugins/hermes-bots/data.ts
index d86dfa082cb..67369b23acc 100644
--- a/apps/desktop/src/plugins/hermes-bots/data.ts
+++ b/apps/desktop/src/plugins/hermes-bots/data.ts
@@ -1188,6 +1188,13 @@ export function botHandle(name: string, bot?: Partial<RosterRow> | null): string
return (name || '').trim().toLowerCase() === 'default' && !bot?.hermesHandleTaken ? 'hermes' : name
}
+/** The row's own `handle` as a mention form, lowercased. A stale 'hermes'
+ * handle on a default row whose source has a real 'hermes' profile is that
+ * profile's tag, not this row's (same rule as `botHandle`). */
+function claimableRowHandle(bot: Partial<RosterRow>): string {
+ return bot.handle && !(bot.hermesHandleTaken && bot.handle === 'hermes') ? String(bot.handle).toLowerCase() : ''
+}
+
/** Mark each default row whose source also lists a real `hermes` profile, so
* that profile keeps @hermes and the roster never shows two (the backend's
* `tools/bot_mode_probe._handle` applies the same rule). Rows group by
@@ -1380,8 +1387,10 @@ export function resolveRosterMentions(
const name = String(bot.name || '').toLowerCase()
const forms = new Set([handle, name])
- if (bot.handle) {
- forms.add(String(bot.handle).toLowerCase())
+ const rowHandle = claimableRowHandle(bot)
+
+ if (rowHandle) {
+ forms.add(rowHandle)
}
// Renamed bots are taggable by their friendly names too β€” the core
diff --git a/apps/desktop/src/plugins/hermes-bots/group-chat.ts b/apps/desktop/src/plugins/hermes-bots/group-chat.ts
index d74f5378cec..764905a56cc 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-chat.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-chat.ts
@@ -382,6 +382,11 @@ export function groupChatSyncSnapshot(
? {
sourceScoped: true
}
+ : {}),
+ ...(member?.hermesHandleTaken
+ ? {
+ hermesHandleTaken: true
+ }
: {})
})),
...(typeof room?.image === 'string' && room.image.length <= GROUP_CHAT_SYNC_IMAGE_CHARS
diff --git a/apps/desktop/src/plugins/hermes-bots/group-membership.ts b/apps/desktop/src/plugins/hermes-bots/group-membership.ts
index cc7667119f2..c3c73960bee 100644
--- a/apps/desktop/src/plugins/hermes-bots/group-membership.ts
+++ b/apps/desktop/src/plugins/hermes-bots/group-membership.ts
@@ -424,6 +424,15 @@ export function durableGroupChatMembers(bots: RosterRow[]): GroupMember[] {
return {
name: bot.name,
handle: botHandle(bot.name, bot) || bot.handle || bot.name,
+ // The stored handle alone cannot say why a default is not @hermes, and
+ // botHandle re-derives 'hermes' for it: keep the claim, or a room whose
+ // live row is gone tells two bots they are both @hermes. A live row
+ // (groupChatMemberBots prefers it) recomputes this from the roster.
+ ...(bot.hermesHandleTaken
+ ? {
+ hermesHandleTaken: true
+ }
+ : {}),
...(title
? {
title
diff --git a/apps/desktop/src/plugins/hermes-bots/group-rounds.hermes-handle.test.ts b/apps/desktop/src/plugins/hermes-bots/group-rounds.hermes-handle.test.ts
new file mode 100644
index 00000000000..f22d2224590
--- /dev/null
+++ b/apps/desktop/src/plugins/hermes-bots/group-rounds.hermes-handle.test.ts
@@ -0,0 +1,56 @@
+/**
+ * A room holding the default bot and a real (pre-reservation) `hermes`
+ * profile: the stored member descriptors must keep the roster's claim, or
+ * every reader that re-derives handles from them (the turn prompt, mention
+ * parsing, the next re-persist) tells both bots they are @hermes.
+ */
+
+import { beforeEach, expect, it, vi } from 'vitest'
+
+import { botMentionTag, claimDefaultHandles } from './data'
+import { $groupChats } from './group-chat'
+import { durableGroupChatMembers, groupMemberKey } from './group-membership'
+import { buildGroupChatTurnPrompt } from './group-round-prompt'
+import { parseGroupChatMentions } from './group-rounds'
+import type { RosterRow } from './types'
+
+vi.mock('@hermes/plugin-sdk', async () => {
+ const { atom } = await import('nanostores')
+
+ return {
+ atom,
+ host: { request: vi.fn(), state: { connectionId: { get: () => 'local' }, profile: { get: () => 'default' } } },
+ queryClient: { invalidateQueries: vi.fn() },
+ useQuery: vi.fn(),
+ useValue: vi.fn()
+ }
+})
+vi.mock('./shared', () => ({ getPluginCtx: () => null, ID: 'hermes-bots' }))
+
+beforeEach(() => $groupChats.set({}))
+
+it('keeps @default and @hermes apart in a room whose live roster rows are gone', () => {
+ const live = claimDefaultHandles<RosterRow>(
+ ['default', 'hermes', 'researcher'].map(name => ({ connectionId: 'local', name }))
+ )
+
+ const stored = durableGroupChatMembers(live)
+ // The next send re-persists from whatever is seated β€” the stored rows here.
+ const repersisted = durableGroupChatMembers(stored as RosterRow[])
+
+ for (const members of [stored, repersisted]) {
+ expect(members.map(member => botMentionTag(member))).toEqual(['default', 'hermes', 'researcher'])
+ expect([...parseGroupChatMentions('@hermes please review', members).mentioned]).toEqual([
+ groupMemberKey(members[1])
+ ])
+ expect([...parseGroupChatMentions('@default please review', members).mentioned]).toEqual([
+ groupMemberKey(members[0])
+ ])
+
+ const header = (viewer: number) =>
+ buildGroupChatTurnPrompt({ groupName: 'g', members, viewer: members[viewer], deltaLines: [] }).split('\n')[0]
+
+ expect(header(0)).toMatch(/You are @default, one participant in a group chat with @hermes \[on local\], @researcher/)
+ expect(header(1)).toMatch(/You are @hermes, one participant in a group chat with @default \[on local\], @researcher/)
+ }
+})
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts b/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
index 89cb62d4ffd..94625d515cf 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.mentions.test.ts
@@ -19,7 +19,7 @@
* composes no CLI handoff and delivers nothing itself.
*/
-import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
+import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import type { RosterRow } from './types'
@@ -539,3 +539,46 @@ describe('the mention middleware', () => {
expect((await handler({ text: untouched })).text).toBe(untouched)
})
})
+
+describe('the local default when a real hermes profile exists', () => {
+ const RAW = ['default', 'hermes', 'researcher'].map(name => ({
+ connectionId: 'local',
+ connectionKind: 'local',
+ connectionLabel: 'This device',
+ name
+ }))
+
+ afterEach(() => {
+ hostMock.request.mockImplementation(async () => ({}))
+ })
+
+ it.each([
+ ['a warm roster cache', 'warm'],
+ ['a cold cache primed from the raw backend rows', 'cold']
+ ])('hands the agent a target that reaches the profile the user tagged (%s)', async (_label, cache) => {
+ if (cache === 'cold') {
+ // What the backend's profiles.list and Electron's union roster report: raw names, bare handles.
+ hostMock.request.mockImplementation(async () => ({ profiles: RAW }))
+ hostMock.agents.mockResolvedValueOnce({
+ agents: RAW.map(({ name, ...row }) => ({ ...row, handle: name, profile: name, targetProfile: name })),
+ sources: [{ connectionId: 'local', kind: 'local' }]
+ })
+ }
+
+ const { claimDefaultHandles } = await import('./data')
+
+ const { handler } = await contributions({
+ focused: 'researcher',
+ profiles: cache === 'warm' ? (claimDefaultHandles(RAW as RosterRow[]) as never) : null
+ })
+
+ const toDefault = (await handler({ text: 'please ask @default to review' })).text
+ const toHermes = (await handler({ text: 'please ask @hermes to review' })).text
+
+ // message_agent maps 'hermes' to the real hermes profile, so the default must never be handed it.
+ expect(toDefault).toMatch(/@default = agent profile "default"/)
+ expect(toDefault).not.toMatch(/message_agent target: "hermes"/)
+ expect(toHermes).toMatch(/@hermes = agent profile "hermes"/)
+ expect(toHermes).not.toMatch(/agent profile "default"/)
+ })
+})
diff --git a/apps/desktop/src/plugins/hermes-bots/plugin.tsx b/apps/desktop/src/plugins/hermes-bots/plugin.tsx
index adc7deb5ed2..eee40a32a7e 100644
--- a/apps/desktop/src/plugins/hermes-bots/plugin.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/plugin.tsx
@@ -47,6 +47,7 @@ import {
botMentionTag,
botSelectionKey,
cachedUnionRoster,
+ claimDefaultHandles,
isActiveRosterBot,
migrateBotMeta,
primeRoster,
@@ -830,7 +831,9 @@ export default {
// Same resolver as the cached path β€” renamed bots (display_name
// / ui_meta title) stay taggable when the roster cache is cold.
- mentionedBots = resolveRosterMentions(text, res?.profiles ?? [], live).map(bot => ({
+ // The same handle claim the pane applies: a real 'hermes'
+ // profile keeps @hermes, so the default must not answer it too.
+ mentionedBots = resolveRosterMentions(text, claimDefaultHandles(res?.profiles ?? []), live).map(bot => ({
...bot,
remoteSource: false
}))
@@ -860,8 +863,12 @@ export default {
// local path a bare profile name or 'hermes'. botHandle() prefers
// the row's source-qualified UI alias ('default-vera'), which
// neither resolver accepts β€” annotate the canonical form instead.
+ // The default's canonical form is 'hermes' only while no real
+ // 'hermes' profile holds it; then it is 'default' itself.
const target =
- bot.remoteSource && bot.connectionId ? `${bot.name}@${bot.connectionId}` : botHandle(bot.name)
+ bot.remoteSource && bot.connectionId
+ ? `${bot.name}@${bot.connectionId}`
+ : botHandle(bot.name, { hermesHandleTaken: bot.hermesHandleTaken })
// Local rows get the same annotation whenever their UI alias
// ('default-this-device') differs from the resolvable handle β€”
diff --git a/apps/desktop/src/plugins/hermes-bots/row-helpers.ts b/apps/desktop/src/plugins/hermes-bots/row-helpers.ts
index ec8bd2b6919..50192c70c38 100644
--- a/apps/desktop/src/plugins/hermes-bots/row-helpers.ts
+++ b/apps/desktop/src/plugins/hermes-bots/row-helpers.ts
@@ -24,8 +24,14 @@ export const A2A_PREFIX_RE = /^Message from (?:agent '[^']+'|πŸ€–[^:]+):\s*/i
/** Classify a roster preview: `{ fromBot: handle|null }`. A preview that
* starts with the delivery prefix is a bot-to-bot message β€” the receiving
- * bot's row should show WHO sent it, not present it as the human's chat. */
-export function previewKind(preview: null | string | undefined): { fromBot: null | string } {
+ * bot's row should show WHO sent it, not present it as the human's chat.
+ * `roster` + `connectionId` name the sender's row on the receiver's source,
+ * so its handle follows the roster (a real 'hermes' profile keeps @hermes). */
+export function previewKind(
+ preview: null | string | undefined,
+ roster: readonly Partial<RosterRow>[] = [],
+ connectionId?: string
+): { fromBot: null | string } {
const text = (preview || '').trim()
if (!text) {
@@ -42,8 +48,12 @@ export function previewKind(preview: null | string | undefined): { fromBot: null
// profile reads @hermes, never @default (#89484).
const sender = (match[1] || match[2] || '').trim().toLowerCase()
+ const row = roster.find(
+ bot => bot?.name === sender && (!connectionId || String(bot?.connectionId || '') === connectionId)
+ )
+
return {
- fromBot: sender ? botHandle(sender) : null
+ fromBot: sender ? botHandle(sender, row) : null
}
}
diff --git a/apps/desktop/src/plugins/hermes-bots/types.ts b/apps/desktop/src/plugins/hermes-bots/types.ts
index 11e687edb24..e424253d094 100644
--- a/apps/desktop/src/plugins/hermes-bots/types.ts
+++ b/apps/desktop/src/plugins/hermes-bots/types.ts
@@ -150,6 +150,7 @@ export type GroupMember = Pick<
| 'display_name'
| 'ghost'
| 'handle'
+ | 'hermesHandleTaken'
| 'installId'
| 'name'
| 'previous_names'
diff --git a/gateway/platforms/api_server_profile_prefix.py b/gateway/platforms/api_server_profile_prefix.py
index 06ec806df2b..4da71630df6 100644
--- a/gateway/platforms/api_server_profile_prefix.py
+++ b/gateway/platforms/api_server_profile_prefix.py
@@ -23,11 +23,22 @@ def _handle_is_free() -> bool:
return False
+def _prefix_profile(request: Any) -> str:
+ """The prefix as a canonical profile id. Profile ids are lowercase on disk and every other
+ reader (``get_profile_dir``, ``profile_exists``, the peer client) normalizes case, so
+ ``/p/Hermes/`` must name the same profile ``/p/hermes/`` does, never fall to the alias."""
+ raw = (request.match_info.get("profile") or "").strip()
+ if not raw:
+ return ""
+ from hermes_cli.profiles import normalize_profile_name
+ return normalize_profile_name(raw)
+
+
def rejection_response(request: Any):
"""The 404 for a rejected prefix. A 'hermes' profile this gateway does not serve gets its own
body, so a peer reads it as "exists elsewhere", never as "no such profile, use default"."""
from aiohttp import web
- if (request.match_info.get("profile") or "").strip() == DEFAULT_PROFILE_HANDLE and not _handle_is_free():
+ if _prefix_profile(request) == DEFAULT_PROFILE_HANDLE and not _handle_is_free():
return web.json_response({"error": {
"message": f"Profile '{DEFAULT_PROFILE_HANDLE}' exists on this host but this gateway does not serve it",
"code": "profile_not_served"}}, status=404)
@@ -41,7 +52,7 @@ def resolve_request_profile(adapter: Any, request: Any):
``hermes`` reaches the default profile, because peers address the mirror by the handle their
roster shows (#118076), unless the host has a profile literally named ``hermes``."""
from gateway.platforms.api_server import _PROFILE_REJECTED, _prefix_names_served_profile
- profile = (request.match_info.get("profile") or "").strip()
+ profile = _prefix_profile(request)
if not profile:
return None
alias = profile == DEFAULT_PROFILE_HANDLE
diff --git a/hermes_cli/subcommands/peer.py b/hermes_cli/subcommands/peer.py
index e020b63752f..1fda8eac53c 100644
--- a/hermes_cli/subcommands/peer.py
+++ b/hermes_cli/subcommands/peer.py
@@ -121,7 +121,7 @@ def _resolve_base(peer: dict, profile: str | None, key: str) -> str:
must keep winning β€” so ``/p/hermes`` is tried first and ``/p/default`` is used only when the
peer itself answers that it has no such profile (an older peer has no alias on its side)."""
base = _base_url(peer, profile)
- if not profile or profile.lower() != DEFAULT_PROFILE_HANDLE:
+ if profile != DEFAULT_PROFILE_HANDLE:
return base
try:
_request(f"{base}/health", key)
@@ -188,6 +188,11 @@ def _parse_target(target: str) -> tuple[str, str | None]:
raise ValueError("Peer name required (hermes peer dm <peer>[/<agent>] ...)")
if profile and not _PROFILE_RE.match(profile):
raise ValueError(f"Invalid agent/profile name: {profile!r}")
+ if profile:
+ # Profile ids are lowercase (normalize_profile_name); 'box/Hermes' must address the
+ # peer's real 'hermes' profile, never reach the /p/default fallback by case alone.
+ from hermes_cli.profiles import normalize_profile_name
+ profile = normalize_profile_name(profile)
return peer, profile
diff --git a/tests/gateway/test_multiplex_api_server_routing.py b/tests/gateway/test_multiplex_api_server_routing.py
index 6d7d5573b77..2f8aee6ef34 100644
--- a/tests/gateway/test_multiplex_api_server_routing.py
+++ b/tests/gateway/test_multiplex_api_server_routing.py
@@ -145,6 +145,40 @@ async def test_hermes_handle_reaches_the_default_profile_only_when_no_hermes_pro
assert (prefix, resp.status, body) == (prefix, 200, {"profile": expected})
[email protected]("multiplex,legacy_hermes,answers", [
+ (True, True, {"Hermes": "hermes", "HERMES": "hermes", "Worker": "worker", "Default": "default"}),
+ (True, False, {"Hermes": "default", "Worker": "worker"}),
+ (False, True, {"Hermes": _NOT_SERVED}),
+ (False, False, {"Hermes": None}),
+])
+async def test_profile_prefix_names_the_same_profile_in_any_case(tmp_path, monkeypatch, multiplex, legacy_hermes, answers):
+ """Profile ids are lowercase (``normalize_profile_name``), so ``/p/Hermes/`` is ``/p/hermes/``:
+ a real 'hermes' profile keeps it, and only without one does it alias the default. An
+ exact-case comparison answered it with the unknown-profile 404 that peers reroute to the
+ default profile, misdelivering box/Hermes."""
+ root = tmp_path / "root"
+ for home in [root, root / "profiles" / "worker"] + ([root / "profiles" / "hermes"] if legacy_hermes else []):
+ home.mkdir(parents=True, exist_ok=True)
+ (home / "config.yaml").write_text("{}\n", encoding="utf-8")
+ monkeypatch.setenv("HERMES_HOME", str(root))
+ adapter = _make_adapter(multiplex=multiplex)
+
+ async def handler(request):
+ return web.json_response({"profile": _api_request_profile.get()})
+
+ app = web.Application(middlewares=[adapter._make_profile_prefix_middleware()])
+ app.router.add_get("/p/{profile}/v1/test", handler)
+ async with TestClient(TestServer(app)) as cli:
+ for prefix, expected in answers.items():
+ resp = await cli.get(f"/p/{prefix}/v1/test")
+ body = await resp.json()
+ if expected == _NOT_SERVED:
+ assert (prefix, resp.status, body["error"]["code"]) == (prefix, 404, _NOT_SERVED)
+ else:
+ assert (prefix, resp.status, body) == (prefix, 200, {"profile": expected})
+
+
diff --git a/tests/hermes_cli/test_peer_cmd.py b/tests/hermes_cli/test_peer_cmd.py
index dea9de46e47..cd2ec0f3fef 100644
--- a/tests/hermes_cli/test_peer_cmd.py
+++ b/tests/hermes_cli/test_peer_cmd.py
@@ -118,6 +118,24 @@ def test_hermes_handle_reaches_the_profile_the_peer_serves(
assert {hit.split("/")[2] for hit in _ProfilePeer.hits if not hit.endswith("/health")} == {expected}
[email protected]("target", ["box/Hermes", "box/HERMES"])
+def test_mixed_case_hermes_target_reaches_the_peers_real_hermes_profile(monkeypatch, capsys, target):
+ """Profile ids are lowercase, so ``box/Hermes`` is ``box/hermes``. A peer comparing prefixes
+ exactly (every peer before the case fix) answers ``/p/Hermes`` with its unknown-profile 404,
+ which the @hermes fallback read as "no hermes here" and rerouted the DM to the default."""
+ _ProfilePeer.served, _ProfilePeer.probe_status, _ProfilePeer.hits = {"default", "hermes"}, 200, []
+ _ProfilePeer.refusal = {"error": "Unknown or unconfigured profile"}
+ server = HTTPServer(("127.0.0.1", 0), _ProfilePeer)
+ threading.Thread(target=server.serve_forever, daemon=True).start()
+ monkeypatch.setattr(peer_cmd, "_load_peers", lambda: {"box": {"url": f"http://127.0.0.1:{server.server_port}"}})
+ monkeypatch.setattr(peer_cmd, "_peer_secret", lambda name: "secret-key-123456")
+ try:
+ rc = peer_cmd.cmd_peer(SimpleNamespace(peer_action="dm", target=target, message="hi", json=True))
+ finally:
+ server.shutdown()
+ assert (rc, json.loads(capsys.readouterr().out)["reply"]) == (0, "from hermes")
+
+
# ── registry round-trip (isolated config) ────────────────────────────────────