/** * @fileoverview Dialect detection — picks a dialect id for a connection from * the cached `CapabilityProfile` (server name / organization) plus an env * override (`BRAPI__DIALECT`). Pure functions; the async lookup that * pulls the profile lives in `index.ts → resolveDialect`. * * Supported override values match registered dialect ids: `spec`, * `brapi-test`, `breedbase`, `cassavabase`. * `auto` (or unset) triggers detection from the profile. * * @module services/brapi-dialect/detect */ import type { CapabilityProfile } from '../../services/capability-registry/types.js'; /** * Where the resolved dialect id came from. Surfaced in the orientation * envelope so agents (and operators reading logs) can tell whether the * dialect was pinned, inferred from `/serverinfo`, or fell through to the * spec passthrough. * * - `env-override` — the operator pinned `BRAPI__DIALECT`. * - `url-pattern` — matched on the registered base URL host. * - `server-name` — matched on `serverInfo.serverName`. * - `organization-name` — matched on `serverInfo.organizationName` (used when * the server name is generic but the host is a known SGN deployment). * - `fallback` — nothing matched; defaulted to the `spec` passthrough. */ export type DialectDetectionSource = 'env-override' | 'url-pattern' | 'server-name' | 'organization-name' | 'fallback'; export interface DialectDetection { id: string; source: DialectDetectionSource; } /** Compute the env-var name for an alias. `my-server` → `BRAPI_MY_SERVER_DIALECT`. */ export declare function dialectEnvVar(alias: string): string; /** * Read the per-alias dialect override. Returns `undefined` when unset, empty, * or `auto` (case-insensitive) — those all defer to detection. */ export declare function readDialectOverride(alias: string, env?: NodeJS.ProcessEnv): string | undefined; /** * Pattern-match a server name (or organization name) to a registered dialect * id. Falls back to `spec` when nothing matches. Match is case-insensitive * and substring-based — `CassavaBase` keeps its historical `cassavabase` * dialect id, while sister SGN / Breedbase deployments resolve to the broader * `breedbase` dialect. * * Returns both the matched id and which field triggered the match so callers * can surface that provenance to the agent. */ export declare function detectDialectFromName(name: string | undefined, organizationName?: string | undefined): DialectDetection; /** * Pattern-match a registered base URL to a dialect. This catches SGN-family * deployments with generic or sparse `/serverinfo` identity fields. */ export declare function detectDialectFromBaseUrl(baseUrl: string | undefined): DialectDetection; /** * End-to-end detection: env override beats profile inference. Returns the * resolved dialect id and the source that produced it. Callers that only * need the id can read `.id`; the orientation envelope reads both. */ export declare function detectDialectId(alias: string, profile: CapabilityProfile | undefined, env?: NodeJS.ProcessEnv): DialectDetection; //# sourceMappingURL=detect.d.ts.map