import type { ConnectedAccountListParams, ConnectedAccountListResponse, Tool as ComposioRawTool, ToolListParams, ToolRouterCreateSessionConfig, ToolRouterSessionSearchResponse, ToolkitConnectionsDetails } from "@composio/core";
import type { AgentTool } from "../../types.js";
export type { ComposioRawTool };
export interface ComposioToolMetadata {
    slug: string;
    name: string;
    toolkit?: string;
    isNoAuth?: boolean;
    version?: string;
}
export interface ComposioToolExecutionDetails extends ComposioToolMetadata {
    successful: boolean;
    error: string | null;
    logId?: string;
    data: Record<string, unknown>;
}
export interface ComposioAgentTool extends AgentTool<any, ComposioToolExecutionDetails> {
    composio: ComposioToolMetadata;
}
export interface ComposioToolListResult {
    items: ComposioRawTool[];
    nextCursor?: string | null;
    totalPages?: number;
}
export type ComposioRawToolListResponse = ComposioToolListResult | ComposioRawTool[];
export interface ComposioExecuteResult {
    data: Record<string, unknown>;
    error: string | null;
    successful: boolean;
    logId?: string;
    sessionInfo?: unknown;
}
export interface ComposioConnectResult {
    action: "created" | "refreshed" | "already_connected";
    accountId: string;
    status: string;
    redirectUrl?: string | null;
    toolkit?: string;
    authConfigId?: string;
    raw: Record<string, unknown>;
}
export interface ComposioConnectionRequestLike {
    id: string;
    status?: string;
    redirectUrl?: string | null;
    toJSON?: () => {
        id: string;
        status?: string;
        redirectUrl?: string | null;
    };
}
export interface ComposioSessionLike {
    sessionId: string;
    tools: (modifiers?: unknown) => Promise<ComposioAgentTool[]>;
    authorize: (toolkit: string, options?: {
        callbackUrl?: string;
    }) => Promise<ComposioConnectionRequestLike>;
    toolkits: (options?: {
        toolkits?: string[];
        nextCursor?: string;
        limit?: number;
        isConnected?: boolean;
        search?: string;
    }) => Promise<ToolkitConnectionsDetails>;
    search: (params: {
        query: string;
        toolkits?: string[];
    }) => Promise<ToolRouterSessionSearchResponse>;
    execute: (toolSlug: string, arguments_?: Record<string, unknown>) => Promise<{
        data: Record<string, unknown>;
        error: string | null;
        logId: string;
    }>;
}
export interface ComposioSdkLike {
    create(userId: string, config?: ToolRouterCreateSessionConfig): Promise<ComposioSessionLike>;
    tools: {
        getRawComposioTools(filters: ToolListParams): Promise<ComposioRawToolListResponse>;
        getRawComposioToolBySlug(slug: string): Promise<ComposioRawTool>;
    };
    connectedAccounts: {
        list(query?: ConnectedAccountListParams): Promise<ConnectedAccountListResponse>;
        refresh(nanoid: string, params?: Record<string, unknown> | null): Promise<Record<string, unknown>>;
    };
}
export type ComposioClientFactory = (options: {
    apiKey?: string;
    provider: unknown;
}) => ComposioSdkLike;
export interface ComposioBaseOptions {
    apiKey?: string;
    getApiKey?: () => Promise<string | undefined> | string | undefined;
    userId?: string;
    resolveUserId?: () => Promise<string> | string;
    manageConnections?: boolean;
    clientFactory?: ComposioClientFactory;
}
export interface ComposioToolSelection {
    toolkits?: string[];
    toolSlugs?: string[];
    authConfigs?: Record<string, string>;
    connectedAccounts?: Record<string, string>;
    authConfigId?: string;
    connectedAccountId?: string;
}
export interface ComposioAgentToolsOptions extends ComposioBaseOptions, ComposioToolSelection {
}
export type ComposioEnableHandler = (tools: ComposioAgentTool[], metadata: ComposioToolMetadata[]) => Promise<void> | void;
export interface ComposioServiceLike {
    resolveUserId(): Promise<string>;
    listToolkits(input: {
        toolkits?: string[];
        search?: string;
        limit?: number;
        nextCursor?: string;
        isConnected?: boolean;
    }): Promise<ToolkitConnectionsDetails>;
    searchTools(query: string, toolkits?: string[]): Promise<ToolRouterSessionSearchResponse>;
    listRawTools(filters: ToolListParams): Promise<ComposioToolListResult>;
    getRawToolBySlug(slug: string): Promise<ComposioRawTool>;
    createAgentTools(options: ComposioAgentToolsOptions): Promise<ComposioAgentTool[]>;
    executeTool(options: ComposioAgentToolsOptions & {
        toolSlug: string;
        arguments?: Record<string, unknown>;
    }): Promise<ComposioExecuteResult>;
    connectAccount(options: {
        toolkit?: string;
        connectedAccountId?: string;
        authConfigId?: string;
        callbackUrl?: string;
    }): Promise<ComposioConnectResult>;
    listAccounts(filters?: ConnectedAccountListParams): Promise<ConnectedAccountListResponse>;
}
export interface ComposioToolFactoryOptions extends ComposioBaseOptions {
    service?: ComposioServiceLike;
    onEnable?: ComposioEnableHandler;
}
