@browserbasehq/orca 3.0.0-preview.7 → 3.0.0-test.1
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 +47 -32
- package/dist/index.js +303 -232
- package/package.json +3 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ZodType, z, ZodError, ZodTypeAny } from 'zod';
|
|
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';
|
|
@@ -140,6 +140,14 @@ interface CreateChatCompletionOptions {
|
|
|
140
140
|
logger: (message: LogLine) => void;
|
|
141
141
|
retries?: number;
|
|
142
142
|
}
|
|
143
|
+
interface LLMParsedResponse<T> {
|
|
144
|
+
data: T;
|
|
145
|
+
usage?: {
|
|
146
|
+
prompt_tokens: number;
|
|
147
|
+
completion_tokens: number;
|
|
148
|
+
total_tokens: number;
|
|
149
|
+
};
|
|
150
|
+
}
|
|
143
151
|
declare abstract class LLMClient {
|
|
144
152
|
type: "openai" | "anthropic" | "cerebras" | "groq" | (string & {});
|
|
145
153
|
modelName: AvailableModel | (string & {});
|
|
@@ -147,9 +155,15 @@ declare abstract class LLMClient {
|
|
|
147
155
|
clientOptions: ClientOptions;
|
|
148
156
|
userProvidedInstructions?: string;
|
|
149
157
|
constructor(modelName: AvailableModel, userProvidedInstructions?: string);
|
|
150
|
-
abstract createChatCompletion<T
|
|
151
|
-
|
|
152
|
-
|
|
158
|
+
abstract createChatCompletion<T>(options: CreateChatCompletionOptions & {
|
|
159
|
+
options: {
|
|
160
|
+
response_model: {
|
|
161
|
+
name: string;
|
|
162
|
+
schema: ZodType;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
}): Promise<LLMParsedResponse<T>>;
|
|
166
|
+
abstract createChatCompletion<T = LLMResponse>(options: CreateChatCompletionOptions): Promise<T>;
|
|
153
167
|
generateObject: typeof generateObject;
|
|
154
168
|
generateText: typeof generateText;
|
|
155
169
|
streamText: typeof streamText;
|
|
@@ -522,6 +536,15 @@ declare class DeepLocatorDelegate {
|
|
|
522
536
|
composed?: boolean;
|
|
523
537
|
detail?: number;
|
|
524
538
|
}): Promise<void>;
|
|
539
|
+
setInputFiles(files: string | string[] | {
|
|
540
|
+
name: string;
|
|
541
|
+
mimeType: string;
|
|
542
|
+
buffer: ArrayBuffer | Uint8Array | Buffer | string;
|
|
543
|
+
} | Array<{
|
|
544
|
+
name: string;
|
|
545
|
+
mimeType: string;
|
|
546
|
+
buffer: ArrayBuffer | Uint8Array | Buffer | string;
|
|
547
|
+
}>): Promise<void>;
|
|
525
548
|
first(): DeepLocatorDelegate;
|
|
526
549
|
nth(index: number): DeepLocatorDelegate;
|
|
527
550
|
}
|
|
@@ -583,7 +606,7 @@ declare class StagehandAPIClient {
|
|
|
583
606
|
constructor({ apiKey, projectId, logger }: StagehandAPIConstructorParams);
|
|
584
607
|
init({ modelName, modelApiKey, domSettleTimeoutMs, verbose, systemPrompt, selfHeal, browserbaseSessionCreateParams, browserbaseSessionID, }: StartSessionParams): Promise<StartSessionResult>;
|
|
585
608
|
act({ input, options, frameId }: APIActParameters): Promise<ActResult>;
|
|
586
|
-
extract<T extends z.
|
|
609
|
+
extract<T extends z.ZodObject>({ instruction, schema: zodSchema, options, frameId, }: APIExtractParameters): Promise<ExtractResult<T>>;
|
|
587
610
|
observe({ instruction, options, frameId, }: APIObserveParameters): Promise<Action[]>;
|
|
588
611
|
goto(url: string, options?: {
|
|
589
612
|
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
@@ -1052,7 +1075,7 @@ interface ActResult {
|
|
|
1052
1075
|
actionDescription: string;
|
|
1053
1076
|
actions: Action[];
|
|
1054
1077
|
}
|
|
1055
|
-
type ExtractResult<T extends z
|
|
1078
|
+
type ExtractResult<T extends z.ZodObject> = z.infer<T>;
|
|
1056
1079
|
interface Action {
|
|
1057
1080
|
selector: string;
|
|
1058
1081
|
description: string;
|
|
@@ -1071,20 +1094,12 @@ interface ExtractOptions {
|
|
|
1071
1094
|
selector?: string;
|
|
1072
1095
|
page?: Page$1 | Page$2 | Page$3 | Page;
|
|
1073
1096
|
}
|
|
1074
|
-
declare const defaultExtractSchema: z
|
|
1075
|
-
extraction: z
|
|
1076
|
-
},
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
}>;
|
|
1081
|
-
declare const pageTextSchema: z$1.ZodObject<{
|
|
1082
|
-
pageText: z$1.ZodString;
|
|
1083
|
-
}, "strip", z$1.ZodTypeAny, {
|
|
1084
|
-
pageText?: string;
|
|
1085
|
-
}, {
|
|
1086
|
-
pageText?: string;
|
|
1087
|
-
}>;
|
|
1097
|
+
declare const defaultExtractSchema: z.ZodObject<{
|
|
1098
|
+
extraction: z.ZodString;
|
|
1099
|
+
}, z.core.$strip>;
|
|
1100
|
+
declare const pageTextSchema: z.ZodObject<{
|
|
1101
|
+
pageText: z.ZodString;
|
|
1102
|
+
}, z.core.$strip>;
|
|
1088
1103
|
interface ObserveOptions {
|
|
1089
1104
|
model?: ModelConfiguration;
|
|
1090
1105
|
timeout?: number;
|
|
@@ -1098,7 +1113,7 @@ declare enum V3FunctionName {
|
|
|
1098
1113
|
AGENT = "AGENT"
|
|
1099
1114
|
}
|
|
1100
1115
|
|
|
1101
|
-
interface
|
|
1116
|
+
interface StagehandMetrics {
|
|
1102
1117
|
actPromptTokens: number;
|
|
1103
1118
|
actCompletionTokens: number;
|
|
1104
1119
|
actInferenceTimeMs: number;
|
|
@@ -1591,13 +1606,13 @@ declare class V3 {
|
|
|
1591
1606
|
private actCache;
|
|
1592
1607
|
private agentCache;
|
|
1593
1608
|
private apiClient;
|
|
1594
|
-
|
|
1609
|
+
stagehandMetrics: StagehandMetrics;
|
|
1595
1610
|
constructor(opts: V3Options);
|
|
1596
1611
|
/**
|
|
1597
1612
|
* Async property for metrics so callers can `await v3.metrics`.
|
|
1598
1613
|
* Returning a Promise future-proofs async aggregation/storage.
|
|
1599
1614
|
*/
|
|
1600
|
-
get metrics(): Promise<
|
|
1615
|
+
get metrics(): Promise<StagehandMetrics>;
|
|
1601
1616
|
private resolveLlmClient;
|
|
1602
1617
|
private beginAgentReplayRecording;
|
|
1603
1618
|
private endAgentReplayRecording;
|
|
@@ -1642,10 +1657,10 @@ declare class V3 {
|
|
|
1642
1657
|
* - extract(instruction, schema) → schema-inferred
|
|
1643
1658
|
* - extract(instruction, schema, options)
|
|
1644
1659
|
*/
|
|
1645
|
-
extract(): Promise<z
|
|
1646
|
-
extract(options: ExtractOptions): Promise<z
|
|
1647
|
-
extract(instruction: string, options?: ExtractOptions): Promise<z
|
|
1648
|
-
extract<T extends ZodTypeAny>(instruction: string, schema: T, options?: ExtractOptions): Promise<z
|
|
1660
|
+
extract(): Promise<z.infer<typeof pageTextSchema>>;
|
|
1661
|
+
extract(options: ExtractOptions): Promise<z.infer<typeof pageTextSchema>>;
|
|
1662
|
+
extract(instruction: string, options?: ExtractOptions): Promise<z.infer<typeof defaultExtractSchema>>;
|
|
1663
|
+
extract<T extends ZodTypeAny>(instruction: string, schema: T, options?: ExtractOptions): Promise<z.infer<T>>;
|
|
1649
1664
|
/**
|
|
1650
1665
|
* Run an "observe" instruction through the ObserveHandler.
|
|
1651
1666
|
*/
|
|
@@ -1717,14 +1732,14 @@ declare class AgentProvider {
|
|
|
1717
1732
|
static getAgentProvider(modelName: string): AgentProviderType;
|
|
1718
1733
|
}
|
|
1719
1734
|
|
|
1720
|
-
declare function validateZodSchema(schema: z
|
|
1735
|
+
declare function validateZodSchema(schema: z.ZodTypeAny, data: unknown): boolean;
|
|
1721
1736
|
/**
|
|
1722
1737
|
* Detects if the code is running in the Bun runtime environment.
|
|
1723
1738
|
* @returns {boolean} True if running in Bun, false otherwise.
|
|
1724
1739
|
*/
|
|
1725
1740
|
declare function isRunningInBun(): boolean;
|
|
1726
|
-
declare function toGeminiSchema(zodSchema: z
|
|
1727
|
-
declare function getZodType(schema: z
|
|
1741
|
+
declare function toGeminiSchema(zodSchema: z.ZodTypeAny): Schema;
|
|
1742
|
+
declare function getZodType(schema: z.ZodTypeAny): string;
|
|
1728
1743
|
/**
|
|
1729
1744
|
* Recursively traverses a given Zod schema, scanning for any fields of type `z.string().url()`.
|
|
1730
1745
|
* For each such field, it replaces the `z.string().url()` with `z.number()`.
|
|
@@ -1738,7 +1753,7 @@ declare function getZodType(schema: z$1.ZodTypeAny): string;
|
|
|
1738
1753
|
* 1. The updated Zod schema, with any `.url()` fields replaced by `z.number()`.
|
|
1739
1754
|
* 2. An array of {@link ZodPathSegments} objects representing each replaced field, including the path segments.
|
|
1740
1755
|
*/
|
|
1741
|
-
declare function transformSchema(schema: z
|
|
1756
|
+
declare function transformSchema(schema: z.ZodTypeAny, currentPath: Array<string | number>): [z.ZodTypeAny, ZodPathSegments[]];
|
|
1742
1757
|
/**
|
|
1743
1758
|
* Once we get the final extracted object that has numeric IDs in place of URLs,
|
|
1744
1759
|
* use `injectUrls` to walk the object and replace numeric IDs
|
|
@@ -1807,4 +1822,4 @@ declare class V3Evaluator {
|
|
|
1807
1822
|
private _evaluateWithMultipleScreenshots;
|
|
1808
1823
|
}
|
|
1809
1824
|
|
|
1810
|
-
export { type AISDKCustomProvider, type AISDKProvider, 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, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, 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, type ResponseInputItem, type ResponseItem, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, type ToolUseItem, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type
|
|
1825
|
+
export { type AISDKCustomProvider, type AISDKProvider, 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, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, type FunctionCallItem, HandlerNotInitializedError, type HistoryEntry, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaProperty, LLMClient, type LLMParsedResponse, 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, type ResponseInputItem, type ResponseItem, 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 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 };
|