import { ResolvedRef } from "../../validation/dolt-schemas.js";
import { ProjectScopeConfig } from "../../db/manage/scope-definitions.js";
import { ConversationHistoryConfig, ConversationMetadata, MessageContent, PaginationConfig } from "../../types/utility.js";
import { AgentsRunDatabaseClient } from "../../db/runtime/runtime-client.js";
import "../../types/index.js";
import { ConversationInsert, ConversationSelect, ConversationUpdate, MessageSelect } from "../../types/entities.js";

//#region src/data-access/runtime/conversations.d.ts
declare const listConversations: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  userId?: string;
  agentIds?: string[];
  pagination?: PaginationConfig;
}) => Promise<{
  conversations: ConversationSelect[];
  total: number;
}>;
declare const createConversation: (db: AgentsRunDatabaseClient) => (params: ConversationInsert) => Promise<{
  id: string;
  properties: Record<string, unknown> | null;
  title: string | null;
  createdAt: string;
  updatedAt: string;
  tenantId: string;
  projectId: string;
  metadata: ConversationMetadata | null;
  agentId: string | null;
  userId: string | null;
  ref: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null;
  userProperties: Record<string, unknown> | null;
  activeSubAgentId: string;
  lastContextResolution: string | null;
}>;
declare const updateConversation: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  conversationId: string;
  data: ConversationUpdate;
}) => Promise<{
  createdAt: string;
  updatedAt: string;
  userId: string | null;
  agentId: string | null;
  activeSubAgentId: string;
  ref: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null;
  title: string | null;
  lastContextResolution: string | null;
  metadata: ConversationMetadata | null;
  userProperties: Record<string, unknown> | null;
  properties: Record<string, unknown> | null;
  projectId: string;
  tenantId: string;
  id: string;
}>;
declare const deleteConversation: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  conversationId: string;
}) => Promise<boolean>;
declare const updateConversationActiveSubAgent: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  conversationId: string;
  activeSubAgentId: string;
}) => Promise<{
  createdAt: string;
  updatedAt: string;
  userId: string | null;
  agentId: string | null;
  activeSubAgentId: string;
  ref: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null;
  title: string | null;
  lastContextResolution: string | null;
  metadata: ConversationMetadata | null;
  userProperties: Record<string, unknown> | null;
  properties: Record<string, unknown> | null;
  projectId: string;
  tenantId: string;
  id: string;
}>;
declare const getConversation: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  conversationId: string;
}) => Promise<{
  id: string;
  properties: Record<string, unknown> | null;
  title: string | null;
  createdAt: string;
  updatedAt: string;
  tenantId: string;
  projectId: string;
  metadata: ConversationMetadata | null;
  agentId: string | null;
  userId: string | null;
  ref: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null;
  userProperties: Record<string, unknown> | null;
  activeSubAgentId: string;
  lastContextResolution: string | null;
} | undefined>;
/**
 * Batch-fetch conversations by id within a project scope.
 *
 * Set-based alternative to calling {@link getConversation} once per id, so callers
 * enriching many results (e.g. evaluation results) issue a single query instead of
 * fanning out one connection acquisition per conversation.
 */
declare const getConversationsByIds: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  conversationIds: string[];
}) => Promise<{
  id: string;
  agentId: string | null;
  createdAt: string;
}[]>;
declare const createOrGetConversation: (db: AgentsRunDatabaseClient) => (input: ConversationInsert) => Promise<{
  activeSubAgentId: string;
  projectId: string;
  tenantId: string;
  id: string;
  ref: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  };
  createdAt?: string | undefined;
  updatedAt?: string | undefined;
  userId?: string | null | undefined;
  agentId?: string | null | undefined;
  title?: string | null | undefined;
  lastContextResolution?: string | null | undefined;
  metadata?: ConversationMetadata | null | undefined;
  contextConfigId?: string | undefined;
  userProperties?: Record<string, unknown> | null | undefined;
  properties?: Record<string, unknown> | null | undefined;
} | {
  id: string;
  properties: Record<string, unknown> | null;
  title: string | null;
  createdAt: string;
  updatedAt: string;
  tenantId: string;
  projectId: string;
  metadata: ConversationMetadata | null;
  agentId: string | null;
  userId: string | null;
  ref: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null;
  userProperties: Record<string, unknown> | null;
  activeSubAgentId: string;
  lastContextResolution: string | null;
}>;
/**
 * Extract text content from message content object
 */
declare function extractMessageText(content: MessageContent): string;
/**
 * Get conversation history with filtering and context management
 */
declare const getConversationHistory: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  conversationId: string;
  options?: ConversationHistoryConfig;
}) => Promise<MessageSelect[]>;
/**
 * Get active agent for a conversation
 */
declare const getActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  conversationId: string;
}) => Promise<{
  id: string;
  properties: Record<string, unknown> | null;
  title: string | null;
  createdAt: string;
  updatedAt: string;
  tenantId: string;
  projectId: string;
  metadata: ConversationMetadata | null;
  agentId: string | null;
  userId: string | null;
  ref: {
    type: "commit" | "tag" | "branch";
    name: string;
    hash: string;
  } | null;
  userProperties: Record<string, unknown> | null;
  activeSubAgentId: string;
  lastContextResolution: string | null;
} | undefined>;
/**
 * Set active agent for a conversation (upsert operation)
 */
declare const setActiveAgentForConversation: (db: AgentsRunDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  conversationId: string;
  subAgentId: string;
  agentId: string;
  ref: ResolvedRef;
  userId?: string;
  metadata?: ConversationMetadata;
  userProperties?: Record<string, unknown> | null;
  properties?: Record<string, unknown> | null;
}) => Promise<void>;
declare const setActiveAgentForThread: (db: AgentsRunDatabaseClient) => ({
  scopes,
  threadId,
  subAgentId,
  agentId,
  ref
}: {
  scopes: ProjectScopeConfig;
  threadId: string;
  subAgentId: string;
  agentId: string;
  ref: ResolvedRef;
}) => Promise<void>;
//#endregion
export { createConversation, createOrGetConversation, deleteConversation, extractMessageText, getActiveAgentForConversation, getConversation, getConversationHistory, getConversationsByIds, listConversations, setActiveAgentForConversation, setActiveAgentForThread, updateConversation, updateConversationActiveSubAgent };