From 3261623f90e674f7c469cc1faff02bf9f33cf8b8 Mon Sep 17 00:00:00 2001 From: Ben Davis <45952064+bmdavis419@users.noreply.github.com> Date: Fri, 24 Jul 2026 22:40:31 -0700 Subject: [PATCH] fix: make Hermes pairing recoverable and self-updating MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A failed enrollment left an orphaned provider instance in the picker, permanently `instance-not-found`, with no explanation and no way to clear it except editing settings by hand. Enrolling before persisting is not possible: `createEnrollment` reads `providerInstances[instanceId]` and fails unless the instance is already persisted with the Hermes driver, so the settings write is a hard precondition of the RPC. The failure path therefore cleans up after itself. The write registers a pending undo in a ref rather than closure state, and two effects drain it — the existing `!open` reset and a new unmount cleanup, since the parent renders this dialog conditionally and closing unmounts it, so the `!open` branch alone would never run. Rollback reads the latest settings map instead of restoring a captured pre-write snapshot, which would silently revert instances another client added in the interim, and no-ops when the entry is already gone or was replaced. The claimed instance id is retained across a rollback with a `persisted: false` flag so the retry path still refuses to mint a duplicate id while knowing it must re-write the instance. Pairing completes out-of-band on another host, so the dialog now shows an explicit waiting state: what to run, that `hermes gateway restart` is required rather than an error, and a ticking expiry with a way to mint a fresh command. It flips to connected on its own through the status stream already published by the broker — no new polling. That live update watches the snapshot's `checkedAt` revision rather than the connected flag, because `upgrade-required` closes the connection and is therefore indistinguishable from "still offline" through connectedness alone; keying on it would leave the panel waiting forever on a plugin that needs updating. An authoritative status re-read then distinguishes upgrade-required and revoked from a plain wait. Also surfaces the install step the flow always required but never mentioned, and stops labelling the terminal button "Done" while pairing is still pending. Co-Authored-By: Claude Opus 5 (1M context) --- .../AddProviderInstanceDialog.logic.ts | 99 ++++- .../AddProviderInstanceDialog.test.ts | 104 +++++ .../settings/AddProviderInstanceDialog.tsx | 390 ++++++++++++++++-- ...HermesGatewayInstanceSection.logic.test.ts | 84 ++++ .../HermesGatewayInstanceSection.logic.ts | 73 +++- 5 files changed, 714 insertions(+), 36 deletions(-) diff --git a/apps/web/src/components/settings/AddProviderInstanceDialog.logic.ts b/apps/web/src/components/settings/AddProviderInstanceDialog.logic.ts index bb76ce7911..10030681c7 100644 --- a/apps/web/src/components/settings/AddProviderInstanceDialog.logic.ts +++ b/apps/web/src/components/settings/AddProviderInstanceDialog.logic.ts @@ -1,4 +1,4 @@ -import type { ProviderDriverKind } from "@t3tools/contracts"; +import type { HermesGatewayConnectionState, ProviderDriverKind } from "@t3tools/contracts"; export type WizardNavigation = | { readonly kind: "navigate"; readonly step: number } @@ -31,6 +31,16 @@ export function createHermesProviderInstanceId(label: string, randomUuid: () => return labelSlug ? `hermes-${labelSlug}-${shortSuffix}` : `hermes-${shortSuffix}`; } +/** + * Command that installs the gateway plugin into the Hermes profile. + * + * Installation is a manual step performed on the Hermes host — T3 has no + * remote access to it — so the dialog documents the command rather than + * implying anything happens automatically. The script symlinks this repository + * checkout into `~/.hermes/plugins` and enables the plugin. + */ +export const HERMES_PLUGIN_INSTALL_COMMAND = "./integrations/hermes-t3-gateway/install.sh" as const; + export function isHermesInstanceRemovedError(error: unknown): boolean { return ( typeof error === "object" && @@ -40,6 +50,30 @@ export function isHermesInstanceRemovedError(error: unknown): boolean { ); } +/** + * Drop an instance the dialog itself just wrote, without clobbering anything + * that changed underneath it. + * + * Used to roll back the settings write when Hermes enrollment fails. The + * server is authoritative between the write and the rollback, so this reads + * the *latest* map rather than restoring a captured pre-write snapshot — that + * would silently revert instances added by another client in between. If the + * id is already gone, or has been replaced by a different config object, the + * write is not ours to undo and `null` signals "no rollback needed". + */ +export function rollbackProviderInstances(input: { + readonly latest: Readonly>; + readonly instanceId: string; + readonly written: T; +}): Record | null { + const current = input.latest[input.instanceId]; + if (current === undefined) return null; + if (current !== input.written) return null; + const next = { ...input.latest }; + delete next[input.instanceId]; + return next; +} + export function isOwnedHermesEnrollmentRetry(input: { readonly driver: ProviderDriverKind; readonly instanceId: string; @@ -52,6 +86,69 @@ export function isOwnedHermesEnrollmentRetry(input: { ); } +/** + * Presentation state of the post-enrollment "waiting for Hermes" panel. + * + * `waiting` is the expected steady state immediately after the command is + * generated — the user still has to paste it and restart the gateway — so it + * is deliberately not modelled as an error. `expired` and `blocked` are the + * two states that need a fresh command, and `connected` is terminal success. + */ +export type HermesWaitingPhase = "waiting" | "connected" | "blocked" | "expired"; + +export interface HermesWaitingState { + readonly phase: HermesWaitingPhase; + readonly statusLabelState: HermesGatewayConnectionState; + /** True while T3 legitimately has nothing to report yet. */ + readonly isPending: boolean; + /** True when the only way forward is minting a replacement command. */ + readonly needsNewCommand: boolean; +} + +/** + * Resolve what the waiting panel should show. + * + * Connection wins over expiry: once the gateway has dialled in, the one-time + * token has already been consumed and its expiry is irrelevant. `revoked` and + * `upgrade-required` are surfaced ahead of the generic wait because neither + * resolves by waiting longer. + */ +export function resolveHermesWaitingState(input: { + readonly connectionState: HermesGatewayConnectionState | null; + readonly isExpired: boolean; +}): HermesWaitingState { + if (input.connectionState === "connected") { + return { + phase: "connected", + statusLabelState: "connected", + isPending: false, + needsNewCommand: false, + }; + } + if (input.connectionState === "upgrade-required" || input.connectionState === "revoked") { + return { + phase: "blocked", + statusLabelState: input.connectionState, + isPending: false, + needsNewCommand: input.connectionState === "revoked", + }; + } + if (input.isExpired) { + return { + phase: "expired", + statusLabelState: input.connectionState ?? "offline", + isPending: false, + needsNewCommand: true, + }; + } + return { + phase: "waiting", + statusLabelState: input.connectionState ?? "offline", + isPending: true, + needsNewCommand: false, + }; +} + export function validateProviderInstanceIdForWizard(input: { readonly driver: ProviderDriverKind; readonly instanceId: string; diff --git a/apps/web/src/components/settings/AddProviderInstanceDialog.test.ts b/apps/web/src/components/settings/AddProviderInstanceDialog.test.ts index fda07aa9f4..dfaab9e2dd 100644 --- a/apps/web/src/components/settings/AddProviderInstanceDialog.test.ts +++ b/apps/web/src/components/settings/AddProviderInstanceDialog.test.ts @@ -6,7 +6,9 @@ import { createHermesProviderInstanceId, isHermesInstanceRemovedError, isOwnedHermesEnrollmentRetry, + resolveHermesWaitingState, resolveWizardNavigation, + rollbackProviderInstances, validateProviderInstanceIdForWizard, } from "./AddProviderInstanceDialog.logic"; @@ -131,3 +133,105 @@ describe("Hermes enrollment retry ownership", () => { ).toContain("already exists"); }); }); + +describe("rollbackProviderInstances", () => { + interface TestInstance { + readonly driver: string; + readonly enabled: boolean; + } + const written: TestInstance = { driver: "hermes", enabled: true }; + const other: TestInstance = { driver: "codex", enabled: true }; + + it("removes only the instance this dialog wrote", () => { + expect( + rollbackProviderInstances({ + latest: { "hermes-a": written, codex_work: other }, + instanceId: "hermes-a", + written, + }), + ).toEqual({ codex_work: other }); + }); + + it("preserves instances another client added between the write and the rollback", () => { + const concurrent: TestInstance = { driver: "claude", enabled: true }; + expect( + rollbackProviderInstances({ + latest: { "hermes-a": written, "added-elsewhere": concurrent }, + instanceId: "hermes-a", + written, + }), + ).toEqual({ "added-elsewhere": concurrent }); + }); + + it("does nothing when the id is already gone or was replaced by a different config", () => { + expect( + rollbackProviderInstances({ latest: { codex_work: other }, instanceId: "hermes-a", written }), + ).toBeNull(); + expect( + rollbackProviderInstances({ + latest: { "hermes-a": { ...written } }, + instanceId: "hermes-a", + written, + }), + ).toBeNull(); + }); +}); + +describe("resolveHermesWaitingState", () => { + it("treats a not-yet-dialled-in gateway as an expected pending wait, not an error", () => { + expect(resolveHermesWaitingState({ connectionState: null, isExpired: false })).toEqual({ + phase: "waiting", + statusLabelState: "offline", + isPending: true, + needsNewCommand: false, + }); + expect(resolveHermesWaitingState({ connectionState: "offline", isExpired: false })).toEqual({ + phase: "waiting", + statusLabelState: "offline", + isPending: true, + needsNewCommand: false, + }); + expect(resolveHermesWaitingState({ connectionState: "connecting", isExpired: false })).toEqual({ + phase: "waiting", + statusLabelState: "connecting", + isPending: true, + needsNewCommand: false, + }); + }); + + it("flips to connected and ignores expiry once the gateway has dialled in", () => { + expect(resolveHermesWaitingState({ connectionState: "connected", isExpired: true })).toEqual({ + phase: "connected", + statusLabelState: "connected", + isPending: false, + needsNewCommand: false, + }); + }); + + it("offers a fresh command when the one-time token expired unused", () => { + expect(resolveHermesWaitingState({ connectionState: "offline", isExpired: true })).toEqual({ + phase: "expired", + statusLabelState: "offline", + isPending: false, + needsNewCommand: true, + }); + }); + + it("surfaces upgrade-required and revoked ahead of waiting, since neither resolves by waiting", () => { + expect( + resolveHermesWaitingState({ connectionState: "upgrade-required", isExpired: false }), + ).toEqual({ + phase: "blocked", + statusLabelState: "upgrade-required", + isPending: false, + // A protocol upgrade needs a new plugin, not a new token. + needsNewCommand: false, + }); + expect(resolveHermesWaitingState({ connectionState: "revoked", isExpired: false })).toEqual({ + phase: "blocked", + statusLabelState: "revoked", + isPending: false, + needsNewCommand: true, + }); + }); +}); diff --git a/apps/web/src/components/settings/AddProviderInstanceDialog.tsx b/apps/web/src/components/settings/AddProviderInstanceDialog.tsx index 23e1e5110b..d86f80db8f 100644 --- a/apps/web/src/components/settings/AddProviderInstanceDialog.tsx +++ b/apps/web/src/components/settings/AddProviderInstanceDialog.tsx @@ -1,9 +1,11 @@ "use client"; import { Radio as RadioPrimitive } from "@base-ui/react/radio"; -import { CheckIcon, CopyIcon, LoaderIcon } from "lucide-react"; -import { useEffect, useMemo, useState } from "react"; +import { CheckIcon, CopyIcon, LoaderIcon, TriangleAlertIcon } from "lucide-react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; +import { useAtomValue } from "@effect/atom-react"; import { + type HermesGatewayConnectionState, type HermesGatewayEnrollmentResult, ProviderInstanceId, ProviderDriverKind, @@ -35,19 +37,26 @@ import { AnimatedHeight } from "../AnimatedHeight"; import { ADD_PROVIDER_WIZARD_STEPS, createHermesProviderInstanceId, + HERMES_PLUGIN_INSTALL_COMMAND, isHermesInstanceRemovedError, isOwnedHermesEnrollmentRetry, + resolveHermesWaitingState, resolveWizardNavigation, + rollbackProviderInstances, type WizardNavigation, validateProviderInstanceIdForWizard, } from "./AddProviderInstanceDialog.logic"; import { AddProviderInstanceWizardSteps } from "./AddProviderInstanceWizardSteps"; import { usePrimaryEnvironment } from "../../state/environments"; -import { serverEnvironment } from "../../state/server"; +import { primaryServerProvidersAtom, serverEnvironment } from "../../state/server"; import { useAtomCommand } from "../../state/use-atom-command"; import { defaultHermesConnectorUrl, formatHermesLastConnected, + hermesGatewayProviderSignal, + hermesGatewayStatusGuidance, + hermesGatewayStatusLabel, + isHermesEnrollmentExpired, messageFromUnknownError, } from "./HermesGatewayInstanceSection.logic"; @@ -113,6 +122,17 @@ const COMING_SOON_DRIVER_OPTIONS: readonly ComingSoonDriverOption[] = [ }, ]; +const HERMES_BADGE_VARIANT_BY_STATUS: Record< + HermesGatewayConnectionState, + "success" | "warning" | "error" | "secondary" +> = { + connected: "success", + connecting: "warning", + offline: "secondary", + "upgrade-required": "warning", + revoked: "error", +}; + interface AddProviderInstanceDialogProps { open: boolean; onOpenChange: (open: boolean) => void; @@ -128,6 +148,10 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns const createHermesEnrollment = useAtomCommand(serverEnvironment.hermesGatewayCreateEnrollment, { reportFailure: false, }); + const getHermesStatus = useAtomCommand(serverEnvironment.hermesGatewayGetInstanceStatus, { + reportFailure: false, + }); + const serverProviders = useAtomValue(primaryServerProvidersAtom); const [wizardStep, setWizardStep] = useState(0); const [driver, setDriver] = useState(DEFAULT_DRIVER_KIND); @@ -154,7 +178,17 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns const [createdHermesIdentity, setCreatedHermesIdentity] = useState<{ readonly instanceId: string; readonly nickname: string; + /** + * False once a failed enrollment rolled the settings write back. The id + * stays claimed by this dialog session (so validation keeps exempting it + * and no duplicate is ever created), but the next attempt has to write it + * again before the server will accept an enrollment for it. + */ + readonly persisted: boolean; } | null>(null); + const [hermesConnectionState, setHermesConnectionState] = + useState(null); + const [nowMillis, setNowMillis] = useState(() => Date.now()); const { copyToClipboard, isCopied } = useCopyToClipboard({ target: "Hermes enrollment command", onCopy: () => @@ -164,9 +198,53 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns description: "Run it in the terminal where Hermes is installed.", }), }); + const { copyToClipboard: copyInstallCommand, isCopied: isInstallCommandCopied } = + useCopyToClipboard({ + target: "Hermes plugin install command", + onCopy: () => + toastManager.add({ + type: "success", + title: "Install command copied", + description: "Run it from the T3 Code checkout on the Hermes host.", + }), + }); + // Rollback of a failed Hermes enrollment must survive the dialog closing + // mid-failure, so the pending undo lives in a ref that an unmount-safe + // effect drains rather than in the `handleSave` closure alone. + const pendingRollbackRef = useRef<{ + readonly instanceId: string; + readonly written: ProviderInstanceConfig; + } | null>(null); + const latestProviderInstancesRef = useRef(settings.providerInstances); + latestProviderInstancesRef.current = settings.providerInstances; + const environmentIdRef = useRef(environmentId); + environmentIdRef.current = environmentId; + const updateServerSettingsRef = useRef(updateServerSettings); + updateServerSettingsRef.current = updateServerSettings; + + const rollbackPendingHermesInstance = useCallback(async () => { + const pending = pendingRollbackRef.current; + pendingRollbackRef.current = null; + const rollbackEnvironmentId = environmentIdRef.current; + if (pending === null || rollbackEnvironmentId === null) return; + const providerInstances = rollbackProviderInstances({ + latest: latestProviderInstancesRef.current ?? {}, + instanceId: pending.instanceId, + written: pending.written, + }); + if (providerInstances === null) return; + await updateServerSettingsRef.current({ + environmentId: rollbackEnvironmentId, + input: { patch: { providerInstances } }, + }); + }, []); + + // Fires both when the dialog is closed and when it is unmounted outright + // (its parent renders it conditionally), so an orphan is never left behind. useEffect(() => { if (open) return; + void rollbackPendingHermesInstance(); setWizardStep(0); setDriver(DEFAULT_DRIVER_KIND); setLabel(""); @@ -184,7 +262,70 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns setSaveError(null); setIsSaving(false); setCreatedHermesIdentity(null); - }, [open]); + setHermesConnectionState(null); + }, [open, rollbackPendingHermesInstance]); + + useEffect( + () => () => { + void rollbackPendingHermesInstance(); + }, + [rollbackPendingHermesInstance], + ); + + const enrolledInstanceId = hermesEnrollment?.instanceId ?? null; + // The server pushes a fresh `ServerProvider` snapshot over the already-open + // `subscribeServerConfig` stream every time the broker publishes a gateway + // status change, so this flips the moment Hermes dials in — no polling. + const hermesProviderSignal = useMemo( + () => + enrolledInstanceId === null + ? null + : hermesGatewayProviderSignal(serverProviders, enrolledInstanceId), + [serverProviders, enrolledInstanceId], + ); + const hermesProviderSignalKey = hermesProviderSignal + ? `${hermesProviderSignal.present}:${hermesProviderSignal.connected}:${hermesProviderSignal.revision ?? ""}` + : null; + + // The pushed snapshot only tells us connected/not. Resolve the authoritative + // `HermesGatewayConnectionState` once per change so `upgrade-required` and + // `revoked` are distinguishable from a plain wait. + useEffect(() => { + if (enrolledInstanceId === null || environmentId === null) return; + if (hermesProviderSignalKey === null) return; + let cancelled = false; + void (async () => { + const result = await getHermesStatus({ + environmentId, + input: { instanceId: ProviderInstanceId.make(enrolledInstanceId) }, + }); + if (cancelled) return; + if (result._tag === "Success") setHermesConnectionState(result.value.status); + })(); + return () => { + cancelled = true; + }; + }, [enrolledInstanceId, environmentId, getHermesStatus, hermesProviderSignalKey]); + + // Re-evaluate the enrollment expiry on a coarse tick so the panel switches + // itself to the "mint a new command" affordance without a manual refresh. + useEffect(() => { + if (hermesEnrollment === null) return; + setNowMillis(Date.now()); + const interval = window.setInterval(() => setNowMillis(Date.now()), 15_000); + return () => window.clearInterval(interval); + }, [hermesEnrollment]); + + const hermesWaitingState = useMemo( + () => + hermesEnrollment === null + ? null + : resolveHermesWaitingState({ + connectionState: hermesConnectionState, + isExpired: isHermesEnrollmentExpired(hermesEnrollment.expiresAt, nowMillis), + }), + [hermesEnrollment, hermesConnectionState, nowMillis], + ); const existingIds = useMemo( () => new Set(Object.keys(settings.providerInstances ?? {})), @@ -261,11 +402,15 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns // keeps the type boundary honest and guards against any future drift in // the slug rules. const brandedId = ProviderInstanceId.make(instanceId); - const isOwnedHermesRetry = isOwnedHermesEnrollmentRetry({ - driver, - instanceId, - createdHermesInstanceId: createdHermesIdentity?.instanceId ?? null, - }); + // Only skip the settings write when the instance this dialog created is + // still persisted. After a rolled-back failure the id is still ours, but + // it has to be written again before the server will enroll it. + const isOwnedHermesRetry = + isOwnedHermesEnrollmentRetry({ + driver, + instanceId, + createdHermesInstanceId: createdHermesIdentity?.instanceId ?? null, + }) && createdHermesIdentity?.persisted === true; const nextMap = { ...settings.providerInstances, [brandedId]: nextInstance, @@ -277,6 +422,12 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns if (environmentId === null) { throw new Error("Connect this browser to a T3 server before pairing Hermes."); } + // The server rejects `create-enrollment` unless the instance already + // exists in `providerInstances` with the Hermes driver, so the write + // genuinely has to come first. Instead of enroll-first, the write is + // registered as a pending rollback that the failure path — and the + // close/unmount effects — undo, so a failed enrollment never leaves a + // visible `instance-not-found` orphan in the model picker. if (!isOwnedHermesRetry) { const settingsResult = await updateServerSettings({ environmentId, @@ -285,9 +436,11 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns if (settingsResult._tag === "Failure") { throw squashAtomCommandFailure(settingsResult); } + pendingRollbackRef.current = { instanceId, written: nextInstance }; setCreatedHermesIdentity({ instanceId, nickname: label.trim(), + persisted: true, }); } const enrollmentResult = await createHermesEnrollment({ @@ -300,12 +453,24 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns }); if (enrollmentResult._tag === "Failure") { const enrollmentError = squashAtomCommandFailure(enrollmentResult); + // The server already deleted the tombstoned instance itself, so + // there is nothing left for us to roll back — just rotate the nonce + // so the next attempt uses a fresh, untainted id. if (isHermesInstanceRemovedError(enrollmentError)) { + pendingRollbackRef.current = null; setCreatedHermesIdentity(null); setHermesIdentityNonce(randomUUID()); + } else { + await rollbackPendingHermesInstance(); + setCreatedHermesIdentity((current) => + current ? { ...current, persisted: false } : current, + ); } throw enrollmentError; } + // Enrollment succeeded: the instance is legitimately persisted now. + pendingRollbackRef.current = null; + setHermesConnectionState(null); setHermesEnrollment(enrollmentResult.value); toastManager.add({ type: "success", @@ -336,6 +501,50 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns } }; + /** + * Mint a replacement one-time command for the instance already persisted by + * this dialog session. The instance itself is untouched, so there is nothing + * to roll back here — only the expired/revoked token is replaced. + */ + const handleRegenerateEnrollment = async () => { + const identity = createdHermesIdentity; + if (identity === null || environmentId === null) return; + try { + setIsSaving(true); + setSaveError(null); + const enrollmentResult = await createHermesEnrollment({ + environmentId, + input: { + instanceId: ProviderInstanceId.make(identity.instanceId), + nickname: identity.nickname, + connectorUrl: hermesConnectorUrl, + }, + }); + if (enrollmentResult._tag === "Failure") { + const enrollmentError = squashAtomCommandFailure(enrollmentResult); + if (isHermesInstanceRemovedError(enrollmentError)) { + setCreatedHermesIdentity(null); + setHermesIdentityNonce(randomUUID()); + setHermesEnrollment(null); + } + throw enrollmentError; + } + setHermesConnectionState(null); + setHermesEnrollment(enrollmentResult.value); + setNowMillis(Date.now()); + } catch (error) { + const message = messageFromUnknownError(error); + setSaveError(message); + toastManager.add({ + type: "error", + title: "Could not create a new Hermes command", + description: message, + }); + } finally { + setIsSaving(false); + } + }; + return ( @@ -360,29 +569,137 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns data-slot="dialog-panel" className="space-y-4 bg-zinc-25/80 px-6 py-5 ring-1 ring-black/5 dark:bg-white/2 dark:ring-white/5" > - {hermesEnrollment ? ( -
-
-

