/** Duck-typed ToolBuilder — avoids circular imports */ interface ToolBuilderLike { getName(): string; buildToolDefinition?(): unknown; } /** Duck-typed ToolRegistry — avoids circular imports */ interface ToolRegistryLike { register(builder: ToolBuilderLike): void; } /** * Options for `autoDiscover()`. */ export interface AutoDiscoverOptions { /** * Regex pattern to filter files. Only files matching this pattern * are imported. Default: matches `.ts`, `.js`, `.mjs`, `.mts` files, * excluding `.test.`, `.spec.`, and `.d.ts` files. */ pattern?: RegExp; /** * Whether to recurse into subdirectories. * @default true */ recursive?: boolean; /** * Module resolution style: * - `'esm'` — Uses dynamic `import()` (default for ESM projects) * - `'cjs'` — Uses `require()` (for CommonJS projects) * * @default 'esm' */ loader?: 'esm' | 'cjs'; /** * Custom export resolver. When provided, this function is called * with the module's exports and must return the tool builder(s). * * Default behavior: looks for `default` export or named `tool` export. */ resolve?: (mod: Record) => ToolBuilderLike | ToolBuilderLike[] | undefined; /** * Error handler called when a file fails to import. * Receives the file path and the thrown error. * If not provided, import errors are silently ignored. */ onError?: (filePath: string, error: unknown) => void; /** * When `true`, rethrow import errors instead of skipping. * Takes precedence over `onError`. * @default false */ strict?: boolean; } /** * Scan a directory and auto-register all discovered tool builders. * * Eliminates the need for a central `index.ts` that manually imports * and registers every tool. New tools are automatically picked up * when they are dropped into the scanned directory. * * @param registry - A ToolRegistry instance to register discovered tools * @param dir - Path to the tools directory (absolute or relative to CWD) * @param options - Discovery options (pattern, recursive, loader, resolve) * @returns Array of discovered file paths (for logging/debugging) * @throws If the directory does not exist or is not readable * * @example * ```typescript * const registry = new ToolRegistry(); * const files = await autoDiscover(registry, './src/tools'); * console.log(`Discovered ${files.length} tool files`); * ``` */ export declare function autoDiscover(registry: ToolRegistryLike, dir: string, options?: AutoDiscoverOptions): Promise; export {}; //# sourceMappingURL=autoDiscover.d.ts.map