/** * When may the agent details page OFFER to repair an agent's gateway * credentials? (BOFF-8686) * * Opening an agent page used to send `setupAgentGatewayAuth` by itself. On the * server that mutation is not a refresh: for a reachable agent it rotates the * app's OAuth secret on auth-svc (the old secret dies at once), rewrites * `appId`, `appClientId` and `appProvisionedByUserId` (re-attributing the app * to the viewer), grants mesh RBAC capabilities, flips * `lastGatewayAuthPushStatus` to `pending` and pushes the new credentials to * the agent. A page view, a refresh, back/forward navigation or a link an * assistant generated must never do that. The page therefore never sends it on * its own: this module only decides whether to SHOW a "Repair gateway auth" * button, and the click goes through a confirmation dialog. * * "Stuck" means the agent itself says it never received its gateway * credentials. The agent reports this on `/health/ready` * (vibecontrols-agent `health.routes.ts`), and wspace-vibecontrols-svc joins * each failing component as `: ` into the probe's * `errorMessage`: * - `session: agent is awaiting-config - POST OAuth credentials to ...` * (also reported for `tunnel`) on current agents; * - `session: no session provider registered` on older agents. */ /** The part of the agent record the repair offer reads. */ export interface GatewayRecoveryAgent { id: string; appId?: string | null; appClientId?: string | null; tunnelUrl?: string | null; lastGatewayAuthPushStatus?: string | null; } /** The part of the live health probe the repair offer reads. */ export interface GatewayRecoveryProbe { healthy: boolean; errorMessage?: string | null; } /** What `shouldOfferGatewayAuthRepair` needs to decide. */ export interface GatewayRecoveryInput { agent: GatewayRecoveryAgent; /** The probe for THIS agent, or undefined when none has been reported. */ probe: GatewayRecoveryProbe | undefined; /** * True only once this mount has received a probe from the network (or the stream). * The probe query is `cache-and-network`, so before that the probe may be a stale * copy cached by the agents list: an old "awaiting-config" must never invite a * rotation of the secret of an agent that has since become healthy. */ probesReady: boolean; } /** True when a probe's `errorMessage` says the agent is waiting for its gateway credentials. */ export declare function isAwaitingGatewayAuth(errorMessage: string | null | undefined): boolean; /** * Should the page show the "Repair gateway auth" button for this agent? * Every condition must hold: * 1. this mount's probe has arrived (not a stale cached copy) and reports THIS * agent as unhealthy; * 2. the probe's message says the agent is awaiting its credentials; * 3. the agent already has an OAuth app and a tunnel to push through; * 4. no push is already in flight. * A healthy, offline or probe-less agent therefore never gets the offer. This * is display logic only: nothing is sent until the user confirms. */ export declare function shouldOfferGatewayAuthRepair({ agent, probe, probesReady, }: GatewayRecoveryInput): boolean;