import type { AgDefaultRegistry } from '../agDefaultRegistry'; import type { AgBaseRegistry } from '../agRegistry'; import type { AgAiConversationItem } from '../ai/agAiMessage'; import type { AgAiArtifactBase } from '../ai/agAiTool'; import type { AgWidgetState } from '../widgets/agWidgetType'; export type AgAiProfileType = 'lead' | 'widget' | 'data' | 'page' | 'planning'; export type AgAiExchangeStatus = 'in_progress' | 'completed' | 'failed' | 'cancelled'; /** Indicates how a conversation was initiated. */ export type AgAiConversationOrigin = { type: 'user'; } | { type: 'llm'; conversationId: string; }; export interface AgAiAssistantState { /** ID of the currently active thread */ activeThreadId?: string; threads: AgAiThreadState[]; } export interface AgAiProfileState { type: AgAiProfileType; params?: Record; } /** * Represents a single turn within an exchange. * Turn 1: user message(s) * Turn 2+: tool outputs (and potentially user messages if added mid-exchange) */ export interface AgAiTurnState { id: string; /** Input to the AI for this turn (user messages or tool outputs) */ input: AgAiConversationItem[]; /** AI response for this turn (text, tool calls, reasoning) */ output: AgAiConversationItem[]; } /** * Represents one user request through full AI completion. * May include multiple turns if the AI makes tool calls. */ export interface AgAiExchangeState { id: string; status: AgAiExchangeStatus; /** All AI processing turns (may be multiple if tool calls) */ turns: AgAiTurnState[]; /** Profile used for this exchange */ profile: AgAiProfileState; /** Timestamp when the exchange started */ startedAt?: number; /** Timestamp when the exchange completed */ completedAt?: number; /** Model ID used for this exchange */ modelId?: string; } export interface AgAiConversationState { id: string; /** How this conversation was initiated. */ from: AgAiConversationOrigin; /** Structured exchange history */ exchanges: AgAiExchangeState[]; } export interface AgAiThreadState { id: string; name: string; conversationId: string; conversations: AgAiConversationState[]; artifacts: Record; toolCallMetadata: Record; /** Serialised plan data (opaque at the API layer — structured internally). */ plan?: unknown; } /** * Persisted artifact state. Extends the base artifact interface with summary for display. */ export interface AgAiArtifactState extends AgAiArtifactBase { type: 'widget'; summary: string; data: AgWidgetState; } export type AgAiToolCallMetadataState = { type: 'artifact'; artifactId: string; } | { type: 'delegate'; conversationId: string; };