import * as _playwright_test from '@playwright/test';
export { expect } from '@playwright/test';
import { VariableStore } from './VariableStore.js';
import { WebAgent } from './agent/webAgent.js';
import { ShiplightUseOptions } from './index.js';
import './core/agentContext.js';
import './config.js';

/**
 * Per-test auth: path to a login script + optional args passed to the login function.
 * The auth path is resolved relative to process.cwd() (the project root where `playwright test` runs).
 * The login module must export a login(args) function that spawns its own browser,
 * performs the login flow, caches the storageState, and returns the file path.
 *
 * Usage in playwright.config.ts:
 *   use: {
 *     auth: './auth.login.ts',
 *     args: { username: 'admin@example.com', password: '{{ADMIN_PASSWORD}}' },
 *   }
 */
interface AuthSpec {
    auth: string;
    args?: Record<string, unknown>;
}
/**
 * Calls the auth module's login(args) function.
 * The login function is responsible for spawning its own browser/context,
 * performing the login flow, caching/expiring storageState, and returning
 * the path to a storageState JSON file.
 *
 * The module is cached by Node's module system after the first import,
 * so multiple tests sharing the same auth path reuse the same instance.
 */
declare function resolveAuthState(spec: AuthSpec): Promise<string>;
/**
 * Standard Playwright context-option `use:` keys whose resolved (per-test aware)
 * values we overlay onto `testInfo.project.use`. Must stay identical to the
 * fixture-arg destructure and the `resolvedContextOptions` object in the
 * `context` fixture below — the drift guard test
 * (fixture.contextOptions.test.ts) asserts this set, together with
 * EXCLUDED_CONTEXT_OPTION_KEYS, equals the full set Playwright actually resolves.
 */
declare const HANDLED_CONTEXT_OPTION_KEYS: readonly ["acceptDownloads", "baseURL", "bypassCSP", "colorScheme", "deviceScaleFactor", "extraHTTPHeaders", "geolocation", "hasTouch", "httpCredentials", "ignoreHTTPSErrors", "isMobile", "javaScriptEnabled", "locale", "offline", "permissions", "proxy", "serviceWorkers", "timezoneId", "userAgent", "viewport"];
/**
 * Context-option keys Playwright resolves that we deliberately do NOT overlay:
 * - `storageState`: the fixture's auth system owns it (see resolveAuthState).
 * - `contextOptions`: raw escape-hatch object, left to flow through unchanged.
 * - `clientCertificates`: specially resolved by Playwright; left untouched.
 */
declare const EXCLUDED_CONTEXT_OPTION_KEYS: readonly ["storageState", "contextOptions", "clientCertificates"];
/**
 * Context options Playwright rejects when `viewport` is `null` (no fixed
 * viewport / `noDefaultViewport`). Each entry's `conflicts` predicate mirrors
 * the exact condition in Playwright's `validateBrowserContextOptions`:
 *   - `deviceScaleFactor`: throws when `!== void 0` (any defined value).
 *   - `isMobile`: throws when `!!isMobile` (any truthy value).
 * The drift guard test asserts these keys stay in sync with that function, so a
 * future Playwright that adds a new `viewport: null` conflict fails loudly
 * instead of crashing context creation unguarded.
 */
declare const VIEWPORT_INCOMPATIBLE_OPTIONS: ReadonlyArray<{
    key: string;
    conflicts: (value: unknown) => boolean;
}>;
/**
 * Resolve the `viewport: null` ⇄ emulation conflict that Playwright rejects.
 *
 * An explicit `viewport: null` (no fixed viewport, for responsive testing) is
 * incompatible with `deviceScaleFactor` / `isMobile: true` — `browser.newContext`
 * and `launchPersistentContext` THROW on the combination. `viewport: null` is the
 * more specific, intentional per-test signal, so we honor it and drop the
 * incompatible emulation options (e.g. a project sets `deviceScaleFactor: 2`
 * globally and a single test wants a responsive `viewport: null`).
 *
 * Mutates `options` in place; returns the names of the keys that were dropped
 * (so the caller can warn). A no-op unless `options.viewport === null`.
 */
declare function dropViewportIncompatibleOptions(options: Record<string, unknown>): string[];
/**
 * Merge the project-level `use: { ... }` with the per-test context options
 * Playwright resolved for THIS test.
 *
 * Why this is needed: the Shiplight `context` fixture overrides Playwright's
 * built-in `context` fixture and builds context options from
 * `testInfo.project.use`. That object only carries the PROJECT-level `use:`
 * block — it does NOT contain a per-test `test.use({ ... })` (which is exactly
 * what the transpiled YAML `use:` block emits). When the project sets a context
 * option (e.g. `viewport: 1280x720`), it pre-seeds that key, and Playwright's
 * fill-missing merge (`runBeforeCreateBrowserContext`, which only fills keys NOT
 * already present) can then never apply the per-test value. Options the project
 * did NOT set got filled from the per-test values, so they appeared to work —
 * only project-set keys (viewport, in the typical config) were silently dropped.
 *
 * `resolved` holds the values of Playwright's standard context-option fixtures
 * (viewport, colorScheme, locale, isMobile, ...). Those honor the full override
 * chain (file-level test.use() > project use: > defaults), so applying them over
 * the project use restores the documented precedence for every context option.
 * Keys resolved to `undefined` are skipped so we never inject options the test
 * never asked for.
 *
 * Finally, `dropViewportIncompatibleOptions` resolves the `viewport: null` ⇄
 * emulation conflict that Playwright would otherwise throw on.
 */
