"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NavigateResultSchema = exports.NavigateRequestSchema = exports.NavigateOptionsSchema = exports.AgentExecuteResponseSchema = exports.AgentExecuteResultSchema = exports.AgentExecuteRequestSchema = exports.AgentExecuteOptionsSchema = exports.AgentCacheEntrySchema = exports.AgentResultDataSchema = exports.AgentUsageSchema = exports.AgentActionSchema = exports.AgentConfigSchema = exports.ObserveResponseSchema = exports.ObserveResultSchema = exports.ObserveRequestSchema = exports.ObserveOptionsSchema = exports.ExtractResponseSchema = exports.ExtractResultSchema = exports.ExtractRequestSchema = exports.ExtractOptionsSchema = exports.ActResponseSchema = exports.ActResultSchema = exports.ActResultDataSchema = exports.ActRequestSchema = exports.ActOptionsSchema = exports.SessionEndResponseSchema = exports.SessionEndResultSchema = exports.SessionEndRequestSchema = exports.SessionStartResponseSchema = exports.SessionStartResultSchema = exports.SessionStartRequestSchema = exports.BrowserbaseSessionCreateParamsSchema = exports.BrowserbaseRegionSchema = exports.ProxyConfigSchema = exports.ExternalProxyConfigSchema = exports.BrowserbaseProxyConfigSchema = exports.BrowserbaseProxyGeolocationSchema = exports.BrowserbaseBrowserSettingsSchema = exports.BrowserbaseContextSchema = exports.BrowserbaseFingerprintSchema = exports.BrowserbaseFingerprintScreenSchema = exports.BrowserbaseViewportSchema = exports.ErrorResponseSchema = exports.SessionHeadersSchema = exports.BrowserConfigSchema = exports.SessionIdParamsSchema = exports.ActionSchema = exports.ModelConfigSchema = exports.ModelConfigObjectSchema = exports.LocalBrowserLaunchOptionsSchema = void 0;
exports.Operations = exports.openApiLinks = exports.openApiSecuritySchemes = exports.StreamEventSchema = exports.StreamEventLogDataSchema = exports.StreamEventSystemDataSchema = exports.StreamEventTypeSchema = exports.StreamEventStatusSchema = exports.ReplayResponseSchema = exports.ReplayResultSchema = exports.ReplayPageSchema = exports.ReplayActionSchema = exports.TokenUsageSchema = exports.NavigateResponseSchema = void 0;
/**
 * Centralized Zod schemas for Stagehand Server API
 *
 * Naming conventions:
 * - `*RequestSchema` - Request body schemas (zod4), `*Request` is the inferred type
 * - `*ResultSchema` - Inner response data (unwrapped), `*Result` is the inferred type
 * - `*ResponseSchema` - Full response with success wrapper: { success: true, data: *Result }, `*Response` is the inferred type
 *
 * All TypeScript types are inferred from the Zod4 *Schemas using z.infer<>
 */
const v4_1 = require("zod/v4");
// =============================================================================
// Shared Components
// =============================================================================
/** Browser launch options for local browsers */
exports.LocalBrowserLaunchOptionsSchema = v4_1.z
    .object({
    args: v4_1.z.array(v4_1.z.string()).optional(),
    executablePath: v4_1.z.string().optional(),
    port: v4_1.z.number().optional(),
    userDataDir: v4_1.z.string().optional(),
    preserveUserDataDir: v4_1.z.boolean().optional(),
    headless: v4_1.z.boolean().optional(),
    devtools: v4_1.z.boolean().optional(),
    chromiumSandbox: v4_1.z.boolean().optional(),
    ignoreDefaultArgs: v4_1.z.union([v4_1.z.boolean(), v4_1.z.array(v4_1.z.string())]).optional(),
    proxy: v4_1.z
        .object({
        server: v4_1.z.string(),
        bypass: v4_1.z.string().optional(),
        username: v4_1.z.string().optional(),
        password: v4_1.z.string().optional(),
    })
        .optional(),
    locale: v4_1.z.string().optional(),
    viewport: v4_1.z.object({ width: v4_1.z.number(), height: v4_1.z.number() }).optional(),
    deviceScaleFactor: v4_1.z.number().optional(),
    hasTouch: v4_1.z.boolean().optional(),
    ignoreHTTPSErrors: v4_1.z.boolean().optional(),
    cdpUrl: v4_1.z.string().optional(),
    connectTimeoutMs: v4_1.z.number().optional(),
    downloadsPath: v4_1.z.string().optional(),
    acceptDownloads: v4_1.z.boolean().optional(),
})
    .strict()
    .meta({ id: "LocalBrowserLaunchOptions" });
