/**
 * Get an environment variable value, checking overrides first.
 *
 * Resolution order:
 * 1. Isolated overrides (temporary - set via withEnv/withEnvSync)
 * 2. Shared overrides (persistent - set via setEnv in beforeEach)
 * 3. process.env (including vi.stubEnv modifications)
 *
 * @internal Used by env getters to support test rewiring
 */
export declare function getEnvValue(key: string): string | undefined;
/**
 * Set an environment variable override for testing.
 * This does not modify process.env, only affects env getters.
 *
 * Works in test hooks (beforeEach) without needing AsyncLocalStorage context.
 * Vitest's module isolation ensures each test file has independent overrides.
 *
 * @example
 * ```typescript
 * import { setEnv, resetEnv } from './rewire'
 * import { getCI } from './ci'
 *
 * beforeEach(() => {
 *   setEnv('CI', '1')
 * })
 *
 * afterEach(() => {
 *   resetEnv()
 * })
 *
 * it('should detect CI environment', () => {
 *   expect(getCI()).toBe(true)
 * })
 * ```
 */
export declare function setEnv(key: string, value: string | undefined): void;
/**
 * Clear a specific environment variable override.
 */
export declare function clearEnv(key: string): void;
/**
 * Clear all environment variable overrides.
 * Useful in afterEach hooks to ensure clean test state.
 *
 * @example
 * ```typescript
 * import { resetEnv } from './rewire'
 *
 * afterEach(() => {
 *   resetEnv()
 * })
 * ```
 */
export declare function resetEnv(): void;
/**
 * Check if an environment variable has been overridden.
 */
export declare function hasOverride(key: string): boolean;
/**
 * Run code with environment overrides in an isolated AsyncLocalStorage context.
 * Creates true context isolation - overrides don't leak to concurrent code.
 *
 * Useful for tests that need temporary overrides without affecting other tests
 * or for nested override scenarios.
 *
 * @example
 * ```typescript
 * import { withEnv } from './rewire'
 * import { getCI } from './ci'
 *
 * // Temporary override in isolated context
 * await withEnv({ CI: '1' }, async () => {
 *   expect(getCI()).toBe(true)
 * })
 * expect(getCI()).toBe(false) // Override is gone
 * ```
 *
 * @example
 * ```typescript
 * // Nested overrides work correctly
 * setEnv('CI', '1') // Shared override (persistent)
 *
 * await withEnv({ CI: '0' }, async () => {
 *   expect(getCI()).toBe(false) // Isolated override takes precedence
 * })
 *
 * expect(getCI()).toBe(true) // Back to shared override
 * ```
 */
export declare function withEnv<T>(overrides: Record<string, string | undefined>, fn: () => T | Promise<T>): Promise<T>;
/**
 * Synchronous version of withEnv for non-async code.
 *
 * @example
 * ```typescript
 * import { withEnvSync } from './rewire'
 * import { getCI } from './ci'
 *
 * const result = withEnvSync({ CI: '1' }, () => {
 *   return getCI()
 * })
 * expect(result).toBe(true)
 * ```
 */
export declare function withEnvSync<T>(overrides: Record<string, string | undefined>, fn: () => T): T;
