import type { McpServer } from "@stigmer/protos/ai/stigmer/agentic/mcpserver/v1/api_pb";
/**
 * Message type posted by {@link OAuthCallbackHandler} to the opener window.
 *
 * @internal
 */
export declare const OAUTH_CALLBACK_MESSAGE_TYPE = "stigmer:oauth:callback";
/**
 * BroadcastChannel name used as a fallback when `window.opener` is severed
 * by `Cross-Origin-Opener-Policy` headers on the OAuth provider.
 *
 * @internal
 */
export declare const OAUTH_BROADCAST_CHANNEL = "stigmer:oauth:broadcast";
/**
 * Shape of the `postMessage` payload sent from the OAuth callback popup.
 *
 * @internal
 */
export interface OAuthCallbackMessage {
    readonly type: typeof OAUTH_CALLBACK_MESSAGE_TYPE;
    readonly code: string;
    readonly state: string;
}
/** Progress phases of the OAuth connect flow. */
export type OAuthConnectPhase = "idle" | "initiating" | "awaiting-callback" | "completing" | "connecting" | "done";
/** Return value of {@link useMcpServerOAuthConnect}. */
export interface UseMcpServerOAuthConnectReturn {
    /**
     * Start the OAuth connect flow for an MCP server.
     *
     * Opens a popup for the OAuth consent screen, waits for the callback,
     * exchanges the authorization code for tokens, then chains to the
     * `connect` RPC for tool discovery.
     *
     * **Must be called from a synchronous user-gesture handler** (e.g.,
     * an `onClick` callback) so the browser allows the popup. The popup
     * is opened synchronously before any async work to avoid popup
     * blockers.
     *
     * @param mcpServerId - System-generated ID (metadata.id) of the MCP server.
     * @param org - Organization context for token storage (caller's active org).
     * @param declaredEnvKeys - Keys from the server's `spec.env` declaration.
     *   System vars are only injected when declared here.
     * @returns The updated McpServer after tool discovery completes.
     */
    readonly startOAuth: (mcpServerId: string, org: string, declaredEnvKeys?: readonly string[]) => Promise<McpServer>;
    /** `true` while any phase of the OAuth flow is in progress. */
    readonly isInProgress: boolean;
    /** Current phase of the OAuth flow. */
    readonly phase: OAuthConnectPhase;
    /** Error from the most recent unsuccessful attempt, or `null`. */
    readonly error: Error | null;
    /** Reset the hook to idle state, clearing any error. */
    readonly clearError: () => void;
}
/**
 * Action hook that orchestrates the full OAuth popup flow for MCP servers.
 *
 * Handles the complete lifecycle:
 * 1. Calls `initiateOAuthConnect` to get the authorization URL
 * 2. Opens a popup window to the OAuth consent screen
 * 3. Listens for the callback via `window.postMessage`
 * 4. Calls `completeOAuthConnect` to exchange the code for tokens
 * 5. Chains to `connect` for tool discovery
 *
 * The popup is opened **synchronously** before the `initiateOAuthConnect`
 * RPC to avoid browser popup blockers. A blank page is shown briefly
 * while the RPC resolves, then the popup navigates to the auth URL.
 *
 * @example
 * ```tsx
 * const oauth = useMcpServerOAuthConnect();
 * const { refetch } = useMcpServer(org, slug);
 *
 * async function handleSignIn() {
 *   try {
 *     await oauth.startOAuth(mcpServer.metadata.id, org);
 *     refetch();
 *   } catch {
 *     // error is available via oauth.error
 *   }
 * }
 *
 * <button onClick={handleSignIn} disabled={oauth.isInProgress}>
 *   {oauth.isInProgress ? "Signing in..." : "Sign in with OAuth"}
 * </button>
 * ```
 */
export declare function useMcpServerOAuthConnect(): UseMcpServerOAuthConnectReturn;
//# sourceMappingURL=useMcpServerOAuthConnect.d.ts.map