@browserbasehq/orca 3.0.2-zod360 → 3.0.2-zod370

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/index.d.ts +12 -26
  2. package/dist/index.js +310 -565
  3. package/package.json +3 -6
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import * as z3 from 'zod/v3';
2
- import { ZodTypeAny, z, ZodObject, ZodRawShape, ZodError } from 'zod';
1
+ import { ZodType, z, ZodError, ZodTypeAny } from 'zod';
3
2
  import { ClientOptions as ClientOptions$2 } from '@anthropic-ai/sdk';
4
3
  import { LanguageModelV2 } from '@ai-sdk/provider';
5
4
  import { ClientOptions as ClientOptions$1 } from 'openai';
@@ -69,16 +68,6 @@ type LogLine = {
69
68
  };
70
69
  type Logger = (logLine: LogLine) => void;
71
70
 
72
- type StagehandZodSchema = ZodTypeAny | z3.ZodTypeAny;
73
- type StagehandZodObject = ZodObject<ZodRawShape> | z3.ZodObject<z3.ZodRawShape>;
74
- type InferStagehandSchema<T extends StagehandZodSchema> = T extends z3.ZodTypeAny ? z3.infer<T> : T extends ZodTypeAny ? z.infer<T> : never;
75
- declare const isZod4Schema: (schema: StagehandZodSchema) => schema is ZodTypeAny & {
76
- _zod: unknown;
77
- };
78
- declare const isZod3Schema: (schema: StagehandZodSchema) => schema is z3.ZodTypeAny;
79
- type JsonSchemaDocument = Record<string, unknown>;
80
- declare function toJsonSchema(schema: StagehandZodSchema): JsonSchemaDocument;
81
-
82
71
  interface ChatMessage {
83
72
  role: "system" | "user" | "assistant";
84
73
  content: ChatMessageContent;
@@ -113,7 +102,7 @@ interface ChatCompletionOptions {
113
102
  };
114
103
  response_model?: {
115
104
  name: string;
116
- schema: StagehandZodSchema;
105
+ schema: ZodType;
117
106
  };
118
107
  tools?: LLMTool[];
119
108
  tool_choice?: "auto" | "none" | "required";
@@ -178,7 +167,7 @@ declare abstract class LLMClient {
178
167
  options: {
179
168
  response_model: {
180
169
  name: string;
181
- schema: StagehandZodSchema;
170
+ schema: ZodType;
182
171
  };
183
172
  };
184
173
  }): Promise<LLMParsedResponse<T>>;
