/** * Module Path Resolver * Shared utility for resolving module-relative paths in both ESM and CJS builds * Used by knowledge pack loader and policy discovery */ import type { Logger } from 'pino'; export interface ModulePathResolverOptions { /** Relative path from package root (e.g., 'policies', 'knowledge/packs') */ relativePath: string; /** Logger instance for debug/info messages */ logger: Logger; /** Module URL captured at module scope (import.meta.url) */ moduleUrl?: string; } /** * Resolve module-relative paths using a chain of strategies * * This function attempts multiple strategies to find the correct path to a * resource directory (like 'policies' or 'knowledge/packs') that ships with * the package. * * Search priority: * 1. Relative to the installed module location (CJS __dirname) * 2. Relative to the installed module location (ESM import.meta.url) * 3. Heuristic based on process.argv[1] (CLI entrypoint with symlink resolution) * 4. Walk upward from process.cwd() (dev / repo root) * * Works in all deployment scenarios: * - Local development (ts-node / tsx / node from repo root) * - Installed globally via npm and run via CLI * - Used as a dependency inside another project * - Executed through npm bin symlinks * * @returns Array of search paths in priority order */ export declare function resolveModulePaths(options: ModulePathResolverOptions): string[]; /** * Find the first existing directory from a list of search paths * * @param searchPaths - Array of paths to check * @param logger - Optional logger for debugging * @returns The first path that exists as a directory, or undefined */ export declare function findExistingDirectory(searchPaths: string[], logger?: Logger): string | undefined; //# sourceMappingURL=module-path-resolver.d.ts.map