import { ConnectController, type ConnectAttempt } from "@opengeni/connect"; import type { OpenGeniBrowserClient as OpenGeniClient } from "@opengeni/sdk/browser"; import { type ConnectWindowHost } from "../connect-window-host.js"; export type IntegrationCapabilityConnectInput = { client: OpenGeniClient; workspaceId: string; sessionId: string; /** `api:integration:` from the agent's recommendation. */ capabilityId: string; name: 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; }; export type IntegrationCapabilityAvailability = { kind: "loading"; } | { kind: "ready"; } | { kind: "connected"; } | { kind: "unavailable"; reason: string; } | { kind: "error"; }; type ListedIntegration = Awaited>["integrations"][number]; /** The in-chat Connect card for a reviewed integration, as a renderer draws it. */ export type IntegrationCapabilityConnect = { controller: ConnectController; attempt: ConnectAttempt | null; availability: IntegrationCapabilityAvailability; busy: boolean; /** The sign-in window is open and the card waits for it. */ waiting: boolean; /** * While {@link waiting}, the card can no longer see the sign-in window: the * person closed it, or the provider's page cut the card off from it (Google's * sign-in pages do, while staying open). The card keeps waiting and says * something true either way; it never claims the window closed. */ signInWindowGone: boolean; /** * A plain line when starting or signing in failed, or null. Never a raw * server message. Like {@link notice}, it shows only while setup is still at * the step it was written for, so it is never stale. */ error: string | null; /** * The person closed the sign-in window before finishing. Not an error: the * card says so and its sign-in button offers to try again. */ signInClosed: boolean; /** * "Sign-in window closed…" while {@link signInClosed}; after Cancel, a * reminder to close a sign-in window the card couldn't close itself. */ notice: string | null; chatAccessFailed: boolean; notRequester: boolean; /** The last attempt ended (failed, cancelled, expired) and a new one can start. */ restartable: boolean; start: () => void; /** * Sign in for an attempt that already waits for authorization. It never * rejects: the card's own {@link error} and {@link notice} say what happened, * and they stay while the setup controls are hidden. */ authorizeAttempt: (next: ConnectAttempt) => Promise; /** * End the attempt. The card closes the sign-in window when the browser lets * it; when it can't, {@link notice} asks the person to close it. */ stopWaiting: () => void; /** * Bring the sign-in window back while waiting. Call it from their tap. A * window the card can still see comes to the front; one that closed or that * the card lost track of is opened again, for the same attempt. */ reopenSignIn: () => void; reload: () => void; }; /** The account to reconnect: the most recently used one that lost its sign-in. */ export declare function reconnectCandidate(integrations: readonly ListedIntegration[], definitionId: string): ListedIntegration | null; /** * One-tap Connect for a reviewed integration recommended in chat. The person * viewing it signs in with their own account; setup then installs the * integration's reviewed tools for that personal account only, adds them to * this chat and lets the agent continue the request that asked. It follows * the viewer's own state, so a teammate in a shared chat connects their own. * Mount it once per client, workspace, session and capability. */ export declare function useIntegrationCapabilityConnect({ client, workspaceId, sessionId, capabilityId, name, returnUrl, windows, onConfigured, }: IntegrationCapabilityConnectInput): IntegrationCapabilityConnect; export {};