@browserbasehq/orca 3.0.0-preview.1 → 3.0.0-preview.4
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 +806 -682
- package/dist/index.js +34207 -23774
- package/package.json +46 -83
- package/LICENSE +0 -21
- package/README.md +0 -165
- package/dist/lib/StagehandContext.d.ts +0 -25
- package/dist/lib/StagehandPage.d.ts +0 -103
- package/dist/lib/a11y/utils.d.ts +0 -144
- package/dist/lib/agent/AgentClient.d.ts +0 -20
- package/dist/lib/agent/AgentProvider.d.ts +0 -19
- package/dist/lib/agent/AnthropicCUAClient.d.ts +0 -56
- package/dist/lib/agent/GoogleCUAClient.d.ts +0 -63
- package/dist/lib/agent/OpenAICUAClient.d.ts +0 -65
- package/dist/lib/agent/StagehandAgent.d.ts +0 -15
- package/dist/lib/agent/tools/act.d.ts +0 -59
- package/dist/lib/agent/tools/ariaTree.d.ts +0 -11
- package/dist/lib/agent/tools/close.d.ts +0 -22
- package/dist/lib/agent/tools/extract.d.ts +0 -38
- package/dist/lib/agent/tools/fillform.d.ts +0 -37
- package/dist/lib/agent/tools/goto.d.ts +0 -29
- package/dist/lib/agent/tools/index.d.ts +0 -257
- package/dist/lib/agent/tools/navback.d.ts +0 -17
- package/dist/lib/agent/tools/screenshot.d.ts +0 -13
- package/dist/lib/agent/tools/scroll.d.ts +0 -23
- package/dist/lib/agent/tools/wait.d.ts +0 -18
- package/dist/lib/agent/utils/cuaKeyMapping.d.ts +0 -10
- package/dist/lib/agent/utils/imageCompression.d.ts +0 -53
- package/dist/lib/agent/utils/messageProcessing.d.ts +0 -13
- package/dist/lib/api.d.ts +0 -23
- package/dist/lib/browserbaseDefaults.d.ts +0 -9
- package/dist/lib/cache/ActionCache.d.ts +0 -62
- package/dist/lib/cache/BaseCache.d.ts +0 -66
- package/dist/lib/cache/LLMCache.d.ts +0 -22
- package/dist/lib/cache.d.ts +0 -29
- package/dist/lib/dom/build/scriptContent.d.ts +0 -1
- package/dist/lib/dom/elementCheckUtils.d.ts +0 -2
- package/dist/lib/dom/genDomScripts.d.ts +0 -1
- package/dist/lib/dom/index.d.ts +0 -2
- package/dist/lib/dom/process.d.ts +0 -17
- package/dist/lib/dom/utils.d.ts +0 -7
- package/dist/lib/dom/xpathUtils.d.ts +0 -14
- package/dist/lib/handlers/actHandler.d.ts +0 -33
- package/dist/lib/handlers/cuaAgentHandler.d.ts +0 -58
- package/dist/lib/handlers/extractHandler.d.ts +0 -54
- package/dist/lib/handlers/handlerUtils/actHandlerUtils.d.ts +0 -21
- package/dist/lib/handlers/observeHandler.d.ts +0 -40
- package/dist/lib/handlers/stagehandAgentHandler.d.ts +0 -27
- package/dist/lib/index.d.ts +0 -94
- package/dist/lib/inference.d.ts +0 -71
- package/dist/lib/inferenceLogUtils.d.ts +0 -12
- package/dist/lib/llm/AnthropicClient.d.ts +0 -21
- package/dist/lib/llm/CerebrasClient.d.ts +0 -22
- package/dist/lib/llm/GoogleClient.d.ts +0 -24
- package/dist/lib/llm/GroqClient.d.ts +0 -22
- package/dist/lib/llm/LLMClient.d.ts +0 -99
- package/dist/lib/llm/LLMProvider.d.ts +0 -13
- package/dist/lib/llm/OpenAIClient.d.ts +0 -20
- package/dist/lib/llm/aisdk.d.ts +0 -20
- package/dist/lib/logger.d.ts +0 -54
- package/dist/lib/mcp/connection.d.ts +0 -11
- package/dist/lib/mcp/utils.d.ts +0 -3
- package/dist/lib/prompt.d.ts +0 -12
- package/dist/lib/utils.d.ts +0 -65
- package/dist/lib/v3/agent/AgentClient.d.ts +0 -18
- package/dist/lib/v3/agent/AgentProvider.d.ts +0 -18
- package/dist/lib/v3/agent/AnthropicCUAClient.d.ts +0 -55
- package/dist/lib/v3/agent/OpenAICUAClient.d.ts +0 -64
- package/dist/lib/v3/agent/StagehandAgent.d.ts +0 -15
- package/dist/lib/v3/agent/tools/index.d.ts +0 -229
- package/dist/lib/v3/agent/tools/v3-act.d.ts +0 -29
- package/dist/lib/v3/agent/tools/v3-ariaTree.d.ts +0 -11
- package/dist/lib/v3/agent/tools/v3-close.d.ts +0 -24
- package/dist/lib/v3/agent/tools/v3-extract.d.ts +0 -38
- package/dist/lib/v3/agent/tools/v3-fillform.d.ts +0 -37
- package/dist/lib/v3/agent/tools/v3-goto.d.ts +0 -29
- package/dist/lib/v3/agent/tools/v3-navback.d.ts +0 -17
- package/dist/lib/v3/agent/tools/v3-screenshot.d.ts +0 -13
- package/dist/lib/v3/agent/tools/v3-scroll.d.ts +0 -23
- package/dist/lib/v3/agent/tools/v3-wait.d.ts +0 -19
- package/dist/lib/v3/agent/utils/cuaKeyMapping.d.ts +0 -10
- package/dist/lib/v3/agent/utils/imageCompression.d.ts +0 -18
- package/dist/lib/v3/agent/utils/messageProcessing.d.ts +0 -13
- package/dist/lib/v3/dom/build/scriptV3Content.d.ts +0 -1
- package/dist/lib/v3/dom/genDomScripts.d.ts +0 -1
- package/dist/lib/v3/dom/index.d.ts +0 -1
- package/dist/lib/v3/dom/piercer.entry.d.ts +0 -1
- package/dist/lib/v3/dom/piercer.runtime.d.ts +0 -25
- package/dist/lib/v3/handlers/actHandler.d.ts +0 -18
- package/dist/lib/v3/handlers/extractHandler.d.ts +0 -29
- package/dist/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +0 -18
- package/dist/lib/v3/handlers/observeHandler.d.ts +0 -15
- package/dist/lib/v3/handlers/v3AgentHandler.d.ts +0 -17
- package/dist/lib/v3/handlers/v3CuaAgentHandler.d.ts +0 -26
- package/dist/lib/v3/index.d.ts +0 -10
- package/dist/lib/v3/launch/browserbase.d.ts +0 -8
- package/dist/lib/v3/launch/local.d.ts +0 -13
- package/dist/lib/v3/llm/AnthropicClient.d.ts +0 -16
- package/dist/lib/v3/llm/CerebrasClient.d.ts +0 -17
- package/dist/lib/v3/llm/GoogleClient.d.ts +0 -19
- package/dist/lib/v3/llm/GroqClient.d.ts +0 -17
- package/dist/lib/v3/llm/LLMClient.d.ts +0 -99
- package/dist/lib/v3/llm/LLMProvider.d.ts +0 -10
- package/dist/lib/v3/llm/OpenAIClient.d.ts +0 -15
- package/dist/lib/v3/llm/aisdk.d.ts +0 -15
- package/dist/lib/v3/logger.d.ts +0 -48
- package/dist/lib/v3/mcp/connection.d.ts +0 -11
- package/dist/lib/v3/mcp/utils.d.ts +0 -3
- package/dist/lib/v3/tests/default-page-tracking.spec.d.ts +0 -1
- package/dist/lib/v3/tests/downloads.spec.d.ts +0 -1
- package/dist/lib/v3/tests/perform-understudy-method.spec.d.ts +0 -1
- package/dist/lib/v3/tests/shadow-iframe.spec.d.ts +0 -1
- package/dist/lib/v3/tests/timeouts.spec.d.ts +0 -1
- package/dist/lib/v3/tests/v3.bb.config.d.ts +0 -4
- package/dist/lib/v3/tests/v3.config.d.ts +0 -4
- package/dist/lib/v3/tests/v3.playwright.config.d.ts +0 -2
- package/dist/lib/v3/tests/xpath-for-location-deep.spec.d.ts +0 -1
- package/dist/lib/v3/types/act.d.ts +0 -10
- package/dist/lib/v3/types/agent.d.ts +0 -132
- package/dist/lib/v3/types/api.d.ts +0 -40
- package/dist/lib/v3/types/cache.d.ts +0 -71
- package/dist/lib/v3/types/context.d.ts +0 -2
- package/dist/lib/v3/types/evals.d.ts +0 -71
- package/dist/lib/v3/types/evaluator.d.ts +0 -40
- package/dist/lib/v3/types/llm.d.ts +0 -11
- package/dist/lib/v3/types/log.d.ts +0 -23
- package/dist/lib/v3/types/model.d.ts +0 -20
- package/dist/lib/v3/types/playwright.d.ts +0 -6
- package/dist/lib/v3/types/stagehand.d.ts +0 -113
- package/dist/lib/v3/types/stagehandApiErrors.d.ts +0 -18
- package/dist/lib/v3/types/stagehandErrors.d.ts +0 -104
- package/dist/lib/v3/types.d.ts +0 -176
- package/dist/lib/v3/understudy/a11y/snapshot.d.ts +0 -71
- package/dist/lib/v3/understudy/cdp.d.ts +0 -58
- package/dist/lib/v3/understudy/context.d.ts +0 -120
- package/dist/lib/v3/understudy/deepLocator.d.ts +0 -69
- package/dist/lib/v3/understudy/executionContextRegistry.d.ts +0 -15
- package/dist/lib/v3/understudy/frame.d.ts +0 -63
- package/dist/lib/v3/understudy/frameLocator.d.ts +0 -46
- package/dist/lib/v3/understudy/frameRegistry.d.ts +0 -100
- package/dist/lib/v3/understudy/locator.d.ts +0 -196
- package/dist/lib/v3/understudy/page.d.ts +0 -241
- package/dist/lib/v3/understudy/piercer.d.ts +0 -4
- package/dist/lib/v3/v3.d.ts +0 -158
- package/dist/lib/version.d.ts +0 -5
- package/dist/stagehand.config.d.ts +0 -3
- package/dist/types/act.d.ts +0 -50
- package/dist/types/agent.d.ts +0 -143
- package/dist/types/api.d.ts +0 -40
- package/dist/types/browser.d.ts +0 -10
- package/dist/types/context.d.ts +0 -117
- package/dist/types/evals.d.ts +0 -94
- package/dist/types/evaluator.d.ts +0 -40
- package/dist/types/llm.d.ts +0 -11
- package/dist/types/log.d.ts +0 -23
- package/dist/types/model.d.ts +0 -17
- package/dist/types/page.d.ts +0 -38
- package/dist/types/playwright.d.ts +0 -12
- package/dist/types/stagehand.d.ts +0 -330
- package/dist/types/stagehandApiErrors.d.ts +0 -18
- package/dist/types/stagehandErrors.d.ts +0 -104
package/dist/lib/v3/v3.d.ts
DELETED
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { V3Options, ActOptions, ObserveOptions, V3Metrics, V3FunctionName, ExtractOptions } from "@/lib/v3/types";
|
|
2
|
-
import { V3Context } from "@/lib/v3/understudy/context";
|
|
3
|
-
import { LLMClient } from "./llm/LLMClient";
|
|
4
|
-
import { z } from "zod/v3";
|
|
5
|
-
import type { ZodTypeAny } from "zod/v3";
|
|
6
|
-
import { Action, ActResult, HistoryEntry, AgentConfig } from "./types/stagehand";
|
|
7
|
-
import { AgentExecuteOptions, AgentResult } from "./types/agent";
|
|
8
|
-
import { LogLine } from "./types/log";
|
|
9
|
-
import { defaultExtractSchema, pageTextSchema } from "./types";
|
|
10
|
-
import type { AgentReplayStep } from "./types/cache";
|
|
11
|
-
/**
|
|
12
|
-
* V3
|
|
13
|
-
*
|
|
14
|
-
* Purpose:
|
|
15
|
-
* A high-level orchestrator for Stagehand V3. Abstracts away whether the browser
|
|
16
|
-
* runs **locally via Chrome** or remotely on **Browserbase**, and exposes simple
|
|
17
|
-
* entrypoints (`act`, `extract`, `observe`) that delegate to the corresponding
|
|
18
|
-
* handler classes.
|
|
19
|
-
*
|
|
20
|
-
* Responsibilities:
|
|
21
|
-
* - Bootstraps Chrome or Browserbase, ensures a working CDP WebSocket, and builds a `V3Context`.
|
|
22
|
-
* - Manages lifecycle: init, context access, cleanup.
|
|
23
|
-
* - Bridges external page objects (Playwright/Puppeteer) into internal frameIds for handlers.
|
|
24
|
-
* - Provides a stable API surface for downstream code regardless of runtime environment.
|
|
25
|
-
*/
|
|
26
|
-
export declare class V3 {
|
|
27
|
-
private readonly opts;
|
|
28
|
-
private state;
|
|
29
|
-
private actHandler;
|
|
30
|
-
private extractHandler;
|
|
31
|
-
private observeHandler;
|
|
32
|
-
private ctx;
|
|
33
|
-
llmClient: LLMClient;
|
|
34
|
-
private modelName;
|
|
35
|
-
private modelClientOptions;
|
|
36
|
-
private llmProvider;
|
|
37
|
-
private readonly domSettleTimeoutMs?;
|
|
38
|
-
private _isClosing;
|
|
39
|
-
browserbaseSessionId?: string;
|
|
40
|
-
private _onCdpClosed;
|
|
41
|
-
readonly experimental: boolean;
|
|
42
|
-
readonly logInferenceToFile: boolean;
|
|
43
|
-
private externalLogger?;
|
|
44
|
-
verbose: 0 | 1 | 2;
|
|
45
|
-
private _history;
|
|
46
|
-
private readonly instanceId;
|
|
47
|
-
private static _processGuardsInstalled;
|
|
48
|
-
private static _instances;
|
|
49
|
-
private cacheDir?;
|
|
50
|
-
private _agentReplayRecording;
|
|
51
|
-
v3Metrics: V3Metrics;
|
|
52
|
-
/**
|
|
53
|
-
* Async property for metrics so callers can `await v3.metrics`.
|
|
54
|
-
* Returning a Promise future-proofs async aggregation/storage.
|
|
55
|
-
*/
|
|
56
|
-
get metrics(): Promise<V3Metrics>;
|
|
57
|
-
private cloneForCache;
|
|
58
|
-
private beginAgentReplayRecording;
|
|
59
|
-
private endAgentReplayRecording;
|
|
60
|
-
private discardAgentReplayRecording;
|
|
61
|
-
private isAgentReplayRecording;
|
|
62
|
-
isAgentReplayActive(): boolean;
|
|
63
|
-
recordAgentReplayStep(step: AgentReplayStep): void;
|
|
64
|
-
/**
|
|
65
|
-
* Async property for history so callers can `await v3.history`.
|
|
66
|
-
* Returns a frozen copy to avoid external mutation.
|
|
67
|
-
*/
|
|
68
|
-
get history(): Promise<ReadonlyArray<HistoryEntry>>;
|
|
69
|
-
addToHistory(method: HistoryEntry["method"], parameters: unknown, result?: unknown): void;
|
|
70
|
-
updateMetrics(functionName: V3FunctionName, promptTokens: number, completionTokens: number, inferenceTimeMs: number): void;
|
|
71
|
-
private updateTotalMetrics;
|
|
72
|
-
constructor(opts: V3Options);
|
|
73
|
-
private _immediateShutdown;
|
|
74
|
-
private static _installProcessGuards;
|
|
75
|
-
/**
|
|
76
|
-
* Entrypoint: initializes handlers, launches Chrome or Browserbase,
|
|
77
|
-
* and sets up a CDP context.
|
|
78
|
-
*/
|
|
79
|
-
init(): Promise<void>;
|
|
80
|
-
/** Apply post-connect local browser options that require CDP. */
|
|
81
|
-
private _applyPostConnectLocalOptions;
|
|
82
|
-
private _ensureBrowserbaseDownloadsEnabled;
|
|
83
|
-
/**
|
|
84
|
-
* Run an "act" instruction through the ActHandler.
|
|
85
|
-
*
|
|
86
|
-
* New API:
|
|
87
|
-
* - act(instruction: string, options?: ActOptions)
|
|
88
|
-
* - act(action: Action, options?: ActOptions)
|
|
89
|
-
*/
|
|
90
|
-
act(instruction: string, options?: ActOptions): Promise<ActResult>;
|
|
91
|
-
act(action: Action, options?: ActOptions): Promise<ActResult>;
|
|
92
|
-
/**
|
|
93
|
-
* Run an "extract" instruction through the ExtractHandler.
|
|
94
|
-
*
|
|
95
|
-
* Accepted forms:
|
|
96
|
-
* - extract() → pageText
|
|
97
|
-
* - extract(options) → pageText
|
|
98
|
-
* - extract(instruction) → defaultExtractSchema
|
|
99
|
-
* - extract(instruction, schema) → schema-inferred
|
|
100
|
-
* - extract(instruction, schema, options)
|
|
101
|
-
*/
|
|
102
|
-
extract(): Promise<z.infer<typeof pageTextSchema>>;
|
|
103
|
-
extract(options: ExtractOptions): Promise<z.infer<typeof pageTextSchema>>;
|
|
104
|
-
extract(instruction: string, options?: ExtractOptions): Promise<z.infer<typeof defaultExtractSchema>>;
|
|
105
|
-
extract<T extends ZodTypeAny>(instruction: string, schema: T, options?: ExtractOptions): Promise<z.infer<T>>;
|
|
106
|
-
/**
|
|
107
|
-
* Run an "observe" instruction through the ObserveHandler.
|
|
108
|
-
*/
|
|
109
|
-
observe(): Promise<Action[]>;
|
|
110
|
-
observe(options: ObserveOptions): Promise<Action[]>;
|
|
111
|
-
observe(instruction: string, options?: ObserveOptions): Promise<Action[]>;
|
|
112
|
-
/** Return the browser-level CDP WebSocket endpoint. */
|
|
113
|
-
connectURL(): string;
|
|
114
|
-
/** Expose the current CDP-backed context. */
|
|
115
|
-
get context(): V3Context;
|
|
116
|
-
/** Best-effort cleanup of context and launched resources. */
|
|
117
|
-
close(opts?: {
|
|
118
|
-
force?: boolean;
|
|
119
|
-
}): Promise<void>;
|
|
120
|
-
/** Guard: ensure Browserbase credentials exist in options. */
|
|
121
|
-
private requireBrowserbaseCreds;
|
|
122
|
-
get logger(): (logLine: LogLine) => void;
|
|
123
|
-
/**
|
|
124
|
-
* Normalize a Playwright/Puppeteer page object into its top frame id,
|
|
125
|
-
* so handlers can resolve it to a `Page` within our V3Context.
|
|
126
|
-
*/
|
|
127
|
-
private resolveTopFrameId;
|
|
128
|
-
private isPlaywrightPage;
|
|
129
|
-
private isPatchrightPage;
|
|
130
|
-
private isPuppeteerPage;
|
|
131
|
-
private normalizeToV3Page;
|
|
132
|
-
private buildActCacheKey;
|
|
133
|
-
private safeGetPageUrl;
|
|
134
|
-
private readActCacheEntry;
|
|
135
|
-
private writeActCacheEntry;
|
|
136
|
-
private sanitizeAgentExecuteOptions;
|
|
137
|
-
private buildAgentCacheSignature;
|
|
138
|
-
private buildAgentCacheKey;
|
|
139
|
-
private readAgentCacheEntry;
|
|
140
|
-
private writeAgentCacheEntry;
|
|
141
|
-
private replayAgentCacheEntry;
|
|
142
|
-
private executeAgentReplayStep;
|
|
143
|
-
private replayAgentActStep;
|
|
144
|
-
private replayAgentFillFormStep;
|
|
145
|
-
private replayAgentGotoStep;
|
|
146
|
-
private replayAgentScrollStep;
|
|
147
|
-
private replayAgentWaitStep;
|
|
148
|
-
private replayAgentNavBackStep;
|
|
149
|
-
private replayCachedActions;
|
|
150
|
-
private runWithActTimeout;
|
|
151
|
-
/**
|
|
152
|
-
* Create a v3 agent instance (AISDK tool-based) with execute().
|
|
153
|
-
* Mirrors the v2 Stagehand.agent() tool mode (no CUA provider here).
|
|
154
|
-
*/
|
|
155
|
-
agent(options?: AgentConfig): {
|
|
156
|
-
execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
|
|
157
|
-
};
|
|
158
|
-
}
|
package/dist/lib/version.d.ts
DELETED
package/dist/types/act.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { LLMClient } from "../lib/llm/LLMClient";
|
|
2
|
-
import { Locator } from "playwright";
|
|
3
|
-
import { Logger } from "@/types/log";
|
|
4
|
-
import { StagehandPage } from "@/lib/StagehandPage";
|
|
5
|
-
export interface ActCommandParams {
|
|
6
|
-
action: string;
|
|
7
|
-
steps?: string;
|
|
8
|
-
domElements: string;
|
|
9
|
-
llmClient: LLMClient;
|
|
10
|
-
retries?: number;
|
|
11
|
-
logger: (message: {
|
|
12
|
-
category?: string;
|
|
13
|
-
message: string;
|
|
14
|
-
}) => void;
|
|
15
|
-
requestId: string;
|
|
16
|
-
variables?: Record<string, string>;
|
|
17
|
-
userProvidedInstructions?: string;
|
|
18
|
-
}
|
|
19
|
-
export interface ActCommandResult {
|
|
20
|
-
method: string;
|
|
21
|
-
element: number;
|
|
22
|
-
args: unknown[];
|
|
23
|
-
completed: boolean;
|
|
24
|
-
step: string;
|
|
25
|
-
why?: string;
|
|
26
|
-
}
|
|
27
|
-
export declare enum SupportedPlaywrightAction {
|
|
28
|
-
CLICK = "click",
|
|
29
|
-
FILL = "fill",
|
|
30
|
-
TYPE = "type",
|
|
31
|
-
PRESS = "press",
|
|
32
|
-
SCROLL = "scrollTo",
|
|
33
|
-
NEXT_CHUNK = "nextChunk",
|
|
34
|
-
PREV_CHUNK = "prevChunk",
|
|
35
|
-
SELECT_OPTION_FROM_DROPDOWN = "selectOptionFromDropdown"
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* A context object to hold all parameters that might be needed by
|
|
39
|
-
* any of the methods in the `methodHandlerMap`
|
|
40
|
-
*/
|
|
41
|
-
export interface MethodHandlerContext {
|
|
42
|
-
method: string;
|
|
43
|
-
locator: Locator;
|
|
44
|
-
xpath: string;
|
|
45
|
-
args: unknown[];
|
|
46
|
-
logger: Logger;
|
|
47
|
-
stagehandPage: StagehandPage;
|
|
48
|
-
initialUrl: string;
|
|
49
|
-
domSettleTimeoutMs?: number;
|
|
50
|
-
}
|
package/dist/types/agent.d.ts
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { LogLine } from "./log";
|
|
2
|
-
import { ObserveResult } from "./stagehand";
|
|
3
|
-
export interface ActToolResult {
|
|
4
|
-
success: boolean;
|
|
5
|
-
action?: string;
|
|
6
|
-
error?: string;
|
|
7
|
-
isIframe?: boolean;
|
|
8
|
-
playwrightArguments?: ObserveResult | null;
|
|
9
|
-
}
|
|
10
|
-
export interface AgentAction {
|
|
11
|
-
type: string;
|
|
12
|
-
reasoning?: string;
|
|
13
|
-
taskCompleted?: boolean;
|
|
14
|
-
action?: string;
|
|
15
|
-
timeMs?: number;
|
|
16
|
-
pageText?: string;
|
|
17
|
-
pageUrl?: string;
|
|
18
|
-
instruction?: string;
|
|
19
|
-
playwrightArguments?: ObserveResult | null;
|
|
20
|
-
[key: string]: unknown;
|
|
21
|
-
}
|
|
22
|
-
export interface AgentResult {
|
|
23
|
-
success: boolean;
|
|
24
|
-
message: string;
|
|
25
|
-
actions: AgentAction[];
|
|
26
|
-
completed: boolean;
|
|
27
|
-
metadata?: Record<string, unknown>;
|
|
28
|
-
usage?: {
|
|
29
|
-
input_tokens: number;
|
|
30
|
-
output_tokens: number;
|
|
31
|
-
inference_time_ms: number;
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
export interface AgentOptions {
|
|
35
|
-
maxSteps?: number;
|
|
36
|
-
autoScreenshot?: boolean;
|
|
37
|
-
waitBetweenActions?: number;
|
|
38
|
-
context?: string;
|
|
39
|
-
highlightCursor?: boolean;
|
|
40
|
-
}
|
|
41
|
-
export interface AgentExecuteOptions extends AgentOptions {
|
|
42
|
-
instruction: string;
|
|
43
|
-
}
|
|
44
|
-
export type AgentProviderType = "openai" | "anthropic" | "google";
|
|
45
|
-
export interface AgentClientOptions {
|
|
46
|
-
apiKey: string;
|
|
47
|
-
organization?: string;
|
|
48
|
-
baseURL?: string;
|
|
49
|
-
defaultMaxSteps?: number;
|
|
50
|
-
[key: string]: unknown;
|
|
51
|
-
}
|
|
52
|
-
export type AgentType = "openai" | "anthropic" | "google";
|
|
53
|
-
export interface AgentExecutionOptions {
|
|
54
|
-
options: AgentExecuteOptions;
|
|
55
|
-
logger: (message: LogLine) => void;
|
|
56
|
-
retries?: number;
|
|
57
|
-
}
|
|
58
|
-
export interface AgentHandlerOptions {
|
|
59
|
-
modelName: string;
|
|
60
|
-
clientOptions?: Record<string, unknown>;
|
|
61
|
-
userProvidedInstructions?: string;
|
|
62
|
-
agentType: AgentType;
|
|
63
|
-
experimental?: boolean;
|
|
64
|
-
}
|
|
65
|
-
export interface ActionExecutionResult {
|
|
66
|
-
success: boolean;
|
|
67
|
-
error?: string;
|
|
68
|
-
data?: unknown;
|
|
69
|
-
}
|
|
70
|
-
export interface ToolUseItem extends ResponseItem {
|
|
71
|
-
type: "tool_use";
|
|
72
|
-
id: string;
|
|
73
|
-
name: string;
|
|
74
|
-
input: Record<string, unknown>;
|
|
75
|
-
}
|
|
76
|
-
export interface AnthropicMessage {
|
|
77
|
-
role: string;
|
|
78
|
-
content: string | Array<AnthropicContentBlock>;
|
|
79
|
-
}
|
|
80
|
-
export interface AnthropicContentBlock {
|
|
81
|
-
type: string;
|
|
82
|
-
[key: string]: unknown;
|
|
83
|
-
}
|
|
84
|
-
export interface AnthropicTextBlock extends AnthropicContentBlock {
|
|
85
|
-
type: "text";
|
|
86
|
-
text: string;
|
|
87
|
-
}
|
|
88
|
-
export interface AnthropicToolResult {
|
|
89
|
-
type: "tool_result";
|
|
90
|
-
tool_use_id: string;
|
|
91
|
-
content: string | Array<AnthropicContentBlock>;
|
|
92
|
-
}
|
|
93
|
-
export interface ResponseItem {
|
|
94
|
-
type: string;
|
|
95
|
-
id: string;
|
|
96
|
-
[key: string]: unknown;
|
|
97
|
-
}
|
|
98
|
-
export interface ComputerCallItem extends ResponseItem {
|
|
99
|
-
type: "computer_call";
|
|
100
|
-
call_id: string;
|
|
101
|
-
action: {
|
|
102
|
-
type: string;
|
|
103
|
-
[key: string]: unknown;
|
|
104
|
-
};
|
|
105
|
-
pending_safety_checks?: Array<{
|
|
106
|
-
id: string;
|
|
107
|
-
code: string;
|
|
108
|
-
message: string;
|
|
109
|
-
}>;
|
|
110
|
-
}
|
|
111
|
-
export interface FunctionCallItem extends ResponseItem {
|
|
112
|
-
type: "function_call";
|
|
113
|
-
call_id: string;
|
|
114
|
-
name: string;
|
|
115
|
-
arguments: string;
|
|
116
|
-
}
|
|
117
|
-
export type ResponseInputItem = {
|
|
118
|
-
role: string;
|
|
119
|
-
content: string;
|
|
120
|
-
} | {
|
|
121
|
-
type: "computer_call_output";
|
|
122
|
-
call_id: string;
|
|
123
|
-
output: {
|
|
124
|
-
type: "input_image";
|
|
125
|
-
image_url: string;
|
|
126
|
-
current_url?: string;
|
|
127
|
-
error?: string;
|
|
128
|
-
[key: string]: unknown;
|
|
129
|
-
} | string;
|
|
130
|
-
acknowledged_safety_checks?: Array<{
|
|
131
|
-
id: string;
|
|
132
|
-
code: string;
|
|
133
|
-
message: string;
|
|
134
|
-
}>;
|
|
135
|
-
} | {
|
|
136
|
-
type: "function_call_output";
|
|
137
|
-
call_id: string;
|
|
138
|
-
output: string;
|
|
139
|
-
};
|
|
140
|
-
export interface AgentInstance {
|
|
141
|
-
execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
|
|
142
|
-
setScreenshotCollector?: (collector: unknown) => void;
|
|
143
|
-
}
|
package/dist/types/api.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import Browserbase from "@browserbasehq/sdk";
|
|
2
|
-
import { LogLine } from "./log";
|
|
3
|
-
export interface StagehandAPIConstructorParams {
|
|
4
|
-
apiKey: string;
|
|
5
|
-
projectId: string;
|
|
6
|
-
logger: (message: LogLine) => void;
|
|
7
|
-
}
|
|
8
|
-
export interface ExecuteActionParams {
|
|
9
|
-
method: "act" | "extract" | "observe" | "navigate" | "end" | "agentExecute";
|
|
10
|
-
args?: unknown;
|
|
11
|
-
params?: unknown;
|
|
12
|
-
}
|
|
13
|
-
export interface StartSessionParams {
|
|
14
|
-
modelName: string;
|
|
15
|
-
modelApiKey: string;
|
|
16
|
-
domSettleTimeoutMs: number;
|
|
17
|
-
verbose: number;
|
|
18
|
-
debugDom: boolean;
|
|
19
|
-
systemPrompt?: string;
|
|
20
|
-
browserbaseSessionCreateParams?: Omit<Browserbase.Sessions.SessionCreateParams, "projectId"> & {
|
|
21
|
-
projectId?: string;
|
|
22
|
-
};
|
|
23
|
-
selfHeal?: boolean;
|
|
24
|
-
waitForCaptchaSolves?: boolean;
|
|
25
|
-
actionTimeoutMs?: number;
|
|
26
|
-
browserbaseSessionID?: string;
|
|
27
|
-
}
|
|
28
|
-
export interface StartSessionResult {
|
|
29
|
-
sessionId: string;
|
|
30
|
-
available?: boolean;
|
|
31
|
-
}
|
|
32
|
-
export interface SuccessResponse<T> {
|
|
33
|
-
success: true;
|
|
34
|
-
data: T;
|
|
35
|
-
}
|
|
36
|
-
export interface ErrorResponse {
|
|
37
|
-
success: false;
|
|
38
|
-
message: string;
|
|
39
|
-
}
|
|
40
|
-
export type ApiResponse<T> = SuccessResponse<T> | ErrorResponse;
|
package/dist/types/browser.d.ts
DELETED
package/dist/types/context.d.ts
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import type { BrowserContext as PlaywrightContext, Frame } from "playwright";
|
|
2
|
-
import { Page } from "../types/page";
|
|
3
|
-
export interface AXNode {
|
|
4
|
-
role?: {
|
|
5
|
-
value: string;
|
|
6
|
-
};
|
|
7
|
-
name?: {
|
|
8
|
-
value: string;
|
|
9
|
-
};
|
|
10
|
-
description?: {
|
|
11
|
-
value: string;
|
|
12
|
-
};
|
|
13
|
-
value?: {
|
|
14
|
-
value: string;
|
|
15
|
-
};
|
|
16
|
-
nodeId: string;
|
|
17
|
-
backendDOMNodeId?: number;
|
|
18
|
-
parentId?: string;
|
|
19
|
-
childIds?: string[];
|
|
20
|
-
properties?: {
|
|
21
|
-
name: string;
|
|
22
|
-
value: {
|
|
23
|
-
type: string;
|
|
24
|
-
value?: string;
|
|
25
|
-
};
|
|
26
|
-
}[];
|
|
27
|
-
}
|
|
28
|
-
export type AccessibilityNode = {
|
|
29
|
-
role: string;
|
|
30
|
-
name?: string;
|
|
31
|
-
description?: string;
|
|
32
|
-
value?: string;
|
|
33
|
-
children?: AccessibilityNode[];
|
|
34
|
-
childIds?: string[];
|
|
35
|
-
parentId?: string;
|
|
36
|
-
nodeId?: string;
|
|
37
|
-
backendDOMNodeId?: number;
|
|
38
|
-
properties?: {
|
|
39
|
-
name: string;
|
|
40
|
-
value: {
|
|
41
|
-
type: string;
|
|
42
|
-
value?: string;
|
|
43
|
-
};
|
|
44
|
-
}[];
|
|
45
|
-
};
|
|
46
|
-
export interface TreeResult {
|
|
47
|
-
tree: AccessibilityNode[];
|
|
48
|
-
simplified: string;
|
|
49
|
-
iframes?: AccessibilityNode[];
|
|
50
|
-
idToUrl: Record<EncodedId, string>;
|
|
51
|
-
xpathMap: Record<EncodedId, string>;
|
|
52
|
-
}
|
|
53
|
-
export type DOMNode = {
|
|
54
|
-
backendNodeId?: number;
|
|
55
|
-
nodeName?: string;
|
|
56
|
-
children?: DOMNode[];
|
|
57
|
-
shadowRoots?: DOMNode[];
|
|
58
|
-
contentDocument?: DOMNode;
|
|
59
|
-
nodeType: number;
|
|
60
|
-
frameId?: string;
|
|
61
|
-
};
|
|
62
|
-
export type BackendIdMaps = {
|
|
63
|
-
tagNameMap: Record<number, string>;
|
|
64
|
-
xpathMap: Record<number, string>;
|
|
65
|
-
iframeXPath?: string;
|
|
66
|
-
};
|
|
67
|
-
export interface EnhancedContext extends Omit<PlaywrightContext, "newPage" | "pages"> {
|
|
68
|
-
newPage(): Promise<Page>;
|
|
69
|
-
pages(): Page[];
|
|
70
|
-
}
|
|
71
|
-
export type FrameId = string;
|
|
72
|
-
export type LoaderId = string;
|
|
73
|
-
export interface CdpFrame {
|
|
74
|
-
id: FrameId;
|
|
75
|
-
parentId?: FrameId;
|
|
76
|
-
loaderId: LoaderId;
|
|
77
|
-
name?: string;
|
|
78
|
-
url: string;
|
|
79
|
-
urlFragment?: string;
|
|
80
|
-
domainAndRegistry?: string;
|
|
81
|
-
securityOrigin: string;
|
|
82
|
-
securityOriginDetails?: Record<string, unknown>;
|
|
83
|
-
mimeType: string;
|
|
84
|
-
unreachableUrl?: string;
|
|
85
|
-
adFrameStatus?: string;
|
|
86
|
-
secureContextType?: string;
|
|
87
|
-
crossOriginIsolatedContextType?: string;
|
|
88
|
-
gatedAPIFeatures?: string[];
|
|
89
|
-
}
|
|
90
|
-
export interface CdpFrameTree {
|
|
91
|
-
frame: CdpFrame;
|
|
92
|
-
childFrames?: CdpFrameTree[];
|
|
93
|
-
}
|
|
94
|
-
export interface FrameOwnerResult {
|
|
95
|
-
backendNodeId?: number;
|
|
96
|
-
}
|
|
97
|
-
export interface CombinedA11yResult {
|
|
98
|
-
combinedTree: string;
|
|
99
|
-
combinedXpathMap: Record<EncodedId, string>;
|
|
100
|
-
combinedUrlMap: Record<EncodedId, string>;
|
|
101
|
-
}
|
|
102
|
-
export interface FrameSnapshot {
|
|
103
|
-
frame: Frame;
|
|
104
|
-
tree: string;
|
|
105
|
-
xpathMap: Record<EncodedId, string>;
|
|
106
|
-
urlMap: Record<EncodedId, string>;
|
|
107
|
-
frameXpath: string;
|
|
108
|
-
backendNodeId: number | null;
|
|
109
|
-
parentFrame?: Frame;
|
|
110
|
-
/** CDP frame identifier for this snapshot; used to generate stable EncodedIds. */
|
|
111
|
-
frameId?: string;
|
|
112
|
-
}
|
|
113
|
-
export type EncodedId = `${number}-${number}`;
|
|
114
|
-
export interface RichNode extends AccessibilityNode {
|
|
115
|
-
encodedId?: EncodedId;
|
|
116
|
-
}
|
|
117
|
-
export declare const ID_PATTERN: RegExp;
|
package/dist/types/evals.d.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v3";
|
|
2
|
-
import type { AvailableModel } from "../types/model";
|
|
3
|
-
import type { LogLine } from "../types/log";
|
|
4
|
-
import type { AgentInstance } from "../types/agent";
|
|
5
|
-
import type { EvalCase } from "braintrust";
|
|
6
|
-
import { Stagehand } from "@/dist";
|
|
7
|
-
import { ConstructorParams } from "@/dist";
|
|
8
|
-
import { EvalLogger } from "@/evals/logger";
|
|
9
|
-
export type StagehandInitResult = {
|
|
10
|
-
stagehand: Stagehand;
|
|
11
|
-
logger: EvalLogger;
|
|
12
|
-
debugUrl: string;
|
|
13
|
-
sessionUrl: string;
|
|
14
|
-
stagehandConfig: ConstructorParams;
|
|
15
|
-
modelName: AvailableModel;
|
|
16
|
-
agent: AgentInstance;
|
|
17
|
-
};
|
|
18
|
-
export declare enum ErrorType {
|
|
19
|
-
TIMEOUT = "timeout",
|
|
20
|
-
NETWORK = "network",
|
|
21
|
-
AGENT_FAILURE = "agent_failure",
|
|
22
|
-
EVALUATION_ERROR = "evaluation_error",
|
|
23
|
-
SETUP_ERROR = "setup_error",
|
|
24
|
-
PARSING_ERROR = "parsing_error",
|
|
25
|
-
ANTIBOT = "bot_detected",
|
|
26
|
-
UNKNOWN = "unknown"
|
|
27
|
-
}
|
|
28
|
-
export interface EvalOutput {
|
|
29
|
-
_success: boolean;
|
|
30
|
-
logs: LogLine[];
|
|
31
|
-
debugUrl: string;
|
|
32
|
-
sessionUrl: string;
|
|
33
|
-
error?: unknown;
|
|
34
|
-
error_type?: ErrorType;
|
|
35
|
-
error_message?: string;
|
|
36
|
-
error_stack?: string;
|
|
37
|
-
execution_time?: number;
|
|
38
|
-
agent_steps?: number;
|
|
39
|
-
final_answer?: string;
|
|
40
|
-
reasoning?: string;
|
|
41
|
-
observations?: string | unknown;
|
|
42
|
-
[key: string]: unknown;
|
|
43
|
-
}
|
|
44
|
-
export type EvalFunction = (taskInput: StagehandInitResult & {
|
|
45
|
-
input: EvalInput;
|
|
46
|
-
}) => Promise<EvalOutput>;
|
|
47
|
-
export declare const EvalCategorySchema: z.ZodEnum<["observe", "act", "combination", "extract", "experimental", "targeted_extract", "regression", "regression_llm_providers", "llm_clients", "agent", "external_agent_benchmarks"]>;
|
|
48
|
-
export type EvalCategory = z.infer<typeof EvalCategorySchema>;
|
|
49
|
-
export interface EvalInput {
|
|
50
|
-
name: string;
|
|
51
|
-
modelName: AvailableModel;
|
|
52
|
-
params?: Record<string, unknown>;
|
|
53
|
-
}
|
|
54
|
-
export interface TestcaseMetadata {
|
|
55
|
-
model: AvailableModel;
|
|
56
|
-
test: string;
|
|
57
|
-
category?: string;
|
|
58
|
-
dataset?: string;
|
|
59
|
-
dataset_id?: string;
|
|
60
|
-
dataset_level?: string | number;
|
|
61
|
-
dataset_category?: string;
|
|
62
|
-
[key: string]: unknown;
|
|
63
|
-
}
|
|
64
|
-
export interface Testcase extends EvalCase<EvalInput, unknown, TestcaseMetadata> {
|
|
65
|
-
input: EvalInput;
|
|
66
|
-
name: string;
|
|
67
|
-
tags: string[];
|
|
68
|
-
metadata: TestcaseMetadata;
|
|
69
|
-
expected: unknown;
|
|
70
|
-
}
|
|
71
|
-
export interface SummaryResult {
|
|
72
|
-
input: EvalInput;
|
|
73
|
-
output: {
|
|
74
|
-
_success: boolean;
|
|
75
|
-
};
|
|
76
|
-
name: string;
|
|
77
|
-
score: number;
|
|
78
|
-
}
|
|
79
|
-
export interface EvalArgs<TInput, TOutput, TExpected> {
|
|
80
|
-
input: TInput;
|
|
81
|
-
output: TOutput;
|
|
82
|
-
expected: TExpected;
|
|
83
|
-
metadata?: {
|
|
84
|
-
model: AvailableModel;
|
|
85
|
-
test: string;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
export interface EvalResult {
|
|
89
|
-
name: string;
|
|
90
|
-
score: number;
|
|
91
|
-
}
|
|
92
|
-
export type LogLineEval = LogLine & {
|
|
93
|
-
parsedAuxiliary?: string | object;
|
|
94
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export type EvaluateOptions = {
|
|
2
|
-
/** The question to ask about the task state */
|
|
3
|
-
question: string;
|
|
4
|
-
/** The answer to the question */
|
|
5
|
-
answer?: string;
|
|
6
|
-
/** Whether to take a screenshot of the task state, or array of screenshots to evaluate */
|
|
7
|
-
screenshot?: boolean | Buffer[];
|
|
8
|
-
/** Custom system prompt for the evaluator */
|
|
9
|
-
systemPrompt?: string;
|
|
10
|
-
/** Delay in milliseconds before taking the screenshot @default 250 */
|
|
11
|
-
screenshotDelayMs?: number;
|
|
12
|
-
/** The agent's reasoning/thought process for completing the task */
|
|
13
|
-
agentReasoning?: string;
|
|
14
|
-
};
|
|
15
|
-
export type BatchAskOptions = {
|
|
16
|
-
/** Array of questions with optional answers */
|
|
17
|
-
questions: Array<{
|
|
18
|
-
question: string;
|
|
19
|
-
answer?: string;
|
|
20
|
-
}>;
|
|
21
|
-
/** Whether to take a screenshot of the task state */
|
|
22
|
-
screenshot?: boolean;
|
|
23
|
-
/** Custom system prompt for the evaluator */
|
|
24
|
-
systemPrompt?: string;
|
|
25
|
-
/** Delay in milliseconds before taking the screenshot @default 1000 */
|
|
26
|
-
screenshotDelayMs?: number;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Result of an evaluation
|
|
30
|
-
*/
|
|
31
|
-
export interface EvaluationResult {
|
|
32
|
-
/**
|
|
33
|
-
* The evaluation result ('YES', 'NO', or 'INVALID' if parsing failed or value was unexpected)
|
|
34
|
-
*/
|
|
35
|
-
evaluation: "YES" | "NO" | "INVALID";
|
|
36
|
-
/**
|
|
37
|
-
* The reasoning behind the evaluation
|
|
38
|
-
*/
|
|
39
|
-
reasoning: string;
|
|
40
|
-
}
|
package/dist/types/llm.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { LanguageModel } from "ai";
|
|
2
|
-
export interface LLMTool {
|
|
3
|
-
type: "function";
|
|
4
|
-
name: string;
|
|
5
|
-
description: string;
|
|
6
|
-
parameters: Record<string, unknown>;
|
|
7
|
-
}
|
|
8
|
-
export type AISDKProvider = (modelName: string) => LanguageModel;
|
|
9
|
-
export type AISDKCustomProvider = (options: {
|
|
10
|
-
apiKey: string;
|
|
11
|
-
}) => AISDKProvider;
|