import type { StreamChunk } from '@n8n/agents'; import type { Thread } from 'chat'; import type { Logger } from 'n8n-workflow'; import { OperationalError } from '@n8n/errors'; import type { AgentExecutionStreamChunk } from '../types/agent-steering'; import type { BridgeStatusHandle } from './agent-chat-integration'; type SuspendedChunk = Extract; type MessageChunk = Extract; export type SuspensionHandlingResult = 'posted' | 'skipped' | 'failed'; interface AgentChatStreamConsumerOptions { disableStreaming: boolean; logger: Logger; postErrorToThread: (thread: Thread | null, error: unknown, throwOnDeliveryError?: boolean) => Promise; handleSuspension: (chunk: SuspendedChunk, thread: Thread, actingUserId?: string) => Promise; handleMessage: (chunk: MessageChunk, thread: Thread, throwOnDeliveryError?: boolean) => Promise; isIntegrationActionTool?: (toolName: string) => boolean; singleStreamedRunPerTurn?: boolean; maxMessageLength?: number; postReplyFiles?: (thread: Thread, params: { fileIds: string[]; caption: string; agentThreadId: string; onPosted?: () => void; }) => Promise; } export declare class ReplyDeliveryError extends OperationalError { constructor(cause: unknown); } export interface EarlierToolResult { toolCallId: string; toolName: string; output: unknown; } interface ConsumeStreamOptions { forceBuffered?: boolean; throwOnDeliveryError?: boolean; statusHandle?: BridgeStatusHandle; actingUserId?: string; quietErrors?: boolean; agentThreadId?: string; earlierToolResults?: EarlierToolResult[]; } export declare class AgentChatStreamConsumer { private readonly options; constructor(options: AgentChatStreamConsumerOptions); consume(stream: AsyncGenerator, thread: Thread, options?: ConsumeStreamOptions): Promise; private separateTextSteps; private postBufferedText; private postBudgetStop; private postError; private noteToolResult; private noteReplyFiles; private seedReplyFiles; private postReplyFiles; private isSilentOutcome; private createResponseLifecycle; private postFallbackIfNeeded; private consumeBuffered; } export {};