import { Schema } from "@google/genai"; import { z, ZodTypeAny } from "zod"; import { LogLine } from "./v3/types/public/logs.js"; import { ModelProvider } from "./v3/types/public/model.js"; import { ZodPathSegments } from "./v3/types/private/internal.js"; import type { StagehandZodSchema } from "./v3/zodCompat.js"; export declare function getZFactory(schema: StagehandZodSchema): typeof z; export declare function validateZodSchema(schema: StagehandZodSchema, data: unknown): boolean; /** * Detects if the code is running in the Bun runtime environment. * @returns {boolean} True if running in Bun, false otherwise. */ export declare function isRunningInBun(): boolean; export declare function toGeminiSchema(zodSchema: StagehandZodSchema): Schema; export declare function getZodType(schema: StagehandZodSchema): string; /** * Recursively traverses a given Zod schema, scanning for any fields of type `z.string().url()`. * For each such field, it replaces the `z.string().url()` with `z.number()`. * * This function is used internally by higher-level utilities (e.g., transforming entire object schemas) * and handles nested objects, arrays, unions, intersections, optionals. * * @param schema - The Zod schema to transform. * @param currentPath - An array of string/number keys representing the current schema path (used internally for recursion). * @returns A two-element tuple: * 1. The updated Zod schema, with any `.url()` fields replaced by `z.number()`. * 2. An array of {@link ZodPathSegments} objects representing each replaced field, including the path segments. */ export declare function transformSchema(schema: StagehandZodSchema, currentPath: Array): [StagehandZodSchema, ZodPathSegments[]]; /** * Once we get the final extracted object that has numeric IDs in place of URLs, * use `injectUrls` to walk the object and replace numeric IDs * with the real URL strings from idToUrlMapping. The `path` may include `*` * for array indices (indicating "all items in the array"). */ export declare function injectUrls(obj: unknown, path: Array, idToUrlMapping: Record): void; /** * Mapping from LLM provider names to their corresponding environment variable names for API keys. */ export declare const providerEnvVarMap: Partial>>; /** * Loads an API key for a provider, checking environment variables. * @param provider The name of the provider (e.g., 'openai', 'anthropic') * @param logger Optional logger for info/error messages * @returns The API key if found, undefined otherwise */ export declare function loadApiKeyFromEnv(provider: string | undefined, logger: (logLine: LogLine) => void): string | undefined; export declare function trimTrailingTextNode(path: string | undefined): string | undefined; export declare function toTitleCase(str: string): string; export interface JsonSchemaProperty { type: string; enum?: unknown[]; items?: JsonSchemaProperty; properties?: Record; required?: string[]; minimum?: number; maximum?: number; description?: string; format?: string; } export interface JsonSchema extends JsonSchemaProperty { type: string; } /** * Converts a JSON Schema object to a Zod schema * @param schema The JSON Schema object to convert * @returns A Zod schema equivalent to the input JSON Schema */ export declare function jsonSchemaToZod(schema: JsonSchema): ZodTypeAny;