/** Detailed model configuration object */
exports.ModelConfigObjectSchema = v4_1.z
    .object({
    provider: v4_1.z
        .enum(["openai", "anthropic", "google", "microsoft"])
        .optional()
        .meta({
        description: "AI provider for the model (or provide a baseURL endpoint instead)",
        example: "openai",
    }),
    modelName: v4_1.z.string().meta({
        description: "Model name string with provider prefix (e.g., 'openai/gpt-5-nano')",
        example: "openai/gpt-5-nano",
    }),
    apiKey: v4_1.z.string().optional().meta({
        description: "API key for the model provider",
        example: "sk-some-openai-api-key",
    }),
    baseURL: v4_1.z.string().url().optional().meta({
        description: "Base URL for the model provider",
        example: "https://api.openai.com/v1",
    }),
})
    .meta({ id: "ModelConfigObject" });
/** Model configuration */
exports.ModelConfigSchema = exports.ModelConfigObjectSchema.meta({
    id: "ModelConfig",
});
/** Action object returned by observe and used by act */
exports.ActionSchema = v4_1.z
    .object({
    selector: v4_1.z.string().meta({
        description: "CSS selector or XPath for the element",
        example: "[data-testid='submit-button']",
    }),
    description: v4_1.z.string().meta({
        description: "Human-readable description of the action",
        example: "Click the submit button",
    }),
    backendNodeId: v4_1.z.number().optional().meta({
        description: "Backend node ID for the element",
    }),
    method: v4_1.z.string().optional().meta({
        description: "The method to execute (click, fill, etc.)",
        example: "click",
    }),
    arguments: v4_1.z
        .array(v4_1.z.string())
        .optional()
        .meta({
        description: "Arguments to pass to the method",
        example: ["Hello World"],
    }),
})
    .meta({
    id: "Action",
    description: "Action object returned by observe and used by act",
});
/** Session ID path parameter */
exports.SessionIdParamsSchema = v4_1.z
    .object({
    id: v4_1.z.string().meta({
        description: "Unique session identifier",
        example: "c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
    }),
})
    .strict()
    .meta({ id: "SessionIdParams" });
/** Browser configuration for session start */
exports.BrowserConfigSchema = v4_1.z
    .object({
    type: v4_1.z.enum(["local", "browserbase"]).optional().meta({
        description: "Browser type to use",
        example: "local",
    }),
    cdpUrl: v4_1.z.string().optional().meta({
        description: "Chrome DevTools Protocol URL for connecting to existing browser",
        example: "ws://localhost:9222",
    }),
    launchOptions: exports.LocalBrowserLaunchOptionsSchema.optional(),
})
    .meta({ id: "BrowserConfig" });
// =============================================================================
// Request Headers (operational only - auth headers are in security schemes)
// =============================================================================
/** Operational headers for all session requests (auth handled via security schemes) */
exports.SessionHeadersSchema = v4_1.z
    .object({
    "x-stream-response": v4_1.z.enum(["true", "false"]).optional().meta({
        description: "Whether to stream the response via SSE",
        example: "true",
    }),
})
    .meta({ id: "SessionHeaders" });
// =============================================================================
// Response Wrapper Helper
// =============================================================================
/** Wraps a result schema in standard success response format */
const wrapResponse = (resultSchema, name) => v4_1.z
    .object({
    success: v4_1.z.boolean().meta({
        description: "Indicates whether the request was successful",
    }),
    data: resultSchema,
})
    .meta({ id: name });
/** Standard error response */
exports.ErrorResponseSchema = v4_1.z
    .object({
    success: v4_1.z.literal(false),
    error: v4_1.z.string(),
    code: v4_1.z.string().optional(),
})
    .strict()
    .meta({ id: "ErrorResponse" });
// =============================================================================
// Browserbase Session Create Params  (zod+hints duplicated version of Browserbase.Sessions.SessionCreateParams)
// =============================================================================
/** Browserbase viewport configuration */
exports.BrowserbaseViewportSchema = v4_1.z
    .object({
    width: v4_1.z.number().optional(),
    height: v4_1.z.number().optional(),
})
    .meta({ id: "BrowserbaseViewport" });
/** Browserbase fingerprint screen configuration */
exports.BrowserbaseFingerprintScreenSchema = v4_1.z
    .object({
    maxHeight: v4_1.z.number().optional(),
    maxWidth: v4_1.z.number().optional(),
    minHeight: v4_1.z.number().optional(),
    minWidth: v4_1.z.number().optional(),
})
    .meta({ id: "BrowserbaseFingerprintScreen" });
