import { AgentWithinContextOfProjectSelectWithRelationIds, ArtifactComponentApiSelect, CanDelegateToItem, CanRelateToInternalSubAgent, DataComponentApiSelect, ExternalAgentApiSelect, FullAgentSubAgentSelectWithRelationIds, FullProjectSelectWithRelationIds, ToolApiSelect } from "@inkeep/agents-core";

//#region src/domains/run/utils/project.d.ts

/**
 * Get an agent from the project definition
 * Replaces direct database calls with lookup from pre-fetched project data
 */
declare function getAgentFromProject(params: {
  project: FullProjectSelectWithRelationIds;
  agentId: string;
}): AgentWithinContextOfProjectSelectWithRelationIds | null;
/**
 * Get a sub-agent from the project definition
 * Replaces direct database calls with lookup from pre-fetched project data
 */
declare function getSubAgentFromProject(params: {
  project: FullProjectSelectWithRelationIds;
  agentId: string;
  subAgentId?: string;
}): FullAgentSubAgentSelectWithRelationIds | null;
type InternalRelation = {
  id: string;
  name: string;
  description: string | null;
  relationType: 'transfer' | 'delegate';
  relationId: string;
};
type ExternalRelation = {
  externalAgent: {
    id: string;
    name: string;
    description: string | null;
    baseUrl: string;
    credentialReferenceId?: string | null;
  };
  headers?: Record<string, string> | null;
  relationId: string;
};
type TeamRelation = {
  targetAgent: {
    id: string;
    name: string;
    description: string | null;
  };
  targetAgentId: string;
  headers?: Record<string, string> | null;
  relationId: string;
};
type ParsedDelegateRelations = {
  internalDelegateRelations: InternalRelation[];
  externalRelations: ExternalRelation[];
  teamRelations: TeamRelation[];
};
/**
 * Extract transfer relations from a sub-agent's canTransferTo array
 * Returns sub-agents that can be transferred to with their details
 */
declare function extractTransferRelations(params: {
  agent: AgentWithinContextOfProjectSelectWithRelationIds;
  canTransferTo: CanRelateToInternalSubAgent[];
}): InternalRelation[];
/**
 * Parse canDelegateTo array to separate internal, external, and team relations
 * Handles the union type of string | CanDelegateToExternalAgent | CanDelegateToTeamAgent
 */
declare function parseDelegateRelations(params: {
  agent: AgentWithinContextOfProjectSelectWithRelationIds;
  project: FullProjectSelectWithRelationIds;
  canDelegateTo: CanDelegateToItem[];
}): ParsedDelegateRelations;
/**
 * Get all relations for a sub-agent (transfers + delegates combined)
 * Convenience function that combines extractTransferRelations and parseDelegateRelations
 */
declare function getSubAgentRelations(params: {
  agent: AgentWithinContextOfProjectSelectWithRelationIds;
  project: FullProjectSelectWithRelationIds;
  subAgent: FullAgentSubAgentSelectWithRelationIds;
}): {
  transferRelations: InternalRelation[];
  internalDelegateRelations: InternalRelation[];
  externalRelations: ExternalRelation[];
  teamRelations: TeamRelation[];
};
type ToolForAgent = {
  toolId: string;
  tool: ToolApiSelect;
  selectedTools: string[] | null | undefined;
  headers: Record<string, string> | null | undefined;
  toolPolicies: Record<string, {
    needsApproval?: boolean;
  }> | null | undefined;
  relationshipId: string | undefined;
};
/**
 * Get tools for a sub-agent from their canUse array
 * Resolves tool references from both agent-level and project-level tools
 */
declare function getToolsForSubAgent(params: {
  agent: AgentWithinContextOfProjectSelectWithRelationIds;
  project: FullProjectSelectWithRelationIds;
  subAgent: FullAgentSubAgentSelectWithRelationIds;
}): ToolForAgent[];
type DataComponentForAgent = DataComponentApiSelect;
type ArtifactComponentForAgent = ArtifactComponentApiSelect;
/**
 * Get data components for a sub-agent
 * Resolves data component references from project-level dataComponents
 */
