@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.
Files changed (160) hide show
  1. package/dist/index.d.ts +806 -682
  2. package/dist/index.js +34207 -23774
  3. package/package.json +46 -83
  4. package/LICENSE +0 -21
  5. package/README.md +0 -165
  6. package/dist/lib/StagehandContext.d.ts +0 -25
  7. package/dist/lib/StagehandPage.d.ts +0 -103
  8. package/dist/lib/a11y/utils.d.ts +0 -144
  9. package/dist/lib/agent/AgentClient.d.ts +0 -20
  10. package/dist/lib/agent/AgentProvider.d.ts +0 -19
  11. package/dist/lib/agent/AnthropicCUAClient.d.ts +0 -56
  12. package/dist/lib/agent/GoogleCUAClient.d.ts +0 -63
  13. package/dist/lib/agent/OpenAICUAClient.d.ts +0 -65
  14. package/dist/lib/agent/StagehandAgent.d.ts +0 -15
  15. package/dist/lib/agent/tools/act.d.ts +0 -59
  16. package/dist/lib/agent/tools/ariaTree.d.ts +0 -11
  17. package/dist/lib/agent/tools/close.d.ts +0 -22
  18. package/dist/lib/agent/tools/extract.d.ts +0 -38
  19. package/dist/lib/agent/tools/fillform.d.ts +0 -37
  20. package/dist/lib/agent/tools/goto.d.ts +0 -29
  21. package/dist/lib/agent/tools/index.d.ts +0 -257
  22. package/dist/lib/agent/tools/navback.d.ts +0 -17
  23. package/dist/lib/agent/tools/screenshot.d.ts +0 -13
  24. package/dist/lib/agent/tools/scroll.d.ts +0 -23
  25. package/dist/lib/agent/tools/wait.d.ts +0 -18
  26. package/dist/lib/agent/utils/cuaKeyMapping.d.ts +0 -10
  27. package/dist/lib/agent/utils/imageCompression.d.ts +0 -53
  28. package/dist/lib/agent/utils/messageProcessing.d.ts +0 -13
  29. package/dist/lib/api.d.ts +0 -23
  30. package/dist/lib/browserbaseDefaults.d.ts +0 -9
  31. package/dist/lib/cache/ActionCache.d.ts +0 -62
  32. package/dist/lib/cache/BaseCache.d.ts +0 -66
  33. package/dist/lib/cache/LLMCache.d.ts +0 -22
  34. package/dist/lib/cache.d.ts +0 -29
  35. package/dist/lib/dom/build/scriptContent.d.ts +0 -1
  36. package/dist/lib/dom/elementCheckUtils.d.ts +0 -2
  37. package/dist/lib/dom/genDomScripts.d.ts +0 -1
  38. package/dist/lib/dom/index.d.ts +0 -2
  39. package/dist/lib/dom/process.d.ts +0 -17
  40. package/dist/lib/dom/utils.d.ts +0 -7
  41. package/dist/lib/dom/xpathUtils.d.ts +0 -14
  42. package/dist/lib/handlers/actHandler.d.ts +0 -33
  43. package/dist/lib/handlers/cuaAgentHandler.d.ts +0 -58
  44. package/dist/lib/handlers/extractHandler.d.ts +0 -54
  45. package/dist/lib/handlers/handlerUtils/actHandlerUtils.d.ts +0 -21
  46. package/dist/lib/handlers/observeHandler.d.ts +0 -40
  47. package/dist/lib/handlers/stagehandAgentHandler.d.ts +0 -27
  48. package/dist/lib/index.d.ts +0 -94
  49. package/dist/lib/inference.d.ts +0 -71
  50. package/dist/lib/inferenceLogUtils.d.ts +0 -12
  51. package/dist/lib/llm/AnthropicClient.d.ts +0 -21
  52. package/dist/lib/llm/CerebrasClient.d.ts +0 -22
  53. package/dist/lib/llm/GoogleClient.d.ts +0 -24
  54. package/dist/lib/llm/GroqClient.d.ts +0 -22
  55. package/dist/lib/llm/LLMClient.d.ts +0 -99
  56. package/dist/lib/llm/LLMProvider.d.ts +0 -13
  57. package/dist/lib/llm/OpenAIClient.d.ts +0 -20
  58. package/dist/lib/llm/aisdk.d.ts +0 -20
  59. package/dist/lib/logger.d.ts +0 -54
  60. package/dist/lib/mcp/connection.d.ts +0 -11
  61. package/dist/lib/mcp/utils.d.ts +0 -3
  62. package/dist/lib/prompt.d.ts +0 -12
  63. package/dist/lib/utils.d.ts +0 -65
  64. package/dist/lib/v3/agent/AgentClient.d.ts +0 -18
  65. package/dist/lib/v3/agent/AgentProvider.d.ts +0 -18
  66. package/dist/lib/v3/agent/AnthropicCUAClient.d.ts +0 -55
  67. package/dist/lib/v3/agent/OpenAICUAClient.d.ts +0 -64
  68. package/dist/lib/v3/agent/StagehandAgent.d.ts +0 -15
  69. package/dist/lib/v3/agent/tools/index.d.ts +0 -229
  70. package/dist/lib/v3/agent/tools/v3-act.d.ts +0 -29
  71. package/dist/lib/v3/agent/tools/v3-ariaTree.d.ts +0 -11
  72. package/dist/lib/v3/agent/tools/v3-close.d.ts +0 -24
  73. package/dist/lib/v3/agent/tools/v3-extract.d.ts +0 -38
  74. package/dist/lib/v3/agent/tools/v3-fillform.d.ts +0 -37
  75. package/dist/lib/v3/agent/tools/v3-goto.d.ts +0 -29
  76. package/dist/lib/v3/agent/tools/v3-navback.d.ts +0 -17
  77. package/dist/lib/v3/agent/tools/v3-screenshot.d.ts +0 -13
  78. package/dist/lib/v3/agent/tools/v3-scroll.d.ts +0 -23
  79. package/dist/lib/v3/agent/tools/v3-wait.d.ts +0 -19
  80. package/dist/lib/v3/agent/utils/cuaKeyMapping.d.ts +0 -10
  81. package/dist/lib/v3/agent/utils/imageCompression.d.ts +0 -18
  82. package/dist/lib/v3/agent/utils/messageProcessing.d.ts +0 -13
  83. package/dist/lib/v3/dom/build/scriptV3Content.d.ts +0 -1
  84. package/dist/lib/v3/dom/genDomScripts.d.ts +0 -1
  85. package/dist/lib/v3/dom/index.d.ts +0 -1
  86. package/dist/lib/v3/dom/piercer.entry.d.ts +0 -1
  87. package/dist/lib/v3/dom/piercer.runtime.d.ts +0 -25
  88. package/dist/lib/v3/handlers/actHandler.d.ts +0 -18
  89. package/dist/lib/v3/handlers/extractHandler.d.ts +0 -29
  90. package/dist/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +0 -18
  91. package/dist/lib/v3/handlers/observeHandler.d.ts +0 -15
  92. package/dist/lib/v3/handlers/v3AgentHandler.d.ts +0 -17
  93. package/dist/lib/v3/handlers/v3CuaAgentHandler.d.ts +0 -26
  94. package/dist/lib/v3/index.d.ts +0 -10
  95. package/dist/lib/v3/launch/browserbase.d.ts +0 -8
  96. package/dist/lib/v3/launch/local.d.ts +0 -13
  97. package/dist/lib/v3/llm/AnthropicClient.d.ts +0 -16
  98. package/dist/lib/v3/llm/CerebrasClient.d.ts +0 -17
  99. package/dist/lib/v3/llm/GoogleClient.d.ts +0 -19
  100. package/dist/lib/v3/llm/GroqClient.d.ts +0 -17
  101. package/dist/lib/v3/llm/LLMClient.d.ts +0 -99
  102. package/dist/lib/v3/llm/LLMProvider.d.ts +0 -10
  103. package/dist/lib/v3/llm/OpenAIClient.d.ts +0 -15
  104. package/dist/lib/v3/llm/aisdk.d.ts +0 -15
  105. package/dist/lib/v3/logger.d.ts +0 -48
  106. package/dist/lib/v3/mcp/connection.d.ts +0 -11
  107. package/dist/lib/v3/mcp/utils.d.ts +0 -3
  108. package/dist/lib/v3/tests/default-page-tracking.spec.d.ts +0 -1
  109. package/dist/lib/v3/tests/downloads.spec.d.ts +0 -1
  110. package/dist/lib/v3/tests/perform-understudy-method.spec.d.ts +0 -1
  111. package/dist/lib/v3/tests/shadow-iframe.spec.d.ts +0 -1
  112. package/dist/lib/v3/tests/timeouts.spec.d.ts +0 -1
  113. package/dist/lib/v3/tests/v3.bb.config.d.ts +0 -4
  114. package/dist/lib/v3/tests/v3.config.d.ts +0 -4
  115. package/dist/lib/v3/tests/v3.playwright.config.d.ts +0 -2
  116. package/dist/lib/v3/tests/xpath-for-location-deep.spec.d.ts +0 -1
  117. package/dist/lib/v3/types/act.d.ts +0 -10
  118. package/dist/lib/v3/types/agent.d.ts +0 -132
  119. package/dist/lib/v3/types/api.d.ts +0 -40
  120. package/dist/lib/v3/types/cache.d.ts +0 -71
  121. package/dist/lib/v3/types/context.d.ts +0 -2
  122. package/dist/lib/v3/types/evals.d.ts +0 -71
  123. package/dist/lib/v3/types/evaluator.d.ts +0 -40
  124. package/dist/lib/v3/types/llm.d.ts +0 -11
  125. package/dist/lib/v3/types/log.d.ts +0 -23
  126. package/dist/lib/v3/types/model.d.ts +0 -20
  127. package/dist/lib/v3/types/playwright.d.ts +0 -6
  128. package/dist/lib/v3/types/stagehand.d.ts +0 -113
  129. package/dist/lib/v3/types/stagehandApiErrors.d.ts +0 -18
  130. package/dist/lib/v3/types/stagehandErrors.d.ts +0 -104
  131. package/dist/lib/v3/types.d.ts +0 -176
  132. package/dist/lib/v3/understudy/a11y/snapshot.d.ts +0 -71
  133. package/dist/lib/v3/understudy/cdp.d.ts +0 -58
  134. package/dist/lib/v3/understudy/context.d.ts +0 -120
  135. package/dist/lib/v3/understudy/deepLocator.d.ts +0 -69
  136. package/dist/lib/v3/understudy/executionContextRegistry.d.ts +0 -15
  137. package/dist/lib/v3/understudy/frame.d.ts +0 -63
  138. package/dist/lib/v3/understudy/frameLocator.d.ts +0 -46
  139. package/dist/lib/v3/understudy/frameRegistry.d.ts +0 -100
  140. package/dist/lib/v3/understudy/locator.d.ts +0 -196
  141. package/dist/lib/v3/understudy/page.d.ts +0 -241
  142. package/dist/lib/v3/understudy/piercer.d.ts +0 -4
  143. package/dist/lib/v3/v3.d.ts +0 -158
  144. package/dist/lib/version.d.ts +0 -5
  145. package/dist/stagehand.config.d.ts +0 -3
  146. package/dist/types/act.d.ts +0 -50
  147. package/dist/types/agent.d.ts +0 -143
  148. package/dist/types/api.d.ts +0 -40
  149. package/dist/types/browser.d.ts +0 -10
  150. package/dist/types/context.d.ts +0 -117
  151. package/dist/types/evals.d.ts +0 -94
  152. package/dist/types/evaluator.d.ts +0 -40
  153. package/dist/types/llm.d.ts +0 -11
  154. package/dist/types/log.d.ts +0 -23
  155. package/dist/types/model.d.ts +0 -17
  156. package/dist/types/page.d.ts +0 -38
  157. package/dist/types/playwright.d.ts +0 -12
  158. package/dist/types/stagehand.d.ts +0 -330
  159. package/dist/types/stagehandApiErrors.d.ts +0 -18
  160. package/dist/types/stagehandErrors.d.ts +0 -104
