/** * register-tools-discovery — installed + authored tool admission and discovery. * * Extracted from register-tools.ts so the bundled registration path stays a * focused module under the file-length soft limit. */ import { type BootstrapDiagnosticsCollector, type ToolPluginManifest, type ToolProvenance, type ToolRegistry, type ToolDiscoverySource } from '@opensip-cli/core'; import { type ToolRuntimeLoad } from './admit-tool-package.js'; import { type PolicyAuditCollector } from './policy-audit.js'; import { type ToolTrustReason } from './tool-trust.js'; import type { ToolRuntimeExecutionMode } from './worker-datastore.js'; import type { ResolvedTrustPolicy } from '@opensip-cli/config'; /** * Emit the best-effort stderr line + structured warning for a discovered * INSTALLED tool whose runtime failed to load. Each failure reason maps to its * own diagnostic while preserving the installed leg's skip-not-crash posture. */ /** Record + structured log when an installed tool is skipped by the trust gate. */ export declare function emitInstalledTrustDenied(toolId: string, packageName: string, packageDir: string, reason?: ToolTrustReason, collector?: BootstrapDiagnosticsCollector): void; export declare function emitInstalledLoadFailure(name: string, load: Extract, collector?: BootstrapDiagnosticsCollector): void; export interface DiscoveryOptions { /** * Ordered tool-discovery sources (precedence: first wins on duplicate * name). Built by {@link buildToolDiscoverySources} at the composition * root; passed in here so this function reads no ambient HOME/cwd state * and stays unit-testable with explicit anchors. */ readonly sources: readonly ToolDiscoverySource[]; /** Injectable env for installed-tool trust (bootstrap-time; defaults to `process.env`). */ readonly env?: NodeJS.ProcessEnv; /** Project root for project-local managed-install trust checks. */ readonly projectRoot?: string; /** Tool ids from project config `tools.trusted`. */ readonly projectTrustedTools?: ReadonlySet; readonly trustPolicy?: ResolvedTrustPolicy; readonly policyAudit?: PolicyAuditCollector; /** Optional bootstrap diagnostics sink (defaults to the process-wide buffer). */ readonly bootstrapDiagnostics?: BootstrapDiagnosticsCollector; /** Prevalidated startup posture; never derive import authority from env alone. */ readonly runtimeMode: ToolRuntimeExecutionMode; } /** * Build the ordered tool-discovery sources. Order is precedence * (first-occurrence-wins on duplicate name): * * 1. project-local `.runtime/plugins/tool` — `plugin add --project` * 2. project tree (walk up from cwd) — plain `npm install @tool` * 3. user-global `~/.opensip-cli/plugins/tool` — `plugin add` (default) * 4. CLI install dir (walk up) — `npm i -g @tool` * * A project-local pin therefore shadows a user-global install of the same * tool. Project-root resolution is best-effort: an unresolvable context * (e.g. running outside any project) simply contributes no `.runtime` * source. */ export declare function buildToolDiscoverySources(cwd: string, cliInstallDir: string): ToolDiscoverySource[]; export declare function discoverAndRegisterToolPackages(registry: ToolRegistry, opts: DiscoveryOptions, builtInIds: ReadonlySet, provenance?: ToolProvenance[], manifests?: ToolPluginManifest[]): Promise; //# sourceMappingURL=register-tools-discovery.d.ts.map