import { EntitySchema, EntityData, PeekEntity, PaginatedPeekResponse, AllCapabilities, EntityRevisionsResponse, BulkReadSource, BulkReadResponse } from '../types/schema';
export interface AiSemanticSearchResult {
    entity_id: number;
    title: string;
    entity_name: string;
    score: number;
}
export interface AiChatMessage {
    role: 'user' | 'assistant';
    content: string;
    /** Tool names used during this assistant turn (frontend-only, not sent to backend) */
    tools_used?: string[];
}
export interface AiSanityCheckResult {
    field: string;
    passed: boolean;
    message?: string;
    severity: 'Warning' | 'Error';
}
export interface AiDiffSummaryResult {
    summary: string;
}
export interface AiNaturalLanguageFilterResult {
    interpreted_filters: {
        field: string;
        operator: string;
        value: string;
    }[];
    combination: string;
    natural_language_interpretation: string;
    results: {
        id: number;
        title: string;
        modified_gmt: string;
    }[];
    used_vector_fallback: boolean;
}
export interface AiRelationSuggestResult {
    id: number;
    title: string;
    score: number;
}
export interface AiAgentChatToolCall {
    tool: string;
    arguments: Record<string, unknown>;
    result_preview: string;
}
export interface AiProposedAction {
    action_id: string;
    action_type: 'create_entity' | 'update_entity' | 'delete_entity' | 'set_field' | 'navigate' | 'show_quality_report' | 'sheet_edit' | 'sheet_add_source';
    description: string;
    requires_approval: boolean;
    entity_type?: string;
    entity_id?: number;
    payload?: Record<string, unknown>;
}
export interface AiExecutedAction {
    action_id: string;
    action_type?: string;
    entity_type?: string;
    entity_id?: number;
    success: boolean;
    message: string;
    result?: Record<string, unknown>;
}
export interface AiAgentChatResponse {
    response: string;
    tool_calls_made: AiAgentChatToolCall[];
    proposed_actions: AiProposedAction[];
    executed_actions?: AiExecutedAction[];
}
export interface AiAgentContext {
    current_page?: string;
    entity_type?: string;
    entity_id?: number;
    current_fields?: Record<string, unknown>;
    errors?: string[];
    selected_field?: string;
    sheet_sources?: string[];
    selected_cell?: string;
}
export interface AiActionConfirmation {
    action_id: string;
    approved: boolean;
    action: AiProposedAction;
}
export declare function setApiBaseUrl(url: string): void;
export declare function getApiBaseUrl(): string;
export declare function setAiBaseUrl(url: string | null): void;
export declare function setAiDisabled(disabled: boolean): void;
export declare function isAiDisabled(): boolean;
export interface ApiResponse<T> {
    data?: T;
    error?: string;
}
type UnauthorizedListener = () => void;
export declare function onUnauthorized(listener: UnauthorizedListener | null): void;
export declare function fetchSchema(entityName: string): Promise<ApiResponse<EntitySchema>>;
export declare function fetchAllSchemas(): Promise<ApiResponse<Record<string, EntitySchema>>>;
export declare function readEntity(entityName: string, id: number): Promise<ApiResponse<EntityData>>;
export declare function peekAllEntities(entityName: string): Promise<ApiResponse<PeekEntity[]>>;
export declare function peekAllEntitiesPaginated(entityName: string, pageSize?: number, pageToken?: string | null): Promise<ApiResponse<PaginatedPeekResponse>>;
export declare function createEntity(entityName: string, data: Partial<EntityData>): Promise<ApiResponse<EntityData>>;
export declare function updateEntity(entityName: string, data: Partial<EntityData>): Promise<ApiResponse<EntityData>>;
export declare function deleteEntity(entityName: string, id: number): Promise<ApiResponse<EntityData>>;
export declare function sanityCheck(entityName: string, data: Partial<EntityData>): Promise<ApiResponse<{
    message: string;
}>>;
export interface SharingCandidate {
    id: number;
    name: string;
    max_permission: 'view' | 'edit';
}
export interface SharingCandidatesResponse {
    users: SharingCandidate[];
    roles: SharingCandidate[];
}
export declare function fetchSharingCandidates(entityName: string): Promise<ApiResponse<SharingCandidatesResponse>>;
export interface LockStatus {
    entity_id: number;
    locked_by_user_id: number;
    locked_by_user_name: string | null;
    locked_by_tab_id?: string | null;
}
export declare function tryLockEntity(entityName: string, id: number, tabId?: string): Promise<ApiResponse<void>>;
export declare function unlockEntity(entityName: string, id: number, tabId?: string): Promise<ApiResponse<void>>;
export declare function fetchLockStatus(entityName: string, id: number): Promise<ApiResponse<LockStatus>>;
export declare function fetchAllLocked(entityName: string): Promise<ApiResponse<LockStatus[]>>;
export declare function login(email: string, password: string): Promise<ApiResponse<{
    token: string;
}>>;
export declare function logout(): Promise<ApiResponse<{
    message: string;
}>>;
export declare function checkAuth(): Promise<boolean>;
export declare function fetchCapabilities(): Promise<ApiResponse<AllCapabilities>>;
export interface FrontendSettingsResponse {
    edit_inactivity_timeout_ms?: number;
    sheets_enabled?: boolean;
}
export declare function fetchFrontendSettings(): Promise<ApiResponse<FrontendSettingsResponse>>;
export declare function fetchEntityHistory(entityName: string, id: number): Promise<ApiResponse<EntityRevisionsResponse>>;
export declare function bulkRead(sources: BulkReadSource[]): Promise<ApiResponse<BulkReadResponse>>;
export declare function aiSemanticSearch(query: string, entityName?: string, topK?: number): Promise<ApiResponse<AiSemanticSearchResult[]>>;
export declare function aiSanityCheck(entityName: string, fieldName: string, fieldValue: unknown): Promise<ApiResponse<AiSanityCheckResult[]>>;
export declare function aiDiffSummary(entityName: string, entityId: number, revisionIndex: number): Promise<ApiResponse<AiDiffSummaryResult>>;
export declare function aiNaturalLanguageFilter(entityName: string, query: string): Promise<ApiResponse<AiNaturalLanguageFilterResult>>;
export declare function aiRelationSuggest(entityName: string, relationField: string, currentText: string): Promise<ApiResponse<AiRelationSuggestResult[]>>;
export declare function aiAgentChat(message: string, context?: AiAgentContext, confirmedActions?: AiActionConfirmation[], history?: {
    role: string;
    content: string;
}[]): Promise<ApiResponse<AiAgentChatResponse>>;
export {};
