@browserbasehq/orca 3.0.1-zod4 → 3.0.2-patch
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 +71 -41
- package/dist/index.js +777 -602
- package/package.json +21 -19
- package/LICENSE +0 -21
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ZodType, z, ZodError, ZodTypeAny } from 'zod';
|
|
1
|
+
import z, { ZodType, z as z$1, ZodError, ZodTypeAny } from 'zod/v3';
|
|
2
2
|
import { ClientOptions as ClientOptions$2 } from '@anthropic-ai/sdk';
|
|
3
3
|
import { LanguageModelV2 } from '@ai-sdk/provider';
|
|
4
4
|
import { ClientOptions as ClientOptions$1 } from 'openai';
|
|
@@ -141,14 +141,6 @@ interface CreateChatCompletionOptions {
|
|
|
141
141
|
logger: (message: LogLine) => void;
|
|
142
142
|
retries?: number;
|
|
143
143
|
}
|
|
144
|
-
interface LLMParsedResponse<T> {
|
|
145
|
-
data: T;
|
|
146
|
-
usage?: {
|
|
147
|
-
prompt_tokens: number;
|
|
148
|
-
completion_tokens: number;
|
|
149
|
-
total_tokens: number;
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
144
|
declare abstract class LLMClient {
|
|
153
145
|
type: "openai" | "anthropic" | "cerebras" | "groq" | (string & {});
|
|
154
146
|
modelName: AvailableModel | (string & {});
|
|
@@ -156,15 +148,9 @@ declare abstract class LLMClient {
|
|
|
156
148
|
clientOptions: ClientOptions;
|
|
157
149
|
userProvidedInstructions?: string;
|
|
158
150
|
constructor(modelName: AvailableModel, userProvidedInstructions?: string);
|
|
159
|
-
abstract createChatCompletion<T
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
name: string;
|
|
163
|
-
schema: ZodType;
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
}): Promise<LLMParsedResponse<T>>;
|
|
167
|
-
abstract createChatCompletion<T = LLMResponse>(options: CreateChatCompletionOptions): Promise<T>;
|
|
151
|
+
abstract createChatCompletion<T = LLMResponse & {
|
|
152
|
+
usage?: LLMResponse["usage"];
|
|
153
|
+
}>(options: CreateChatCompletionOptions): Promise<T>;
|
|
168
154
|
generateObject: typeof generateObject;
|
|
169
155
|
generateText: typeof generateText;
|
|
170
156
|
streamText: typeof streamText;
|
|
@@ -213,11 +199,7 @@ declare class CdpConnection implements CDPSessionLike {
|
|
|
213
199
|
close(): Promise<void>;
|
|
214
200
|
getSession(sessionId: string): CdpSession | undefined;
|
|
215
201
|
attachToTarget(targetId: string): Promise<CdpSession>;
|
|
216
|
-
getTargets(): Promise<
|
|
217
|
-
targetId: string;
|
|
218
|
-
type: string;
|
|
219
|
-
url: string;
|
|
220
|
-
}>>;
|
|
202
|
+
getTargets(): Promise<Protocol.Target.TargetInfo[]>;
|
|
221
203
|
private onMessage;
|
|
222
204
|
_sendViaSession<R = unknown>(sessionId: string, method: string, params?: object): Promise<R>;
|
|
223
205
|
_onSessionEvent(sessionId: string, event: string, handler: EventHandler): void;
|
|
@@ -737,6 +719,14 @@ declare class Response$1 {
|
|
|
737
719
|
* richer metadata.
|
|
738
720
|
*/
|
|
739
721
|
applyExtraInfo(event: Protocol.Network.ResponseReceivedExtraInfoEvent): void;
|
|
722
|
+
/**
|
|
723
|
+
* Internal helper for creating a Response object from a Serializable
|
|
724
|
+
* goto response from the Stagehand API
|
|
725
|
+
*/
|
|
726
|
+
static fromSerializable(serialized: SerializableResponse, context: {
|
|
727
|
+
page: Page;
|
|
728
|
+
session: CDPSessionLike;
|
|
729
|
+
}): Response$1;
|
|
740
730
|
/** Marks the response as finished and resolves the `finished()` promise. */
|
|
741
731
|
markFinished(error: Error | null): void;
|
|
742
732
|
}
|
|
@@ -755,11 +745,11 @@ declare class StagehandAPIClient {
|
|
|
755
745
|
constructor({ apiKey, projectId, logger }: StagehandAPIConstructorParams);
|
|
756
746
|
init({ modelName, modelApiKey, domSettleTimeoutMs, verbose, systemPrompt, selfHeal, browserbaseSessionCreateParams, browserbaseSessionID, }: StartSessionParams): Promise<StartSessionResult>;
|
|
757
747
|
act({ input, options, frameId }: APIActParameters): Promise<ActResult>;
|
|
758
|
-
extract<T extends z.
|
|
748
|
+
extract<T extends z.AnyZodObject>({ instruction, schema: zodSchema, options, frameId, }: APIExtractParameters): Promise<ExtractResult<T>>;
|
|
759
749
|
observe({ instruction, options, frameId, }: APIObserveParameters): Promise<Action[]>;
|
|
760
750
|
goto(url: string, options?: {
|
|
761
751
|
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
762
|
-
}, frameId?: string): Promise<
|
|
752
|
+
}, frameId?: string): Promise<SerializableResponse | null>;
|
|
763
753
|
agentExecute(agentConfig: AgentConfig, executeOptions: AgentExecuteOptions | string, frameId?: string): Promise<AgentResult>;
|
|
764
754
|
end(): Promise<Response>;
|
|
765
755
|
getReplayMetrics(): Promise<StagehandMetrics>;
|
|
@@ -1307,7 +1297,7 @@ interface ActResult {
|
|
|
1307
1297
|
actionDescription: string;
|
|
1308
1298
|
actions: Action[];
|
|
1309
1299
|
}
|
|
1310
|
-
type ExtractResult<T extends z.
|
|
1300
|
+
type ExtractResult<T extends z$1.AnyZodObject> = z$1.infer<T>;
|
|
1311
1301
|
interface Action {
|
|
1312
1302
|
selector: string;
|
|
1313
1303
|
description: string;
|
|
@@ -1326,12 +1316,20 @@ interface ExtractOptions {
|
|
|
1326
1316
|
selector?: string;
|
|
1327
1317
|
page?: Page$1 | Page$2 | Page$3 | Page;
|
|
1328
1318
|
}
|
|
1329
|
-
declare const defaultExtractSchema: z.ZodObject<{
|
|
1330
|
-
extraction: z.ZodString;
|
|
1331
|
-
}, z.
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1319
|
+
declare const defaultExtractSchema: z$1.ZodObject<{
|
|
1320
|
+
extraction: z$1.ZodString;
|
|
1321
|
+
}, "strip", z$1.ZodTypeAny, {
|
|
1322
|
+
extraction?: string;
|
|
1323
|
+
}, {
|
|
1324
|
+
extraction?: string;
|
|
1325
|
+
}>;
|
|
1326
|
+
declare const pageTextSchema: z$1.ZodObject<{
|
|
1327
|
+
pageText: z$1.ZodString;
|
|
1328
|
+
}, "strip", z$1.ZodTypeAny, {
|
|
1329
|
+
pageText?: string;
|
|
1330
|
+
}, {
|
|
1331
|
+
pageText?: string;
|
|
1332
|
+
}>;
|
|
1335
1333
|
interface ObserveOptions {
|
|
1336
1334
|
model?: ModelConfiguration;
|
|
1337
1335
|
timeout?: number;
|
|
@@ -1506,6 +1504,9 @@ declare class ExperimentalApiConflictError extends StagehandError {
|
|
|
1506
1504
|
declare class ExperimentalNotConfiguredError extends StagehandError {
|
|
1507
1505
|
constructor(featureName: string);
|
|
1508
1506
|
}
|
|
1507
|
+
declare class CuaModelRequiredError extends StagehandError {
|
|
1508
|
+
constructor(availableModels: readonly string[]);
|
|
1509
|
+
}
|
|
1509
1510
|
declare class ZodSchemaValidationError extends Error {
|
|
1510
1511
|
readonly received: unknown;
|
|
1511
1512
|
readonly issues: ReturnType<ZodError["format"]>;
|
|
@@ -1528,6 +1529,24 @@ declare class StagehandShadowSegmentEmptyError extends StagehandError {
|
|
|
1528
1529
|
declare class StagehandShadowSegmentNotFoundError extends StagehandError {
|
|
1529
1530
|
constructor(segment: string, hint?: string);
|
|
1530
1531
|
}
|
|
1532
|
+
declare class ElementNotVisibleError extends StagehandError {
|
|
1533
|
+
constructor(selector: string);
|
|
1534
|
+
}
|
|
1535
|
+
declare class ResponseBodyError extends StagehandError {
|
|
1536
|
+
constructor(message: string);
|
|
1537
|
+
}
|
|
1538
|
+
declare class ResponseParseError extends StagehandError {
|
|
1539
|
+
constructor(message: string);
|
|
1540
|
+
}
|
|
1541
|
+
declare class TimeoutError extends StagehandError {
|
|
1542
|
+
constructor(operation: string, timeoutMs: number);
|
|
1543
|
+
}
|
|
1544
|
+
declare class PageNotFoundError extends StagehandError {
|
|
1545
|
+
constructor(identifier: string);
|
|
1546
|
+
}
|
|
1547
|
+
declare class ConnectionTimeoutError extends StagehandError {
|
|
1548
|
+
constructor(message: string);
|
|
1549
|
+
}
|
|
1531
1550
|
|
|
1532
1551
|
declare class AISdkClient extends LLMClient {
|
|
1533
1552
|
type: "aisdk";
|
|
@@ -1575,6 +1594,16 @@ interface APIObserveParameters {
|
|
|
1575
1594
|
options?: ObserveOptions;
|
|
1576
1595
|
frameId?: string;
|
|
1577
1596
|
}
|
|
1597
|
+
interface SerializableResponse {
|
|
1598
|
+
requestId: string;
|
|
1599
|
+
frameId?: string;
|
|
1600
|
+
loaderId?: string;
|
|
1601
|
+
response: Protocol.Network.Response;
|
|
1602
|
+
fromServiceWorkerFlag?: boolean;
|
|
1603
|
+
finishedSettled?: boolean;
|
|
1604
|
+
extraInfoHeaders?: Protocol.Network.Headers | null;
|
|
1605
|
+
extraInfoHeadersText?: string;
|
|
1606
|
+
}
|
|
1578
1607
|
|
|
1579
1608
|
/**
|
|
1580
1609
|
* Represents a path through a Zod schema from the root object down to a
|
|
@@ -1678,6 +1707,7 @@ declare class V3Context {
|
|
|
1678
1707
|
* We poll internal maps that bootstrap/onAttachedToTarget populate.
|
|
1679
1708
|
*/
|
|
1680
1709
|
private waitForFirstTopLevelPage;
|
|
1710
|
+
private waitForInitialTopLevelTargets;
|
|
1681
1711
|
private ensurePiercer;
|
|
1682
1712
|
/** Mark a page target as the most-recent one (active). */
|
|
1683
1713
|
private _pushActive;
|
|
@@ -1899,10 +1929,10 @@ declare class V3 {
|
|
|
1899
1929
|
* - extract(instruction, schema) → schema-inferred
|
|
1900
1930
|
* - extract(instruction, schema, options)
|
|
1901
1931
|
*/
|
|
1902
|
-
extract(): Promise<z.infer<typeof pageTextSchema>>;
|
|
1903
|
-
extract(options: ExtractOptions): Promise<z.infer<typeof pageTextSchema>>;
|
|
1904
|
-
extract(instruction: string, options?: ExtractOptions): Promise<z.infer<typeof defaultExtractSchema>>;
|
|
1905
|
-
extract<T extends ZodTypeAny>(instruction: string, schema: T, options?: ExtractOptions): Promise<z.infer<T>>;
|
|
1932
|
+
extract(): Promise<z$1.infer<typeof pageTextSchema>>;
|
|
1933
|
+
extract(options: ExtractOptions): Promise<z$1.infer<typeof pageTextSchema>>;
|
|
1934
|
+
extract(instruction: string, options?: ExtractOptions): Promise<z$1.infer<typeof defaultExtractSchema>>;
|
|
1935
|
+
extract<T extends ZodTypeAny>(instruction: string, schema: T, options?: ExtractOptions): Promise<z$1.infer<T>>;
|
|
1906
1936
|
/**
|
|
1907
1937
|
* Run an "observe" instruction through the ObserveHandler.
|
|
1908
1938
|
*/
|
|
@@ -1974,14 +2004,14 @@ declare class AgentProvider {
|
|
|
1974
2004
|
static getAgentProvider(modelName: string): AgentProviderType;
|
|
1975
2005
|
}
|
|
1976
2006
|
|
|
1977
|
-
declare function validateZodSchema(schema: z.ZodTypeAny, data: unknown): boolean;
|
|
2007
|
+
declare function validateZodSchema(schema: z$1.ZodTypeAny, data: unknown): boolean;
|
|
1978
2008
|
/**
|
|
1979
2009
|
* Detects if the code is running in the Bun runtime environment.
|
|
1980
2010
|
* @returns {boolean} True if running in Bun, false otherwise.
|
|
1981
2011
|
*/
|
|
1982
2012
|
declare function isRunningInBun(): boolean;
|
|
1983
|
-
declare function toGeminiSchema(zodSchema: z.ZodTypeAny): Schema;
|
|
1984
|
-
declare function getZodType(schema: z.ZodTypeAny): string;
|
|
2013
|
+
declare function toGeminiSchema(zodSchema: z$1.ZodTypeAny): Schema;
|
|
2014
|
+
declare function getZodType(schema: z$1.ZodTypeAny): string;
|
|
1985
2015
|
/**
|
|
1986
2016
|
* Recursively traverses a given Zod schema, scanning for any fields of type `z.string().url()`.
|
|
1987
2017
|
* For each such field, it replaces the `z.string().url()` with `z.number()`.
|
|
@@ -1995,7 +2025,7 @@ declare function getZodType(schema: z.ZodTypeAny): string;
|
|
|
1995
2025
|
* 1. The updated Zod schema, with any `.url()` fields replaced by `z.number()`.
|
|
1996
2026
|
* 2. An array of {@link ZodPathSegments} objects representing each replaced field, including the path segments.
|
|
1997
2027
|
*/
|
|
1998
|
-
declare function transformSchema(schema: z.ZodTypeAny, currentPath: Array<string | number>): [z.ZodTypeAny, ZodPathSegments[]];
|
|
2028
|
+
declare function transformSchema(schema: z$1.ZodTypeAny, currentPath: Array<string | number>): [z$1.ZodTypeAny, ZodPathSegments[]];
|
|
1999
2029
|
/**
|
|
2000
2030
|
* Once we get the final extracted object that has numeric IDs in place of URLs,
|
|
2001
2031
|
* use `injectUrls` to walk the object and replace numeric IDs
|
|
@@ -2064,4 +2094,4 @@ declare class V3Evaluator {
|
|
|
2064
2094
|
private _evaluateWithMultipleScreenshots;
|
|
2065
2095
|
}
|
|
2066
2096
|
|
|
2067
|
-
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, type ConsoleListener, ConsoleMessage, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, type FunctionCallItem, HandlerNotInitializedError, type HistoryEntry, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaProperty, LLMClient, type
|
|
2097
|
+
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 LLMResponse, LLMResponseError, type LLMTool, 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 };
|