import type { ReactNode } from 'react';
import type { FormDataObject, SchemaArray } from 'zod-schema-form';
import type { MessageEventDetails, ReasoningEventDetails, ToolCallLifecycleMetadata, UseChatAgentOptions } from '../../hooks/useChatAgent/useChatAgent.types';
import type { StoredModel } from '../../contexts/ModelContext';
import type { AttachmentToolDefinition } from '../attachmentTools';
export type { AttachmentToolDefinition };
export type ProviderId = string;
export type ProviderAgent = unknown;
export type ProviderModelSettings = Record<string, unknown>;
type ProviderToolNeedsApproval = AttachmentToolDefinition['needsApproval'] extends infer T ? (T | boolean | undefined) : boolean | undefined;
export interface ProviderToolDefinition<TNeedsApproval extends ProviderToolNeedsApproval = ProviderToolNeedsApproval> {
    name: string;
    description: string;
    parameters?: unknown;
    strict?: boolean;
    execute: (input: unknown, context: Record<string, unknown> | undefined) => Promise<unknown> | unknown;
    needsApproval?: TNeedsApproval;
    [key: string]: unknown;
}
export interface ProviderToolApprovalItem {
    toJSON?: () => {
        rawItem?: Record<string, unknown>;
        agent?: {
            name?: string;
        };
        [key: string]: unknown;
    };
    rawItem?: Record<string, unknown>;
    agent?: {
        name?: string;
    };
    [key: string]: unknown;
}
export interface ProviderRunState {
    toString(): string;
    getInterruptions(): ProviderToolApprovalItem[] | null | undefined;
    approve(interruption: unknown, options?: Record<string, unknown>): Promise<void> | void;
    reject(interruption: unknown, options?: Record<string, unknown>): Promise<void> | void;
}
export interface ProviderAgentInputItem {
    role: string;
    type: string;
    content: unknown;
    metadata?: Record<string, unknown>;
    [key: string]: unknown;
}
export interface ProviderAgentOutputItem {
    role?: string;
    type?: string;
    content?: unknown;
    status?: string;
    [key: string]: unknown;
}
export interface ProviderToolEvent {
    callId: string;
    name: string;
    args: string;
    status: 'in_progress' | 'completed' | 'failed';
    metadata?: Record<string, unknown>;
}
export interface ProviderMessageEvent {
    id: string;
    role?: string;
    status?: string;
    phase: 'started' | 'completed';
    content?: unknown;
    metadata?: Record<string, unknown>;
}
export interface ProviderReasoningEvent {
    id: string;
    phase: 'started' | 'completed';
    summary?: unknown;
    metadata?: Record<string, unknown>;
}
export interface ProviderStatusEvent {
    id: string;
    status: string;
    metadata?: Record<string, unknown>;
}
export interface ProviderFinalOutputEvent {
    id: string;
    content: string;
    metadata?: Record<string, unknown>;
}
export interface ProviderInitialization {
    kind: ProviderId;
    options: UseChatAgentOptions;
}
export interface ProviderMetadata {
    kind: ProviderId;
    name: string;
    supportsTools: boolean;
    supportsApprovals: boolean;
    supportsStreaming: boolean;
    isImplemented?: boolean;
}
export interface ProviderRunCallbacks {
    onOutputTextDelta?: (delta: string) => Promise<void>;
    onMessageOutputCreated?: (finalOutput: string) => Promise<void>;
    onFinalOutputAccessed?: (finalOutput: string) => Promise<void>;
    onToolCall?: (name: string, args: string, metadata?: ToolCallLifecycleMetadata) => Promise<void>;
    onToolOutput?: (name: string, output: string, metadata?: ToolCallLifecycleMetadata) => Promise<void>;
    onReasoningEvent?: (event: ReasoningEventDetails) => Promise<void>;
    onMessageEvent?: (event: MessageEventDetails) => Promise<void>;
}
export interface ProviderRunResult {
    finalOutput?: string;
    interruptions?: ProviderToolApprovalItem[];
    state?: ProviderRunState;
    rawResponse?: unknown;
    metadata?: Record<string, unknown>;
}
export interface ProviderRunHandle {
    cancel: () => Promise<void>;
    completed: Promise<ProviderRunResult | void>;
    signal?: AbortSignal;
}
export interface ProviderStreamCallbacks {
    onOutputTextDelta: (delta: string) => Promise<void>;
    onMessageOutputCreated: (finalOutput: string) => Promise<void>;
    onToolCall: (name: string, args: string, metadata?: ToolCallLifecycleMetadata) => Promise<void>;
    onToolOutput: (name: string, output: string, metadata?: ToolCallLifecycleMetadata) => Promise<void>;
    onReasoningEvent?: (event: ReasoningEventDetails) => Promise<void>;
    onMessageEvent?: (event: MessageEventDetails) => Promise<void>;
    onFinalOutputAccessed?: (finalOutput: string) => Promise<void>;
}
export type ProviderStreamHandler = (response: unknown, callbacks: ProviderStreamCallbacks) => Promise<void>;
export interface ChatProvider {
    metadata: ProviderMetadata;
    createAgent: (options: UseChatAgentOptions) => ProviderAgent | Promise<ProviderAgent>;
    startRun: (agent: ProviderAgent, input: ProviderRunInput, callbacks: ProviderRunCallbacks) => Promise<ProviderRunHandle>;
    resumeRun?: (agent: ProviderAgent, input: ProviderResumeInput, callbacks: ProviderRunCallbacks) => Promise<ProviderRunHandle>;
    deserializeRunState?: (agent: ProviderAgent, serialized: string) => Promise<ProviderRunState>;
}
export interface ProviderRuntime {
    hasProvider: (kind: ProviderId) => boolean;
    getProvider: (kind: ProviderId) => ChatProvider | undefined;
    listProviders: () => ChatProvider[];
    getAttachmentToolDefinitions: () => AttachmentToolDefinition[];
}
export declare abstract class ProviderPlugin {
    abstract readonly id: ProviderId;
    abstract createProvider(): ChatProvider | Promise<ChatProvider>;
    getModelDefinition?(): ModelProviderDefinition | Promise<ModelProviderDefinition | undefined> | undefined;
    getStreamHandler?(): ProviderStreamHandler | Promise<ProviderStreamHandler | undefined> | undefined;
    configureAttachmentTools?(resolve: () => AttachmentToolDefinition[]): void | Promise<void>;
    onRegistered?(runtime: ProviderRuntime): void | Promise<void>;
}
export interface ProviderRunInput {
    threadId: string;
    messages: ProviderMessageInput[];
    attachments?: ProviderAttachmentInput[];
    signal?: AbortSignal;
    abortController?: AbortController;
    context?: Record<string, unknown>;
    metadata?: Record<string, unknown>;
}
export interface ProviderResumeInput extends ProviderRunInput {
    state: ProviderRunState;
}
export type ProviderMessageRole = 'user' | 'assistant' | 'system';
export interface ProviderMessageInput {
    role: ProviderMessageRole;
    content: string;
}
export interface ProviderAttachmentInput {
    id: string;
    name: string;
    mimeType: string;
    contentUrl?: string;
}
export interface ProviderViewField {
    label: string;
    render: (model: StoredModel) => ReactNode;
}
export interface ProviderFormDefinition {
    schema: SchemaArray;
    getInitialValues: (model: StoredModel) => FormDataObject;
    transformSubmit: (values: FormDataObject, model: StoredModel) => Partial<StoredModel>;
    submitButtonText?: string;
    size?: 'small' | 'medium' | 'large';
}
export interface ModelProviderDefinition {
    id: ProviderId;
    displayName: string;
    badgeClassName?: string;
    viewFields: ProviderViewField[];
    form: ProviderFormDefinition;
    defaultModelTemplate?: Omit<StoredModel, 'id'>;
}
//# sourceMappingURL=types.d.ts.map