import type { PluginDefinition, Request } from '@ace-fetch/core';
export interface DifyStreamReadOptions {
}
export type CitationItem = {
    content: string;
    data_source_type: string;
    dataset_name: string;
    dataset_id: string;
    document_id: string;
    document_name: string;
    hit_count: number;
    index_node_hash: string;
    segment_id: string;
    segment_position: number;
    score: number;
    word_count: number;
};
export type MessageEnd = {
    id: string;
    metadata: {
        retriever_resources?: CitationItem[];
        annotation_reply: {
            id: string;
            account: {
                id: string;
                name: string;
            };
        };
    };
};
export type MessageReplace = {
    id: string;
    task_id: string;
    answer: string;
    conversation_id: string;
};
export type AnnotationReply = {
    id: string;
    task_id: string;
    answer: string;
    conversation_id: string;
    annotation_id: string;
    annotation_author_name: string;
};
export declare enum TransferMethod {
    all = "all",
    local_file = "local_file",
    remote_url = "remote_url"
}
export type VisionFile = {
    id?: string;
    type: string;
    transfer_method: TransferMethod;
    url: string;
    upload_file_id: string;
    belongs_to?: string;
};
export type ThoughtItem = {
    id: string;
    tool: string;
    thought: string;
    tool_input: string;
    message_id: string;
    observation: string;
    position: number;
    files?: string[];
    message_files?: VisionFile[];
};
export type WorkflowStartedResponse = {
    task_id: string;
    workflow_run_id: string;
    event: string;
    data: {
        id: string;
        workflow_id: string;
        sequence_number: number;
        created_at: number;
    };
};
export type WorkflowFinishedResponse = {
    task_id: string;
    workflow_run_id: string;
    event: string;
    data: {
        id: string;
        workflow_id: string;
        status: string;
        outputs: any;
        error: string;
        elapsed_time: number;
        total_tokens: number;
        total_steps: number;
        created_at: number;
        finished_at: number;
    };
};
export type NodeStartedResponse = {
    task_id: string;
    workflow_run_id: string;
    event: string;
    data: {
        id: string;
        node_id: string;
        node_type: string;
        index: number;
        predecessor_node_id?: string;
        inputs: any;
        created_at: number;
        extras?: any;
    };
};
export type NodeFinishedResponse = {
    task_id: string;
    workflow_run_id: string;
    event: string;
    data: {
        id: string;
        node_id: string;
        node_type: string;
        index: number;
        predecessor_node_id?: string;
        inputs: any;
        process_data: any;
        outputs: any;
        status: string;
        error: string;
        elapsed_time: number;
        execution_metadata: {
            total_tokens: number;
            total_price: number;
            currency: string;
        };
        created_at: number;
    };
};
export type IOnDataMoreInfo = {
    conversationId?: string;
    taskId?: string;
    messageId: string;
    errorMessage?: string;
    errorCode?: string;
};
export type IOnData = (message: string, isFirstMessage: boolean, moreInfo: IOnDataMoreInfo) => void;
export type IOnThought = (though: ThoughtItem) => void;
export type IOnFile = (file: VisionFile) => void;
export type IOnMessageEnd = (messageEnd: MessageEnd) => void;
export type IOnMessageReplace = (messageReplace: MessageReplace) => void;
export type IOnAnnotationReply = (messageReplace: AnnotationReply) => void;
export type IOnCompleted = (hasError?: boolean) => void;
export type IOnError = (msg: string, code?: string) => void;
export type IOnWorkflowStarted = (workflowStarted: WorkflowStartedResponse) => void;
export type IOnWorkflowFinished = (workflowFinished: WorkflowFinishedResponse) => void;
export type IOnNodeStarted = (nodeStarted: NodeStartedResponse) => void;
export type IOnNodeFinished = (nodeFinished: NodeFinishedResponse) => void;
/**
 * regist dify stream read plugin on current promise request
 * @param request request promise
 * @param options dify stream read options
 */
export declare function registDifyStreamRead(request: Request, options?: DifyStreamReadOptions): Request;
/**
 * 注册Dify消息流处理插件
 * 只在regist apis上运行 (and 自定义条件下)
 * @param options 插件配置
 */
export declare const createDifyStreamReadPlugin: PluginDefinition<DifyStreamReadOptions>;
declare module '@ace-fetch/core' {
    interface RequestCustomConfig {
        onData?: IOnData;
        onCompleted?: IOnCompleted;
        onThought?: IOnThought;
        onMessageEnd?: IOnMessageEnd;
        onMessageReplace?: IOnMessageReplace;
        onFile?: IOnFile;
        onWorkflowStarted?: IOnWorkflowStarted;
        onWorkflowFinished?: IOnWorkflowFinished;
        onNodeStarted?: IOnNodeStarted;
        onNodeFinished?: IOnNodeFinished;
    }
}