/** Browserbase fingerprint configuration for stealth mode */
exports.BrowserbaseFingerprintSchema = v4_1.z
    .object({
    browsers: v4_1.z
        .array(v4_1.z.enum(["chrome", "edge", "firefox", "safari"]))
        .optional(),
    devices: v4_1.z.array(v4_1.z.enum(["desktop", "mobile"])).optional(),
    httpVersion: v4_1.z.enum(["1", "2"]).optional(),
    locales: v4_1.z.array(v4_1.z.string()).optional(),
    operatingSystems: v4_1.z
        .array(v4_1.z.enum(["android", "ios", "linux", "macos", "windows"]))
        .optional(),
    screen: exports.BrowserbaseFingerprintScreenSchema.optional(),
})
    .meta({ id: "BrowserbaseFingerprint" });
/** Browserbase context configuration for session persistence */
exports.BrowserbaseContextSchema = v4_1.z
    .object({
    id: v4_1.z.string(),
    persist: v4_1.z.boolean().optional(),
})
    .meta({ id: "BrowserbaseContext" });
/** Browserbase browser settings for session creation */
exports.BrowserbaseBrowserSettingsSchema = v4_1.z
    .object({
    advancedStealth: v4_1.z.boolean().optional(),
    blockAds: v4_1.z.boolean().optional(),
    context: exports.BrowserbaseContextSchema.optional(),
    extensionId: v4_1.z.string().optional(),
    fingerprint: exports.BrowserbaseFingerprintSchema.optional(),
    logSession: v4_1.z.boolean().optional(),
    recordSession: v4_1.z.boolean().optional(),
    solveCaptchas: v4_1.z.boolean().optional(),
    viewport: exports.BrowserbaseViewportSchema.optional(),
})
    .meta({ id: "BrowserbaseBrowserSettings" });
/** Browserbase managed proxy geolocation configuration */
exports.BrowserbaseProxyGeolocationSchema = v4_1.z
    .object({
    country: v4_1.z.string(),
    city: v4_1.z.string().optional(),
    state: v4_1.z.string().optional(),
})
    .meta({ id: "BrowserbaseProxyGeolocation" });
/** Browserbase managed proxy configuration */
exports.BrowserbaseProxyConfigSchema = v4_1.z
    .object({
    type: v4_1.z.literal("browserbase"),
    domainPattern: v4_1.z.string().optional(),
    geolocation: exports.BrowserbaseProxyGeolocationSchema.optional(),
})
    .meta({ id: "BrowserbaseProxyConfig" });
/** External proxy configuration */
exports.ExternalProxyConfigSchema = v4_1.z
    .object({
    type: v4_1.z.literal("external"),
    server: v4_1.z.string(),
    domainPattern: v4_1.z.string().optional(),
    username: v4_1.z.string().optional(),
    password: v4_1.z.string().optional(),
})
    .meta({ id: "ExternalProxyConfig" });
/** Union of proxy configuration types */
exports.ProxyConfigSchema = v4_1.z
    .discriminatedUnion("type", [
    exports.BrowserbaseProxyConfigSchema,
    exports.ExternalProxyConfigSchema,
])
    .meta({ id: "ProxyConfig" });
/** Browserbase region identifier for multi-region support */
exports.BrowserbaseRegionSchema = v4_1.z
    .enum(["us-west-2", "us-east-1", "eu-central-1", "ap-southeast-1"])
    .meta({ id: "BrowserbaseRegion" });
/** Browserbase session creation parameters */
exports.BrowserbaseSessionCreateParamsSchema = v4_1.z
    .object({
    projectId: v4_1.z.string().optional(),
    browserSettings: exports.BrowserbaseBrowserSettingsSchema.optional(),
    extensionId: v4_1.z.string().optional(),
    keepAlive: v4_1.z.boolean().optional(),
    proxies: v4_1.z.union([v4_1.z.boolean(), v4_1.z.array(exports.ProxyConfigSchema)]).optional(),
    region: exports.BrowserbaseRegionSchema.optional(),
    timeout: v4_1.z.number().optional(),
    userMetadata: v4_1.z.record(v4_1.z.string(), v4_1.z.unknown()).optional(),
})
    .meta({ id: "BrowserbaseSessionCreateParams" });