@@ -789,7 +778,7 @@ declare class StagehandAPIClient {
789
778
  constructor({ apiKey, projectId, logger }: StagehandAPIConstructorParams);
790
779
  init({ modelName, modelApiKey, domSettleTimeoutMs, verbose, systemPrompt, selfHeal, browserbaseSessionCreateParams, browserbaseSessionID, }: StartSessionParams): Promise<StartSessionResult>;
791
780
  act({ input, options, frameId }: APIActParameters): Promise<ActResult>;
792
- extract<T extends StagehandZodSchema>({ instruction, schema: zodSchema, options, frameId, }: APIExtractParameters): Promise<ExtractResult<T>>;
781
+ extract<T extends z.ZodObject>({ instruction, schema: zodSchema, options, frameId, }: APIExtractParameters): Promise<ExtractResult<T>>;
793
782
  observe({ instruction, options, frameId, }: APIObserveParameters): Promise<Action[]>;
794
783
  goto(url: string, options?: {
795
784
  waitUntil?: "load" | "domcontentloaded" | "networkidle";
@@ -1344,7 +1333,7 @@ interface ActResult {
1344
1333
  actionDescription: string;
1345
1334
  actions: Action[];
1346
1335
  }
1347
- type ExtractResult<T extends StagehandZodSchema> = InferStagehandSchema<T>;
1336
+ type ExtractResult<T extends z.ZodObject> = z.infer<T>;
1348
1337
  interface Action {
1349
1338
  selector: string;
1350
1339
  description: string;
@@ -1634,7 +1623,7 @@ interface APIActParameters {
1634
1623
  }
1635
1624
  interface APIExtractParameters {
1636
1625
  instruction?: string;
1637
- schema?: StagehandZodSchema;
1626
+ schema?: ZodTypeAny;
1638
1627
  options?: ExtractOptions;
1639
1628
  frameId?: string;
1640
1629
  }
@@ -1981,9 +1970,7 @@ declare class V3 {
1981
1970
  extract(): Promise<z.infer<typeof pageTextSchema>>;
1982
1971
  extract(options: ExtractOptions): Promise<z.infer<typeof pageTextSchema>>;
1983
1972
  extract(instruction: string, options?: ExtractOptions): Promise<z.infer<typeof defaultExtractSchema>>;
1984
- extract<T extends z.ZodTypeAny>(instruction: string, schema: T, options?: ExtractOptions): Promise<z.infer<T>>;
1985
- extract<T extends z3.ZodTypeAny>(instruction: string, schema: T, options?: ExtractOptions): Promise<z3.infer<T>>;
1986
- extract(instruction: string, schema: unknown, options?: ExtractOptions): Promise<unknown>;
1973
+ extract<T extends ZodTypeAny>(instruction: string, schema: T, options?: ExtractOptions): Promise<z.infer<T>>;
1987
1974
  /**
1988
1975
  * Run an "observe" instruction through the ObserveHandler.
1989
1976
  */
@@ -2055,14 +2042,14 @@ declare class AgentProvider {
2055
2042
  static getAgentProvider(modelName: string): AgentProviderType;
2056
2043
  }
2057
2044
 
2058
- declare function validateZodSchema(schema: StagehandZodSchema, data: unknown): boolean;
2045
+ declare function validateZodSchema(schema: z.ZodTypeAny, data: unknown): boolean;
2059
2046
  /**
2060
2047
  * Detects if the code is running in the Bun runtime environment.
2061
2048
  * @returns {boolean} True if running in Bun, false otherwise.
2062
2049
  */
2063
2050
  declare function isRunningInBun(): boolean;
2064
- declare function toGeminiSchema(zodSchema: StagehandZodSchema): Schema;
2065
- declare function getZodType(schema: StagehandZodSchema): string;
2051
+ declare function toGeminiSchema(zodSchema: z.ZodTypeAny): Schema;
2052
+ declare function getZodType(schema: z.ZodTypeAny): string;
2066
2053
  /**
2067
2054
  * Recursively traverses a given Zod schema, scanning for any fields of type `z.string().url()`.
2068
2055
  * For each such field, it replaces the `z.string().url()` with `z.number()`.
@@ -2076,7 +2063,7 @@ declare function getZodType(schema: StagehandZodSchema): string;
2076
2063
  * 1. The updated Zod schema, with any `.url()` fields replaced by `z.number()`.
2077
2064
  * 2. An array of {@link ZodPathSegments} objects representing each replaced field, including the path segments.
2078
2065
  */
2079
- declare function transformSchema(schema: StagehandZodSchema, currentPath: Array<string | number>): [StagehandZodSchema, ZodPathSegments[]];
2066
+ declare function transformSchema(schema: z.ZodTypeAny, currentPath: Array<string | number>): [z.ZodTypeAny, ZodPathSegments[]];
2080
2067
  /**
2081
2068
  * Once we get the final extracted object that has numeric IDs in place of URLs,
2082
2069
  * use `injectUrls` to walk the object and replace numeric IDs
@@ -2105,7 +2092,6 @@ interface JsonSchemaProperty {
2105
2092
  minimum?: number;
2106
2093
  maximum?: number;
2107
2094
  description?: string;
2108
- format?: string;
2109
2095
  }
2110
2096
  interface JsonSchema extends JsonSchemaProperty {
2111
2097
  type: string;
@@ -2146,4 +2132,4 @@ declare class V3Evaluator {
2146
2132
  private _evaluateWithMultipleScreenshots;
2147
2133
  }
2148
2134
 
2149
- export { type AISDKCustomProvider, type AISDKProvider, AISdkClient, AVAILABLE_CUA_MODELS, type ActOptions, type ActResult, type Action, type ActionExecutionResult, type AgentAction, type AgentConfig, type AgentExecuteOptions, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type AgentResult, AgentScreenshotProviderError, type AgentType, AnnotatedScreenshotText, type AnthropicContentBlock, type AnthropicJsonSchemaObject, type AnthropicMessage, type AnthropicTextBlock, type AnthropicToolResult, type AnyPage, type AvailableCuaModel, type AvailableModel, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, type ChatCompletionOptions, type ChatMessage, type ChatMessageContent, type ChatMessageImageContent, type ChatMessageTextContent, type ClientOptions, type ComputerCallItem, ConnectionTimeoutError, type ConsoleListener, ConsoleMessage, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, CuaModelRequiredError, ElementNotVisibleError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, type FunctionCallItem, HandlerNotInitializedError, type HistoryEntry, type InferStagehandSchema, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaDocument, type JsonSchemaProperty, LLMClient, type LLMParsedResponse, type LLMResponse, LLMResponseError, type LLMTool, type LLMUsage, LOG_LEVEL_NAMES, type LoadState, type LocalBrowserLaunchOptions, type LogLevel, type LogLine, type Logger, MCPConnectionError, MissingEnvironmentVariableError, MissingLLMConfigurationError, type ModelConfiguration, type ModelProvider, type ObserveOptions, Page, PageNotFoundError, Response$1 as Response, ResponseBodyError, type ResponseInputItem, type ResponseItem, ResponseParseError, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, type StagehandMetrics, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, type StagehandZodObject, type StagehandZodSchema, TimeoutError, type ToolUseItem, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type V3Options, XPathResolutionError, ZodSchemaValidationError, connectToMCPServer, defaultExtractSchema, getZodType, injectUrls, isRunningInBun, isZod3Schema, isZod4Schema, jsonSchemaToZod, loadApiKeyFromEnv, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, toJsonSchema, transformSchema, trimTrailingTextNode, validateZodSchema };
2135
+ export { type AISDKCustomProvider, type AISDKProvider, AISdkClient, AVAILABLE_CUA_MODELS, type ActOptions, type ActResult, type Action, type ActionExecutionResult, type AgentAction, type AgentConfig, type AgentExecuteOptions, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type AgentResult, AgentScreenshotProviderError, type AgentType, AnnotatedScreenshotText, type AnthropicContentBlock, type AnthropicJsonSchemaObject, type AnthropicMessage, type AnthropicTextBlock, type AnthropicToolResult, type AnyPage, type AvailableCuaModel, type AvailableModel, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, type ChatCompletionOptions, type ChatMessage, type ChatMessageContent, type ChatMessageImageContent, type ChatMessageTextContent, type ClientOptions, type ComputerCallItem, ConnectionTimeoutError, type ConsoleListener, ConsoleMessage, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, CuaModelRequiredError, ElementNotVisibleError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, type FunctionCallItem, HandlerNotInitializedError, type HistoryEntry, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaProperty, LLMClient, type LLMParsedResponse, type LLMResponse, LLMResponseError, type LLMTool, type LLMUsage, LOG_LEVEL_NAMES, type LoadState, type LocalBrowserLaunchOptions, type LogLevel, type LogLine, type Logger, MCPConnectionError, MissingEnvironmentVariableError, MissingLLMConfigurationError, type ModelConfiguration, type ModelProvider, type ObserveOptions, Page, PageNotFoundError, Response$1 as Response, ResponseBodyError, type ResponseInputItem, type ResponseItem, ResponseParseError, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, type StagehandMetrics, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, TimeoutError, type ToolUseItem, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type V3Options, XPathResolutionError, ZodSchemaValidationError, connectToMCPServer, defaultExtractSchema, getZodType, injectUrls, isRunningInBun, jsonSchemaToZod, loadApiKeyFromEnv, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, transformSchema, trimTrailingTextNode, validateZodSchema };