/** * @license * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ /** Describes the optional peer dependency a feature is asking for. */ export interface OptionalPeer { /** The npm package name, e.g. `@google-cloud/storage`. */ packageName: string; /** The ADK feature that needs it, used in the error message. */ feature: string; } /** * Loads an optional peer dependency, translating "not installed" into an * actionable error. * * The dynamic `import()` is passed in as a thunk rather than being built from * `packageName`, so that the specifier stays a literal in the calling module * and remains visible to bundlers and to test doubles installed with * `vi.mock()`. * * ```ts * const {Storage} = await loadOptionalPeer( * {packageName: '@google-cloud/storage', feature: 'GcsArtifactService'}, * () => import('@google-cloud/storage'), * ); * ``` * * @param peer The package being loaded and the feature that needs it. * @param load Thunk performing the dynamic `import()`. * @return The imported module namespace. * @throws If the package is not installed, an error naming the feature and * the `npm install` command that fixes it. Any other load failure is * rethrown unchanged. */ export declare function loadOptionalPeer(peer: OptionalPeer, load: () => Promise): Promise;