示例工程 61-chat-ui-streaming

61-chat-ui-streaming/app/.tsc/shared/chat.d.ts

typescript · 1.5 KB

export type DiffLine = {
    kind: "add" | "del" | "ctx";
    text: string;
};
export type DiffView = {
    path: string;
    lines: DiffLine[];
};
export type ToolView = {
    name: string;
    args: Record<string, string>;
    status: "running" | "ok";
    result: string;
};
export type ChatMessage = {
    id: string;
    role: "user" | "assistant";
    text: string;
    streaming: boolean;
    attempt: number;
    tool: ToolView | null;
    diff: DiffView | null;
    error: string | null;
    at: number;
};
export type RunSummary = {
    id: string;
    prompt: string;
    attempt: number;
    deltas: number;
    chars: number;
    toolCalls: number;
    diffLines: number;
    done: boolean;
    cancelled: boolean;
    error: string | null;
    elapsedMs: number;
};
export type ChatSnapshot = {
    platform: string;
    electronVersion: string;
    nodeVersion: string;
    messages: ChatMessage[];
    running: boolean;
    lastRun: RunSummary | null;
    runs: RunSummary[];
    draft: string;
};
export type StreamHandlers = {
    onDelta: (text: string) => void;
    onTool: (tool: ToolView) => void;
    onDiff: (diff: DiffView) => void;
    onToolResult: (result: string) => void;
};
export declare function streamAssistant(options: {
    prompt: string;
    attempt: number;
    paceMs: number;
    signal: AbortSignal;
    handlers: StreamHandlers;
}): Promise<RunSummary>;
export declare function diffSummary(diff: DiffView): string;
//# sourceMappingURL=chat.d.ts.map