/** * [WHO]: AgentDefinitionRegistry — agent name registry, definition cache, lookup * [FROM]: Depends on ./agent-definition for AgentDefinition, BUILT_IN_AGENT_DEFINITIONS * [TO]: Consumed by ./agent-tool, ./index.ts, extensions/builtin/subagent/* * [HERE]: core/sub-agent/agent-registry.ts - Agent registration and lookup per CC §XIV * [COVENANT]: Change registry shape → update P2 AGENT.md member list */ import type { AgentDefinition } from "./agent-definition.js"; /** * Manages agent definitions and the name→agentId mapping. * * Per CC §XIV: * - agentDefinitions has activeAgents (currently usable) and allAgents (including disabled) * - agentNameRegistry maps name → agentId for SendMessage routing * - Definitions are loaded at startup, config change, and plugin load * - Sources: built-in, plugin, user custom (.catui/agents/*.md) */ export declare class AgentDefinitionRegistry { /** Currently active (usable) agent definitions */ private activeAgents; /** All agent definitions (including disabled/filtered) */ private allAgents; /** Name → agentId mapping (for SendMessage routing and name-based lookup) */ private agentNameRegistry; /** Failed agent definition files (for error reporting) */ private failedFiles; /** Path for persisting agentNameRegistry to disk (CC §XIV, §18.6) */ private persistencePath; /** Project cwd for loading custom agent definitions from .catui/agents/ */ private cwd; /** Global agent config directory for user-scoped agent definitions */ private agentDir; /** * @param persistencePath Optional path for agentNameRegistry JSON persistence. * Per CC §14.1, the name registry is persisted so it survives process restarts. * Typical: join(cwd, ".catui", "agent-registry.json") */ constructor(persistencePath?: string); /** * Reload all agent definitions from all sources. * Called at startup, config change, and plugin load (CC §XIV). */ reload(): void; /** * Resolve an agent type name to its definition. * Matches CC's resolveAgentType (Mq8) function. * * @param subagentType The agent type to look up (e.g. "Explore", "general-purpose") * @returns The matching AgentDefinition, or undefined if not found */ resolve(subagentType: string): AgentDefinition | undefined; /** * Resolve an agent type, throwing if not found or denied. * Matches CC's agent type resolution path (§VI step 5). * * @param subagentType The agent type to look up * @param deniedTypes Optional set of agent types denied by permission rules * @returns The matching AgentDefinition * @throws Error if agent type not found or denied */ resolveOrThrow(subagentType: string, deniedTypes?: ReadonlySet): AgentDefinition; /** * Get the default fork agent definition. * Used when subagent_type is not specified (CC §VI step 5). */ getDefaultForkAgent(): AgentDefinition; /** * Register a name → agentId mapping. * Used by the Agent tool when a `name` parameter is provided. * This allows SendMessage({to: name}) to address a running agent. * Persists to disk if persistencePath is configured (CC §18.6). */ registerAgentName(name: string, agentId: string): void; /** * Find an agent by its registered name. * Used by SendMessage routing. */ findAgentByName(name: string): string | undefined; /** * Remove a name registration (when the agent completes). * Persists to disk if persistencePath is configured (CC §18.6). */ unregisterAgentName(name: string): void; /** * Load agentNameRegistry from disk. * Called during reload(). Silently ignores missing or corrupt files. */ private loadNameRegistry; /** * Persist agentNameRegistry to disk. * Called on every register/unregister. Errors are logged but not thrown. */ private saveNameRegistry; /** Get the current persistence path (if configured). */ getPersistencePath(): string | undefined; /** Configure directories for custom agent loading and trigger async reload. */ configureDirectories(cwd: string, agentDir: string): Promise; /** Load custom agent definitions from configured directories (async). */ loadCustomAgents(): Promise; /** * Set or update the persistence path for agentNameRegistry. * Called from createAgentTool when the parent session's cwd is known. * If the registry already has entries (from a previous session), they are * preserved; only the path is updated for future saves. */ setPersistencePath(path: string): void; /** * Register a custom agent definition (from plugin or user settings). * Per CC §XIV, definitions can come from: * - Plugin definitions (ao6) * - User custom agents (.catui/agents/*.md) * - Flag / settings overrides */ registerCustomAgent(definition: AgentDefinition): void; /** * Remove a custom agent definition. */ unregisterCustomAgent(agentType: string): void; /** Get all currently active agent type names. */ getActiveAgentTypes(): string[]; /** Get all active agent definitions. */ getActiveDefinitions(): AgentDefinition[]; /** Get all agent definitions (including inactive). */ getAllDefinitions(): AgentDefinition[]; /** Get failed file entries (for error reporting). */ getFailedFiles(): Array<{ path: string; error: string; }>; /** Get the name registry (for SendMessage). */ getNameRegistry(): Map; /** * Record a failed agent definition file. * Used during loading when a .md or .json file fails to parse. */ recordFailedFile(path: string, error: string): void; /** Whether an agent definition is a built-in type. */ isBuiltIn(agentType: string): boolean; } /** * Default global agent definition registry instance. * Per CC §XIV, this is maintained in AppState and refreshed at * startup, config change, and plugin load. */ export declare const agentDefinitionRegistry: AgentDefinitionRegistry;