/** * Conversation Manager * Manages multi-turn AI conversations for spec generation */ import { type Tool } from 'ai'; import { type AIProvider } from '../providers.js'; import type { ScanResult } from '../../scanner/types.js'; /** * Conversation message */ export interface ConversationMessage { role: 'user' | 'assistant' | 'system'; content: string; } /** * Conversation context */ export interface ConversationContext { codebaseSummary?: string; references: Array<{ source: string; content: string; }>; } /** * Tool use callback for displaying tool usage */ export type ToolUseCallback = (toolName: string, args: Record) => void; /** * Tool result callback for capturing tool completion */ export type ToolResultCallback = (toolName: string, result: unknown) => void; /** * Conversation manager options */ export interface ConversationManagerOptions { provider: AIProvider; model: string; systemPrompt?: string; /** Tools available to the AI */ tools?: Record; /** Callback when a tool is used */ onToolUse?: ToolUseCallback; /** Callback when a tool completes with result */ onToolResult?: ToolResultCallback; /** Maximum tool calling steps (default: 5) */ maxToolSteps?: number; } /** * Manages a multi-turn conversation with an AI model */ export declare class ConversationManager { private messages; private context; private readonly provider; private readonly modelId; private systemPrompt; private tools?; private onToolUse?; private onToolResult?; private maxToolSteps; constructor(options: ConversationManagerOptions); /** * Set tools for the conversation */ setTools(tools: Record): void; /** * Set tool use callback */ setOnToolUse(callback: ToolUseCallback): void; /** * Set tool result callback */ setOnToolResult(callback: ToolResultCallback): void; /** * Update the system prompt */ setSystemPrompt(prompt: string): void; /** * Append to the system prompt */ appendSystemPrompt(addition: string): void; private getDefaultSystemPrompt; /** * Set codebase context from scan result */ setCodebaseContext(scanResult: ScanResult): void; /** * Add a reference document to the context */ addReference(content: string, source: string): void; /** * Clear all references */ clearReferences(): void; /** * Get the current context as a string for inclusion in prompts */ private getContextString; /** * Build the full message array for the AI */ private buildMessages; /** * Send a message and get a response */ chat(userMessage: string): Promise; /** * Send a message and stream the response */ chatStream(userMessage: string): AsyncIterable; /** * Get conversation history */ getHistory(): ConversationMessage[]; /** * Clear conversation history */ clearHistory(): void; /** * Add a message to history without sending to AI */ addToHistory(message: ConversationMessage): void; }