Connect Hermes

-

- This one-time command expires{" "} - {formatHermesLastConnected(hermesEnrollment.expiresAt)}. -

-
-
- - {hermesEnrollment.command} - - + {hermesWaitingState.isPending ? ( + + ) : hermesWaitingState.phase === "connected" ? ( + + ) : null} + {hermesGatewayStatusLabel(hermesWaitingState.statusLabelState)} +
+ + {hermesWaitingState.phase === "connected" ? ( +

+ The gateway dialled in and its persistent credential is stored on the Hermes + host. You can close this dialog and start a thread against it. +

+ ) : ( +
    +
  1. +

    + 1. Install the plugin on the Hermes host +

    +

    + Run this from your T3 Code checkout on the machine running Hermes. It + symlinks the plugin into ~/.hermes/plugins and enables it. T3 + Code cannot do this for you — skip it only if you already installed the + plugin there. +

    +
    + + {HERMES_PLUGIN_INSTALL_COMMAND} + + +
    +
  2. + +
  3. +

    + 2. Run the one-time connect command +

    + {hermesWaitingState.phase === "expired" ? ( +

    + + + This command expired{" "} + {formatHermesLastConnected(hermesEnrollment.expiresAt)}. Generate a new + one below — the instance itself is unchanged. + +

    + ) : ( +

    + Expires {formatHermesLastConnected(hermesEnrollment.expiresAt)}. +

    + )} +
    + + {hermesEnrollment.command} + + +
    +
  4. + +
  5. +

    + 3. Restart the gateway on that host +

    +

    + Run hermes gateway restart. This step is required — the plugin + only dials T3 Code after the restart, so nothing is wrong while this panel + still says {hermesGatewayStatusLabel(hermesWaitingState.statusLabelState)}. + This page updates itself the moment Hermes connects. +

    +
  6. +
+ )} + + {hermesWaitingState.needsNewCommand ? ( +
+ +
+ ) : null} + + {saveError ?

{saveError}

: null} +

The persistent gateway credential is delivered directly to the plugin and is never shown in T3 Code. @@ -577,8 +894,9 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns {saveError ?

{saveError}

: null} {createdHermesIdentity ? (

- The Hermes instance was added. Retry enrollment for this exact instance, or - close this dialog and finish pairing from its Settings card. + {createdHermesIdentity.persisted + ? "The Hermes instance was added. Retry enrollment for this exact instance, or close this dialog and finish pairing from its Settings card." + : "Nothing was left behind — the half-created instance was removed. Retry to create it again with the same identity."}

) : null} @@ -587,8 +905,12 @@ export function AddProviderInstanceDialog({ open, onOpenChange }: AddProviderIns {hermesEnrollment ? ( - ) : (