@browserbasehq/orca 3.0.0-preview.0 → 3.0.0-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/dist/index.d.ts +2 -0
  2. package/dist/index.js +43 -6
  3. package/dist/lib/StagehandContext.d.ts +25 -0
  4. package/dist/lib/StagehandPage.d.ts +103 -0
  5. package/dist/lib/a11y/utils.d.ts +144 -0
  6. package/dist/lib/agent/AgentClient.d.ts +20 -0
  7. package/dist/lib/agent/AgentProvider.d.ts +19 -0
  8. package/dist/lib/agent/AnthropicCUAClient.d.ts +56 -0
  9. package/dist/lib/agent/GoogleCUAClient.d.ts +63 -0
  10. package/dist/lib/agent/OpenAICUAClient.d.ts +65 -0
  11. package/dist/lib/agent/StagehandAgent.d.ts +15 -0
  12. package/dist/lib/agent/tools/act.d.ts +59 -0
  13. package/dist/lib/agent/tools/ariaTree.d.ts +11 -0
  14. package/dist/lib/agent/tools/close.d.ts +22 -0
  15. package/dist/lib/agent/tools/extract.d.ts +38 -0
  16. package/dist/lib/agent/tools/fillform.d.ts +37 -0
  17. package/dist/lib/agent/tools/goto.d.ts +29 -0
  18. package/dist/lib/agent/tools/index.d.ts +257 -0
  19. package/dist/lib/agent/tools/navback.d.ts +17 -0
  20. package/dist/lib/agent/tools/screenshot.d.ts +13 -0
  21. package/dist/lib/agent/tools/scroll.d.ts +23 -0
  22. package/dist/lib/agent/tools/wait.d.ts +18 -0
  23. package/dist/lib/agent/utils/cuaKeyMapping.d.ts +10 -0
  24. package/dist/lib/agent/utils/imageCompression.d.ts +53 -0
  25. package/dist/lib/agent/utils/messageProcessing.d.ts +13 -0
  26. package/dist/lib/browserbaseDefaults.d.ts +9 -0
  27. package/dist/lib/cache/ActionCache.d.ts +62 -0
  28. package/dist/lib/cache/BaseCache.d.ts +66 -0
  29. package/dist/lib/cache/LLMCache.d.ts +22 -0
  30. package/dist/lib/cache.d.ts +29 -0
  31. package/dist/lib/dom/elementCheckUtils.d.ts +2 -0
  32. package/dist/lib/dom/genDomScripts.d.ts +1 -0
  33. package/dist/lib/dom/index.d.ts +2 -0
  34. package/dist/lib/dom/process.d.ts +17 -0
  35. package/dist/lib/dom/utils.d.ts +7 -0
  36. package/dist/lib/dom/xpathUtils.d.ts +14 -0
  37. package/dist/lib/handlers/actHandler.d.ts +33 -0
  38. package/dist/lib/handlers/cuaAgentHandler.d.ts +58 -0
  39. package/dist/lib/handlers/extractHandler.d.ts +54 -0
  40. package/dist/lib/handlers/handlerUtils/actHandlerUtils.d.ts +21 -0
  41. package/dist/lib/handlers/observeHandler.d.ts +40 -0
  42. package/dist/lib/handlers/stagehandAgentHandler.d.ts +27 -0
  43. package/dist/lib/index.d.ts +94 -0
  44. package/dist/lib/llm/AnthropicClient.d.ts +21 -0
  45. package/dist/lib/llm/CerebrasClient.d.ts +22 -0
  46. package/dist/lib/llm/GoogleClient.d.ts +24 -0
  47. package/dist/lib/llm/GroqClient.d.ts +22 -0
  48. package/dist/lib/llm/LLMClient.d.ts +99 -0
  49. package/dist/lib/llm/LLMProvider.d.ts +13 -0
  50. package/dist/lib/llm/OpenAIClient.d.ts +20 -0
  51. package/dist/lib/llm/aisdk.d.ts +20 -0
  52. package/dist/lib/mcp/connection.d.ts +11 -0
  53. package/dist/lib/mcp/utils.d.ts +3 -0
  54. package/dist/lib/v3/tests/downloads.spec.d.ts +1 -0
  55. package/dist/lib/v3/tests/v3.bb.config.d.ts +4 -0
  56. package/dist/lib/v3/v3.d.ts +2 -0
  57. package/dist/lib/version.d.ts +1 -1
  58. package/dist/stagehand.config.d.ts +3 -0
  59. package/dist/types/act.d.ts +50 -0
  60. package/dist/types/agent.d.ts +143 -0
  61. package/dist/types/api.d.ts +40 -0
  62. package/dist/types/browser.d.ts +10 -0
  63. package/dist/types/context.d.ts +117 -0
  64. package/dist/types/evals.d.ts +94 -0
  65. package/dist/types/evaluator.d.ts +40 -0
  66. package/dist/types/llm.d.ts +11 -0
  67. package/dist/types/log.d.ts +23 -0
  68. package/dist/types/model.d.ts +17 -0
  69. package/dist/types/page.d.ts +38 -0
  70. package/dist/types/playwright.d.ts +12 -0
  71. package/dist/types/stagehand.d.ts +330 -0
  72. package/dist/types/stagehandApiErrors.d.ts +18 -0
  73. package/dist/types/stagehandErrors.d.ts +104 -0
  74. package/package.json +1 -1
