import { type ServerCapabilities } from '@frontmcp/protocol'; import { type EntryOwnerRef, type PromptEntry, type PromptRecord, type PromptType } from '../common'; import type ProviderRegistry from '../provider/provider.registry'; import { RegistryAbstract, type RegistryBuildMapResult } from '../regsitry'; import { type PromptChangeEvent } from './prompt.events'; import { PromptInstance } from './prompt.instance'; import { type IndexedPrompt, type PromptExportOptions } from './prompt.types'; export default class PromptRegistry extends RegistryAbstract { /** Who owns this registry (used for provenance). */ owner: EntryOwnerRef; /** Prompts truly owned/constructed by THIS registry (with lineage applied) */ private localRows; /** Adopted prompt rows from each child registry (references to the same instances) */ private adopted; /** Children registries that we track */ private children; private byQualifiedId; private byName; private byOwnerAndName; private byOwner; private version; private emitter; constructor(providers: ProviderRegistry, list: PromptType[], owner: EntryOwnerRef); protected buildMap(list: PromptType[]): RegistryBuildMapResult; protected buildGraph(): void; protected initialize(): Promise; /** * Adopt prompts from a child registry. Parent runs after children are ready. * We *reference* the child's prompt instances; no duplicates are created. */ adoptFromChild(child: PromptRegistry, _childOwner: EntryOwnerRef): void; /** * Adopt prompts directly from a remote app's prompts registry. * Remote apps expose prompts via proxy entries that forward execution to the remote server. * This also subscribes to updates from the remote app's registry for lazy-loaded prompts. */ private adoptPromptsFromRemoteApp; /** * Adopt prompts from a local app's child PromptRegistry instances. * Local apps use the hierarchical registry pattern for prompt discovery. */ private adoptPromptsFromLocalApp; /** * Get all prompts */ getPrompts(includeHidden?: boolean): PromptEntry[]; /** * Get inline prompts (local only) */ getInlinePrompts(): PromptEntry[]; /** * Find a prompt by exact name match */ findByName(name: string): PromptEntry | undefined; /** * Find all prompts matching a name */ findAllByName(name: string): PromptEntry[]; /** Internal snapshot of effective indexed rows (locals + adopted). */ listAllIndexed(): IndexedPrompt[]; /** List all instances (locals + adopted). */ listAllInstances(): readonly PromptEntry[]; /** List instances by owner path (e.g. "app:Portal/plugin:Okta") */ listByOwner(ownerPath: string): readonly PromptEntry[]; private reindex; /** * Produce unique, MCP-valid exported names. */ exportResolvedNames(opts?: PromptExportOptions): Array<{ name: string; instance: PromptEntry; }>; /** Lookup by the exported (resolved) name. */ getExported(name: string, opts?: PromptExportOptions): PromptEntry | undefined; subscribe(opts: { immediate?: boolean; filter?: (i: PromptEntry) => boolean; }, cb: (evt: PromptChangeEvent) => void): () => void; private bump; /** Build an IndexedPrompt row */ private makeRow; /** Clone a child row and prepend lineage (with adjacent de-dup to avoid double prefixes). */ private relineage; /** Best-effort provider id used for prefixing. */ private providerIdOf; /** True if this registry (or adopted children) has any prompts. */ hasAny(): boolean; /** * Replace all prompts owned by the given owner. * Clears local rows, rebuilds from new list, reindexes, and emits 'reset'. * Used by adapter polling to hot-swap prompts when specs change. */ replaceAll(list: PromptType[], owner: EntryOwnerRef): void; /** * Register an existing PromptEntry instance directly (for remote prompts). * This allows pre-constructed prompt instances to be added without going through * the standard token-based initialization flow. * * **IMPORTANT: Scope Binding** * The PromptEntry captures its scope and providers at construction time. * The prompt will use the scope from its original `providers` argument, NOT this registry's scope. * * @param prompt - The prompt instance to register (PromptInstance or RemotePromptInstance) * @throws Error if prompt is not a valid instance */ registerPromptInstance(prompt: PromptEntry): void; /** * Get the MCP capabilities for prompts. * These are reported to clients during initialization. * * Issue #407: we always advertise the `prompts` capability so the MCP SDK * accepts the always-registered `prompts/list` handler (see * `createMcpHandlers`). `listChanged` still reflects whether anything is * actually registered. */ getCapabilities(): Partial; } //# sourceMappingURL=prompt.registry.d.ts.map