import { ConnectController, type ConnectOwnership } from "@opengeni/connect"; import { type CapabilityCatalogItem, type ConnectionMetadata } from "@opengeni/sdk"; import type { OpenGeniBrowserClient as OpenGeniClient } from "@opengeni/sdk/browser"; import { type ConnectWindowHost } from "../connect-window-host.js"; import { type ConnectView } from "../hooks/use-connect.js"; /** The OAuth MCP connect card, as a renderer draws it. */ export type McpCapabilityConnect = { controller: ConnectController; view: ConnectView; /** The live catalog entry, once read. */ item: CapabilityCatalogItem | null; personalOnly: boolean; expanded: boolean; complete: boolean; /** An account is connected; the capability still has to be added here. */ connected: boolean; /** * Your own login for this, added in another workspace and not turned on in * this one: the card asks once whether to use it here too (D-54). */ offHere: ConnectionMetadata | null; waiting: boolean; reconciling: boolean; busy: boolean; /** A plain line for the person when a step failed, or null. Never a raw server message. */ error: string | null; /** "Sign-in window closed…" or "Sign-in was cancelled…", or null. */ notice: string | null; ownership: ConnectOwnership; setOwnership: (ownership: ConnectOwnership) => void; /** The sign-in button says "Try signing in again" rather than continuing. */ retrySignIn: boolean; open: () => void; signIn: () => void; addHere: () => void; /** Turn `offHere` on in this workspace, then add it here like `addHere`. */ useHere: () => void; close: () => void; stopWaiting: () => void; }; export type McpCapabilityConnectInput = { client: OpenGeniClient; workspaceId: string; /** Omit for connection management: no session tool selection is written. */ sessionId?: string | undefined; capabilityId: string; /** Exact host route the provider returns to after sign-in. */ returnUrl: string; /** Where the provider's sign-in opens. */ windows: ConnectWindowHost; onConfigured?: (() => void | Promise) | undefined; /** The card opens straight into setup (a dialog), loading and recovering at once. */ dialogOnly?: boolean | undefined; onClose?: (() => void) | undefined; /** * Offer only a personal connection: the provider only ever connects * someone's own account, or the person may only connect their own account. */ personalOnly?: boolean | undefined; }; /** * The OAuth MCP connect flow. Identity and endpoint come from the live * catalog, never from model-authored recommendation text. Mount it once per * client, workspace, session and capability. */ export declare function useMcpCapabilityConnect({ client, workspaceId, sessionId, capabilityId, returnUrl, windows, onConfigured, dialogOnly, onClose, personalOnly: configuredPersonalOnly, }: McpCapabilityConnectInput): McpCapabilityConnect;