// =============================================================================
// Session Start
// =============================================================================
exports.SessionStartRequestSchema = v4_1.z
    .object({
    modelName: v4_1.z.string().meta({
        description: "Model name to use for AI operations",
        example: "openai/gpt-4o",
    }),
    domSettleTimeoutMs: v4_1.z.number().optional().meta({
        description: "Timeout in ms to wait for DOM to settle",
        example: 5000,
    }),
    verbose: v4_1.z
        .union([v4_1.z.literal(0), v4_1.z.literal(1), v4_1.z.literal(2)])
        .optional()
        .meta({
        description: "Logging verbosity level (0=quiet, 1=normal, 2=debug)",
        example: 1,
        override: ({ jsonSchema }) => {
            delete jsonSchema.anyOf;
            delete jsonSchema.allOf;
            delete jsonSchema.oneOf;
            jsonSchema.type = "number";
            jsonSchema.enum = [0, 1, 2];
        },
    }),
    systemPrompt: v4_1.z.string().optional().meta({
        description: "Custom system prompt for AI operations",
    }),
    browserbaseSessionCreateParams: exports.BrowserbaseSessionCreateParamsSchema.optional(),
    browser: exports.BrowserConfigSchema.optional(),
    selfHeal: v4_1.z.boolean().optional().meta({
        description: "Enable self-healing for failed actions",
        example: true,
    }),
    browserbaseSessionID: v4_1.z.string().optional().meta({
        description: "Existing Browserbase session ID to resume",
    }),
    // experimental is a V3 field but doesn't need to go over the wire - included because wire type imports options type
    experimental: v4_1.z.boolean().optional(),
    // V2 compatibility fields - only included because the server imports this type and supports V2
    // should never be used in v3 clients or v3-only server implementations
    waitForCaptchaSolves: v4_1.z.boolean().optional().meta({
        description: "Wait for captcha solves (deprecated, v2 only)",
    }),
    actTimeoutMs: v4_1.z.number().optional().meta({
        description: "Timeout in ms for act operations (deprecated, v2 only)",
    }),
})
    .meta({ id: "SessionStartRequest" });
exports.SessionStartResultSchema = v4_1.z
    .object({
    sessionId: v4_1.z.string().meta({
        description: "Unique Browserbase session identifier",
        example: "c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
    }),
    cdpUrl: v4_1.z.string().nullish().meta({
        description: "CDP WebSocket URL for connecting to the Browserbase cloud browser (present when available)",
        example: "wss://connect.browserbase.com/?signingKey=abc123",
    }),
    available: v4_1.z.boolean(),
})
    .meta({ id: "SessionStartResult" });
exports.SessionStartResponseSchema = wrapResponse(exports.SessionStartResultSchema, "SessionStartResponse");
// =============================================================================
// Session End
// =============================================================================
/** Session end request - no request body. */
exports.SessionEndRequestSchema = v4_1.z
    .object({})
    .strict()
    .optional()
    .meta({ id: "SessionEndRequest" });
exports.SessionEndResultSchema = v4_1.z
    .object({})
    .strict()
    .meta({ id: "SessionEndResult" });
/** Session end response - just success flag, no data wrapper */
exports.SessionEndResponseSchema = v4_1.z
    .object({
    success: v4_1.z.boolean().meta({
        description: "Indicates whether the request was successful",
    }),
})
    .strict()
    .meta({ id: "SessionEndResponse" });
// =============================================================================
// Act
// =============================================================================
exports.ActOptionsSchema = v4_1.z
    .object({
    model: v4_1.z.union([exports.ModelConfigSchema, v4_1.z.string()]).optional().meta({
        description: "Model configuration object or model name string (e.g., 'openai/gpt-5-nano')",
    }),
    variables: v4_1.z
        .record(v4_1.z.string(), v4_1.z.string())
        .optional()
        .meta({
        description: "Variables to substitute in the action instruction",
        example: { username: "john_doe" },
    }),
    timeout: v4_1.z.number().optional().meta({
        description: "Timeout in ms for the action",
        example: 30000,
    }),
})
    .optional()
    .meta({ id: "ActOptions" });
exports.ActRequestSchema = v4_1.z
    .object({
    input: v4_1.z.string().or(exports.ActionSchema).meta({
        description: "Natural language instruction or Action object",
        example: "Click the login button",
    }),
    options: exports.ActOptionsSchema,
    frameId: v4_1.z.string().nullish().meta({
        description: "Target frame ID for the action",
    }),
    streamResponse: v4_1.z.boolean().optional().meta({
        description: "Whether to stream the response via SSE",
        example: true,
    }),
})
    .meta({ id: "ActRequest" });
/** Inner act result data */
exports.ActResultDataSchema = v4_1.z
    .object({
    success: v4_1.z.boolean().meta({
        description: "Whether the action completed successfully",
        example: true,
    }),
    message: v4_1.z.string().meta({
        description: "Human-readable result message",
        example: "Successfully clicked the login button",
    }),
    actionDescription: v4_1.z.string().meta({
        description: "Description of the action that was performed",
        example: "Clicked button with text 'Login'",
    }),
    actions: v4_1.z.array(exports.ActionSchema).meta({
        description: "List of actions that were executed",
    }),
})
    .meta({ id: "ActResultData" });
