import { McpServerConfig } from "../mcp-client.js";
import { PrebuiltMCPServerSchema } from "../../validation/schemas.js";
import { z } from "@hono/zod-openapi";
import { Composio } from "@composio/core";

//#region src/utils/third-party-mcp-servers/composio-client.d.ts

type PrebuiltMCPServer = z.infer<typeof PrebuiltMCPServerSchema>;
/**
 * Get or create a Composio instance
 * Returns null if COMPOSIO_API_KEY is not configured
 */
declare function getComposioInstance(): Composio | null;
/**
 * Credential scope type for MCP servers
 */
type CredentialScope = 'project' | 'user';
/**
 * Get the Composio user ID based on credential scope
 * - For project-scoped: uses derived tenant||project ID (shared team credentials)
 * - For user-scoped: uses the actual user ID (per-user credentials)
 */
declare function getComposioUserId(tenantId: string, projectId: string, credentialScope: CredentialScope, userId?: string): string;
/**
 * Configure a Composio MCP server config with the appropriate user_id and x-api-key.
 * Mutates serverConfig in place:
 *  - Injects user_id query param into the URL (scoped by tenant/project/user)
 *  - Injects connected_account_id query param if provided (pins to a specific account)
 *  - Injects x-api-key header from COMPOSIO_API_KEY env var
 *
 * No-op if the URL is not a composio.dev URL or already has a user_id.
 */
declare function configureComposioMCPServer(serverConfig: McpServerConfig, tenantId: string, projectId: string, credentialScope: CredentialScope, userId?: string, connectedAccountId?: string): void;
/**
 * Extract server ID from a Composio MCP URL
 * Example: https://backend.composio.dev/v3/mcp/1234-1234-1234?user_id=... -> 1234-1234-1234
 */
declare function extractComposioServerId(mcpUrl: string): string | null;
/**
 * Delete a Composio connected account
 * Returns true if successful, false if failed (non-blocking)
 */
declare function deleteComposioConnectedAccount(accountId: string): Promise<boolean>;
interface ComposioAuthResult {
  authenticated: boolean;
  connectedAccountId?: string;
  error?: boolean;
}
/**
 * Check if a Composio MCP server is authenticated for the given tenant/project/user
 * @param credentialScope - 'project' for shared team credentials, 'user' for per-user credentials
 * @param userId - The actual user ID (required if credentialScope is 'user')
 */
declare function isComposioMCPServerAuthenticated(tenantId: string, projectId: string, mcpServerUrl: string, credentialScope?: CredentialScope, userId?: string): Promise<ComposioAuthResult>;
/**
 * Get the OAuth redirect URL for a Composio MCP server based on credential scope
 * This should be called AFTER scope selection to get the correct URL
 * @param credentialScope - 'project' for shared team credentials, 'user' for per-user credentials
 * @param userId - The actual user ID (required if credentialScope is 'user')
 */
declare function getComposioOAuthRedirectUrl(tenantId: string, projectId: string, mcpServerUrl: string, credentialScope: CredentialScope, userId?: string): Promise<string | null>;
/**
 * Fetch Composio MCP servers for the catalog
 */
declare function fetchComposioServers(): Promise<PrebuiltMCPServer[]>;
/**
 * Fetch a single Composio MCP server by URL and return its details with auth status
 * @param credentialScope - 'project' uses tenant||project, 'user' uses actual userId
 * @param userId - The actual user ID (required if credentialScope is 'user')
 */
declare function fetchSingleComposioServer(tenantId: string, projectId: string, mcpServerUrl: string, credentialScope?: CredentialScope, userId?: string): Promise<PrebuiltMCPServer | null>;
//#endregion
export { ComposioAuthResult, CredentialScope, configureComposioMCPServer, deleteComposioConnectedAccount, extractComposioServerId, fetchComposioServers, fetchSingleComposioServer, getComposioInstance, getComposioOAuthRedirectUrl, getComposioUserId, isComposioMCPServerAuthenticated };