@browserbasehq/orca 3.0.2-zod370 → 3.0.2-zod371
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 +26 -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 * as z3 from 'zod/v3';
|
|
2
|
+
import { ZodTypeAny, z, ZodObject, ZodRawShape, ZodError } from 'zod';
|
|
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';
|
|
@@ -68,6 +69,16 @@ type LogLine = {
|
|
|
68
69
|
};
|
|
69
70
|
type Logger = (logLine: LogLine) => void;
|
|
70
71
|
|
|
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
|
+
|
|
71
82
|
interface ChatMessage {
|
|
72
83
|
role: "system" | "user" | "assistant";
|
|
73
84
|
content: ChatMessageContent;
|
|
@@ -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,9 @@ 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 ZodTypeAny>(instruction: string, schema: T, options?: ExtractOptions): Promise<z.infer<T>>;
|
|
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>;
|
|
1974
1987
|
/**
|
|
1975
1988
|
* Run an "observe" instruction through the ObserveHandler.
|
|
1976
1989
|
*/
|
|
@@ -2042,14 +2055,14 @@ declare class AgentProvider {
|
|
|
2042
2055
|
static getAgentProvider(modelName: string): AgentProviderType;
|
|
2043
2056
|
}
|
|
2044
2057
|
|
|
2045
|
-
declare function validateZodSchema(schema:
|
|
2058
|
+
declare function validateZodSchema(schema: StagehandZodSchema, data: unknown): boolean;
|
|
2046
2059
|
/**
|
|
2047
2060
|
* Detects if the code is running in the Bun runtime environment.
|
|
2048
2061
|
* @returns {boolean} True if running in Bun, false otherwise.
|
|
2049
2062
|
*/
|
|
2050
2063
|
declare function isRunningInBun(): boolean;
|
|
2051
|
-
declare function toGeminiSchema(zodSchema:
|
|
2052
|
-
declare function getZodType(schema:
|
|
2064
|
+
declare function toGeminiSchema(zodSchema: StagehandZodSchema): Schema;
|
|
2065
|
+
declare function getZodType(schema: StagehandZodSchema): string;
|
|
2053
2066
|
/**
|
|
2054
2067
|
* Recursively traverses a given Zod schema, scanning for any fields of type `z.string().url()`.
|
|
2055
2068
|
* For each such field, it replaces the `z.string().url()` with `z.number()`.
|
|
@@ -2063,7 +2076,7 @@ declare function getZodType(schema: z.ZodTypeAny): string;
|
|
|
2063
2076
|
* 1. The updated Zod schema, with any `.url()` fields replaced by `z.number()`.
|
|
2064
2077
|
* 2. An array of {@link ZodPathSegments} objects representing each replaced field, including the path segments.
|
|
2065
2078
|
*/
|
|
2066
|
-
declare function transformSchema(schema:
|
|
2079
|
+
declare function transformSchema(schema: StagehandZodSchema, currentPath: Array<string | number>): [StagehandZodSchema, ZodPathSegments[]];
|
|
2067
2080
|
/**
|
|
2068
2081
|
* Once we get the final extracted object that has numeric IDs in place of URLs,
|
|
2069
2082
|
* use `injectUrls` to walk the object and replace numeric IDs
|
|
@@ -2092,6 +2105,7 @@ interface JsonSchemaProperty {
|
|
|
2092
2105
|
minimum?: number;
|
|
2093
2106
|
maximum?: number;
|
|
2094
2107
|
description?: string;
|
|
2108
|
+
format?: string;
|
|
2095
2109
|
}
|
|
2096
2110
|
interface JsonSchema extends JsonSchemaProperty {
|
|
2097
2111
|
type: string;
|
|
@@ -2132,4 +2146,4 @@ declare class V3Evaluator {
|
|
|
2132
2146
|
private _evaluateWithMultipleScreenshots;
|
|
2133
2147
|
}
|
|
2134
2148
|
|
|
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 };
|
|
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 };
|