exports.ActResultSchema = v4_1.z
    .object({
    result: exports.ActResultDataSchema,
    actionId: v4_1.z.string().optional().meta({
        description: "Action ID for tracking",
    }),
})
    .meta({ id: "ActResult" });
exports.ActResponseSchema = wrapResponse(exports.ActResultSchema, "ActResponse");
// =============================================================================
// Extract
// =============================================================================
exports.ExtractOptionsSchema = v4_1.z
    .object({
    model: v4_1.z.union([exports.ModelConfigSchema, v4_1.z.string()]).optional().meta({
        description: "Model configuration object or model name string (e.g., 'openai/gpt-5-nano')",
    }),
    timeout: v4_1.z.number().optional().meta({
        description: "Timeout in ms for the extraction",
        example: 30000,
    }),
    selector: v4_1.z.string().optional().meta({
        description: "CSS selector to scope extraction to a specific element",
        example: "#main-content",
    }),
})
    .optional()
    .meta({ id: "ExtractOptions" });
exports.ExtractRequestSchema = v4_1.z
    .object({
    instruction: v4_1.z.string().optional().meta({
        description: "Natural language instruction for what to extract",
        example: "Extract all product names and prices from the page",
    }),
    schema: v4_1.z.record(v4_1.z.string(), v4_1.z.unknown()).optional().meta({
        description: "JSON Schema defining the structure of data to extract",
    }),
    options: exports.ExtractOptionsSchema,
    frameId: v4_1.z.string().nullish().meta({
        description: "Target frame ID for the extraction",
    }),
    streamResponse: v4_1.z.boolean().optional().meta({
        description: "Whether to stream the response via SSE",
        example: true,
    }),
})
    .meta({ id: "ExtractRequest" });
exports.ExtractResultSchema = v4_1.z
    .object({
    result: v4_1.z.unknown().meta({
        description: "Extracted data matching the requested schema",
        override: ({ jsonSchema }) => {
            jsonSchema["x-stainless-any"] = true;
        },
    }),
    actionId: v4_1.z.string().optional().meta({
        description: "Action ID for tracking",
    }),
})
    .meta({ id: "ExtractResult" });
exports.ExtractResponseSchema = wrapResponse(exports.ExtractResultSchema, "ExtractResponse");
// =============================================================================
// Observe
// =============================================================================
exports.ObserveOptionsSchema = v4_1.z
    .object({
    model: v4_1.z.union([exports.ModelConfigSchema, v4_1.z.string()]).optional().meta({
        description: "Model configuration object or model name string (e.g., 'openai/gpt-5-nano')",
    }),
    timeout: v4_1.z.number().optional().meta({
        description: "Timeout in ms for the observation",
        example: 30000,
    }),
    selector: v4_1.z.string().optional().meta({
        description: "CSS selector to scope observation to a specific element",
        example: "nav",
    }),
})
    .optional()
    .meta({ id: "ObserveOptions" });
exports.ObserveRequestSchema = v4_1.z
    .object({
    instruction: v4_1.z.string().optional().meta({
        description: "Natural language instruction for what actions to find",
        example: "Find all clickable navigation links",
    }),
    options: exports.ObserveOptionsSchema,
    frameId: v4_1.z.string().nullish().meta({
        description: "Target frame ID for the observation",
    }),
    streamResponse: v4_1.z.boolean().optional().meta({
        description: "Whether to stream the response via SSE",
        example: true,
    }),
})
    .meta({ id: "ObserveRequest" });
exports.ObserveResultSchema = v4_1.z
    .object({
    result: v4_1.z.array(exports.ActionSchema),
    actionId: v4_1.z.string().optional().meta({
        description: "Action ID for tracking",
    }),
})
    .meta({ id: "ObserveResult" });
exports.ObserveResponseSchema = wrapResponse(exports.ObserveResultSchema, "ObserveResponse");
// =============================================================================
// Agent Execute
// =============================================================================
exports.AgentConfigSchema = v4_1.z
    .object({
    provider: v4_1.z // cloud accepts provider: at the top level for legacy reasons, in the future we should remove it
        .enum(["openai", "anthropic", "google", "microsoft"])
        .optional()
        .meta({
        description: "AI provider for the agent (legacy, use model: openai/gpt-5-nano instead)",
        example: "openai",
    }),
    model: v4_1.z.union([exports.ModelConfigSchema, v4_1.z.string()]).optional().meta({
        description: "Model configuration object or model name string (e.g., 'openai/gpt-5-nano')",
    }),
    systemPrompt: v4_1.z.string().optional().meta({
        description: "Custom system prompt for the agent",
    }),
    cua: v4_1.z.boolean().optional().meta({
        description: "Deprecated. Use mode: 'cua' instead. If both are provided, mode takes precedence.",
        example: true,
    }),
    mode: v4_1.z.enum(["dom", "hybrid", "cua"]).optional().meta({
        description: "Tool mode for the agent (dom, hybrid, cua). If set, overrides cua.",
        example: "cua",
    }),
    executionModel: v4_1.z.union([exports.ModelConfigSchema, v4_1.z.string()]).optional().meta({
        description: "Model configuration object or model name string (e.g., 'openai/gpt-5-nano') for tool execution (observe/act calls within agent tools). If not specified, inherits from the main model configuration.",
    }),
})
    .meta({ id: "AgentConfig" });
