import type { QueryContext } from '../dhf/query-engine.js'; import { type OntologyView } from '../model/kind-registry.js'; import type { LLMProvider, ChatMessage, ToolDefinition } from './llm-provider.js'; import { type ContextOptions } from './model-context.js'; export interface ProposedElementCreate { kind: 'create-element'; id: string; elementId: string; name: string; elementKind: string; layer?: string; attributes?: Record; doc?: string; summary: string; } export interface ProposedElementUpdate { kind: 'update-element'; id: string; elementId: string; /** Only the fields the model asked to change. */ changes: { name?: string; attributes?: Record; doc?: string; }; /** Current values for the same fields, so the UI can render a diff. */ before: { name?: string; attributes?: Record; doc?: string; }; summary: string; } export interface ProposedRelationshipCreate { kind: 'create-relationship'; id: string; relationshipType: string; sourceId: string; targetId: string; summary: string; } export interface ProposedRelationshipDelete { kind: 'delete-relationship'; id: string; relationshipId: string; sourceId: string; targetId: string; relationshipType: string; summary: string; } export type ProposedChange = ProposedElementCreate | ProposedElementUpdate | ProposedRelationshipCreate | ProposedRelationshipDelete; export interface ChatTurnResult { /** The assistant's final prose for this turn. */ answer: string; /** Changes awaiting approval. Empty when the turn was read-only. */ proposedChanges: ProposedChange[]; /** * The full message history including this turn, ready to be sent back on * the next call. Tool calls and results are included — the model needs * them to stay coherent across turns. */ messages: ChatMessage[]; usage?: { promptTokens: number; completionTokens: number; totalTokens: number; }; /** True when the loop hit `maxIterations` before the model finished. */ truncated?: boolean; } export interface ChatTurnOptions { /** The user's new message. */ question: string; /** Prior conversation, excluding the system prompt. */ history?: ChatMessage[]; ctx: QueryContext; provider: LLMProvider; /** The kinds and relationships the resolved ontology declares. */ ontology?: OntologyView; /** Allow the model to propose edits. Read-only when false. */ allowEdits?: boolean; contextOptions?: ContextOptions; /** Cap on tool round-trips per turn. */ maxIterations?: number; } declare const READ_TOOLS: ToolDefinition[]; declare function writeTools(ontology?: OntologyView): ToolDefinition[]; /** * Run one conversational turn, looping until the model stops calling tools. * * The returned `messages` include every tool call and result, so passing them * straight back as `history` on the next turn keeps the model coherent. */ export declare function runChatTurn(options: ChatTurnOptions): Promise; /** The tool names this engine exposes — used by tests and the MCP server. */ export declare function chatToolNames(allowEdits?: boolean): string[]; export { READ_TOOLS, writeTools }; //# sourceMappingURL=chat-engine.d.ts.map