import { AgentScopeConfig, ProjectScopeConfig, ScopedTable } from "../../db/manage/scope-definitions.js";
import { ConversationHistoryConfig, PaginationConfig } from "../../types/utility.js";
import { AgentsManageDatabaseClient } from "../../db/manage/manage-client.js";
import "../../index.js";
import { AgentInsert, AgentSelect, AgentUpdate, FullAgentDefinition, FullAgentSelectWithRelationIds } from "../../types/entities.js";
import { Column } from "drizzle-orm";
import { PgColumn } from "drizzle-orm/pg-core";

//#region src/data-access/manage/agents.d.ts
declare const getAgentById: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
}) => Promise<{
  id: string;
  name: string;
  description: string | null;
  models: {
    base?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
    structuredOutput?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
    summarizer?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
  } | null;
  stopWhen: {
    transferCountIs?: number | undefined;
  } | null;
  createdAt: string;
  updatedAt: string;
  tenantId: string;
  projectId: string;
  defaultSubAgentId: string | null;
  contextConfigId: string | null;
  prompt: string | null;
  statusUpdates: {
    enabled?: boolean | undefined;
    numEvents?: number | undefined;
    timeInSeconds?: number | undefined;
    prompt?: string | undefined;
    statusComponents?: {
      type: string;
      description?: string | undefined;
      detailsSchema?: {
        type: "object";
        properties: Record<string, any>;
        required?: string[] | undefined;
      } | undefined;
    }[] | undefined;
  } | null;
  executionMode: "classic" | "durable";
} | null>;
declare const getAgentWithDefaultSubAgent: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
}) => Promise<{
  id: string;
  name: string;
  description: string | null;
  models: {
    base?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
    structuredOutput?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
    summarizer?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
  } | null;
  stopWhen: {
    transferCountIs?: number | undefined;
  } | null;
  createdAt: string;
  updatedAt: string;
  tenantId: string;
  projectId: string;
  defaultSubAgentId: string | null;
  contextConfigId: string | null;
  prompt: string | null;
  statusUpdates: {
    enabled?: boolean | undefined;
    numEvents?: number | undefined;
    timeInSeconds?: number | undefined;
    prompt?: string | undefined;
    statusComponents?: {
      type: string;
      description?: string | undefined;
      detailsSchema?: {
        type: "object";
        properties: Record<string, any>;
        required?: string[] | undefined;
      } | undefined;
    }[] | undefined;
  } | null;
  executionMode: "classic" | "durable";
  defaultSubAgent: {
    id: string;
    name: string;
    description: string | null;
    models: {
      base?: {
        model?: string | undefined;
        providerOptions?: Record<string, unknown> | undefined;
        fallbackModels?: string[] | undefined;
        allowedProviders?: string[] | undefined;
      } | undefined;
      structuredOutput?: {
        model?: string | undefined;
        providerOptions?: Record<string, unknown> | undefined;
        fallbackModels?: string[] | undefined;
        allowedProviders?: string[] | undefined;
      } | undefined;
      summarizer?: {
        model?: string | undefined;
        providerOptions?: Record<string, unknown> | undefined;
        fallbackModels?: string[] | undefined;
        allowedProviders?: string[] | undefined;
      } | undefined;
    } | null;
    stopWhen: {
      stepCountIs?: number | undefined;
    } | null;
    createdAt: string;
    updatedAt: string;
    tenantId: string;
    projectId: string;
    prompt: string | null;
    agentId: string;
    conversationHistoryConfig: ConversationHistoryConfig | null;
    outputContract: {
      [x: string]: unknown;
      allowText?: boolean | undefined;
      requireComponent?: string[] | undefined;
      requireArtifact?: string[] | undefined;
      requireTransfer?: boolean | undefined;
      onViolation?: "retry" | "reject" | "warn" | undefined;
      retryBudget?: number | undefined;
    } | null;
  } | null;
} | null>;
declare const listAgents: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
}) => Promise<{
  id: string;
  name: string;
  description: string | null;
  models: {
    base?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
    structuredOutput?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
    summarizer?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
  } | null;
  stopWhen: {
    transferCountIs?: number | undefined;
  } | null;
  createdAt: string;
  updatedAt: string;
  tenantId: string;
  projectId: string;
  defaultSubAgentId: string | null;
  contextConfigId: string | null;
  prompt: string | null;
  statusUpdates: {
    enabled?: boolean | undefined;
    numEvents?: number | undefined;
    timeInSeconds?: number | undefined;
    prompt?: string | undefined;
    statusComponents?: {
      type: string;
      description?: string | undefined;
      detailsSchema?: {
        type: "object";
        properties: Record<string, any>;
        required?: string[] | undefined;
      } | undefined;
    }[] | undefined;
  } | null;
  executionMode: "classic" | "durable";
}[]>;
declare const listAgentsPaginated: (db: AgentsManageDatabaseClient) => (params: {
  scopes: ProjectScopeConfig;
  pagination?: PaginationConfig;
}) => Promise<{
  data: {
    createdAt: string;
    updatedAt: string;
    defaultSubAgentId: string | null;
    contextConfigId: string | null;
    models: {
      base?: {
        model?: string | undefined;
        providerOptions?: Record<string, unknown> | undefined;
        fallbackModels?: string[] | undefined;
        allowedProviders?: string[] | undefined;
      } | undefined;
      structuredOutput?: {
        model?: string | undefined;
        providerOptions?: Record<string, unknown> | undefined;
        fallbackModels?: string[] | undefined;
        allowedProviders?: string[] | undefined;
      } | undefined;
      summarizer?: {
        model?: string | undefined;
        providerOptions?: Record<string, unknown> | undefined;
        fallbackModels?: string[] | undefined;
        allowedProviders?: string[] | undefined;
      } | undefined;
    } | null;
    statusUpdates: {
      enabled?: boolean | undefined;
      numEvents?: number | undefined;
      timeInSeconds?: number | undefined;
      prompt?: string | undefined;
      statusComponents?: {
        type: string;
        description?: string | undefined;
        detailsSchema?: {
          type: "object";
          properties: Record<string, any>;
          required?: string[] | undefined;
        } | undefined;
      }[] | undefined;
    } | null;
    prompt: string | null;
    stopWhen: {
      transferCountIs?: number | undefined;
    } | null;
    executionMode: "classic" | "durable";
    name: string;
    description: string | null;
    projectId: string;
    tenantId: string;
    id: string;
  }[];
  pagination: {
    page: number;
    limit: number;
    total: number;
    pages: number;
  };
}>;
type AvailableAgentInfo = {
  agentId: string;
  agentName: string;
  projectId: string;
};
/**
 * List agents across multiple project main branches for a tenant.
 *
 * Uses Dolt AS OF queries against each project's main branch without checkout.
 *
 * @param db - Database client
 * @param params - Tenant and project IDs
 */
