n8n
Version:
n8n Workflow Automation Tool
16 lines (15 loc) • 682 B
TypeScript
import { type StreamChunk } from '@n8n/agents';
import type { AgentSseEvent } from '@n8n/api-types';
import type { Response } from 'express';
export type FlushableResponse = Response & {
flush?: () => void;
};
export interface ToolEventCallbacks {
toolInputStart?: (toolName: string) => void;
toolInputDelta?: (toolCallId: string, delta: string) => void;
toolResult?: (toolName: string) => void;
}
export declare function initSseStream(res: FlushableResponse): {
send: (event: AgentSseEvent) => void;
};
export declare function pumpChunks(chunks: AsyncIterable<StreamChunk>, send: (e: AgentSseEvent) => void, onToolEvent?: ToolEventCallbacks): Promise<boolean>;