/** * Environment-variable reference resolution for portable MCP configuration * values. This is a port of the Copilot runtime's `env_var_resolution` * primitive and must stay in sync with it. * * Supports: * - `$VAR`, `${VAR}`, and `${VAR:-default}` syntaxes * - ASCII-only identifier characters (`[A-Za-z_][A-Za-z0-9_]*`) * - A default ends at its matching `}`, tracking `${...}` and `$(...)` nesting * so neither ends it early. Only nesting and unquoted `\}` escapes carry * the scan past a `}`: quoting spans braces in bash, so honouring it here * would let an apostrophe in one default swallow the text and references * that follow it. Quoting is still tracked, to tell whether a `${`, `$(` * or `)` is structural. Syntax outside that set (a quoted `}`, comments, * backticks, heredocs) is not modelled: the default then ends at the * first `}`. * - When the variable is unset and no default is supplied, the reference * is left in place verbatim. A variable that is set to an empty string * resolves to that empty string, not to its default. * - A default is substituted literally and never expanded again, so any * references it contains reach the caller untouched * - Strings longer than {@link MAX_ENV_VAR_RESOLVE_LENGTH} UTF-16 code units * are returned unchanged, bounding the work any single value can cost * * VS Code variables with an argument, such as `${env:X}` or `${input:x}`, do * not match this grammar and are left untouched. */ /** * Maximum string length, in UTF-16 code units, for which environment-variable * expansion is attempted. Above this, the input is returned unchanged. */ export declare const MAX_ENV_VAR_RESOLVE_LENGTH = 1000; /** An environment, such as `process.env`. Entries whose value is `undefined` are treated as unset. */ export type EnvVarEnvironment = Readonly>; /** Restricts which references are resolved. By default, all references are resolved, as in the Copilot runtime. */ export interface IEnvVarResolverOptions { /** Whether bare `$VAR` references are resolved. Defaults to `true`. */ readonly bareReferences?: boolean; } /** * Creates a function that resolves environment-variable references in a * string against `env`. Use this when resolving several values against the * same environment. When `env` is `undefined`, values are returned unchanged. * * When `caseInsensitive` is `true`, variable names are matched without regard * to case. This mirrors Node.js's case-insensitive `process.env` lookups on * Windows, where e.g. `${PATH}` must resolve against a `Path` entry. */ export declare function createEnvVarResolver(env: EnvVarEnvironment | undefined, caseInsensitive: boolean, options?: IEnvVarResolverOptions): (value: string) => string; /** * Resolves environment-variable references in `value`. Returns `value` * unchanged if `env` is `undefined` or if the input exceeds * {@link MAX_ENV_VAR_RESOLVE_LENGTH}. */ export declare function resolveEnvVars(value: string, env: EnvVarEnvironment | undefined, caseInsensitive: boolean, options?: IEnvVarResolverOptions): string; /** * Reports whether `value` contains references the resolver recognises, * independent of any environment. Uses the same length cap and parser as * resolution. */ export declare function hasEnvVarReferences(value: string, options?: IEnvVarResolverOptions): boolean;