@@ -0,0 +1,59 @@
1
+ import { z } from "zod/v3";
2
+ import { Stagehand } from "../../index";
3
+ export declare const createActTool: (stagehand: Stagehand, executionModel?: string) => import("ai/dist").Tool<z.ZodObject<{
4
+ action: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ action?: string;
7
+ }, {
8
+ action?: string;
9
+ }>, {
10
+ success: boolean;
11
+ error: string;
12
+ isIframe: boolean;
13
+ action?: undefined;
14
+ playwrightArguments?: undefined;
15
+ } | {
16
+ success: boolean;
17
+ action: string;
18
+ isIframe: boolean;
19
+ playwrightArguments: {
20
+ description: string;
21
+ method: string;
22
+ arguments: string[];
23
+ selector: string;
24
+ };
25
+ error?: undefined;
26
+ } | {
27
+ success: boolean;
28
+ error: any;
29
+ isIframe?: undefined;
30
+ action?: undefined;
31
+ playwrightArguments?: undefined;
32
+ }> & {
33
+ execute: (args: {
34
+ action?: string;
35
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
36
+ success: boolean;
37
+ error: string;
38
+ isIframe: boolean;
39
+ action?: undefined;
40
+ playwrightArguments?: undefined;
41
+ } | {
42
+ success: boolean;
43
+ action: string;
44
+ isIframe: boolean;
45
+ playwrightArguments: {
46
+ description: string;
47
+ method: string;
48
+ arguments: string[];
49
+ selector: string;
50
+ };
51
+ error?: undefined;
52
+ } | {
53
+ success: boolean;
54
+ error: any;
55
+ isIframe?: undefined;
56
+ action?: undefined;
57
+ playwrightArguments?: undefined;
58
+ }>;
59
+ };
@@ -0,0 +1,11 @@
1
+ import { z } from "zod/v3";
2
+ import { Stagehand } from "../../index";
3
+ export declare const createAriaTreeTool: (stagehand: Stagehand) => import("ai/dist").Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {
4
+ content: string;
5
+ pageUrl: string;
6
+ }> & {
7
+ execute: (args: {}, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
8
+ content: string;
9
+ pageUrl: string;
10
+ }>;
11
+ };
@@ -0,0 +1,22 @@
1
+ import { z } from "zod/v3";
2
+ export declare const createCloseTool: () => import("ai/dist").Tool<z.ZodObject<{
3
+ reasoning: z.ZodString;
4
+ success: z.ZodBoolean;
5
+ }, "strip", z.ZodTypeAny, {
6
+ reasoning?: string;
7
+ success?: boolean;
8
+ }, {
9
+ reasoning?: string;
10
+ success?: boolean;
11
+ }>, {
12
+ success: boolean;
13
+ reasoning: string;
14
+ }> & {
15
+ execute: (args: {
16
+ reasoning?: string;
17
+ success?: boolean;
18
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
19
+ success: boolean;
20
+ reasoning: string;
21
+ }>;
22
+ };
@@ -0,0 +1,38 @@
1
+ import { z } from "zod/v3";
2
+ import { Stagehand } from "../../index";
3
+ import { LogLine } from "@/types/log";
4
+ export declare const createExtractTool: (stagehand: Stagehand, executionModel?: string, logger?: (message: LogLine) => void) => import("ai/dist").Tool<z.ZodObject<{
5
+ instruction: z.ZodString;
6
+ schema: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ schema?: string;
9
+ instruction?: string;
10
+ }, {
11
+ schema?: string;
12
+ instruction?: string;
13
+ }>, {
14
+ success: boolean;
15
+ data: any;
16
+ timestamp: number;
17
+ error?: undefined;
18
+ } | {
19
+ success: boolean;
20
+ error: string;
21
+ timestamp: number;
22
+ data?: undefined;
23
+ }> & {
24
+ execute: (args: {
25
+ schema?: string;
26
+ instruction?: string;
27
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
28
+ success: boolean;
29
+ data: any;
30
+ timestamp: number;
31
+ error?: undefined;
32
+ } | {
33
+ success: boolean;
34
+ error: string;
35
+ timestamp: number;
36
+ data?: undefined;
37
+ }>;
38
+ };
@@ -0,0 +1,37 @@
1
+ import { z } from "zod/v3";
2
+ import { Stagehand } from "../../index";
3
+ export declare const createFillFormTool: (stagehand: Stagehand, executionModel?: string) => import("ai/dist").Tool<z.ZodObject<{
4
+ fields: z.ZodArray<z.ZodObject<{
5
+ action: z.ZodString;
6
+ value: z.ZodString;
7
+ }, "strip", z.ZodTypeAny, {
8
+ value?: string;
9
+ action?: string;
10
+ }, {
11
+ value?: string;
12
+ action?: string;
13
+ }>, "many">;
14
+ }, "strip", z.ZodTypeAny, {
15
+ fields?: {
16
+ value?: string;
17
+ action?: string;
18
+ }[];
19
+ }, {
20
+ fields?: {
21
+ value?: string;
22
+ action?: string;
23
+ }[];
24
+ }>, {
25
+ success: boolean;
26
+ actions: import("@/types/stagehand").ActResult[];
27
+ }> & {
28
+ execute: (args: {
29
+ fields?: {
30
+ value?: string;
31
+ action?: string;
32
+ }[];
33
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
34
+ success: boolean;
35
+ actions: import("@/types/stagehand").ActResult[];
36
+ }>;
37
+ };
@@ -0,0 +1,29 @@
1
+ import { z } from "zod/v3";
2
+ import { Stagehand } from "../../index";
3
+ export declare const createGotoTool: (stagehand: Stagehand) => import("ai/dist").Tool<z.ZodObject<{
4
+ url: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ url?: string;
7
+ }, {
8
+ url?: string;
9
+ }>, {
10
+ success: boolean;
11
+ url: string;
12
+ error?: undefined;
13
+ } | {
14
+ success: boolean;
15
+ error: any;
16
+ url?: undefined;
17
+ }> & {
18
+ execute: (args: {
19
+ url?: string;
20
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
21
+ success: boolean;
22
+ url: string;
23
+ error?: undefined;
24
+ } | {
25
+ success: boolean;
26
+ error: any;
27
+ url?: undefined;
28
+ }>;
29
+ };
@@ -0,0 +1,257 @@
1
+ import { Stagehand } from "../../index";
2
+ import { LogLine } from "@/types/log";
3
+ export interface AgentToolOptions {
4
+ executionModel?: string;
5
+ logger?: (message: LogLine) => void;
6
+ }
7
+ export declare function createAgentTools(stagehand: Stagehand, options?: AgentToolOptions): {
8
+ act: import("ai/dist").Tool<import("zod/v3").ZodObject<{
9
+ action: import("zod/v3").ZodString;
10
+ }, "strip", import("zod/v3").ZodTypeAny, {
11
+ action?: string;
12
+ }, {
13
+ action?: string;
14
+ }>, {
15
+ success: boolean;
16
+ error: string;
17
+ isIframe: boolean;
18
+ action?: undefined;
19
+ playwrightArguments?: undefined;
20
+ } | {
21
+ success: boolean;
22
+ action: string;
23
+ isIframe: boolean;
24
+ playwrightArguments: {
25
+ description: string;
26
+ method: string;
27
+ arguments: string[];
28
+ selector: string;
29
+ };
30
+ error?: undefined;
31
+ } | {
32
+ success: boolean;
33
+ error: any;
34
+ isIframe?: undefined;
35
+ action?: undefined;
36
+ playwrightArguments?: undefined;
37
+ }> & {
38
+ execute: (args: {
39
+ action?: string;
40
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
41
+ success: boolean;
42
+ error: string;
43
+ isIframe: boolean;
44
+ action?: undefined;
45
+ playwrightArguments?: undefined;
46
+ } | {
47
+ success: boolean;
48
+ action: string;
49
+ isIframe: boolean;
50
+ playwrightArguments: {
51
+ description: string;
52
+ method: string;
53
+ arguments: string[];
54
+ selector: string;
55
+ };
56
+ error?: undefined;
57
+ } | {
58
+ success: boolean;
59
+ error: any;
60
+ isIframe?: undefined;
61
+ action?: undefined;
62
+ playwrightArguments?: undefined;
63
+ }>;
64
+ };
65
+ ariaTree: import("ai/dist").Tool<import("zod/v3").ZodObject<{}, "strip", import("zod/v3").ZodTypeAny, {}, {}>, {
66
+ content: string;
67
+ pageUrl: string;
68
+ }> & {
69
+ execute: (args: {}, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
70
+ content: string;
71
+ pageUrl: string;
72
+ }>;
73
+ };
74
+ close: import("ai/dist").Tool<import("zod/v3").ZodObject<{
75
+ reasoning: import("zod/v3").ZodString;
76
+ success: import("zod/v3").ZodBoolean;
77
+ }, "strip", import("zod/v3").ZodTypeAny, {
78
+ reasoning?: string;
79
+ success?: boolean;
80
+ }, {
81
+ reasoning?: string;
82
+ success?: boolean;
83
+ }>, {
84
+ success: boolean;
85
+ reasoning: string;
86
+ }> & {
87
+ execute: (args: {
88
+ reasoning?: string;
89
+ success?: boolean;
90
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
91
+ success: boolean;
92
+ reasoning: string;
93
+ }>;
94
+ };
95
+ extract: import("ai/dist").Tool<import("zod/v3").ZodObject<{
96
+ instruction: import("zod/v3").ZodString;
97
+ schema: import("zod/v3").ZodString;
98
+ }, "strip", import("zod/v3").ZodTypeAny, {
99
+ schema?: string;
100
+ instruction?: string;
101
+ }, {
102
+ schema?: string;
103
+ instruction?: string;
104
+ }>, {
105
+ success: boolean;
106
+ data: any;
107
+ timestamp: number;
108
+ error?: undefined;
109
+ } | {
110
+ success: boolean;
111
+ error: string;
112
+ timestamp: number;
113
+ data?: undefined;
114
+ }> & {
115
+ execute: (args: {
116
+ schema?: string;
117
+ instruction?: string;
118
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
119
+ success: boolean;
120
+ data: any;
121
+ timestamp: number;
122
+ error?: undefined;
123
+ } | {
124
+ success: boolean;
125
+ error: string;
126
+ timestamp: number;
127
+ data?: undefined;
128
+ }>;
129
+ };
130
+ fillForm: import("ai/dist").Tool<import("zod/v3").ZodObject<{
131
+ fields: import("zod/v3").ZodArray<import("zod/v3").ZodObject<{
132
+ action: import("zod/v3").ZodString;
133
+ value: import("zod/v3").ZodString;
134
+ }, "strip", import("zod/v3").ZodTypeAny, {
135
+ value?: string;
136
+ action?: string;
137
+ }, {
138
+ value?: string;
139
+ action?: string;
140
+ }>, "many">;
141
+ }, "strip", import("zod/v3").ZodTypeAny, {
142
+ fields?: {
143
+ value?: string;
144
+ action?: string;
145
+ }[];
146
+ }, {
147
+ fields?: {
148
+ value?: string;
149
+ action?: string;
150
+ }[];
151
+ }>, {
152
+ success: boolean;
153
+ actions: import("@/types/stagehand").ActResult[];
154
+ }> & {
155
+ execute: (args: {
156
+ fields?: {
157
+ value?: string;
158
+ action?: string;
159
+ }[];
160
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
161
+ success: boolean;
162
+ actions: import("@/types/stagehand").ActResult[];
163
+ }>;
164
+ };
165
+ goto: import("ai/dist").Tool<import("zod/v3").ZodObject<{
166
+ url: import("zod/v3").ZodString;
167
+ }, "strip", import("zod/v3").ZodTypeAny, {
168
+ url?: string;
169
+ }, {
170
+ url?: string;
171
+ }>, {
172
+ success: boolean;
173
+ url: string;
174
+ error?: undefined;
175
+ } | {
176
+ success: boolean;
177
+ error: any;
178
+ url?: undefined;
179
+ }> & {
180
+ execute: (args: {
181
+ url?: string;
182
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
183
+ success: boolean;
184
+ url: string;
185
+ error?: undefined;
186
+ } | {
187
+ success: boolean;
188
+ error: any;
189
+ url?: undefined;
190
+ }>;
191
+ };
192
+ navback: import("ai/dist").Tool<import("zod/v3").ZodObject<{
193
+ reasoning: import("zod/v3").ZodString;
194
+ }, "strip", import("zod/v3").ZodTypeAny, {
195
+ reasoning?: string;
196
+ }, {
197
+ reasoning?: string;
198
+ }>, {
199
+ success: boolean;
200
+ }> & {
201
+ execute: (args: {
202
+ reasoning?: string;
203
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
204
+ success: boolean;
205
+ }>;
206
+ };
207
+ screenshot: import("ai/dist").Tool<import("zod/v3").ZodObject<{}, "strip", import("zod/v3").ZodTypeAny, {}, {}>, {
208
+ base64: string;
209
+ timestamp: number;
210
+ pageUrl: string;
211
+ }> & {
212
+ execute: (args: {}, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
213
+ base64: string;
214
+ timestamp: number;
215
+ pageUrl: string;
216
+ }>;
217
+ };
218
+ scroll: import("ai/dist").Tool<import("zod/v3").ZodObject<{
219
+ pixels: import("zod/v3").ZodNumber;
220
+ direction: import("zod/v3").ZodEnum<["up", "down"]>;
221
+ }, "strip", import("zod/v3").ZodTypeAny, {
222
+ direction?: "down" | "up";
223
+ pixels?: number;
224
+ }, {
225
+ direction?: "down" | "up";
226
+ pixels?: number;
227
+ }>, {
228
+ success: boolean;
229
+ pixels: number;
230
+ }> & {
231
+ execute: (args: {
232
+ direction?: "down" | "up";
233
+ pixels?: number;
234
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
235
+ success: boolean;
236
+ pixels: number;
237
+ }>;
238
+ };
239
+ wait: import("ai/dist").Tool<import("zod/v3").ZodObject<{
240
+ timeMs: import("zod/v3").ZodNumber;
241
+ }, "strip", import("zod/v3").ZodTypeAny, {
242
+ timeMs?: number;
243
+ }, {
244
+ timeMs?: number;
245
+ }>, {
246
+ success: boolean;
247
+ waited: number;
248
+ }> & {
249
+ execute: (args: {
250
+ timeMs?: number;
251
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
252
+ success: boolean;
253
+ waited: number;
254
+ }>;
255
+ };
256
+ };
257
+ export type AgentTools = ReturnType<typeof createAgentTools>;
@@ -0,0 +1,17 @@
1
+ import { z } from "zod/v3";
2
+ import { Stagehand } from "../../index";
3
+ export declare const createNavBackTool: (stagehand: Stagehand) => import("ai/dist").Tool<z.ZodObject<{
4
+ reasoning: z.ZodString;
5
+ }, "strip", z.ZodTypeAny, {
6
+ reasoning?: string;
7
+ }, {
8
+ reasoning?: string;
9
+ }>, {
10
+ success: boolean;
11
+ }> & {
12
+ execute: (args: {
13
+ reasoning?: string;
14
+ }, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
15
+ success: boolean;
16
+ }>;
17
+ };
@@ -0,0 +1,13 @@
1
+ import { z } from "zod/v3";
2
+ import { Stagehand } from "../../index";
3
+ export declare const createScreenshotTool: (stagehand: Stagehand) => import("ai/dist").Tool<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, {
4
+ base64: string;
5
+ timestamp: number;
6
+ pageUrl: string;
7
+ }> & {
8
+ execute: (args: {}, options: import("ai/dist").ToolExecutionOptions) => PromiseLike<{
9
+ base64: string;
10
+ timestamp: number;
11
+ pageUrl: string;
12
+ }>;
13
+ };
@@ -0,0 +1,23 @@
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
+ };
@@ -0,0 +1,18 @@
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
+ };
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1,53 @@
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
+ };
@@ -0,0 +1,13 @@
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
+ };
@@ -0,0 +1,9 @@
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;
@@ -0,0 +1,62 @@
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
+ }