@@ -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
- }
@@ -1,27 +0,0 @@
1
- import { AgentExecuteOptions, AgentResult } from "@/types/agent";
2
- import { LogLine } from "@/types/log";
3
- import { LLMClient } from "../llm/LLMClient";
4
- import { ToolSet } from "ai";
5
- import { Stagehand } from "../index";
6
- export declare class StagehandAgentHandler {
7
- private stagehand;
8
- private logger;
9
- private llmClient;
10
- private executionModel?;
11
- private systemInstructions?;
12
- private tools?;
13
- private screenshotCollector?;
14
- constructor(stagehand: Stagehand, logger: (message: LogLine) => void, llmClient: LLMClient, executionModel?: string, systemInstructions?: string, tools?: ToolSet);
15
- execute(instructionOrOptions: string | AgentExecuteOptions): Promise<AgentResult>;
16
- private buildSystemPrompt;
17
- private createTools;
18
- /**
19
- * Set the screenshot collector for this agent handler
20
- */
21
- setScreenshotCollector(collector: any): void;
22
- /**
23
- * Get the screenshot collector
24
- */
25
- getScreenshotCollector(): any;
26
- setTools(tools: ToolSet): void;
27
- }
@@ -1,94 +0,0 @@
1
- import { GotoOptions } from "@/types/playwright";
2
- import { z } from "zod/v3";
3
- import { AgentExecuteOptions, AgentResult } from "../types/agent";
4
- import { EnhancedContext } from "../types/context";
5
- import { LogLine } from "../types/log";
6
- import { ClientOptions } from "../types/model";
7
- import { Page } from "../types/page";
8
- import { ActOptions, AgentConfig, ConstructorParams, ExtractOptions, HistoryEntry, InitResult, ObserveOptions, StagehandFunctionName, StagehandMetrics } from "../types/stagehand";
9
- import { StagehandPage } from "./StagehandPage";
10
- import { StagehandAPI } from "./api";
11
- import { LLMClient } from "./llm/LLMClient";
12
- import { LLMProvider } from "./llm/LLMProvider";
13
- import { connectToMCPServer } from "./mcp/connection";
14
- export declare class Stagehand {
15
- private stagehandPage;
16
- private stagehandContext;
17
- browserbaseSessionID?: string;
18
- readonly domSettleTimeoutMs: number;
19
- readonly debugDom: boolean;
20
- readonly headless: boolean;
21
- verbose: 0 | 1 | 2;
22
- llmProvider: LLMProvider;
23
- enableCaching: boolean;
24
- protected apiKey: string | undefined;
25
- private projectId;
26
- private externalLogger?;
27
- private browserbaseSessionCreateParams?;
28
- variables: {
29
- [key: string]: unknown;
30
- };
31
- private contextPath?;
32
- llmClient: LLMClient;
33
- readonly userProvidedInstructions?: string;
34
- private usingAPI;
35
- private modelName;
36
- apiClient: StagehandAPI | undefined;
37
- readonly waitForCaptchaSolves: boolean;
38
- private localBrowserLaunchOptions?;
39
- readonly selfHeal: boolean;
40
- private cleanupCalled;
41
- readonly actTimeoutMs: number;
42
- readonly logInferenceToFile?: boolean;
43
- private stagehandLogger;
44
- private disablePino;
45
- protected modelClientOptions: ClientOptions;
46
- private _env;
47
- private _browser;
48
- private _isClosed;
49
- private _history;
50
- readonly experimental: boolean;
51
- private _livePageProxy?;
52
- private createLivePageProxy;
53
- get history(): ReadonlyArray<HistoryEntry>;
54
- protected setActivePage(page: StagehandPage): void;
55
- get page(): Page;
56
- stagehandMetrics: StagehandMetrics;
57
- get metrics(): StagehandMetrics;
58
- get isClosed(): boolean;
59
- updateMetrics(functionName: StagehandFunctionName, promptTokens: number, completionTokens: number, inferenceTimeMs: number): void;
60
- private updateTotalMetrics;
61
- constructor({ env, apiKey, projectId, verbose, llmProvider, llmClient, logger, browserbaseSessionCreateParams, domSettleTimeoutMs, enableCaching, browserbaseSessionID, modelName, modelClientOptions, systemPrompt, useAPI, localBrowserLaunchOptions, waitForCaptchaSolves, logInferenceToFile, selfHeal, disablePino, experimental, }?: ConstructorParams);
62
- private registerSignalHandlers;
63
- get logger(): (logLine: LogLine) => void;
64
- get env(): "LOCAL" | "BROWSERBASE";
65
- get downloadsPath(): string;
66
- get context(): EnhancedContext;
67
- init(): Promise<InitResult>;
68
- log(logObj: LogLine): void;
69
- close(): Promise<void>;
70
- addToHistory(method: HistoryEntry["method"], parameters: ActOptions | ExtractOptions<z.AnyZodObject> | ObserveOptions | {
71
- url: string;
72
- options: GotoOptions;
73
- } | string, result?: unknown): void;
74
- /**
75
- * Create an agent instance that can be executed with different instructions
76
- * @returns An agent instance with execute() method
77
- */
78
- agent(options?: AgentConfig): {
79
- execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
80
- setScreenshotCollector?: (collector: unknown) => void;
81
- };
82
- }
83
- export * from "../types/agent";
84
- export * from "../types/browser";
85
- export * from "../types/log";
86
- export * from "../types/model";
87
- export * from "../types/page";
88
- export * from "../types/playwright";
89
- export * from "../types/stagehand";
90
- export * from "../types/stagehandApiErrors";
91
- export * from "../types/stagehandErrors";
92
- export * from "./llm/LLMClient";
93
- export * from "./llm/aisdk";
94
- export { connectToMCPServer };
@@ -1,71 +0,0 @@
1
- import { z } from "zod/v3";
2
- import { LogLine } from "./v3/types/log";
3
- import { LLMClient } from "./v3/llm/LLMClient";
4
- /** Simple usage shape if your LLM returns usage tokens. */
5
- interface LLMUsage {
6
- prompt_tokens: number;
7
- completion_tokens: number;
8
- total_tokens: number;
9
- }
10
- /**
11
- * For calls that use a schema: the LLMClient may return { data: T; usage?: LLMUsage }
12
- */
13
- export interface LLMParsedResponse<T> {
14
- data: T;
15
- usage?: LLMUsage;
16
- }
17
- export declare function extract({ instruction, domElements, schema, llmClient, logger, userProvidedInstructions, logInferenceToFile, }: {
18
- instruction: string;
19
- domElements: string;
20
- schema: z.ZodObject<z.ZodRawShape>;
21
- llmClient: LLMClient;
22
- userProvidedInstructions?: string;
23
- logger: (message: LogLine) => void;
24
- logInferenceToFile?: boolean;
25
- }): Promise<{
26
- metadata: {
27
- completed: boolean;
28
- progress: string;
29
- };
30
- prompt_tokens: number;
31
- completion_tokens: number;
32
- inference_time_ms: number;
33
- }>;
34
- export declare function observe({ instruction, domElements, llmClient, userProvidedInstructions, logger, logInferenceToFile, }: {
35
- instruction: string;
36
- domElements: string;
37
- llmClient: LLMClient;
38
- userProvidedInstructions?: string;
39
- logger: (message: LogLine) => void;
40
- logInferenceToFile?: boolean;
41
- }): Promise<{
42
- elements: {
43
- elementId: string;
44
- description: string;
45
- method: string;
46
- arguments: string[];
47
- }[];
48
- prompt_tokens: number;
49
- completion_tokens: number;
50
- inference_time_ms: number;
51
- }>;
52
- export declare function act({ instruction, domElements, llmClient, userProvidedInstructions, logger, logInferenceToFile, }: {
53
- instruction: string;
54
- domElements: string;
55
- llmClient: LLMClient;
56
- userProvidedInstructions?: string;
57
- logger: (message: LogLine) => void;
58
- logInferenceToFile?: boolean;
59
- }): Promise<{
60
- element: {
61
- elementId: string;
62
- description: string;
63
- method: string;
64
- arguments: string[];
65
- };
66
- prompt_tokens: number;
67
- completion_tokens: number;
68
- inference_time_ms: number;
69
- twoStep: boolean;
70
- }>;
71
- export {};
@@ -1,12 +0,0 @@
1
- /**
2
- * Appends a new entry to the act_summary.json file, then writes the file back out.
3
- */
4
- export declare function appendSummary<T>(inferenceType: string, entry: T): void;
5
- /**
6
- * Writes `data` as JSON into a file in `directory`, using a prefix plus timestamp.
7
- * Returns both the file name and the timestamp used, so you can log them.
8
- */
9
- export declare function writeTimestampedTxtFile(directory: string, prefix: string, data: unknown): {
10
- fileName: string;
11
- timestamp: string;
12
- };
@@ -1,21 +0,0 @@
1
- import { ClientOptions } from "@anthropic-ai/sdk";
2
- import { LogLine } from "../../types/log";
3
- import { AvailableModel } from "../../types/model";
4
- import { LLMCache } from "../cache/LLMCache";
5
- import { CreateChatCompletionOptions, LLMClient, LLMResponse } from "./LLMClient";
6
- export declare class AnthropicClient extends LLMClient {
7
- type: "anthropic";
8
- private client;
9
- private cache;
10
- private enableCaching;
11
- clientOptions: ClientOptions;
12
- constructor({ enableCaching, cache, modelName, clientOptions, userProvidedInstructions, }: {
13
- logger: (message: LogLine) => void;
14
- enableCaching?: boolean;
15
- cache?: LLMCache;
16
- modelName: AvailableModel;
17
- clientOptions?: ClientOptions;
18
- userProvidedInstructions?: string;
19
- });
20
- createChatCompletion<T = LLMResponse>({ options, retries, logger, }: CreateChatCompletionOptions): Promise<T>;
21
- }
@@ -1,22 +0,0 @@
1
- import type { ClientOptions } from "openai";
2
- import { LogLine } from "../../types/log";
3
- import { AvailableModel } from "../../types/model";
4
- import { LLMCache } from "../cache/LLMCache";
5
- import { CreateChatCompletionOptions, LLMClient, LLMResponse } from "./LLMClient";
6
- export declare class CerebrasClient extends LLMClient {
7
- type: "cerebras";
8
- private client;
9
- private cache;
10
- private enableCaching;
11
- clientOptions: ClientOptions;
12
- hasVision: boolean;
13
- constructor({ enableCaching, cache, modelName, clientOptions, userProvidedInstructions, }: {
14
- logger: (message: LogLine) => void;
15
- enableCaching?: boolean;
16
- cache?: LLMCache;
17
- modelName: AvailableModel;
18
- clientOptions?: ClientOptions;
19
- userProvidedInstructions?: string;
20
- });
21
- createChatCompletion<T = LLMResponse>({ options, retries, logger, }: CreateChatCompletionOptions): Promise<T>;
22
- }
@@ -1,24 +0,0 @@
1
- import { LogLine } from "../../types/log";
2
- import { AvailableModel, ClientOptions } from "../../types/model";
3
- import { LLMCache } from "../cache/LLMCache";
4
- import { CreateChatCompletionOptions, LLMClient, LLMResponse } from "./LLMClient";
5
- export declare class GoogleClient extends LLMClient {
6
- type: "google";
7
- private client;
8
- private cache;
9
- private enableCaching;
10
- clientOptions: ClientOptions;
11
- hasVision: boolean;
12
- private logger;
13
- constructor({ logger, // Added logger based on other clients
14
- enableCaching, cache, modelName, clientOptions, }: {
15
- logger: (message: LogLine) => void;
16
- enableCaching?: boolean;
17
- cache?: LLMCache;
18
- modelName: AvailableModel;
19
- clientOptions?: ClientOptions;
20
- });
21
- private formatMessages;
22
- private formatTools;
23
- createChatCompletion<T = LLMResponse>({ options, logger, retries, }: CreateChatCompletionOptions): Promise<T>;
24
- }
@@ -1,22 +0,0 @@
1
- import type { ClientOptions } from "openai";
2
- import { LogLine } from "../../types/log";
3
- import { AvailableModel } from "../../types/model";
4
- import { LLMCache } from "../cache/LLMCache";
5
- import { CreateChatCompletionOptions, LLMClient, LLMResponse } from "./LLMClient";
6
- export declare class GroqClient extends LLMClient {
7
- type: "groq";
8
- private client;
9
- private cache;
10
- private enableCaching;
11
- clientOptions: ClientOptions;
12
- hasVision: boolean;
13
- constructor({ enableCaching, cache, modelName, clientOptions, userProvidedInstructions, }: {
14
- logger: (message: LogLine) => void;
15
- enableCaching?: boolean;
16
- cache?: LLMCache;
17
- modelName: AvailableModel;
18
- clientOptions?: ClientOptions;
19
- userProvidedInstructions?: string;
20
- });
21
- createChatCompletion<T = LLMResponse>({ options, retries, logger, }: CreateChatCompletionOptions): Promise<T>;
22
- }
@@ -1,99 +0,0 @@
1
- import { LLMTool } from "@/types/llm";
2
- import { embed, embedMany, experimental_generateImage, experimental_generateSpeech, experimental_transcribe, generateObject, generateText, LanguageModel, streamObject, streamText } from "ai";
3
- import { ZodType } from "zod/v3";
4
- import { LogLine } from "../../types/log";
5
- import { AvailableModel, ClientOptions } from "../../types/model";
6
- export interface ChatMessage {
7
- role: "system" | "user" | "assistant";
8
- content: ChatMessageContent;
9
- }
10
- export type ChatMessageContent = string | (ChatMessageImageContent | ChatMessageTextContent)[];
11
- export interface ChatMessageImageContent {
12
- type: string;
13
- image_url?: {
14
- url: string;
15
- };
16
- text?: string;
17
- source?: {
18
- type: string;
19
- media_type: string;
20
- data: string;
21
- };
22
- }
23
- export interface ChatMessageTextContent {
24
- type: string;
25
- text: string;
26
- }
27
- export declare const AnnotatedScreenshotText = "This is a screenshot of the current page state with the elements annotated on it. Each element id is annotated with a number to the top left of it. Duplicate annotations at the same location are under each other vertically.";
28
- export interface ChatCompletionOptions {
29
- messages: ChatMessage[];
30
- temperature?: number;
31
- top_p?: number;
32
- frequency_penalty?: number;
33
- presence_penalty?: number;
34
- image?: {
35
- buffer: Buffer;
36
- description?: string;
37
- };
38
- response_model?: {
39
- name: string;
40
- schema: ZodType;
41
- };
42
- tools?: LLMTool[];
43
- tool_choice?: "auto" | "none" | "required";
44
- maxTokens?: number;
45
- requestId?: string;
46
- }
47
- export type LLMResponse = {
48
- id: string;
49
- object: string;
50
- created: number;
51
- model: string;
52
- choices: {
53
- index: number;
54
- message: {
55
- role: string;
56
- content: string | null;
57
- tool_calls: {
58
- id: string;
59
- type: string;
60
- function: {
61
- name: string;
62
- arguments: string;
63
- };
64
- }[];
65
- };
66
- finish_reason: string;
67
- }[];
68
- usage: {
69
- prompt_tokens: number;
70
- completion_tokens: number;
71
- total_tokens: number;
72
- };
73
- };
74
- export interface CreateChatCompletionOptions {
75
- options: ChatCompletionOptions;
76
- logger: (message: LogLine) => void;
77
- retries?: number;
78
- }
79
- export declare abstract class LLMClient {
80
- type: "openai" | "anthropic" | "cerebras" | "groq" | (string & {});
81
- modelName: AvailableModel | (string & {});
82
- hasVision: boolean;
83
- clientOptions: ClientOptions;
84
- userProvidedInstructions?: string;
85
- constructor(modelName: AvailableModel, userProvidedInstructions?: string);
86
- abstract createChatCompletion<T = LLMResponse & {
87
- usage?: LLMResponse["usage"];
88
- }>(options: CreateChatCompletionOptions): Promise<T>;
89
- generateObject: typeof generateObject;
90
- generateText: typeof generateText;
91
- streamText: typeof streamText;
92
- streamObject: typeof streamObject;
93
- generateImage: typeof experimental_generateImage;
94
- embed: typeof embed;
95
- embedMany: typeof embedMany;
96
- transcribe: typeof experimental_transcribe;
97
- generateSpeech: typeof experimental_generateSpeech;
98
- getLanguageModel?(): LanguageModel;
99
- }
@@ -1,13 +0,0 @@
1
- import { LogLine } from "../../types/log";
2
- import { AvailableModel, ClientOptions, ModelProvider } from "../../types/model";
3
- import { LLMClient } from "./LLMClient";
4
- export declare function getAISDKLanguageModel(subProvider: string, subModelName: string, apiKey?: string, baseURL?: string): import("ai/dist").LanguageModelV1;
5
- export declare class LLMProvider {
6
- private logger;
7
- private enableCaching;
8
- private cache;
9
- constructor(logger: (message: LogLine) => void, enableCaching: boolean);
10
- cleanRequestCache(requestId: string): void;
11
- getClient(modelName: AvailableModel, clientOptions?: ClientOptions): LLMClient;
12
- static getModelProvider(modelName: AvailableModel): ModelProvider;
13
- }
@@ -1,20 +0,0 @@
1
- import { ClientOptions } from "openai";
2
- import { LogLine } from "../../types/log";
3
- import { AvailableModel } from "../../types/model";
4
- import { LLMCache } from "../cache/LLMCache";
5
- import { CreateChatCompletionOptions, LLMClient, LLMResponse } from "./LLMClient";
6
- export declare class OpenAIClient extends LLMClient {
7
- type: "openai";
8
- private client;
9
- private cache;
10
- private enableCaching;
11
- clientOptions: ClientOptions;
12
- constructor({ enableCaching, cache, modelName, clientOptions, }: {
13
- logger: (message: LogLine) => void;
14
- enableCaching?: boolean;
15
- cache?: LLMCache;
16
- modelName: AvailableModel;
17
- clientOptions?: ClientOptions;
18
- });
19
- createChatCompletion<T = LLMResponse>({ options: optionsInitial, logger, retries, }: CreateChatCompletionOptions): Promise<T>;
20
- }
@@ -1,20 +0,0 @@
1
- import { LanguageModel } from "ai";
2
- import { ChatCompletion } from "openai/resources";
3
- import { LogLine } from "../../types/log";
4
- import { LLMCache } from "../cache/LLMCache";
5
- import { CreateChatCompletionOptions, LLMClient } from "./LLMClient";
6
- export declare class AISdkClient extends LLMClient {
7
- type: "aisdk";
8
- private model;
9
- private logger?;
10
- private cache;
11
- private enableCaching;
12
- constructor({ model, logger, enableCaching, cache, }: {
13
- model: LanguageModel;
14
- logger?: (message: LogLine) => void;
15
- enableCaching?: boolean;
16
- cache?: LLMCache;
17
- });
18
- getLanguageModel(): LanguageModel;
19
- createChatCompletion<T = ChatCompletion>({ options, }: CreateChatCompletionOptions): Promise<T>;
20
- }
@@ -1,54 +0,0 @@
1
- import pino from "pino";
2
- import { LogLine } from "./v3/types/log";
3
- export interface LoggerOptions {
4
- pretty?: boolean;
5
- level?: pino.Level;
6
- destination?: pino.DestinationStream;
7
- usePino?: boolean;
8
- }
9
- /**
10
- * Creates a configured Pino logger instance
11
- */
12
- export declare function createLogger(options?: LoggerOptions): import("pino/pino").Logger<never, boolean>;
13
- /**
14
- * StagehandLogger class that wraps Pino for our specific needs
15
- */
16
- export declare class StagehandLogger {
17
- /**
18
- * We maintain a single shared Pino instance when `usePino` is enabled.
19
- * This prevents spawning a new worker thread for every Stagehand instance
20
- * (which happens when `pino-pretty` transport is used), eliminating the
21
- * memory/RSS growth observed when many Stagehand objects are created and
22
- * disposed within the same process (e.g. a request-per-instance API).
23
- */
24
- private static sharedPinoLogger;
25
- private logger?;
26
- private verbose;
27
- private externalLogger?;
28
- private usePino;
29
- private isTest;
30
- constructor(options?: LoggerOptions, externalLogger?: (logLine: LogLine) => void);
31
- /**
32
- * Set the verbosity level
33
- */
34
- setVerbosity(level: 0 | 1 | 2): void;
35
- /**
36
- * Log a message using our LogLine format
37
- */
38
- log(logLine: LogLine): void;
39
- /**
40
- * Helper to format auxiliary data for structured logging
41
- */
42
- private formatAuxiliaryData;
43
- /**
44
- * Convenience methods for different log levels
45
- */
46
- error(message: string, data?: Record<string, unknown>): void;
47
- warn(message: string, data?: Record<string, unknown>): void;
48
- info(message: string, data?: Record<string, unknown>): void;
49
- debug(message: string, data?: Record<string, unknown>): void;
50
- /**
51
- * Convert a plain object to our auxiliary format
52
- */
53
- private convertToAuxiliary;
54
- }
@@ -1,11 +0,0 @@
1
- import { Client, ClientOptions } from "@modelcontextprotocol/sdk/client/index.js";
2
- export interface ConnectToMCPServerOptions {
3
- serverUrl: string | URL;
4
- clientOptions?: ClientOptions;
5
- }
6
- export interface StdioServerConfig {
7
- command: string;
8
- args?: string[];
9
- env?: Record<string, string>;
10
- }
11
- export declare const connectToMCPServer: (serverConfig: string | URL | StdioServerConfig | ConnectToMCPServerOptions) => Promise<Client>;
@@ -1,3 +0,0 @@
1
- import { Client } from "@modelcontextprotocol/sdk/dist/esm/client";
2
- import { ToolSet } from "ai/dist";
3
- export declare const resolveTools: (clients: (Client | string)[], userTools: ToolSet) => Promise<ToolSet>;
@@ -1,12 +0,0 @@
1
- import { ChatMessage } from "./v3/llm/LLMClient";
2
- export declare function buildUserInstructionsString(userProvidedInstructions?: string): string;
3
- export declare function buildExtractSystemPrompt(isUsingPrintExtractedDataTool?: boolean, userProvidedInstructions?: string): ChatMessage;
4
- export declare function buildExtractUserPrompt(instruction: string, domElements: string, isUsingPrintExtractedDataTool?: boolean): ChatMessage;
5
- export declare function buildMetadataSystemPrompt(): ChatMessage;
6
- export declare function buildMetadataPrompt(instruction: string, extractionResponse: object): ChatMessage;
7
- export declare function buildObserveSystemPrompt(userProvidedInstructions?: string): ChatMessage;
8
- export declare function buildObserveUserMessage(instruction: string, domElements: string): ChatMessage;
9
- export declare function buildActSystemPrompt(userProvidedInstructions?: string): ChatMessage;
10
- export declare function buildActPrompt(action: string, supportedActions: string[], variables?: Record<string, string>): string;
11
- export declare function buildStepTwoPrompt(originalUserAction: string, previousAction: string, supportedActions: string[], variables?: Record<string, string>): string;
12
- export declare function buildOperatorSystemPrompt(goal: string): ChatMessage;
@@ -1,65 +0,0 @@
1
- import { Schema } from "@google/genai";
2
- import { z, ZodTypeAny } from "zod/v3";
3
- import { LogLine } from "./v3/types/log";
4
- import { ModelProvider } from "./v3/types/model";
5
- import { ZodPathSegments } from "./v3/types/stagehand";
6
- export declare function validateZodSchema(schema: z.ZodTypeAny, data: unknown): boolean;
7
- /**
8
- * Detects if the code is running in the Bun runtime environment.
9
- * @returns {boolean} True if running in Bun, false otherwise.
10
- */
11
- export declare function isRunningInBun(): boolean;
12
- export declare function toGeminiSchema(zodSchema: z.ZodTypeAny): Schema;
13
- export declare function getZodType(schema: z.ZodTypeAny): string;
14
- /**
15
- * Recursively traverses a given Zod schema, scanning for any fields of type `z.string().url()`.
16
- * For each such field, it replaces the `z.string().url()` with `z.number()`.
17
- *
18
- * This function is used internally by higher-level utilities (e.g., transforming entire object schemas)
19
- * and handles nested objects, arrays, unions, intersections, optionals.
20
- *
21
- * @param schema - The Zod schema to transform.
22
- * @param currentPath - An array of string/number keys representing the current schema path (used internally for recursion).
23
- * @returns A two-element tuple:
24
- * 1. The updated Zod schema, with any `.url()` fields replaced by `z.number()`.
25
- * 2. An array of {@link ZodPathSegments} objects representing each replaced field, including the path segments.
26
- */
27
- export declare function transformSchema(schema: z.ZodTypeAny, currentPath: Array<string | number>): [z.ZodTypeAny, ZodPathSegments[]];
28
- /**
29
- * Once we get the final extracted object that has numeric IDs in place of URLs,
30
- * use `injectUrls` to walk the object and replace numeric IDs
31
- * with the real URL strings from idToUrlMapping. The `path` may include `*`
32
- * for array indices (indicating "all items in the array").
33
- */
34
- export declare function injectUrls(obj: unknown, path: Array<string | number>, idToUrlMapping: Record<string, string>): void;
35
- /**
36
- * Mapping from LLM provider names to their corresponding environment variable names for API keys.
37
- */
38
- export declare const providerEnvVarMap: Partial<Record<ModelProvider | string, string>>;
39
- /**
40
- * Loads an API key for a provider, checking environment variables.
41
- * @param provider The name of the provider (e.g., 'openai', 'anthropic')
42
- * @param logger Optional logger for info/error messages
43
- * @returns The API key if found, undefined otherwise
44
- */
45
- export declare function loadApiKeyFromEnv(provider: string | undefined, logger: (logLine: LogLine) => void): string | undefined;
46
- export declare function trimTrailingTextNode(path: string | undefined): string | undefined;
47
- export interface JsonSchemaProperty {
48
- type: string;
49
- enum?: unknown[];
50
- items?: JsonSchemaProperty;
51
- properties?: Record<string, JsonSchemaProperty>;
52
- required?: string[];
53
- minimum?: number;
54
- maximum?: number;
55
- description?: string;
56
- }
57
- export interface JsonSchema extends JsonSchemaProperty {
58
- type: string;
59
- }
60
- /**
61
- * Converts a JSON Schema object to a Zod schema
62
- * @param schema The JSON Schema object to convert
63
- * @returns A Zod schema equivalent to the input JSON Schema
64
- */
65
- export declare function jsonSchemaToZod(schema: JsonSchema): ZodTypeAny;
@@ -1,18 +0,0 @@
1
- import { AgentAction, AgentResult, AgentType, AgentExecutionOptions } from "../types/agent";
2
- /**
3
- * Abstract base class for agent clients
4
- * This provides a common interface for all agent implementations
5
- */
6
- export declare abstract class AgentClient {
7
- type: AgentType;
8
- modelName: string;
9
- clientOptions: Record<string, unknown>;
10
- userProvidedInstructions?: string;
11
- constructor(type: AgentType, modelName: string, userProvidedInstructions?: string);
12
- abstract execute(options: AgentExecutionOptions): Promise<AgentResult>;
13
- abstract captureScreenshot(options?: Record<string, unknown>): Promise<unknown>;
14
- abstract setViewport(width: number, height: number): void;
15
- abstract setCurrentUrl(url: string): void;
16
- abstract setScreenshotProvider(provider: () => Promise<string>): void;
17
- abstract setActionHandler(handler: (action: AgentAction) => Promise<void>): void;
18
- }