import { loopAgentSteps } from '../../../run-agent-step';
import { getAgentTemplate } from '../../../templates/agent-registry';
import type { AgentTemplate } from '@levelcode/common/types/agent-template';
import type { AgentRuntimeDeps, AgentRuntimeScopedDeps } from '@levelcode/common/types/contracts/agent-runtime';
import type { Logger } from '@levelcode/common/types/contracts/logger';
import type { ParamsExcluding, OptionalFields } from '@levelcode/common/types/function-params';
import type { PrintModeEvent } from '@levelcode/common/types/print-mode';
import type { AgentState, AgentTemplateType, Subgoal } from '@levelcode/common/types/session-state';
import type { TeamConfig, TeamRole } from '@levelcode/common/types/team-config';
import type { ProjectFileContext } from '@levelcode/common/util/file';
import type { ToolSet } from 'ai';
/**
 * Common context params needed for spawning subagents.
 * These are the params that don't change between different spawn calls
 * and are passed through from the parent agent runtime.
 */
export type SubagentContextParams = AgentRuntimeDeps & AgentRuntimeScopedDeps & {
    clientSessionId: string;
    fileContext: ProjectFileContext;
    localAgentTemplates: Record<string, AgentTemplate>;
    repoId: string | undefined;
    repoUrl: string | undefined;
    signal: AbortSignal;
    userId: string | undefined;
};
/**
 * Extracts the common context params needed for spawning subagents.
 * This avoids bugs from spreading all params with `...params` which can
 * accidentally pass through params that should be overridden.
 */
export declare function extractSubagentContextParams(params: SubagentContextParams): SubagentContextParams;
/**
 * Checks if a parent agent is allowed to spawn a child agent
 */
export declare function getMatchingSpawn(spawnableAgents: AgentTemplateType[], childFullAgentId: string): AgentTemplateType | null;
/**
 * Synchronously transforms spawn_agents input to use 'commander-lite' instead of 'commander'
 * when the parent agent doesn't have access to 'commander' but does have access to 'commander-lite'.
 * This should be called BEFORE the tool call is streamed to the UI.
 */
export declare function transformSpawnAgentsInput(input: Record<string, unknown>, spawnableAgents: AgentTemplateType[]): Record<string, unknown>;
/**
 * Validates agent template and permissions
 */
export declare function validateAndGetAgentTemplate(params: {
    agentTypeStr: string;
    parentAgentTemplate: AgentTemplate;
    localAgentTemplates: Record<string, AgentTemplate>;
    logger: Logger;
} & ParamsExcluding<typeof getAgentTemplate, 'agentId'>): Promise<{
    agentTemplate: AgentTemplate;
    agentType: string;
}>;
/**
 * Validates prompt and params against agent schema
 */
export declare function validateAgentInput(agentTemplate: AgentTemplate, agentType: string, prompt?: string, params?: any): void;
/**
 * Creates a new agent state for spawned agents
 */
export declare function createAgentState(agentType: string, agentTemplate: AgentTemplate, parentAgentState: AgentState, agentContext: Record<string, Subgoal>): AgentState;
/**
 * Logs agent spawn information
 */
export declare function logAgentSpawn(params: {
    agentTemplate: AgentTemplate;
    agentType: string;
    agentId: string;
    parentId: string | undefined;
    prompt?: string;
    spawnParams?: any;
    inline?: boolean;
    logger: Logger;
}): void;
/**
 * Executes a subagent using loopAgentSteps
 */
export declare function executeSubagent(options: OptionalFields<{
    agentTemplate: AgentTemplate;
    parentAgentState: AgentState;
    parentTools?: ToolSet;
    onResponseChunk: (chunk: string | PrintModeEvent) => void;
    isOnlyChild?: boolean;
    ancestorRunIds: string[];
} & ParamsExcluding<typeof loopAgentSteps, 'agentType' | 'ancestorRunIds'>, 'isOnlyChild' | 'clearUserPromptMessagesAfterResponse'>): Promise<{
    agentState: AgentState;
    output: import("@levelcode/common/types/session-state").AgentOutput;
}>;
/**
 * Options for registering a spawned agent as a team member.
 */
export interface TeamSpawnOptions {
    teamName: string;
    teamRole?: string;
}
/**
 * Resolves a team_role to the corresponding agent template ID from agents/team/.
 * For example, 'coordinator' maps to the coordinator agent template,
 * 'manager' maps to the manager agent template, etc.
 *
 * Returns the agent template ID (which is the same as the role string for
 * roles that have a dedicated template), or null if no template exists for
 * the given role.
 */
export declare function resolveTeamRoleAgentType(teamRole: string): string | null;
/**
 * Validates that the spawning agent has authority to spawn an agent
 * with the requested team role.
 *
 * Uses canManage from role-hierarchy to check that the spawner's role
 * has a strictly higher authority level than the target role.
 * Also checks getSpawnableRoles to ensure the specific role combination
 * is allowed.
 *
 * @param spawnerRole - The team role of the agent performing the spawn
 * @param targetRole - The team role being requested for the new agent
 * @throws Error if the spawner lacks authority
 */
export declare function validateSpawnAuthority(spawnerRole: TeamRole, targetRole: TeamRole): void;
/**
 * Sends a notification to the team lead when a new agent joins the team.
 * This is a fire-and-forget operation; errors are logged but not thrown.
 */
export declare function notifyTeamLead(teamName: string, teamConfig: TeamConfig, memberName: string, role: TeamRole, logger: Logger): Promise<void>;
/**
 * Registers a spawned agent as a member of an existing team.
 * Returns the team context string to prepend to the agent's prompt,
 * or null if the team does not exist.
 */
export declare function registerAgentAsTeamMember(agentId: string, agentType: string, options: TeamSpawnOptions, logger: Logger): Promise<string | null>;
