import { type Token } from '@frontmcp/di'; import type { ServerCapabilities, Tool } from '@frontmcp/protocol'; import { type AgentEntry, type AgentRecord, type AgentType, type EntryLineage, type EntryOwnerRef } from '../common'; import type ProviderRegistry from '../provider/provider.registry'; import { RegistryAbstract, type RegistryBuildMapResult } from '../regsitry'; import { type AgentChangeEvent } from './agent.events'; import { AgentInstance } from './agent.instance'; /** * Indexed agent for lookups. */ export interface IndexedAgent { token: Token; instance: AgentInstance; baseName: string; lineage: EntryLineage; ownerKey: string; qualifiedName: string; qualifiedId: string; source: AgentRegistry; } /** * Registry for managing agents within a scope. * * AgentRegistry: * - Creates and manages AgentInstance objects * - Provides lookup by ID, name, or qualified name * - Generates tool definitions for agent invocation * - Manages agent visibility in swarms * - Supports nested registries (agents inside agents/plugins/apps) */ export default class AgentRegistry extends RegistryAbstract { /** Who owns this registry (used for provenance). */ owner: EntryOwnerRef; /** Agents owned/constructed by THIS registry (with lineage applied) */ private localRows; /** Adopted agent rows from each child registry */ private adopted; /** Children registries that we track */ private children; /** Unsubscribe functions for child registry subscriptions */ private childSubscriptions; private byQualifiedId; private byName; private byOwnerAndName; private byOwner; private byId; private version; private emitter; constructor(providers: ProviderRegistry, list: AgentType[], owner: EntryOwnerRef); protected buildMap(list: AgentType[]): RegistryBuildMapResult; protected buildGraph(): void; protected initialize(): Promise; /** * Register each agent's ToolInstance in the parent scope's ToolRegistry. * * This enables: * - Agents to be called like any other tool through tools:call-tool flow * - Plugin metadata extensions (cache, codecall) to work on agents * - CodeCall to discover and search for agent tools * - Unified hook/plugin execution for all tools including agents * * NOTE: This method registers ALL agents (local + adopted), not just local ones. * It should only be called by scope-level registries after all apps are initialized. */ private registerAgentToolsInParentScope; /** * Adopt agents from a child registry. */ adoptFromChild(child: AgentRegistry, _childOwner: EntryOwnerRef): void; /** * Remove a child registry and clean up its subscription. */ removeChild(child: AgentRegistry): void; /** * Dispose the registry and clean up all child subscriptions. * Call this when the registry is no longer needed to prevent memory leaks. */ dispose(): void; /** * Get all agents (local + adopted). */ getAgents(includeHidden?: boolean): AgentEntry[]; /** * Get only agents defined inline in this registry. */ getInlineAgents(): AgentEntry[]; /** * Internal snapshot of effective indexed rows (locals + adopted). */ private listAllIndexed; /** * List all instances (locals + adopted) — unfiltered. */ listAllInstances(): readonly AgentInstance[]; /** * List available instances (locals + adopted), filtered by availability. * Used by discovery/listing APIs to enforce registry-level constraints. */ private getAvailableInstances; /** * Find an agent by ID. */ findById(id: string): AgentInstance | undefined; /** * Find an agent by name. */ findByName(name: string): AgentInstance | undefined; /** * Get agents visible to a specific agent. * * @param agentId - The ID of the agent that wants to see others * @returns Array of agents visible to the specified agent */ getVisibleAgentsFor(agentId: string): AgentInstance[]; /** * Get tool definitions for all agents. * * Each agent is exposed as a tool with name `use-agent:`. */ getAgentsAsTools(): Tool[]; /** * Get tool definitions for agents visible to a specific agent. */ getAgentToolsFor(agentId: string): Tool[]; private reindex; subscribe(opts: { immediate?: boolean; filter?: (i: AgentInstance) => boolean; }, cb: (evt: AgentChangeEvent) => void): () => void; private bump; private makeRow; private relineage; /** * True if this registry (or adopted children) has any agents. */ hasAny(): boolean; /** * Get the MCP capabilities for agents. */ getCapabilities(): Partial; } //# sourceMappingURL=agent.registry.d.ts.map