/** Action taken by the agent during execution */
exports.AgentActionSchema = v4_1.z
    .object({
    type: v4_1.z.string().meta({
        description: "Type of action taken",
        example: "click",
    }),
    reasoning: v4_1.z.string().optional().meta({
        description: "Agent's reasoning for taking this action",
    }),
    taskCompleted: v4_1.z.boolean().optional(),
    action: v4_1.z.string().optional(),
    timeMs: v4_1.z.number().optional().meta({
        description: "Time taken for this action in ms",
    }),
    pageText: v4_1.z.string().optional(),
    pageUrl: v4_1.z.string().optional(),
    instruction: v4_1.z.string().optional(),
})
    .passthrough()
    .meta({ id: "AgentAction" });
/** Token usage statistics for agent execution */
exports.AgentUsageSchema = v4_1.z
    .object({
    input_tokens: v4_1.z.number().meta({ example: 1500 }),
    output_tokens: v4_1.z.number().meta({ example: 250 }),
    reasoning_tokens: v4_1.z.number().optional(),
    cached_input_tokens: v4_1.z.number().optional(),
    inference_time_ms: v4_1.z.number().meta({ example: 2500 }),
})
    .meta({ id: "AgentUsage" });
/** Result data from agent execution */
exports.AgentResultDataSchema = v4_1.z
    .object({
    success: v4_1.z.boolean().meta({
        description: "Whether the agent completed successfully",
        example: true,
    }),
    message: v4_1.z.string().meta({
        description: "Summary of what the agent accomplished",
        example: "Successfully logged in and navigated to dashboard",
    }),
    actions: v4_1.z.array(exports.AgentActionSchema),
    completed: v4_1.z.boolean().meta({
        description: "Whether the agent finished its task",
        example: true,
    }),
    metadata: v4_1.z.record(v4_1.z.string(), v4_1.z.unknown()).optional(),
    usage: exports.AgentUsageSchema.optional(),
})
    .meta({ id: "AgentResultData" });
exports.AgentCacheEntrySchema = v4_1.z
    .object({
    cacheKey: v4_1.z.string().meta({
        description: "Opaque cache identifier computed from instruction, URL, options, and config",
    }),
    entry: v4_1.z.unknown().meta({
        description: "Serialized cache entry that can be written to disk",
    }),
})
    .meta({ id: "AgentCacheEntry" });
exports.AgentExecuteOptionsSchema = v4_1.z
    .object({
    instruction: v4_1.z.string().meta({
        description: "Natural language instruction for the agent",
        example: "Log in with username 'demo' and password 'test123', then navigate to settings",
    }),
    maxSteps: v4_1.z.number().optional().meta({
        description: "Maximum number of steps the agent can take",
        example: 20,
    }),
    highlightCursor: v4_1.z.boolean().optional().meta({
        description: "Whether to visually highlight the cursor during execution",
        example: true,
    }),
})
    .meta({ id: "AgentExecuteOptions" });
exports.AgentExecuteRequestSchema = v4_1.z
    .object({
    agentConfig: exports.AgentConfigSchema,
    executeOptions: exports.AgentExecuteOptionsSchema,
    frameId: v4_1.z.string().nullish().meta({
        description: "Target frame ID for the agent",
    }),
    streamResponse: v4_1.z.boolean().optional().meta({
        description: "Whether to stream the response via SSE",
        example: true,
    }),
    shouldCache: v4_1.z.boolean().optional().meta({
        description: "If true, the server captures a cache entry and returns it to the client",
    }),
})
    .meta({ id: "AgentExecuteRequest" });
exports.AgentExecuteResultSchema = v4_1.z
    .object({
    result: exports.AgentResultDataSchema,
    cacheEntry: exports.AgentCacheEntrySchema.optional(),
})
    .meta({ id: "AgentExecuteResult" });
