@browserbasehq/orca 3.0.0-preview.1 → 3.0.0-preview.3
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 +759 -593
- package/dist/index.js +25560 -24375
- package/package.json +35 -74
- 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
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v3";
|
|
2
|
-
import { Stagehand } from "../../index";
|
|
3
|
-
export declare const createScrollTool: (stagehand: Stagehand) => import("ai/dist").Tool<z.ZodObject<{
|
|
4
|
-
pixels: z.ZodNumber;
|
|
5
|
-
direction: z.ZodEnum<["up", "down"]>;
|
|
6
|
-
}, "strip", z.ZodTypeAny, {
|
|
7
|
-
direction?: "down" | "up";
|
|
8
|
-
pixels?: number;
|
|
9
|
-
}, {
|
|
10
|
-
direction?: "down" | "up";
|
|
11
|
-
pixels?: number;
|
|
12
|
-
}>, {
|
|
13
|
-
success: boolean;
|
|
14
|
-
pixels: number;
|
|
15
|
-
}> & {
|
|
16
|
-
execute: (args: {
|
|
17
|
-
direction?: "down" | "up";
|
|
18
|
-
pixels?: number;
|
|
19
|
-
}, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
|
|
20
|
-
success: boolean;
|
|
21
|
-
pixels: number;
|
|
22
|
-
}>;
|
|
23
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v3";
|
|
2
|
-
export declare const createWaitTool: () => import("ai/dist").Tool<z.ZodObject<{
|
|
3
|
-
timeMs: z.ZodNumber;
|
|
4
|
-
}, "strip", z.ZodTypeAny, {
|
|
5
|
-
timeMs?: number;
|
|
6
|
-
}, {
|
|
7
|
-
timeMs?: number;
|
|
8
|
-
}>, {
|
|
9
|
-
success: boolean;
|
|
10
|
-
waited: number;
|
|
11
|
-
}> & {
|
|
12
|
-
execute: (args: {
|
|
13
|
-
timeMs?: number;
|
|
14
|
-
}, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
|
|
15
|
-
success: boolean;
|
|
16
|
-
waited: number;
|
|
17
|
-
}>;
|
|
18
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Universal key mapping utility for converting various key representations
|
|
3
|
-
* to Playwright-compatible key names. Used by all CUA clients and handlers.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Maps a key name from various formats to Playwright-compatible format
|
|
7
|
-
* @param key The key name in any supported format
|
|
8
|
-
* @returns The Playwright-compatible key name
|
|
9
|
-
*/
|
|
10
|
-
export declare function mapKeyToPlaywright(key: string): string;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { AnthropicMessage, AnthropicToolResult, ResponseInputItem as OpenAIResponseInputItem } from "@/types/agent";
|
|
2
|
-
import type { Content as GoogleContent } from "@google/genai";
|
|
3
|
-
export type ResponseInputItem = AnthropicMessage | AnthropicToolResult;
|
|
4
|
-
export type AnthropicResponseInputItem = AnthropicMessage | AnthropicToolResult;
|
|
5
|
-
export type SupportedInputItem = AnthropicResponseInputItem | OpenAIResponseInputItem | GoogleContent;
|
|
6
|
-
/**
|
|
7
|
-
* Finds all items in the conversation history that contain images
|
|
8
|
-
* @param items - Array of conversation items to check
|
|
9
|
-
* @returns Array of indices where images were found
|
|
10
|
-
*/
|
|
11
|
-
export declare function findItemsWithImages(items: ResponseInputItem[]): number[];
|
|
12
|
-
/**
|
|
13
|
-
* Compresses conversation history by removing images from older items
|
|
14
|
-
* while keeping the most recent images intact
|
|
15
|
-
* @param items - Array of conversation items to process
|
|
16
|
-
* @param keepMostRecentCount - Number of most recent image-containing items to preserve (default: 2)
|
|
17
|
-
* @returns Object with processed items
|
|
18
|
-
*/
|
|
19
|
-
export declare function compressConversationImages(items: ResponseInputItem[], keepMostRecentCount?: number): {
|
|
20
|
-
items: ResponseInputItem[];
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Finds all items in the conversation history that contain images (Google format)
|
|
24
|
-
* @param items - Array of conversation items to check
|
|
25
|
-
* @returns Array of indices where images were found
|
|
26
|
-
*/
|
|
27
|
-
export declare function findGoogleItemsWithImages(items: GoogleContent[]): number[];
|
|
28
|
-
/**
|
|
29
|
-
* Finds all items in the conversation history that contain images (OpenAI format)
|
|
30
|
-
* @param items - Array of conversation items to check
|
|
31
|
-
* @returns Array of indices where images were found
|
|
32
|
-
*/
|
|
33
|
-
export declare function findOpenAIItemsWithImages(items: OpenAIResponseInputItem[]): number[];
|
|
34
|
-
/**
|
|
35
|
-
* Compresses OpenAI conversation history by removing images from older items
|
|
36
|
-
* while keeping the most recent images intact
|
|
37
|
-
* @param items - Array of conversation items to process
|
|
38
|
-
* @param keepMostRecentCount - Number of most recent image-containing items to preserve (default: 2)
|
|
39
|
-
* @returns Object with processed items
|
|
40
|
-
*/
|
|
41
|
-
export declare function compressOpenAIConversationImages(items: OpenAIResponseInputItem[], keepMostRecentCount?: number): {
|
|
42
|
-
items: OpenAIResponseInputItem[];
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* Compresses Google conversation history by removing images from older items
|
|
46
|
-
* while keeping the most recent images intact
|
|
47
|
-
* @param items - Array of conversation items to process
|
|
48
|
-
* @param keepMostRecentCount - Number of most recent image-containing items to preserve (default: 2)
|
|
49
|
-
* @returns Object with processed items
|
|
50
|
-
*/
|
|
51
|
-
export declare function compressGoogleConversationImages(items: GoogleContent[], keepMostRecentCount?: number): {
|
|
52
|
-
items: GoogleContent[];
|
|
53
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type LanguageModelV1CallOptions } from "ai";
|
|
2
|
-
export interface CompressionStats {
|
|
3
|
-
originalSize: number;
|
|
4
|
-
compressedSize: number;
|
|
5
|
-
savedChars: number;
|
|
6
|
-
compressionRatio: number;
|
|
7
|
-
screenshotCount: number;
|
|
8
|
-
ariaTreeCount: number;
|
|
9
|
-
}
|
|
10
|
-
export declare function processMessages(params: LanguageModelV1CallOptions): {
|
|
11
|
-
processedPrompt: LanguageModelV1CallOptions["prompt"];
|
|
12
|
-
stats: CompressionStats;
|
|
13
|
-
};
|
package/dist/lib/api.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v3";
|
|
2
|
-
import { StagehandAPIConstructorParams, StartSessionParams, StartSessionResult } from "./v3/types/api";
|
|
3
|
-
import { GotoOptions } from "./v3/types/playwright";
|
|
4
|
-
import { ActOptions, ActResult, AgentConfig, ExtractOptions, ExtractResult, ObserveOptions, Action } from "./v3/types/stagehand";
|
|
5
|
-
import { AgentExecuteOptions, AgentResult } from "@/lib/v3/types/agent";
|
|
6
|
-
export declare class StagehandAPI {
|
|
7
|
-
private apiKey;
|
|
8
|
-
private projectId;
|
|
9
|
-
private sessionId?;
|
|
10
|
-
private modelApiKey;
|
|
11
|
-
private logger;
|
|
12
|
-
private fetchWithCookies;
|
|
13
|
-
constructor({ apiKey, projectId, logger }: StagehandAPIConstructorParams);
|
|
14
|
-
init({ modelName, modelApiKey, domSettleTimeoutMs, verbose, debugDom, systemPrompt, selfHeal, waitForCaptchaSolves, actionTimeoutMs, browserbaseSessionCreateParams, browserbaseSessionID, }: StartSessionParams): Promise<StartSessionResult>;
|
|
15
|
-
act(options: ActOptions | Action): Promise<ActResult>;
|
|
16
|
-
extract<T extends z.AnyZodObject>(options: ExtractOptions<T>): Promise<ExtractResult<T>>;
|
|
17
|
-
observe(options?: ObserveOptions): Promise<Action[]>;
|
|
18
|
-
goto(url: string, options?: GotoOptions): Promise<void>;
|
|
19
|
-
agentExecute(agentConfig: AgentConfig, executeOptions: AgentExecuteOptions): Promise<AgentResult>;
|
|
20
|
-
end(): Promise<Response>;
|
|
21
|
-
private execute;
|
|
22
|
-
private request;
|
|
23
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import Browserbase from "@browserbasehq/sdk";
|
|
2
|
-
export type BrowserbaseSessionCreateParams = Omit<Browserbase.Sessions.SessionCreateParams, "projectId"> & {
|
|
3
|
-
projectId?: string;
|
|
4
|
-
};
|
|
5
|
-
export declare const DEFAULT_BROWSERBASE_VIEWPORT: {
|
|
6
|
-
readonly width: 1288;
|
|
7
|
-
readonly height: 711;
|
|
8
|
-
};
|
|
9
|
-
export declare function applyDefaultBrowserSettingsViewport(params?: BrowserbaseSessionCreateParams): BrowserbaseSessionCreateParams;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { LogLine } from "../../types/log";
|
|
2
|
-
import { BaseCache, CacheEntry } from "./BaseCache";
|
|
3
|
-
export interface PlaywrightCommand {
|
|
4
|
-
method: string;
|
|
5
|
-
args: string[];
|
|
6
|
-
}
|
|
7
|
-
export interface ActionEntry extends CacheEntry {
|
|
8
|
-
data: {
|
|
9
|
-
playwrightCommand: PlaywrightCommand;
|
|
10
|
-
componentString: string;
|
|
11
|
-
xpaths: string[];
|
|
12
|
-
newStepString: string;
|
|
13
|
-
completed: boolean;
|
|
14
|
-
previousSelectors: string[];
|
|
15
|
-
action: string;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* ActionCache handles logging and retrieving actions along with their Playwright commands.
|
|
20
|
-
*/
|
|
21
|
-
export declare class ActionCache extends BaseCache<ActionEntry> {
|
|
22
|
-
constructor(logger: (message: LogLine) => void, cacheDir?: string, cacheFile?: string);
|
|
23
|
-
addActionStep({ url, action, previousSelectors, playwrightCommand, componentString, xpaths, newStepString, completed, requestId, }: {
|
|
24
|
-
url: string;
|
|
25
|
-
action: string;
|
|
26
|
-
previousSelectors: string[];
|
|
27
|
-
playwrightCommand: PlaywrightCommand;
|
|
28
|
-
componentString: string;
|
|
29
|
-
requestId: string;
|
|
30
|
-
xpaths: string[];
|
|
31
|
-
newStepString: string;
|
|
32
|
-
completed: boolean;
|
|
33
|
-
}): Promise<void>;
|
|
34
|
-
/**
|
|
35
|
-
* Retrieves all actions for a specific trajectory.
|
|
36
|
-
* @param trajectoryId - Unique identifier for the trajectory.
|
|
37
|
-
* @param requestId - The identifier for the current request.
|
|
38
|
-
* @returns An array of TrajectoryEntry objects or null if not found.
|
|
39
|
-
*/
|
|
40
|
-
getActionStep({ url, action, previousSelectors, requestId, }: {
|
|
41
|
-
url: string;
|
|
42
|
-
action: string;
|
|
43
|
-
previousSelectors: string[];
|
|
44
|
-
requestId: string;
|
|
45
|
-
}): Promise<ActionEntry["data"] | null>;
|
|
46
|
-
removeActionStep(cacheHashObj: {
|
|
47
|
-
url: string;
|
|
48
|
-
action: string;
|
|
49
|
-
previousSelectors: string[];
|
|
50
|
-
requestId: string;
|
|
51
|
-
}): Promise<void>;
|
|
52
|
-
/**
|
|
53
|
-
* Clears all actions for a specific trajectory.
|
|
54
|
-
* @param trajectoryId - Unique identifier for the trajectory.
|
|
55
|
-
* @param requestId - The identifier for the current request.
|
|
56
|
-
*/
|
|
57
|
-
clearAction(requestId: string): Promise<void>;
|
|
58
|
-
/**
|
|
59
|
-
* Resets the entire action cache.
|
|
60
|
-
*/
|
|
61
|
-
resetCache(): Promise<void>;
|
|
62
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { LogLine } from "../../types/log";
|
|
2
|
-
export interface CacheEntry {
|
|
3
|
-
timestamp: number;
|
|
4
|
-
data: unknown;
|
|
5
|
-
requestId: string;
|
|
6
|
-
}
|
|
7
|
-
export interface CacheStore {
|
|
8
|
-
[key: string]: CacheEntry;
|
|
9
|
-
}
|
|
10
|
-
export declare class BaseCache<T extends CacheEntry> {
|
|
11
|
-
private readonly CACHE_MAX_AGE_MS;
|
|
12
|
-
private readonly CLEANUP_PROBABILITY;
|
|
13
|
-
protected cacheDir: string;
|
|
14
|
-
protected cacheFile: string;
|
|
15
|
-
protected lockFile: string;
|
|
16
|
-
protected logger: (message: LogLine) => void;
|
|
17
|
-
private readonly LOCK_TIMEOUT_MS;
|
|
18
|
-
protected lockAcquired: boolean;
|
|
19
|
-
protected lockAcquireFailures: number;
|
|
20
|
-
protected requestIdToUsedHashes: {
|
|
21
|
-
[key: string]: string[];
|
|
22
|
-
};
|
|
23
|
-
constructor(logger: (message: LogLine) => void, cacheDir?: string, cacheFile?: string);
|
|
24
|
-
private setupProcessHandlers;
|
|
25
|
-
protected ensureCacheDirectory(): void;
|
|
26
|
-
protected createHash(data: unknown): string;
|
|
27
|
-
protected sleep(ms: number): Promise<void>;
|
|
28
|
-
acquireLock(): Promise<boolean>;
|
|
29
|
-
releaseLock(): void;
|
|
30
|
-
/**
|
|
31
|
-
* Cleans up stale cache entries that exceed the maximum age.
|
|
32
|
-
*/
|
|
33
|
-
cleanupStaleEntries(): Promise<void>;
|
|
34
|
-
protected readCache(): CacheStore;
|
|
35
|
-
protected writeCache(cache: CacheStore): void;
|
|
36
|
-
/**
|
|
37
|
-
* Retrieves data from the cache based on the provided options.
|
|
38
|
-
* @param hashObj - The options used to generate the cache key.
|
|
39
|
-
* @param requestId - The identifier for the current request.
|
|
40
|
-
* @returns The cached data if available, otherwise null.
|
|
41
|
-
*/
|
|
42
|
-
get(hashObj: Record<string, unknown> | string, requestId: string): Promise<T["data"] | null>;
|
|
43
|
-
/**
|
|
44
|
-
* Stores data in the cache based on the provided options and requestId.
|
|
45
|
-
* @param hashObj - The options used to generate the cache key.
|
|
46
|
-
* @param data - The data to be cached.
|
|
47
|
-
* @param requestId - The identifier for the cache entry.
|
|
48
|
-
*/
|
|
49
|
-
set(hashObj: Record<string, unknown>, data: T["data"], requestId: string): Promise<void>;
|
|
50
|
-
delete(hashObj: Record<string, unknown>): Promise<void>;
|
|
51
|
-
/**
|
|
52
|
-
* Tracks the usage of a hash with a specific requestId.
|
|
53
|
-
* @param requestId - The identifier for the current request.
|
|
54
|
-
* @param hash - The cache key hash.
|
|
55
|
-
*/
|
|
56
|
-
protected trackRequestIdUsage(requestId: string, hash: string): void;
|
|
57
|
-
/**
|
|
58
|
-
* Deletes all cache entries associated with a specific requestId.
|
|
59
|
-
* @param requestId - The identifier for the request whose cache entries should be deleted.
|
|
60
|
-
*/
|
|
61
|
-
deleteCacheForRequestId(requestId: string): Promise<void>;
|
|
62
|
-
/**
|
|
63
|
-
* Resets the entire cache by clearing the cache file.
|
|
64
|
-
*/
|
|
65
|
-
resetCache(): void;
|
|
66
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BaseCache, CacheEntry } from "./BaseCache";
|
|
2
|
-
export declare class LLMCache extends BaseCache<CacheEntry> {
|
|
3
|
-
constructor(logger: (message: {
|
|
4
|
-
category?: string;
|
|
5
|
-
message: string;
|
|
6
|
-
level?: number;
|
|
7
|
-
}) => void, cacheDir?: string, cacheFile?: string);
|
|
8
|
-
/**
|
|
9
|
-
* Overrides the get method to track used hashes by requestId.
|
|
10
|
-
* @param options - The options used to generate the cache key.
|
|
11
|
-
* @param requestId - The identifier for the current request.
|
|
12
|
-
* @returns The cached data if available, otherwise null.
|
|
13
|
-
*/
|
|
14
|
-
get<T>(options: Record<string, unknown>, requestId: string): Promise<T | null>;
|
|
15
|
-
/**
|
|
16
|
-
* Overrides the set method to include cache cleanup logic.
|
|
17
|
-
* @param options - The options used to generate the cache key.
|
|
18
|
-
* @param data - The data to be cached.
|
|
19
|
-
* @param requestId - The identifier for the current request.
|
|
20
|
-
*/
|
|
21
|
-
set(options: Record<string, unknown>, data: unknown, requestId: string): Promise<void>;
|
|
22
|
-
}
|
package/dist/lib/cache.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A file system cache to skip inference when repeating steps
|
|
3
|
-
* It also acts as the source of truth for identifying previously seen actions and observations
|
|
4
|
-
*/
|
|
5
|
-
declare class Cache {
|
|
6
|
-
disabled: boolean;
|
|
7
|
-
constructor({ disabled }?: {
|
|
8
|
-
disabled?: boolean;
|
|
9
|
-
});
|
|
10
|
-
readObservations(): any;
|
|
11
|
-
readActions(): any;
|
|
12
|
-
writeObservations({ key, value, }: {
|
|
13
|
-
key: string;
|
|
14
|
-
value: {
|
|
15
|
-
id: string;
|
|
16
|
-
result: string;
|
|
17
|
-
};
|
|
18
|
-
}): void;
|
|
19
|
-
writeActions({ key, value, }: {
|
|
20
|
-
key: string;
|
|
21
|
-
value: {
|
|
22
|
-
id: string;
|
|
23
|
-
result: string;
|
|
24
|
-
};
|
|
25
|
-
}): void;
|
|
26
|
-
evictCache(): void;
|
|
27
|
-
private initCache;
|
|
28
|
-
}
|
|
29
|
-
export default Cache;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const scriptContent = "(() => {\n // lib/dom/elementCheckUtils.ts\n function isElementNode(node) {\n return node.nodeType === Node.ELEMENT_NODE;\n }\n function isTextNode(node) {\n return node.nodeType === Node.TEXT_NODE && Boolean(node.textContent?.trim());\n }\n\n // lib/dom/xpathUtils.ts\n function getParentElement(node) {\n return isElementNode(node) ? node.parentElement : node.parentNode;\n }\n function getCombinations(attributes, size) {\n const results = [];\n function helper(start, combo) {\n if (combo.length === size) {\n results.push([...combo]);\n return;\n }\n for (let i = start; i < attributes.length; i++) {\n combo.push(attributes[i]);\n helper(i + 1, combo);\n combo.pop();\n }\n }\n helper(0, []);\n return results;\n }\n function isXPathFirstResultElement(xpath, target) {\n try {\n const result = document.evaluate(\n xpath,\n document.documentElement,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n );\n return result.snapshotItem(0) === target;\n } catch (error) {\n console.warn(`Invalid XPath expression: ${xpath}`, error);\n return false;\n }\n }\n function escapeXPathString(value) {\n if (value.includes(\"'\")) {\n if (value.includes('\"')) {\n return \"concat(\" + value.split(/('+)/).map((part) => {\n if (part === \"'\") {\n return `\"'\"`;\n } else if (part.startsWith(\"'\") && part.endsWith(\"'\")) {\n return `\"${part}\"`;\n } else {\n return `'${part}'`;\n }\n }).join(\",\") + \")\";\n } else {\n return `\"${value}\"`;\n }\n } else {\n return `'${value}'`;\n }\n }\n async function generateXPathsForElement(element) {\n if (!element) return [];\n const [complexXPath, standardXPath, idBasedXPath] = await Promise.all([\n generateComplexXPath(element),\n generateStandardXPath(element),\n generatedIdBasedXPath(element)\n ]);\n return [standardXPath, ...idBasedXPath ? [idBasedXPath] : [], complexXPath];\n }\n async function generateComplexXPath(element) {\n const parts = [];\n let currentElement = element;\n while (currentElement && (isTextNode(currentElement) || isElementNode(currentElement))) {\n if (isElementNode(currentElement)) {\n const el = currentElement;\n let selector = el.tagName.toLowerCase();\n const attributePriority = [\n \"data-qa\",\n \"data-component\",\n \"data-role\",\n \"role\",\n \"aria-role\",\n \"type\",\n \"name\",\n \"aria-label\",\n \"placeholder\",\n \"title\",\n \"alt\"\n ];\n const attributes = attributePriority.map((attr) => {\n let value = el.getAttribute(attr);\n if (attr === \"href-full\" && value) {\n value = el.getAttribute(\"href\");\n }\n return value ? { attr: attr === \"href-full\" ? \"href\" : attr, value } : null;\n }).filter((attr) => attr !== null);\n let uniqueSelector = \"\";\n for (let i = 1; i <= attributes.length; i++) {\n const combinations = getCombinations(attributes, i);\n for (const combo of combinations) {\n const conditions = combo.map((a) => `@${a.attr}=${escapeXPathString(a.value)}`).join(\" and \");\n const xpath2 = `//${selector}[${conditions}]`;\n if (isXPathFirstResultElement(xpath2, el)) {\n uniqueSelector = xpath2;\n break;\n }\n }\n if (uniqueSelector) break;\n }\n if (uniqueSelector) {\n parts.unshift(uniqueSelector.replace(\"//\", \"\"));\n break;\n } else {\n const parent = getParentElement(el);\n if (parent) {\n const siblings = Array.from(parent.children).filter(\n (sibling) => sibling.tagName === el.tagName\n );\n const index = siblings.indexOf(el) + 1;\n selector += siblings.length > 1 ? `[${index}]` : \"\";\n }\n parts.unshift(selector);\n }\n }\n currentElement = getParentElement(currentElement);\n }\n const xpath = \"//\" + parts.join(\"/\");\n return xpath;\n }\n async function generateStandardXPath(element) {\n const parts = [];\n while (element && (isTextNode(element) || isElementNode(element))) {\n let index = 0;\n let hasSameTypeSiblings = false;\n const siblings = element.parentElement ? Array.from(element.parentElement.childNodes) : [];\n for (let i = 0; i < siblings.length; i++) {\n const sibling = siblings[i];\n if (sibling.nodeType === element.nodeType && sibling.nodeName === element.nodeName) {\n index = index + 1;\n hasSameTypeSiblings = true;\n if (sibling.isSameNode(element)) {\n break;\n }\n }\n }\n if (element.nodeName !== \"#text\") {\n const tagName = element.nodeName.toLowerCase();\n const pathIndex = hasSameTypeSiblings ? `[${index}]` : \"\";\n parts.unshift(`${tagName}${pathIndex}`);\n }\n element = element.parentElement;\n }\n return parts.length ? `/${parts.join(\"/\")}` : \"\";\n }\n async function generatedIdBasedXPath(element) {\n if (isElementNode(element) && element.id) {\n return `//*[@id='${element.id}']`;\n }\n return null;\n }\n\n // types/stagehandErrors.ts\n var StagehandError = class extends Error {\n constructor(message) {\n super(message);\n this.name = this.constructor.name;\n }\n };\n var StagehandDomProcessError = class extends StagehandError {\n constructor(message) {\n super(`Error Processing Dom: ${message}`);\n }\n };\n\n // lib/dom/utils.ts\n function canElementScroll(elem) {\n if (typeof elem.scrollTo !== \"function\") {\n console.warn(\"canElementScroll: .scrollTo is not a function.\");\n return false;\n }\n try {\n const originalTop = elem.scrollTop;\n elem.scrollTo({\n top: originalTop + 100,\n left: 0,\n behavior: \"instant\"\n });\n if (elem.scrollTop === originalTop) {\n throw new StagehandDomProcessError(\"scrollTop did not change\");\n }\n elem.scrollTo({\n top: originalTop,\n left: 0,\n behavior: \"instant\"\n });\n return true;\n } catch (error) {\n console.warn(\"canElementScroll error:\", error.message || error);\n return false;\n }\n }\n function getNodeFromXpath(xpath) {\n return document.evaluate(\n xpath,\n document.documentElement,\n null,\n XPathResult.FIRST_ORDERED_NODE_TYPE,\n null\n ).singleNodeValue;\n }\n function waitForElementScrollEnd(element, idleMs = 100) {\n return new Promise((resolve) => {\n let scrollEndTimer;\n const handleScroll = () => {\n clearTimeout(scrollEndTimer);\n scrollEndTimer = window.setTimeout(() => {\n element.removeEventListener(\"scroll\", handleScroll);\n resolve();\n }, idleMs);\n };\n element.addEventListener(\"scroll\", handleScroll, { passive: true });\n handleScroll();\n });\n }\n\n // lib/dom/process.ts\n function getScrollableElements(topN) {\n const docEl = document.documentElement;\n const scrollableElements = [docEl];\n const allElements = document.querySelectorAll(\"*\");\n for (const elem of allElements) {\n const style = window.getComputedStyle(elem);\n const overflowY = style.overflowY;\n const isPotentiallyScrollable = overflowY === \"auto\" || overflowY === \"scroll\" || overflowY === \"overlay\";\n if (isPotentiallyScrollable) {\n const candidateScrollDiff = elem.scrollHeight - elem.clientHeight;\n if (candidateScrollDiff > 0 && canElementScroll(elem)) {\n scrollableElements.push(elem);\n }\n }\n }\n scrollableElements.sort((a, b) => b.scrollHeight - a.scrollHeight);\n if (topN !== void 0) {\n return scrollableElements.slice(0, topN);\n }\n return scrollableElements;\n }\n async function getScrollableElementXpaths(topN) {\n const scrollableElems = getScrollableElements(topN);\n const xpaths = [];\n for (const elem of scrollableElems) {\n const allXPaths = await generateXPathsForElement(elem);\n const firstXPath = allXPaths?.[0] || \"\";\n xpaths.push(firstXPath);\n }\n return xpaths;\n }\n (() => {\n const closedRoots = /* @__PURE__ */ new WeakMap();\n const nativeAttachShadow = Element.prototype.attachShadow;\n Element.prototype.attachShadow = function(init) {\n const root = nativeAttachShadow.call(this, init);\n if (init.mode === \"closed\") closedRoots.set(this, root);\n return root;\n };\n const backdoor = {\n getClosedRoot: (host) => closedRoots.get(host),\n queryClosed: (host, selector) => {\n const root = closedRoots.get(host);\n return root ? Array.from(root.querySelectorAll(selector)) : [];\n },\n xpathClosed: (host, xp) => {\n const root = closedRoots.get(host);\n if (!root) return [];\n const it = document.evaluate(\n xp,\n root,\n null,\n XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,\n null\n );\n const out = [];\n for (let i = 0; i < it.snapshotLength; ++i) {\n const n = it.snapshotItem(i);\n if (n) out.push(n);\n }\n return out;\n }\n };\n if (!(\"__stagehand__\" in window)) {\n Object.defineProperty(window, \"__stagehand__\", {\n value: backdoor,\n enumerable: false,\n writable: false,\n configurable: false\n });\n }\n })();\n window.getScrollableElementXpaths = getScrollableElementXpaths;\n window.getNodeFromXpath = getNodeFromXpath;\n window.waitForElementScrollEnd = waitForElementScrollEnd;\n})();\n";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/lib/dom/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Finds and returns a list of scrollable elements on the page,
|
|
3
|
-
* ordered from the element with the largest scrollHeight to the smallest.
|
|
4
|
-
*
|
|
5
|
-
* @param topN Optional maximum number of scrollable elements to return.
|
|
6
|
-
* If not provided, all found scrollable elements are returned.
|
|
7
|
-
* @returns An array of HTMLElements sorted by descending scrollHeight.
|
|
8
|
-
*/
|
|
9
|
-
export declare function getScrollableElements(topN?: number): HTMLElement[];
|
|
10
|
-
/**
|
|
11
|
-
* Calls getScrollableElements, then for each element calls generateXPaths,
|
|
12
|
-
* and returns the first XPath for each.
|
|
13
|
-
*
|
|
14
|
-
* @param topN (optional) integer limit on how many scrollable elements to process
|
|
15
|
-
* @returns string[] list of XPaths (1 for each scrollable element)
|
|
16
|
-
*/
|
|
17
|
-
export declare function getScrollableElementXpaths(topN?: number): Promise<string[]>;
|
package/dist/lib/dom/utils.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests if the element actually responds to .scrollTo(...)
|
|
3
|
-
* and that scrollTop changes as expected.
|
|
4
|
-
*/
|
|
5
|
-
export declare function canElementScroll(elem: HTMLElement): boolean;
|
|
6
|
-
export declare function getNodeFromXpath(xpath: string): Node;
|
|
7
|
-
export declare function waitForElementScrollEnd(element: HTMLElement, idleMs?: number): Promise<void>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Escapes a string for use in an XPath expression.
|
|
3
|
-
* Handles special characters, including single and double quotes.
|
|
4
|
-
* @param value - The string to escape.
|
|
5
|
-
* @returns The escaped string safe for XPath.
|
|
6
|
-
*/
|
|
7
|
-
export declare function escapeXPathString(value: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* Generates both a complicated XPath and a standard XPath for a given DOM element.
|
|
10
|
-
* @param element - The target DOM element.
|
|
11
|
-
* @param documentOverride - Optional document override.
|
|
12
|
-
* @returns An object containing both XPaths.
|
|
13
|
-
*/
|
|
14
|
-
export declare function generateXPathsForElement(element: ChildNode): Promise<string[]>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { LogLine } from "../../types/log";
|
|
2
|
-
import { LLMClient } from "../llm/LLMClient";
|
|
3
|
-
import { StagehandPage } from "../StagehandPage";
|
|
4
|
-
import { ActResult, ObserveResult, ActOptions } from "@/types/stagehand";
|
|
5
|
-
import { StagehandObserveHandler } from "@/lib/handlers/observeHandler";
|
|
6
|
-
/**
|
|
7
|
-
* NOTE: Vision support has been removed from this version of Stagehand.
|
|
8
|
-
* If useVision or verifierUseVision is set to true, a warning is logged and
|
|
9
|
-
* the flow continues as if vision = false.
|
|
10
|
-
*/
|
|
11
|
-
export declare class StagehandActHandler {
|
|
12
|
-
private readonly stagehandPage;
|
|
13
|
-
private readonly logger;
|
|
14
|
-
private readonly selfHeal;
|
|
15
|
-
private readonly experimental;
|
|
16
|
-
constructor({ logger, stagehandPage, selfHeal, experimental, }: {
|
|
17
|
-
logger: (logLine: LogLine) => void;
|
|
18
|
-
stagehandPage: StagehandPage;
|
|
19
|
-
selfHeal: boolean;
|
|
20
|
-
experimental: boolean;
|
|
21
|
-
});
|
|
22
|
-
/**
|
|
23
|
-
* Perform an immediate Playwright action based on an ObserveResult object
|
|
24
|
-
* that was returned from `page.observe(...)`.
|
|
25
|
-
*/
|
|
26
|
-
actFromObserveResult(observe: ObserveResult, domSettleTimeoutMs?: number): Promise<ActResult>;
|
|
27
|
-
/**
|
|
28
|
-
* Perform an act based on an instruction.
|
|
29
|
-
* This method will observe the page and then perform the act on the first element returned.
|
|
30
|
-
*/
|
|
31
|
-
observeAct(actionOrOptions: ActOptions, observeHandler: StagehandObserveHandler, llmClient: LLMClient, requestId: string): Promise<ActResult>;
|
|
32
|
-
private _performPlaywrightMethod;
|
|
33
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { AgentExecuteOptions, AgentHandlerOptions, AgentResult } from "@/types/agent";
|
|
2
|
-
import { ToolSet } from "ai/dist";
|
|
3
|
-
import { LogLine } from "../../types/log";
|
|
4
|
-
import { StagehandPage } from "../StagehandPage";
|
|
5
|
-
import { AgentClient } from "../agent/AgentClient";
|
|
6
|
-
import { StagehandAgent } from "../agent/StagehandAgent";
|
|
7
|
-
import { Stagehand } from "../index";
|
|
8
|
-
export declare class CuaAgentHandler {
|
|
9
|
-
private stagehand;
|
|
10
|
-
private stagehandPage;
|
|
11
|
-
private agent;
|
|
12
|
-
private provider;
|
|
13
|
-
private logger;
|
|
14
|
-
private agentClient;
|
|
15
|
-
private options;
|
|
16
|
-
private screenshotCollector?;
|
|
17
|
-
private highlightCursor;
|
|
18
|
-
constructor(stagehand: Stagehand, stagehandPage: StagehandPage, logger: (message: LogLine) => void, options: AgentHandlerOptions, tools?: ToolSet);
|
|
19
|
-
private setupAgentClient;
|
|
20
|
-
/**
|
|
21
|
-
* Execute a task with the agent
|
|
22
|
-
*/
|
|
23
|
-
execute(optionsOrInstruction: AgentExecuteOptions | string): Promise<AgentResult>;
|
|
24
|
-
/**
|
|
25
|
-
* Execute a single action on the page
|
|
26
|
-
*/
|
|
27
|
-
private executeAction;
|
|
28
|
-
private updateClientViewport;
|
|
29
|
-
private updateClientUrl;
|
|
30
|
-
getAgent(): StagehandAgent;
|
|
31
|
-
getClient(): AgentClient;
|
|
32
|
-
captureAndSendScreenshot(): Promise<unknown>;
|
|
33
|
-
/**
|
|
34
|
-
* Inject a cursor element into the page for visual feedback
|
|
35
|
-
*/
|
|
36
|
-
private injectCursor;
|
|
37
|
-
/**
|
|
38
|
-
* Update the cursor position on the page
|
|
39
|
-
*/
|
|
40
|
-
private updateCursorPosition;
|
|
41
|
-
/**
|
|
42
|
-
* Animate a click at the given position
|
|
43
|
-
*/
|
|
44
|
-
private animateClick;
|
|
45
|
-
private get page();
|
|
46
|
-
/**
|
|
47
|
-
* Set the screenshot collector for this agent handler
|
|
48
|
-
*/
|
|
49
|
-
setScreenshotCollector(collector: any): void;
|
|
50
|
-
/**
|
|
51
|
-
* Get the screenshot collector
|
|
52
|
-
*/
|
|
53
|
-
getScreenshotCollector(): any;
|
|
54
|
-
/**
|
|
55
|
-
* Set the tools for this agent handler
|
|
56
|
-
*/
|
|
57
|
-
setTools(tools: ToolSet): void;
|
|
58
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v3";
|
|
2
|
-
import { ZodPathSegments } from "../../types/stagehand";
|
|
3
|
-
import { LLMClient } from "../llm/LLMClient";
|
|
4
|
-
import { StagehandPage } from "../StagehandPage";
|
|
5
|
-
import { Stagehand } from "../index";
|
|
6
|
-
export declare class StagehandExtractHandler {
|
|
7
|
-
private readonly stagehand;
|
|
8
|
-
private readonly stagehandPage;
|
|
9
|
-
private readonly logger;
|
|
10
|
-
private readonly userProvidedInstructions?;
|
|
11
|
-
private readonly experimental;
|
|
12
|
-
constructor({ stagehand, logger, stagehandPage, userProvidedInstructions, experimental, }: {
|
|
13
|
-
stagehand: Stagehand;
|
|
14
|
-
logger: (message: {
|
|
15
|
-
category?: string;
|
|
16
|
-
message: string;
|
|
17
|
-
level?: number;
|
|
18
|
-
auxiliary?: {
|
|
19
|
-
[key: string]: {
|
|
20
|
-
value: string;
|
|
21
|
-
type: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
}) => void;
|
|
25
|
-
stagehandPage: StagehandPage;
|
|
26
|
-
userProvidedInstructions?: string;
|
|
27
|
-
experimental: boolean;
|
|
28
|
-
});
|
|
29
|
-
extract<T extends z.AnyZodObject>({ instruction, schema, content, llmClient, requestId, domSettleTimeoutMs, useTextExtract, selector, iframes, }?: {
|
|
30
|
-
instruction?: string;
|
|
31
|
-
schema?: T;
|
|
32
|
-
content?: z.infer<T>;
|
|
33
|
-
chunksSeen?: Array<number>;
|
|
34
|
-
llmClient?: LLMClient;
|
|
35
|
-
requestId?: string;
|
|
36
|
-
domSettleTimeoutMs?: number;
|
|
37
|
-
useTextExtract?: boolean;
|
|
38
|
-
selector?: string;
|
|
39
|
-
iframes?: boolean;
|
|
40
|
-
}): Promise<z.infer<T>>;
|
|
41
|
-
private extractPageText;
|
|
42
|
-
private domExtract;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Scans the provided Zod schema for any `z.string().url()` fields and
|
|
46
|
-
* replaces them with `z.number()`.
|
|
47
|
-
*
|
|
48
|
-
* @param schema - The Zod object schema to transform.
|
|
49
|
-
* @returns A tuple containing:
|
|
50
|
-
* 1. The transformed schema (or the original schema if no changes were needed).
|
|
51
|
-
* 2. An array of {@link ZodPathSegments} objects representing all the replaced URL fields,
|
|
52
|
-
* with each path segment showing where in the schema the replacement occurred.
|
|
53
|
-
*/
|
|
54
|
-
export declare function transformUrlStringsToNumericIds<T extends z.ZodObject<z.ZodRawShape>>(schema: T): [T, ZodPathSegments[]];
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Page, Locator, FrameLocator } from "playwright";
|
|
2
|
-
import { MethodHandlerContext } from "@/types/act";
|
|
3
|
-
export declare function deepLocatorWithShadow(root: Page | FrameLocator, xpath: string): Promise<Locator>;
|
|
4
|
-
export declare function deepLocator(root: Page | FrameLocator, xpath: string): Locator;
|
|
5
|
-
/**
|
|
6
|
-
* A mapping of playwright methods that may be chosen by the LLM to their
|
|
7
|
-
* implementation.
|
|
8
|
-
*/
|
|
9
|
-
export declare const methodHandlerMap: Record<string, (ctx: MethodHandlerContext) => Promise<void>>;
|
|
10
|
-
export declare function scrollToNextChunk(ctx: MethodHandlerContext): Promise<void>;
|
|
11
|
-
export declare function scrollToPreviousChunk(ctx: MethodHandlerContext): Promise<void>;
|
|
12
|
-
export declare function scrollElementIntoView(ctx: MethodHandlerContext): Promise<void>;
|
|
13
|
-
export declare function scrollElementToPercentage(ctx: MethodHandlerContext): Promise<void>;
|
|
14
|
-
export declare function fillOrType(ctx: MethodHandlerContext): Promise<void>;
|
|
15
|
-
export declare function pressKey(ctx: MethodHandlerContext): Promise<void>;
|
|
16
|
-
export declare function selectOption(ctx: MethodHandlerContext): Promise<void>;
|
|
17
|
-
export declare function clickElement(ctx: MethodHandlerContext): Promise<void>;
|
|
18
|
-
/**
|
|
19
|
-
* Fallback method: if method is not in our map but *is* a valid Playwright locator method.
|
|
20
|
-
*/
|
|
21
|
-
export declare function fallbackLocatorMethod(ctx: MethodHandlerContext): Promise<void>;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { LogLine } from "../../types/log";
|
|
2
|
-
import { Stagehand } from "../index";
|
|
3
|
-
import { LLMClient } from "../llm/LLMClient";
|
|
4
|
-
import { StagehandPage } from "../StagehandPage";
|
|
5
|
-
export declare class StagehandObserveHandler {
|
|
6
|
-
private readonly stagehand;
|
|
7
|
-
private readonly logger;
|
|
8
|
-
private readonly stagehandPage;
|
|
9
|
-
private readonly experimental;
|
|
10
|
-
private readonly userProvidedInstructions?;
|
|
11
|
-
constructor({ stagehand, logger, stagehandPage, userProvidedInstructions, experimental, }: {
|
|
12
|
-
stagehand: Stagehand;
|
|
13
|
-
logger: (logLine: LogLine) => void;
|
|
14
|
-
stagehandPage: StagehandPage;
|
|
15
|
-
userProvidedInstructions?: string;
|
|
16
|
-
experimental: boolean;
|
|
17
|
-
});
|
|
18
|
-
observe({ instruction, llmClient, requestId, returnAction, onlyVisible, drawOverlay, fromAct, iframes, }: {
|
|
19
|
-
instruction: string;
|
|
20
|
-
llmClient: LLMClient;
|
|
21
|
-
requestId: string;
|
|
22
|
-
domSettleTimeoutMs?: number;
|
|
23
|
-
returnAction?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated The `onlyVisible` parameter has no effect in this version of Stagehand and will be removed in later versions.
|
|
26
|
-
*/
|
|
27
|
-
onlyVisible?: boolean;
|
|
28
|
-
drawOverlay?: boolean;
|
|
29
|
-
fromAct?: boolean;
|
|
30
|
-
iframes?: boolean;
|
|
31
|
-
}): Promise<({
|
|
32
|
-
selector: string;
|
|
33
|
-
description: string;
|
|
34
|
-
} | {
|
|
35
|
-
selector: string;
|
|
36
|
-
method: string;
|
|
37
|
-
arguments: string[];
|
|
38
|
-
description: string;
|
|
39
|
-
})[]>;
|
|
40
|
-
}
|