@browserbasehq/orca 3.0.2-zod370 → 3.0.2-zod373
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.
- package/dist/index.d.ts +24 -12
- package/dist/index.js +581 -326
- package/package.json +9 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ZodTypeAny, z, ZodObject, ZodRawShape, ZodError } from 'zod';
|
|
2
|
+
import * as z3 from 'zod/v3';
|
|
2
3
|
import { ClientOptions as ClientOptions$2 } from '@anthropic-ai/sdk';
|
|
3
4
|
import { LanguageModelV2 } from '@ai-sdk/provider';
|
|
4
5
|
import { ClientOptions as ClientOptions$1 } from 'openai';
|
|
@@ -17,6 +18,16 @@ import { ChatCompletion } from 'openai/resources';
|
|
|
17
18
|
import { ToolSet as ToolSet$1 } from 'ai/dist';
|
|
18
19
|
import { Schema } from '@google/genai';
|
|
19
20
|
|
|
21
|
+
type StagehandZodSchema = ZodTypeAny | z3.ZodTypeAny;
|
|
22
|
+
type StagehandZodObject = ZodObject<ZodRawShape> | z3.ZodObject<z3.ZodRawShape>;
|
|
23
|
+
type InferStagehandSchema<T extends StagehandZodSchema> = T extends z3.ZodTypeAny ? z3.infer<T> : T extends ZodTypeAny ? z.infer<T> : never;
|
|
24
|
+
declare const isZod4Schema: (schema: StagehandZodSchema) => schema is ZodTypeAny & {
|
|
25
|
+
_zod: unknown;
|
|
26
|
+
};
|
|
27
|
+
declare const isZod3Schema: (schema: StagehandZodSchema) => schema is z3.ZodTypeAny;
|
|
28
|
+
type JsonSchemaDocument = Record<string, unknown>;
|
|
29
|
+
declare function toJsonSchema(schema: StagehandZodSchema): JsonSchemaDocument;
|
|
30
|
+
|
|
20
31
|
type AnthropicJsonSchemaObject = {
|
|
21
32
|
definitions?: {
|
|
22
33
|
MySchema?: {
|
|
@@ -102,7 +113,7 @@ interface ChatCompletionOptions {
|
|
|
102
113
|
};
|
|
103
114
|
response_model?: {
|
|
104
115
|
name: string;
|
|
105
|
-
schema:
|
|
116
|
+
schema: StagehandZodSchema;
|
|
106
117
|
};
|
|
107
118
|
tools?: LLMTool[];
|
|
108
119
|
tool_choice?: "auto" | "none" | "required";
|
|
@@ -167,7 +178,7 @@ declare abstract class LLMClient {
|
|
|
167
178
|
options: {
|
|
168
179
|
response_model: {
|
|
169
180
|
name: string;
|
|
170
|
-
schema:
|
|
181
|
+
schema: StagehandZodSchema;
|
|
171
182
|
};
|
|
172
183
|
};
|
|
173
184
|
}): Promise<LLMParsedResponse<T>>;
|
|
@@ -778,7 +789,7 @@ declare class StagehandAPIClient {
|
|
|
778
789
|
constructor({ apiKey, projectId, logger }: StagehandAPIConstructorParams);
|
|
779
790
|
init({ modelName, modelApiKey, domSettleTimeoutMs, verbose, systemPrompt, selfHeal, browserbaseSessionCreateParams, browserbaseSessionID, }: StartSessionParams): Promise<StartSessionResult>;
|
|
780
791
|
act({ input, options, frameId }: APIActParameters): Promise<ActResult>;
|
|
781
|
-
extract<T extends
|
|
792
|
+
extract<T extends StagehandZodSchema>({ instruction, schema: zodSchema, options, frameId, }: APIExtractParameters): Promise<ExtractResult<T>>;
|
|
782
793
|
observe({ instruction, options, frameId, }: APIObserveParameters): Promise<Action[]>;
|
|
783
794
|
goto(url: string, options?: {
|
|
784
795
|
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
@@ -1333,7 +1344,7 @@ interface ActResult {
|
|
|
1333
1344
|
actionDescription: string;
|
|
1334
1345
|
actions: Action[];
|
|
1335
1346
|
}
|
|
1336
|
-
type ExtractResult<T extends
|
|
1347
|
+
type ExtractResult<T extends StagehandZodSchema> = InferStagehandSchema<T>;
|
|
1337
1348
|
interface Action {
|
|
1338
1349
|
selector: string;
|
|
1339
1350
|
description: string;
|
|
@@ -1623,7 +1634,7 @@ interface APIActParameters {
|
|
|
1623
1634
|
}
|
|
1624
1635
|
interface APIExtractParameters {
|
|
1625
1636
|
instruction?: string;
|
|
1626
|
-
schema?:
|
|
1637
|
+
schema?: StagehandZodSchema;
|
|
1627
1638
|
options?: ExtractOptions;
|
|
1628
1639
|
frameId?: string;
|
|
1629
1640
|
}
|
|
@@ -1970,7 +1981,7 @@ declare class V3 {
|
|
|
1970
1981
|
extract(): Promise<z.infer<typeof pageTextSchema>>;
|
|
1971
1982
|
extract(options: ExtractOptions): Promise<z.infer<typeof pageTextSchema>>;
|
|
1972
1983
|
extract(instruction: string, options?: ExtractOptions): Promise<z.infer<typeof defaultExtractSchema>>;
|
|
1973
|
-
extract<T extends
|
|
1984
|
+
extract<T extends StagehandZodSchema>(instruction: string, schema: T, options?: ExtractOptions): Promise<InferStagehandSchema<T>>;
|
|
1974
1985
|
/**
|
|
1975
1986
|
* Run an "observe" instruction through the ObserveHandler.
|
|
1976
1987
|
*/
|
|
@@ -2042,14 +2053,14 @@ declare class AgentProvider {
|
|
|
2042
2053
|
static getAgentProvider(modelName: string): AgentProviderType;
|
|
2043
2054
|
}
|
|
2044
2055
|
|
|
2045
|
-
declare function validateZodSchema(schema:
|
|
2056
|
+
declare function validateZodSchema(schema: StagehandZodSchema, data: unknown): boolean;
|
|
2046
2057
|
/**
|
|
2047
2058
|
* Detects if the code is running in the Bun runtime environment.
|
|
2048
2059
|
* @returns {boolean} True if running in Bun, false otherwise.
|
|
2049
2060
|
*/
|
|
2050
2061
|
declare function isRunningInBun(): boolean;
|
|
2051
|
-
declare function toGeminiSchema(zodSchema:
|
|
2052
|
-
declare function getZodType(schema:
|
|
2062
|
+
declare function toGeminiSchema(zodSchema: StagehandZodSchema): Schema;
|
|
2063
|
+
declare function getZodType(schema: StagehandZodSchema): string;
|
|
2053
2064
|
/**
|
|
2054
2065
|
* Recursively traverses a given Zod schema, scanning for any fields of type `z.string().url()`.
|
|
2055
2066
|
* For each such field, it replaces the `z.string().url()` with `z.number()`.
|
|
@@ -2063,7 +2074,7 @@ declare function getZodType(schema: z.ZodTypeAny): string;
|
|
|
2063
2074
|
* 1. The updated Zod schema, with any `.url()` fields replaced by `z.number()`.
|
|
2064
2075
|
* 2. An array of {@link ZodPathSegments} objects representing each replaced field, including the path segments.
|
|
2065
2076
|
*/
|
|
2066
|
-
declare function transformSchema(schema:
|
|
2077
|
+
declare function transformSchema(schema: StagehandZodSchema, currentPath: Array<string | number>): [StagehandZodSchema, ZodPathSegments[]];
|
|
2067
2078
|
/**
|
|
2068
2079
|
* Once we get the final extracted object that has numeric IDs in place of URLs,
|
|
2069
2080
|
* use `injectUrls` to walk the object and replace numeric IDs
|
|
@@ -2092,6 +2103,7 @@ interface JsonSchemaProperty {
|
|
|
2092
2103
|
minimum?: number;
|
|
2093
2104
|
maximum?: number;
|
|
2094
2105
|
description?: string;
|
|
2106
|
+
format?: string;
|
|
2095
2107
|
}
|
|
2096
2108
|
interface JsonSchema extends JsonSchemaProperty {
|
|
2097
2109
|
type: string;
|
|
@@ -2132,4 +2144,4 @@ declare class V3Evaluator {
|
|
|
2132
2144
|
private _evaluateWithMultipleScreenshots;
|
|
2133
2145
|
}
|
|
2134
2146
|
|
|
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 };
|
|
2147
|
+
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 };
|