exports.AgentExecuteResponseSchema = wrapResponse(exports.AgentExecuteResultSchema, "AgentExecuteResponse");
// =============================================================================
// Navigate
// =============================================================================
exports.NavigateOptionsSchema = v4_1.z
    .object({
    referer: v4_1.z.string().optional().meta({
        description: "Referer header to send with the request",
    }),
    timeout: v4_1.z.number().optional().meta({
        description: "Timeout in ms for the navigation",
        example: 30000,
    }),
    waitUntil: v4_1.z
        .enum(["load", "domcontentloaded", "networkidle"])
        .optional()
        .meta({
        description: "When to consider navigation complete",
        example: "networkidle",
    }),
})
    .optional()
    .meta({ id: "NavigateOptions" });
exports.NavigateRequestSchema = v4_1.z
    .object({
    url: v4_1.z.string().meta({
        description: "URL to navigate to",
        example: "https://example.com",
    }),
    options: exports.NavigateOptionsSchema,
    frameId: v4_1.z.string().nullish().meta({
        description: "Target frame ID for the navigation",
    }),
    streamResponse: v4_1.z.boolean().optional().meta({
        description: "Whether to stream the response via SSE",
        example: true,
    }),
})
    .meta({ id: "NavigateRequest" });
exports.NavigateResultSchema = v4_1.z
    .object({
    // SerializableResponse from types/private/api.ts - no Zod schema available
    // as it wraps complex devtools-protocol types (Protocol.Network.Response)
    result: v4_1.z
        .unknown()
        .nullable()
        .meta({
        description: "Navigation response (Playwright Response object or null)",
        override: ({ jsonSchema }) => {
            jsonSchema["x-stainless-any"] = true;
        },
    }),
    actionId: v4_1.z.string().optional().meta({
        description: "Action ID for tracking",
    }),
})
    .meta({ id: "NavigateResult" });
exports.NavigateResponseSchema = wrapResponse(exports.NavigateResultSchema, "NavigateResponse");
// =============================================================================
// Replay Metrics
// =============================================================================
/** Token usage for a single action */
exports.TokenUsageSchema = v4_1.z
    .object({
    inputTokens: v4_1.z.number().optional(),
    outputTokens: v4_1.z.number().optional(),
    timeMs: v4_1.z.number().optional(),
    cost: v4_1.z.number().optional(),
})
    .meta({ id: "TokenUsage" });
/** Action entry in replay metrics */
exports.ReplayActionSchema = v4_1.z
    .object({
    method: v4_1.z.string(),
    parameters: v4_1.z.record(v4_1.z.string(), v4_1.z.unknown()),
    result: v4_1.z.record(v4_1.z.string(), v4_1.z.unknown()),
    timestamp: v4_1.z.number(),
    endTime: v4_1.z.number().optional(),
    tokenUsage: exports.TokenUsageSchema.optional(),
})
    .meta({ id: "ReplayAction" });
/** Page entry in replay metrics */
exports.ReplayPageSchema = v4_1.z
    .object({
    url: v4_1.z.string(),
    timestamp: v4_1.z.number(),
    duration: v4_1.z.number(),
    actions: v4_1.z.array(exports.ReplayActionSchema),
})
    .meta({ id: "ReplayPage" });
/** Inner result data for replay */
exports.ReplayResultSchema = v4_1.z
    .object({
    pages: v4_1.z.array(exports.ReplayPageSchema),
    clientLanguage: v4_1.z.string().optional(),
})
    .meta({ id: "ReplayResult" });
exports.ReplayResponseSchema = wrapResponse(exports.ReplayResultSchema, "ReplayResponse");
// =============================================================================
// SSE Stream Events
// =============================================================================
// These schemas define the Server-Sent Events format for streaming responses.
// Streaming is enabled by setting the `x-stream-response: true` header.
/** Status values for SSE stream events */
exports.StreamEventStatusSchema = v4_1.z
    .enum(["starting", "connected", "running", "finished", "error"])
    .meta({
    id: "StreamEventStatus",
    description: "Current status of the streaming operation",
});
/** Type discriminator for SSE stream events */
exports.StreamEventTypeSchema = v4_1.z.enum(["system", "log"]).meta({
    id: "StreamEventType",
    description: "Type of stream event - system events or log messages",
});
/** Data payload for system stream events */
exports.StreamEventSystemDataSchema = v4_1.z
    .object({
    status: exports.StreamEventStatusSchema,
    result: v4_1.z
        .unknown()
        .optional()
        .meta({
        description: "Operation result (present when status is 'finished')",
        override: ({ jsonSchema }) => {
            jsonSchema["x-stainless-any"] = true;
        },
    }),
    error: v4_1.z.string().optional().meta({
        description: "Error message (present when status is 'error')",
    }),
})
    .meta({ id: "StreamEventSystemData" });