declare function listAgentsAcrossProjectMainBranches(db: AgentsManageDatabaseClient, params: {
  tenantId: string;
  projectIds: string[];
}): Promise<AvailableAgentInfo[]>;
declare const createAgent: (db: AgentsManageDatabaseClient) => (data: AgentInsert) => Promise<{
  id: string;
  name: string;
  description: string | null;
  models: {
    base?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
    structuredOutput?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
    summarizer?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
  } | null;
  stopWhen: {
    transferCountIs?: number | undefined;
  } | null;
  createdAt: string;
  updatedAt: string;
  tenantId: string;
  projectId: string;
  defaultSubAgentId: string | null;
  contextConfigId: string | null;
  prompt: string | null;
  statusUpdates: {
    enabled?: boolean | undefined;
    numEvents?: number | undefined;
    timeInSeconds?: number | undefined;
    prompt?: string | undefined;
    statusComponents?: {
      type: string;
      description?: string | undefined;
      detailsSchema?: {
        type: "object";
        properties: Record<string, any>;
        required?: string[] | undefined;
      } | undefined;
    }[] | undefined;
  } | null;
  executionMode: "classic" | "durable";
}>;
declare const updateAgent: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
  data: AgentUpdate;
}) => Promise<{
  createdAt: string;
  updatedAt: string;
  defaultSubAgentId: string | null;
  contextConfigId: string | null;
  models: {
    base?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
    structuredOutput?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
    summarizer?: {
      model?: string | undefined;
      providerOptions?: Record<string, unknown> | undefined;
      fallbackModels?: string[] | undefined;
      allowedProviders?: string[] | undefined;
    } | undefined;
  } | null;
  statusUpdates: {
    enabled?: boolean | undefined;
    numEvents?: number | undefined;
    timeInSeconds?: number | undefined;
    prompt?: string | undefined;
    statusComponents?: {
      type: string;
      description?: string | undefined;
      detailsSchema?: {
        type: "object";
        properties: Record<string, any>;
        required?: string[] | undefined;
      } | undefined;
    }[] | undefined;
  } | null;
  prompt: string | null;
  stopWhen: {
    transferCountIs?: number | undefined;
  } | null;
  executionMode: "classic" | "durable";
  name: string;
  description: string | null;
  projectId: string;
  tenantId: string;
  id: string;
}>;
declare const deleteAgent: (db: AgentsManageDatabaseClient) => (params: {
  scopes: AgentScopeConfig;
}) => Promise<boolean>;
/**
 * Helper function to fetch component relationships using efficient joins
 */
declare const fetchComponentRelationships: (db: AgentsManageDatabaseClient) => <T extends Record<string, unknown>>(scopes: AgentScopeConfig, subAgentIds: string[], config: {
  relationTable: ScopedTable<"agent">;
  componentTable: ScopedTable<"project">;
  relationIdField: Column;
  componentIdField: Column;
  subAgentIdField: Column;
  selectFields: Record<string, PgColumn>;
}) => Promise<Record<string, T>>;
declare const getAgentSubAgentInfos: (db: AgentsManageDatabaseClient) => ({
  scopes: {
    tenantId,
    projectId
  },
  agentId,
  subAgentId
}: {
  scopes: ProjectScopeConfig;
  agentId: string;
  subAgentId: string;
}) => Promise<{
  id: string;
  name: string;
  description: string | null;
}[]>;
declare const getFullAgentDefinition: (db: AgentsManageDatabaseClient) => ({
  scopes
}: {
  scopes: AgentScopeConfig;
}) => Promise<FullAgentDefinition | null>;
declare const getFullAgentDefinitionWithRelationIds: (db: AgentsManageDatabaseClient) => ({
  scopes
}: {
  scopes: AgentScopeConfig;
}) => Promise<FullAgentSelectWithRelationIds | null>;
/**
 * Upsert an agent (create if it doesn't exist, update if it does)
 */
declare const upsertAgent: (db: AgentsManageDatabaseClient) => (params: {
  data: AgentInsert;
}) => Promise<AgentSelect | null>;
//#endregion
export { AvailableAgentInfo, createAgent, deleteAgent, fetchComponentRelationships, getAgentById, getAgentSubAgentInfos, getAgentWithDefaultSubAgent, getFullAgentDefinition, getFullAgentDefinitionWithRelationIds, listAgents, listAgentsAcrossProjectMainBranches, listAgentsPaginated, updateAgent, upsertAgent };