declare function mergeResolvedContextOptions(projectUse: Record<string, unknown>, resolved: Record<string, unknown>): Record<string, unknown>;
/**
 * TestContext — Proxy-backed object for reading/writing runtime variables.
 * Supports property-style access: testContext.myVar = 'value' / const v = testContext.myVar
 * Shared with the agent's VariableStore so $variableName in YAML resolves the same values.
 */
interface TestContext {
    /** @internal Shared VariableStore instance — used by the agent fixture */
    readonly __variableStore: VariableStore;
    get(key: string): any;
    set(key: string, value: any, sensitive?: boolean): void;
    getAll(): Record<string, any>;
    [key: string]: any;
}
declare function createTestContext(variableStore: VariableStore): TestContext;
/**
 * Parse the `SHIPLIGHT_VARS_OVERRIDE` env var.
 * Returns null when unset, throws on invalid JSON or non-string values.
 */
declare function parseVarsOverrideEnv(raw: string | undefined): Record<string, string> | null;
/**
 * Check whether a key was declared `sensitive: true` in the resolved
 * `use.variables` declarations. Test-level overrides project-level.
 */
declare function isDeclaredSensitive(key: string, projectVariables: ShiplightUseOptions['variables'], testVariables: ShiplightUseOptions['variables']): boolean;
/**
 * Apply CLI / env overrides (`SHIPLIGHT_VARS_OVERRIDE`) to the variable store
 * with highest priority. Sensitivity is inherited from whichever declaration
 * the key already has in project/test `use.variables`; undeclared keys are
 * stored as non-sensitive.
 *
 * Exported for testing.
 */
declare function applyVarsOverride(variableStore: VariableStore, projectVariables: ShiplightUseOptions['variables'], testVariables: ShiplightUseOptions['variables'], envVar?: string | undefined): void;
/**
 * Explicit allowlist of environment variable names that Shiplight forwards
 * into sdk-core's internal `SdkConfig.env`. sdk-core is strict — it reads
 * env vars only from `SdkConfig.env`, never from `process.env` directly —
 * so this allowlist is the single point where user-visible env state
 * crosses into the agent runtime.
 *
 * Source is `.env`, not `process.env`. Reads go through
 * `getShiplightEnv()` (see `dotenvSource.ts`) so that a stale shell-level
 * `OPENAI_API_KEY` (or any other provider key) cannot silently override
 * the user's `.env` and bypass the Shiplight LLM proxy. CI runners that
 * inject secrets via env vars instead of a `.env` file are still supported
 * via the fallback in `getShiplightEnv()`.
 *
 * To add a new env var that sdk-core should honor, append it here AND make
 * sure a corresponding consumer exists in `packages/sdk-core/src`. Do NOT
 * spread `process.env` into this object — the allowlist exists so that user
 * test code cannot exfiltrate arbitrary shell state through the SDK.
 *
 * **Not on this list: `WEB_AGENT_MODEL` / `COMPUTER_USE_MODEL`.** Those are
 * read by `resolveWebAgentModelFromEnv` / `resolveComputerUseModelFromEnv`
 * from `shiplight-types`, called with `getShiplightEnv()` in the agent
 * fixture below. The resolved model string is passed as a constructor
 * parameter to `createAgentContext`, not through `SdkConfig.env`. They do
 * not need to be on the allowlist.
 *
 * Keep in sync with the "Environment variables" section of the public
 * documentation at `docs.shiplight.ai/local/cli-reference`.
 */
declare const SDK_ENV_ALLOWLIST: readonly ["GOOGLE_API_KEY", "ANTHROPIC_API_KEY", "OPENAI_API_KEY", "OPENAI_BASE_URL", "ANTHROPIC_MODELS_USE_VERTEXAI", "GOOGLE_GENAI_USE_VERTEXAI", "GOOGLE_CLOUD_PROJECT", "GOOGLE_CLOUD_LOCATION", "MAILGUN_API_KEY", "MAILGUN_DOMAIN", "SHIPLIGHT_API_TOKEN", "SHIPLIGHT_API_URL"];
/**
 * Pick the allowlisted env vars out of a source record (defaults to the
 * Shiplight `.env` stash via `getShiplightEnv()`) and return them as a
 * plain object with empty-string fallbacks. The empty-string default is
 * deliberate — sdk-core checks `config.env?.KEY` for truthiness, and an
 * empty string is falsy, so an unset allowlisted key behaves the same as
 * an entirely missing key.
 */
declare function buildSdkEnv(source?: Record<string, string | undefined>): Record<string, string>;
type ShiplightFixtures = {
    agent: WebAgent;
    testContext: TestContext;
    $: TestContext;
    ctx: TestContext;
    account: AuthSpec | undefined;
    extensionDir: string | undefined;
    userDataDir: string | undefined;
    extensionStorageState: string | undefined;
    autoDismissModal: boolean;
    variables: ShiplightUseOptions['variables'];
};
declare const test: _playwright_test.TestType<_playwright_test.PlaywrightTestArgs & _playwright_test.PlaywrightTestOptions & ShiplightFixtures, _playwright_test.PlaywrightWorkerArgs & _playwright_test.PlaywrightWorkerOptions>;

export { type AuthSpec, EXCLUDED_CONTEXT_OPTION_KEYS, HANDLED_CONTEXT_OPTION_KEYS, SDK_ENV_ALLOWLIST, type TestContext, VIEWPORT_INCOMPATIBLE_OPTIONS, applyVarsOverride, buildSdkEnv, createTestContext, dropViewportIncompatibleOptions, isDeclaredSensitive, mergeResolvedContextOptions, parseVarsOverrideEnv, resolveAuthState, test };