/** Data payload for log stream events */
exports.StreamEventLogDataSchema = v4_1.z
    .object({
    status: v4_1.z.literal("running"),
    message: v4_1.z.string().meta({
        description: "Log message from the operation",
    }),
})
    .meta({ id: "StreamEventLogData" });
/**
 * SSE stream event sent during streaming responses.
 *
 * IMPORTANT: Key ordering matters for Stainless SDK generation.
 * The `data` field MUST be serialized first, with `status` as the first key within it.
 * This allows Stainless to use `data_starts_with: '{"data":{"status":"finished"'` for event handling.
 *
 * Expected serialization order: {"data":{"status":...},"type":...,"id":...}
 */
exports.StreamEventSchema = v4_1.z
    .object({
    data: v4_1.z.union([exports.StreamEventSystemDataSchema, exports.StreamEventLogDataSchema]),
    type: exports.StreamEventTypeSchema,
    id: v4_1.z.string().uuid().meta({
        description: "Unique identifier for this event",
        example: "c4dbf3a9-9a58-4b22-8a1c-9f20f9f9e123",
    }),
})
    .meta({
    id: "StreamEvent",
    description: "Server-Sent Event emitted during streaming responses. Events are sent as `data: <JSON>\\n\\n`. Key order: data (with status first), type, id.",
});
// =============================================================================
// OpenAPI Components
// =============================================================================
// These objects are exported for use in gen-openapi.ts to configure the spec.
/** OpenAPI security schemes for authentication */
exports.openApiSecuritySchemes = {
    BrowserbaseApiKey: {
        type: "apiKey",
        in: "header",
        name: "x-bb-api-key",
        description: "Browserbase API key for authentication",
    },
    BrowserbaseProjectId: {
        type: "apiKey",
        in: "header",
        name: "x-bb-project-id",
        description: "Browserbase project ID",
    },
    ModelApiKey: {
        type: "apiKey",
        in: "header",
        name: "x-model-api-key",
        description: "API key for the AI model provider (OpenAI, Anthropic, etc.)",
    },
};
/** OpenAPI links for session operations (used in SessionStart response) */
exports.openApiLinks = {
    SessionAct: {
        operationId: "SessionAct",
        parameters: { id: "$response.body#/data/sessionId" },
        description: "Perform an action on the session",
    },
    SessionExtract: {
        operationId: "SessionExtract",
        parameters: { id: "$response.body#/data/sessionId" },
        description: "Extract data from the session",
    },
    SessionObserve: {
        operationId: "SessionObserve",
        parameters: { id: "$response.body#/data/sessionId" },
        description: "Observe available actions on the session",
    },
    SessionNavigate: {
        operationId: "SessionNavigate",
        parameters: { id: "$response.body#/data/sessionId" },
        description: "Navigate to a URL in the session",
    },
    SessionAgentExecute: {
        operationId: "SessionAgentExecute",
        parameters: { id: "$response.body#/data/sessionId" },
        description: "Execute an agent on the session",
    },
    SessionReplay: {
        operationId: "SessionReplay",
        parameters: { id: "$response.body#/data/sessionId" },
        description: "Replay session metrics",
    },
    SessionEnd: {
        operationId: "SessionEnd",
        parameters: { id: "$response.body#/data/sessionId" },
        description: "End the session and release resources",
    },
};
/** OpenAPI operation metadata for each endpoint */
exports.Operations = {
    SessionStart: {
        operationId: "SessionStart",
        summary: "Start a new browser session",
        description: "Creates a new browser session with the specified configuration. Returns a session ID used for all subsequent operations.",
    },
    SessionEnd: {
        operationId: "SessionEnd",
        summary: "End a browser session",
        description: "Terminates the browser session and releases all associated resources.",
    },
    SessionAct: {
        operationId: "SessionAct",
        summary: "Perform an action",
        description: "Executes a browser action using natural language instructions or a predefined Action object.",
    },
    SessionExtract: {
        operationId: "SessionExtract",
        summary: "Extract data from the page",
        description: "Extracts structured data from the current page using AI-powered analysis.",
    },
    SessionObserve: {
        operationId: "SessionObserve",
        summary: "Observe available actions",
        description: "Identifies and returns available actions on the current page that match the given instruction.",
    },
    SessionNavigate: {
        operationId: "SessionNavigate",
        summary: "Navigate to a URL",
        description: "Navigates the browser to the specified URL.",
    },
    SessionAgentExecute: {
        operationId: "SessionAgentExecute",
        summary: "Execute an AI agent",
        description: "Runs an autonomous AI agent that can perform complex multi-step browser tasks.",
    },
    SessionReplay: {
        operationId: "SessionReplay",
        summary: "Replay session metrics",
        description: "Retrieves replay metrics for a session.",
    },
};
//# sourceMappingURL=api.js.map