/** * kosha-discovery — Google Vertex AI provider discoverer. * * Resolution strategy (in order): * 1. REST API with Application Default Credentials (ADC) * 2. gcloud CLI fallback (`gcloud ai models list`) * 3. Static fallback list of known Vertex AI models * * Credentials: Uses the Google ADC chain — * ~/.config/gcloud/application_default_credentials.json, * GOOGLE_APPLICATION_CREDENTIALS env var, or the GCP metadata server. * @module */ import type { CredentialResult, ModelCard } from "../types.js"; import { BaseDiscoverer } from "./base.js"; /** * Discovers models available through Google Vertex AI. * * Works without an explicit API key: access tokens are resolved via the * standard ADC chain, so it behaves correctly in local dev environments * (after `gcloud auth application-default login`) and on GCP VMs (metadata * server). When the REST API is unavailable it falls back to the gcloud CLI, * and when that is missing it returns a curated static list so callers always * receive useful results. */ export declare class VertexDiscoverer extends BaseDiscoverer { readonly providerId = "vertex"; readonly providerName = "Google Vertex AI"; /** Template string — region is substituted per-request. */ readonly baseUrl = "https://{region}-aiplatform.googleapis.com"; /** * Discover models from Vertex AI using a three-tier fallback strategy: * 1. Vertex AI REST API (requires an ADC access token + project ID) * 2. `gcloud ai models list` CLI * 3. Curated static list * * @param credential - Credential bag; `accessToken` is used when present. * `metadata.projectId` and `metadata.region` take precedence over env vars. * @param options - Optional timeout in ms (default 10 000). */ discover(credential: CredentialResult, options?: { timeout?: number; }): Promise; /** * Fetch models from the Vertex AI Publisher Models REST endpoint. * * URL: `https://{region}-aiplatform.googleapis.com/v1/projects/{project}/ * locations/{region}/publishers/google/models` * * @param credential - Used to obtain a Bearer token via {@link getAccessToken}. * @param projectId - GCP project ID (required for the REST path). * @param region - GCP region (e.g. "us-central1"). * @param options - Optional timeout override. */ private discoverViaApi; /** * Resolve a Google OAuth2 access token using the ADC chain: * 1. `credential.accessToken` — already resolved upstream * 2. ADC JSON file containing `access_token` (service account / workload identity) * 3. ADC JSON file with `refresh_token` — exchange via Google OAuth endpoint * 4. `gcloud auth print-access-token` CLI fallback * * Returns `undefined` when no token can be obtained. * * @param credential - The credential bag from the discovery pipeline. */ getAccessToken(credential: CredentialResult): Promise; /** * Exchange a refresh token for a short-lived access token via Google OAuth2. * * @param clientId - OAuth2 client ID from the ADC file. * @param clientSecret - OAuth2 client secret from the ADC file. * @param refreshToken - Refresh token from the ADC file. */ private exchangeRefreshToken; /** * Obtain an access token by calling `gcloud auth print-access-token`. * Returns `undefined` when the CLI is not installed or the command fails. */ private tokenFromGcloudCli; /** * Discover models by executing `gcloud ai models list` and parsing JSON output. * * @param projectId - GCP project ID passed as `--project`. * @param region - GCP region passed as `--region`. */ private discoverViaCli; /** * Resolve a GCP project ID from the active `gcloud` configuration. * Returns `undefined` when the CLI is unavailable or unconfigured. */ private resolveProjectFromCli; /** * Return a curated list of well-known Vertex AI models (Feb 2026). * * Used when neither the REST API nor the gcloud CLI is accessible. * All entries carry `source: "manual"` so consumers can distinguish them * from live API data. * * @param region - Propagated to each card's `region` field. * @param projectId - Propagated to each card's `projectId` field (may be undefined). */ private staticFallback; /** * Convert a Vertex AI REST API model object to a {@link ModelCard}. * * The `name` field is a full resource path such as * `publishers/google/models/gemini-2.5-pro`; the prefix is stripped to * obtain the bare model ID used in API calls. * * @param model - Raw Vertex API model entry. * @param region - Region the model was fetched from. * @param projectId - GCP project ID. */ private toModelCard; /** * Convert a `gcloud ai models list` JSON entry to a {@link ModelCard}. * * gcloud returns full resource names such as * `projects/{p}/locations/{r}/models/{id}` — we take only the last segment. * * @param model - Raw gcloud JSON model entry. * @param region - Region used for the gcloud query. * @param projectId - GCP project ID. */ private gcloudModelToCard; /** * Determine the primary {@link ModelMode} from a model ID and its * supported actions list. * * @param id - Bare model ID. * @param actions - `supportedActions` array from the API response. */ private inferMode; /** * Infer capability flags from a model ID and its supported actions. * * Gemini pro/flash/ultra variants receive vision + function_calling because * all modern Gemini editions support multimodal input and tool use. * * @param id - Bare model ID. * @param actions - `supportedActions` from the API response. */ private inferCapabilities; } //# sourceMappingURL=vertex.d.ts.map