declare function getDataComponentsForSubAgent(params: {
  project: FullProjectSelectWithRelationIds;
  subAgent: FullAgentSubAgentSelectWithRelationIds;
}): DataComponentForAgent[];
/**
 * Get artifact components for a sub-agent
 * Resolves artifact component references from project-level artifactComponents
 */
declare function getArtifactComponentsForSubAgent(params: {
  project: FullProjectSelectWithRelationIds;
  subAgent: FullAgentSubAgentSelectWithRelationIds;
}): ArtifactComponentForAgent[];
type TargetTransferRelation = {
  id: string;
  name: string;
  description: string | null;
  relationId: string;
};
type TargetExternalAgentRelation = {
  externalAgent: ExternalAgentApiSelect;
  headers?: Record<string, string> | null;
  relationId: string;
};
/**
 * Get transfer relations for a target sub-agent
 * Used when building agent configurations that need to know what the target can transfer to
 */
declare function getTransferRelationsForTargetSubAgent(params: {
  agent: AgentWithinContextOfProjectSelectWithRelationIds;
  subAgentId: string;
}): TargetTransferRelation[];
/**
 * Get delegate relations (external agents) for a target sub-agent
 * Used when building agent configurations that need to know what external agents the target can delegate to
 */
declare function getExternalAgentRelationsForTargetSubAgent(params: {
  agent: AgentWithinContextOfProjectSelectWithRelationIds;
  project: FullProjectSelectWithRelationIds;
  subAgentId: string;
}): TargetExternalAgentRelation[];
type RelationForDescription = {
  id: string;
  name: string;
  description: string | null;
  relationType?: 'transfer' | 'delegate';
  relationId: string;
};
type ExternalRelationForDescription = {
  externalAgent: {
    id: string;
    name: string;
    description: string | null;
  };
  relationId: string;
};
type TeamRelationForDescription = {
  targetAgent: {
    id: string;
    name: string;
    description: string | null;
  };
  targetAgentId: string;
  relationId: string;
};
type RelationsForDescriptionGeneration = {
  internalRelations: RelationForDescription[];
  externalRelations: ExternalRelationForDescription[];
  teamRelations: TeamRelationForDescription[];
};
/**
 * Build relation arrays from a sub-agent's canTransferTo and canDelegateTo
 * Used for generating enhanced descriptions
 */
declare function buildRelationsForDescription(params: {
  agent: AgentWithinContextOfProjectSelectWithRelationIds;
  project: FullProjectSelectWithRelationIds;
  subAgent: FullAgentSubAgentSelectWithRelationIds;
}): RelationsForDescriptionGeneration;
/**
 * Enhance an internal relation with a generated description
 * Looks up the related sub-agent and builds relation data for description generation
 */
declare function enhanceInternalRelation(params: {
  relation: InternalRelation;
  agent: AgentWithinContextOfProjectSelectWithRelationIds;
  project: FullProjectSelectWithRelationIds;
}): InternalRelation;
/**
 * Enhance a team relation with a generated description
 * Looks up the team agent's default sub-agent and builds relation data for description generation
 */
declare function enhanceTeamRelation(params: {
  relation: TeamRelation;
  project: FullProjectSelectWithRelationIds;
}): TeamRelation;
//#endregion
export { ArtifactComponentForAgent, DataComponentForAgent, ExternalRelation, ExternalRelationForDescription, InternalRelation, ParsedDelegateRelations, RelationForDescription, RelationsForDescriptionGeneration, TargetExternalAgentRelation, TargetTransferRelation, TeamRelation, TeamRelationForDescription, ToolForAgent, buildRelationsForDescription, enhanceInternalRelation, enhanceTeamRelation, extractTransferRelations, getAgentFromProject, getArtifactComponentsForSubAgent, getDataComponentsForSubAgent, getExternalAgentRelationsForTargetSubAgent, getSubAgentFromProject, getSubAgentRelations, getToolsForSubAgent, getTransferRelationsForTargetSubAgent, parseDelegateRelations };