browser-use 0.0.1 → 0.1.0

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 (200) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +761 -0
  3. package/dist/agent/cloud-events.d.ts +264 -0
  4. package/dist/agent/cloud-events.js +318 -0
  5. package/dist/agent/gif.d.ts +15 -0
  6. package/dist/agent/gif.js +215 -0
  7. package/dist/agent/index.d.ts +8 -0
  8. package/dist/agent/index.js +8 -0
  9. package/dist/agent/message-manager/service.d.ts +30 -0
  10. package/dist/agent/message-manager/service.js +208 -0
  11. package/dist/agent/message-manager/utils.d.ts +2 -0
  12. package/dist/agent/message-manager/utils.js +41 -0
  13. package/dist/agent/message-manager/views.d.ts +26 -0
  14. package/dist/agent/message-manager/views.js +73 -0
  15. package/dist/agent/prompts.d.ts +52 -0
  16. package/dist/agent/prompts.js +259 -0
  17. package/dist/agent/service.d.ts +290 -0
  18. package/dist/agent/service.js +2200 -0
  19. package/dist/agent/views.d.ts +741 -0
  20. package/dist/agent/views.js +537 -0
  21. package/dist/browser/browser.d.ts +7 -0
  22. package/dist/browser/browser.js +5 -0
  23. package/dist/browser/context.d.ts +8 -0
  24. package/dist/browser/context.js +4 -0
  25. package/dist/browser/dvd-screensaver.d.ts +101 -0
  26. package/dist/browser/dvd-screensaver.js +270 -0
  27. package/dist/browser/extensions.d.ts +63 -0
  28. package/dist/browser/extensions.js +359 -0
  29. package/dist/browser/index.d.ts +10 -0
  30. package/dist/browser/index.js +9 -0
  31. package/dist/browser/playwright-manager.d.ts +47 -0
  32. package/dist/browser/playwright-manager.js +146 -0
  33. package/dist/browser/profile.d.ts +196 -0
  34. package/dist/browser/profile.js +815 -0
  35. package/dist/browser/session.d.ts +505 -0
  36. package/dist/browser/session.js +3409 -0
  37. package/dist/browser/types.d.ts +1184 -0
  38. package/dist/browser/types.js +1 -0
  39. package/dist/browser/utils.d.ts +1 -0
  40. package/dist/browser/utils.js +19 -0
  41. package/dist/browser/views.d.ts +78 -0
  42. package/dist/browser/views.js +72 -0
  43. package/dist/cli.d.ts +2 -0
  44. package/dist/cli.js +44 -0
  45. package/dist/config.d.ts +108 -0
  46. package/dist/config.js +430 -0
  47. package/dist/controller/index.d.ts +3 -0
  48. package/dist/controller/index.js +3 -0
  49. package/dist/controller/registry/index.d.ts +2 -0
  50. package/dist/controller/registry/index.js +2 -0
  51. package/dist/controller/registry/service.d.ts +45 -0
  52. package/dist/controller/registry/service.js +184 -0
  53. package/dist/controller/registry/views.d.ts +55 -0
  54. package/dist/controller/registry/views.js +174 -0
  55. package/dist/controller/service.d.ts +49 -0
  56. package/dist/controller/service.js +1176 -0
  57. package/dist/controller/views.d.ts +241 -0
  58. package/dist/controller/views.js +88 -0
  59. package/dist/dom/clickable-element-processor/service.d.ts +11 -0
  60. package/dist/dom/clickable-element-processor/service.js +60 -0
  61. package/dist/dom/dom_tree/index.js +1400 -0
  62. package/dist/dom/history-tree-processor/service.d.ts +14 -0
  63. package/dist/dom/history-tree-processor/service.js +75 -0
  64. package/dist/dom/history-tree-processor/view.d.ts +54 -0
  65. package/dist/dom/history-tree-processor/view.js +56 -0
  66. package/dist/dom/playground/extraction.d.ts +19 -0
  67. package/dist/dom/playground/extraction.js +187 -0
  68. package/dist/dom/playground/process-dom.d.ts +1 -0
  69. package/dist/dom/playground/process-dom.js +5 -0
  70. package/dist/dom/playground/test-accessibility.d.ts +44 -0
  71. package/dist/dom/playground/test-accessibility.js +111 -0
  72. package/dist/dom/service.d.ts +19 -0
  73. package/dist/dom/service.js +227 -0
  74. package/dist/dom/utils.d.ts +1 -0
  75. package/dist/dom/utils.js +6 -0
  76. package/dist/dom/views.d.ts +61 -0
  77. package/dist/dom/views.js +247 -0
  78. package/dist/event-bus.d.ts +11 -0
  79. package/dist/event-bus.js +19 -0
  80. package/dist/exceptions.d.ts +10 -0
  81. package/dist/exceptions.js +22 -0
  82. package/dist/filesystem/file-system.d.ts +68 -0
  83. package/dist/filesystem/file-system.js +412 -0
  84. package/dist/filesystem/index.d.ts +1 -0
  85. package/dist/filesystem/index.js +1 -0
  86. package/dist/index.d.ts +31 -0
  87. package/dist/index.js +33 -0
  88. package/dist/integrations/gmail/actions.d.ts +12 -0
  89. package/dist/integrations/gmail/actions.js +113 -0
  90. package/dist/integrations/gmail/index.d.ts +2 -0
  91. package/dist/integrations/gmail/index.js +2 -0
  92. package/dist/integrations/gmail/service.d.ts +61 -0
  93. package/dist/integrations/gmail/service.js +260 -0
  94. package/dist/llm/anthropic/chat.d.ts +28 -0
  95. package/dist/llm/anthropic/chat.js +126 -0
  96. package/dist/llm/anthropic/index.d.ts +2 -0
  97. package/dist/llm/anthropic/index.js +2 -0
  98. package/dist/llm/anthropic/serializer.d.ts +68 -0
  99. package/dist/llm/anthropic/serializer.js +285 -0
  100. package/dist/llm/aws/chat-anthropic.d.ts +61 -0
  101. package/dist/llm/aws/chat-anthropic.js +176 -0
  102. package/dist/llm/aws/chat-bedrock.d.ts +15 -0
  103. package/dist/llm/aws/chat-bedrock.js +80 -0
  104. package/dist/llm/aws/index.d.ts +3 -0
  105. package/dist/llm/aws/index.js +3 -0
  106. package/dist/llm/aws/serializer.d.ts +5 -0
  107. package/dist/llm/aws/serializer.js +68 -0
  108. package/dist/llm/azure/chat.d.ts +15 -0
  109. package/dist/llm/azure/chat.js +83 -0
  110. package/dist/llm/azure/index.d.ts +1 -0
  111. package/dist/llm/azure/index.js +1 -0
  112. package/dist/llm/base.d.ts +16 -0
  113. package/dist/llm/base.js +1 -0
  114. package/dist/llm/deepseek/chat.d.ts +15 -0
  115. package/dist/llm/deepseek/chat.js +51 -0
  116. package/dist/llm/deepseek/index.d.ts +2 -0
  117. package/dist/llm/deepseek/index.js +2 -0
  118. package/dist/llm/deepseek/serializer.d.ts +6 -0
  119. package/dist/llm/deepseek/serializer.js +57 -0
  120. package/dist/llm/exceptions.d.ts +10 -0
  121. package/dist/llm/exceptions.js +18 -0
  122. package/dist/llm/google/chat.d.ts +20 -0
  123. package/dist/llm/google/chat.js +144 -0
  124. package/dist/llm/google/index.d.ts +2 -0
  125. package/dist/llm/google/index.js +2 -0
  126. package/dist/llm/google/serializer.d.ts +6 -0
  127. package/dist/llm/google/serializer.js +64 -0
  128. package/dist/llm/groq/chat.d.ts +15 -0
  129. package/dist/llm/groq/chat.js +52 -0
  130. package/dist/llm/groq/index.d.ts +3 -0
  131. package/dist/llm/groq/index.js +3 -0
  132. package/dist/llm/groq/parser.d.ts +32 -0
  133. package/dist/llm/groq/parser.js +189 -0
  134. package/dist/llm/groq/serializer.d.ts +6 -0
  135. package/dist/llm/groq/serializer.js +56 -0
  136. package/dist/llm/messages.d.ts +77 -0
  137. package/dist/llm/messages.js +157 -0
  138. package/dist/llm/ollama/chat.d.ts +15 -0
  139. package/dist/llm/ollama/chat.js +77 -0
  140. package/dist/llm/ollama/index.d.ts +2 -0
  141. package/dist/llm/ollama/index.js +2 -0
  142. package/dist/llm/ollama/serializer.d.ts +6 -0
  143. package/dist/llm/ollama/serializer.js +53 -0
  144. package/dist/llm/openai/chat.d.ts +38 -0
  145. package/dist/llm/openai/chat.js +174 -0
  146. package/dist/llm/openai/index.d.ts +3 -0
  147. package/dist/llm/openai/index.js +3 -0
  148. package/dist/llm/openai/like.d.ts +17 -0
  149. package/dist/llm/openai/like.js +19 -0
  150. package/dist/llm/openai/serializer.d.ts +6 -0
  151. package/dist/llm/openai/serializer.js +57 -0
  152. package/dist/llm/openrouter/chat.d.ts +15 -0
  153. package/dist/llm/openrouter/chat.js +74 -0
  154. package/dist/llm/openrouter/index.d.ts +2 -0
  155. package/dist/llm/openrouter/index.js +2 -0
  156. package/dist/llm/openrouter/serializer.d.ts +3 -0
  157. package/dist/llm/openrouter/serializer.js +3 -0
  158. package/dist/llm/schema.d.ts +6 -0
  159. package/dist/llm/schema.js +77 -0
  160. package/dist/llm/views.d.ts +15 -0
  161. package/dist/llm/views.js +12 -0
  162. package/dist/logging-config.d.ts +25 -0
  163. package/dist/logging-config.js +89 -0
  164. package/dist/mcp/client.d.ts +142 -0
  165. package/dist/mcp/client.js +638 -0
  166. package/dist/mcp/controller.d.ts +6 -0
  167. package/dist/mcp/controller.js +38 -0
  168. package/dist/mcp/index.d.ts +3 -0
  169. package/dist/mcp/index.js +3 -0
  170. package/dist/mcp/server.d.ts +134 -0
  171. package/dist/mcp/server.js +759 -0
  172. package/dist/observability-decorators.d.ts +158 -0
  173. package/dist/observability-decorators.js +286 -0
  174. package/dist/observability.d.ts +23 -0
  175. package/dist/observability.js +58 -0
  176. package/dist/screenshots/index.d.ts +1 -0
  177. package/dist/screenshots/index.js +1 -0
  178. package/dist/screenshots/service.d.ts +6 -0
  179. package/dist/screenshots/service.js +28 -0
  180. package/dist/sync/auth.d.ts +27 -0
  181. package/dist/sync/auth.js +205 -0
  182. package/dist/sync/index.d.ts +2 -0
  183. package/dist/sync/index.js +2 -0
  184. package/dist/sync/service.d.ts +21 -0
  185. package/dist/sync/service.js +146 -0
  186. package/dist/telemetry/index.d.ts +2 -0
  187. package/dist/telemetry/index.js +2 -0
  188. package/dist/telemetry/service.d.ts +12 -0
  189. package/dist/telemetry/service.js +85 -0
  190. package/dist/telemetry/views.d.ts +112 -0
  191. package/dist/telemetry/views.js +112 -0
  192. package/dist/tokens/index.d.ts +2 -0
  193. package/dist/tokens/index.js +2 -0
  194. package/dist/tokens/service.d.ts +35 -0
  195. package/dist/tokens/service.js +423 -0
  196. package/dist/tokens/views.d.ts +58 -0
  197. package/dist/tokens/views.js +1 -0
  198. package/dist/utils.d.ts +128 -0
  199. package/dist/utils.js +529 -0
  200. package/package.json +94 -5
@@ -0,0 +1,241 @@
1
+ import { z } from 'zod';
2
+ export declare const SearchGoogleActionSchema: z.ZodObject<{
3
+ query: z.ZodString;
4
+ }, "strip", z.ZodTypeAny, {
5
+ query: string;
6
+ }, {
7
+ query: string;
8
+ }>;
9
+ export type SearchGoogleAction = z.infer<typeof SearchGoogleActionSchema>;
10
+ export declare const GoToUrlActionSchema: z.ZodObject<{
11
+ url: z.ZodString;
12
+ new_tab: z.ZodDefault<z.ZodBoolean>;
13
+ }, "strip", z.ZodTypeAny, {
14
+ url: string;
15
+ new_tab: boolean;
16
+ }, {
17
+ url: string;
18
+ new_tab?: boolean | undefined;
19
+ }>;
20
+ export type GoToUrlAction = z.infer<typeof GoToUrlActionSchema>;
21
+ export declare const WaitActionSchema: z.ZodObject<{
22
+ seconds: z.ZodDefault<z.ZodNumber>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ seconds: number;
25
+ }, {
26
+ seconds?: number | undefined;
27
+ }>;
28
+ export type WaitAction = z.infer<typeof WaitActionSchema>;
29
+ export declare const ClickElementActionSchema: z.ZodObject<{
30
+ index: z.ZodNumber;
31
+ }, "strip", z.ZodTypeAny, {
32
+ index: number;
33
+ }, {
34
+ index: number;
35
+ }>;
36
+ export type ClickElementAction = z.infer<typeof ClickElementActionSchema>;
37
+ export declare const InputTextActionSchema: z.ZodObject<{
38
+ index: z.ZodNumber;
39
+ text: z.ZodString;
40
+ }, "strip", z.ZodTypeAny, {
41
+ index: number;
42
+ text: string;
43
+ }, {
44
+ index: number;
45
+ text: string;
46
+ }>;
47
+ export type InputTextAction = z.infer<typeof InputTextActionSchema>;
48
+ export declare const DoneActionSchema: z.ZodObject<{
49
+ text: z.ZodString;
50
+ success: z.ZodBoolean;
51
+ files_to_display: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ text: string;
54
+ success: boolean;
55
+ files_to_display: string[];
56
+ }, {
57
+ text: string;
58
+ success: boolean;
59
+ files_to_display?: string[] | undefined;
60
+ }>;
61
+ export type DoneAction = z.infer<typeof DoneActionSchema>;
62
+ export declare const StructuredOutputActionSchema: <T extends z.ZodTypeAny>(dataSchema: T) => z.ZodObject<{
63
+ success: z.ZodDefault<z.ZodBoolean>;
64
+ data: T;
65
+ }, "strip", z.ZodTypeAny, z.objectUtil.addQuestionMarks<z.baseObjectOutputType<{
66
+ success: z.ZodDefault<z.ZodBoolean>;
67
+ data: T;
68
+ }>, any> extends infer T_1 ? { [k in keyof T_1]: T_1[k]; } : never, z.baseObjectInputType<{
69
+ success: z.ZodDefault<z.ZodBoolean>;
70
+ data: T;
71
+ }> extends infer T_2 ? { [k_1 in keyof T_2]: T_2[k_1]; } : never>;
72
+ export type StructuredOutputAction<T> = {
73
+ success: boolean;
74
+ data: T;
75
+ };
76
+ export declare const SwitchTabActionSchema: z.ZodObject<{
77
+ page_id: z.ZodNumber;
78
+ }, "strip", z.ZodTypeAny, {
79
+ page_id: number;
80
+ }, {
81
+ page_id: number;
82
+ }>;
83
+ export type SwitchTabAction = z.infer<typeof SwitchTabActionSchema>;
84
+ export declare const CloseTabActionSchema: z.ZodObject<{
85
+ page_id: z.ZodNumber;
86
+ }, "strip", z.ZodTypeAny, {
87
+ page_id: number;
88
+ }, {
89
+ page_id: number;
90
+ }>;
91
+ export type CloseTabAction = z.infer<typeof CloseTabActionSchema>;
92
+ export declare const ScrollActionSchema: z.ZodObject<{
93
+ down: z.ZodDefault<z.ZodBoolean>;
94
+ num_pages: z.ZodDefault<z.ZodNumber>;
95
+ index: z.ZodOptional<z.ZodNumber>;
96
+ }, "strip", z.ZodTypeAny, {
97
+ down: boolean;
98
+ num_pages: number;
99
+ index?: number | undefined;
100
+ }, {
101
+ index?: number | undefined;
102
+ down?: boolean | undefined;
103
+ num_pages?: number | undefined;
104
+ }>;
105
+ export type ScrollAction = z.infer<typeof ScrollActionSchema>;
106
+ export declare const SendKeysActionSchema: z.ZodObject<{
107
+ keys: z.ZodString;
108
+ }, "strip", z.ZodTypeAny, {
109
+ keys: string;
110
+ }, {
111
+ keys: string;
112
+ }>;
113
+ export type SendKeysAction = z.infer<typeof SendKeysActionSchema>;
114
+ export declare const UploadFileActionSchema: z.ZodObject<{
115
+ index: z.ZodNumber;
116
+ path: z.ZodString;
117
+ }, "strip", z.ZodTypeAny, {
118
+ index: number;
119
+ path: string;
120
+ }, {
121
+ index: number;
122
+ path: string;
123
+ }>;
124
+ export type UploadFileAction = z.infer<typeof UploadFileActionSchema>;
125
+ export declare const ExtractPageContentActionSchema: z.ZodObject<{
126
+ value: z.ZodString;
127
+ }, "strip", z.ZodTypeAny, {
128
+ value: string;
129
+ }, {
130
+ value: string;
131
+ }>;
132
+ export type ExtractPageContentAction = z.infer<typeof ExtractPageContentActionSchema>;
133
+ export declare const ExtractStructuredDataActionSchema: z.ZodObject<{
134
+ query: z.ZodString;
135
+ extract_links: z.ZodDefault<z.ZodBoolean>;
136
+ }, "strip", z.ZodTypeAny, {
137
+ query: string;
138
+ extract_links: boolean;
139
+ }, {
140
+ query: string;
141
+ extract_links?: boolean | undefined;
142
+ }>;
143
+ export type ExtractStructuredDataAction = z.infer<typeof ExtractStructuredDataActionSchema>;
144
+ export declare const ReadFileActionSchema: z.ZodObject<{
145
+ file_name: z.ZodString;
146
+ }, "strip", z.ZodTypeAny, {
147
+ file_name: string;
148
+ }, {
149
+ file_name: string;
150
+ }>;
151
+ export type ReadFileAction = z.infer<typeof ReadFileActionSchema>;
152
+ export declare const WriteFileActionSchema: z.ZodObject<{
153
+ file_name: z.ZodString;
154
+ content: z.ZodString;
155
+ append: z.ZodOptional<z.ZodBoolean>;
156
+ trailing_newline: z.ZodOptional<z.ZodBoolean>;
157
+ leading_newline: z.ZodOptional<z.ZodBoolean>;
158
+ }, "strip", z.ZodTypeAny, {
159
+ file_name: string;
160
+ content: string;
161
+ append?: boolean | undefined;
162
+ trailing_newline?: boolean | undefined;
163
+ leading_newline?: boolean | undefined;
164
+ }, {
165
+ file_name: string;
166
+ content: string;
167
+ append?: boolean | undefined;
168
+ trailing_newline?: boolean | undefined;
169
+ leading_newline?: boolean | undefined;
170
+ }>;
171
+ export type WriteFileAction = z.infer<typeof WriteFileActionSchema>;
172
+ export declare const ReplaceFileStrActionSchema: z.ZodObject<{
173
+ file_name: z.ZodString;
174
+ old_str: z.ZodString;
175
+ new_str: z.ZodString;
176
+ }, "strip", z.ZodTypeAny, {
177
+ file_name: string;
178
+ old_str: string;
179
+ new_str: string;
180
+ }, {
181
+ file_name: string;
182
+ old_str: string;
183
+ new_str: string;
184
+ }>;
185
+ export type ReplaceFileStrAction = z.infer<typeof ReplaceFileStrActionSchema>;
186
+ export declare const ScrollToTextActionSchema: z.ZodObject<{
187
+ text: z.ZodString;
188
+ }, "strip", z.ZodTypeAny, {
189
+ text: string;
190
+ }, {
191
+ text: string;
192
+ }>;
193
+ export type ScrollToTextAction = z.infer<typeof ScrollToTextActionSchema>;
194
+ export declare const DropdownOptionsActionSchema: z.ZodObject<{
195
+ index: z.ZodNumber;
196
+ }, "strip", z.ZodTypeAny, {
197
+ index: number;
198
+ }, {
199
+ index: number;
200
+ }>;
201
+ export type DropdownOptionsAction = z.infer<typeof DropdownOptionsActionSchema>;
202
+ export declare const SelectDropdownActionSchema: z.ZodObject<{
203
+ index: z.ZodNumber;
204
+ text: z.ZodString;
205
+ }, "strip", z.ZodTypeAny, {
206
+ index: number;
207
+ text: string;
208
+ }, {
209
+ index: number;
210
+ text: string;
211
+ }>;
212
+ export type SelectDropdownAction = z.infer<typeof SelectDropdownActionSchema>;
213
+ export declare const SheetsRangeActionSchema: z.ZodObject<{
214
+ cell_or_range: z.ZodString;
215
+ }, "strip", z.ZodTypeAny, {
216
+ cell_or_range: string;
217
+ }, {
218
+ cell_or_range: string;
219
+ }>;
220
+ export type SheetsRangeAction = z.infer<typeof SheetsRangeActionSchema>;
221
+ export declare const SheetsUpdateActionSchema: z.ZodObject<{
222
+ cell_or_range: z.ZodString;
223
+ value: z.ZodString;
224
+ }, "strip", z.ZodTypeAny, {
225
+ value: string;
226
+ cell_or_range: string;
227
+ }, {
228
+ value: string;
229
+ cell_or_range: string;
230
+ }>;
231
+ export type SheetsUpdateAction = z.infer<typeof SheetsUpdateActionSchema>;
232
+ export declare const SheetsInputActionSchema: z.ZodObject<{
233
+ text: z.ZodString;
234
+ }, "strip", z.ZodTypeAny, {
235
+ text: string;
236
+ }, {
237
+ text: string;
238
+ }>;
239
+ export type SheetsInputAction = z.infer<typeof SheetsInputActionSchema>;
240
+ export declare const NoParamsActionSchema: z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>;
241
+ export type NoParamsAction = z.infer<typeof NoParamsActionSchema>;
@@ -0,0 +1,88 @@
1
+ import { z } from 'zod';
2
+ export const SearchGoogleActionSchema = z.object({
3
+ query: z.string(),
4
+ });
5
+ export const GoToUrlActionSchema = z.object({
6
+ url: z.string(),
7
+ new_tab: z.boolean().default(false),
8
+ });
9
+ export const WaitActionSchema = z.object({
10
+ seconds: z.number().default(3),
11
+ });
12
+ export const ClickElementActionSchema = z.object({
13
+ index: z.number().int(),
14
+ });
15
+ export const InputTextActionSchema = z.object({
16
+ index: z.number().int(),
17
+ text: z.string(),
18
+ });
19
+ export const DoneActionSchema = z.object({
20
+ text: z.string(),
21
+ success: z.boolean(),
22
+ files_to_display: z.array(z.string()).default([]),
23
+ });
24
+ export const StructuredOutputActionSchema = (dataSchema) => z.object({
25
+ success: z.boolean().default(true),
26
+ data: dataSchema,
27
+ });
28
+ export const SwitchTabActionSchema = z.object({
29
+ page_id: z.number().int(),
30
+ });
31
+ export const CloseTabActionSchema = z.object({
32
+ page_id: z.number().int(),
33
+ });
34
+ export const ScrollActionSchema = z.object({
35
+ down: z.boolean().default(true), // Default to scroll down
36
+ num_pages: z.number().default(1), // Default to 1 page
37
+ index: z.number().int().optional(),
38
+ });
39
+ export const SendKeysActionSchema = z.object({
40
+ keys: z.string(),
41
+ });
42
+ export const UploadFileActionSchema = z.object({
43
+ index: z.number().int(),
44
+ path: z.string(),
45
+ });
46
+ export const ExtractPageContentActionSchema = z.object({
47
+ value: z.string(),
48
+ });
49
+ export const ExtractStructuredDataActionSchema = z.object({
50
+ query: z.string(),
51
+ extract_links: z.boolean().default(false),
52
+ });
53
+ export const ReadFileActionSchema = z.object({
54
+ file_name: z.string(),
55
+ });
56
+ export const WriteFileActionSchema = z.object({
57
+ file_name: z.string(),
58
+ content: z.string(),
59
+ append: z.boolean().optional(),
60
+ trailing_newline: z.boolean().optional(),
61
+ leading_newline: z.boolean().optional(),
62
+ });
63
+ export const ReplaceFileStrActionSchema = z.object({
64
+ file_name: z.string(),
65
+ old_str: z.string(),
66
+ new_str: z.string(),
67
+ });
68
+ export const ScrollToTextActionSchema = z.object({
69
+ text: z.string(),
70
+ });
71
+ export const DropdownOptionsActionSchema = z.object({
72
+ index: z.number().int(),
73
+ });
74
+ export const SelectDropdownActionSchema = z.object({
75
+ index: z.number().int(),
76
+ text: z.string(),
77
+ });
78
+ export const SheetsRangeActionSchema = z.object({
79
+ cell_or_range: z.string(),
80
+ });
81
+ export const SheetsUpdateActionSchema = z.object({
82
+ cell_or_range: z.string(),
83
+ value: z.string(),
84
+ });
85
+ export const SheetsInputActionSchema = z.object({
86
+ text: z.string(),
87
+ });
88
+ export const NoParamsActionSchema = z.object({}).passthrough();
@@ -0,0 +1,11 @@
1
+ import { DOMElementNode } from '../views.js';
2
+ export declare class ClickableElementProcessor {
3
+ static get_clickable_elements_hashes(dom_element: DOMElementNode): Set<string>;
4
+ static get_clickable_elements(dom_element: DOMElementNode): DOMElementNode[];
5
+ static hash_dom_element(dom_element: DOMElementNode): string;
6
+ private static _get_parent_branch_path;
7
+ private static _parent_branch_path_hash;
8
+ private static _attributes_hash;
9
+ private static _xpath_hash;
10
+ private static _hash_string;
11
+ }
@@ -0,0 +1,60 @@
1
+ import crypto from 'node:crypto';
2
+ import { DOMElementNode } from '../views.js';
3
+ const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
4
+ export class ClickableElementProcessor {
5
+ static get_clickable_elements_hashes(dom_element) {
6
+ const hashes = new Set();
7
+ for (const element of this.get_clickable_elements(dom_element)) {
8
+ hashes.add(this.hash_dom_element(element));
9
+ }
10
+ return hashes;
11
+ }
12
+ static get_clickable_elements(dom_element) {
13
+ const elements = [];
14
+ const traverse = (node) => {
15
+ for (const child of node.children) {
16
+ if (child instanceof DOMElementNode) {
17
+ if (child.highlight_index !== null &&
18
+ child.highlight_index !== undefined) {
19
+ elements.push(child);
20
+ }
21
+ traverse(child);
22
+ }
23
+ }
24
+ };
25
+ traverse(dom_element);
26
+ return elements;
27
+ }
28
+ static hash_dom_element(dom_element) {
29
+ const parent_branch_path = this._get_parent_branch_path(dom_element);
30
+ const branch_path_hash = this._parent_branch_path_hash(parent_branch_path);
31
+ const attributes_hash = this._attributes_hash(dom_element.attributes);
32
+ const xpath_hash = this._xpath_hash(dom_element.xpath);
33
+ return this._hash_string(`${branch_path_hash}-${attributes_hash}-${xpath_hash}`);
34
+ }
35
+ static _get_parent_branch_path(dom_element) {
36
+ const parents = [];
37
+ let current = dom_element;
38
+ while (current && current.parent) {
39
+ parents.push(current);
40
+ current = current.parent;
41
+ }
42
+ parents.reverse();
43
+ return parents.map((parent) => parent.tag_name);
44
+ }
45
+ static _parent_branch_path_hash(parent_branch_path) {
46
+ return sha256(parent_branch_path.join('/'));
47
+ }
48
+ static _attributes_hash(attributes) {
49
+ const attributes_string = Object.entries(attributes)
50
+ .map(([key, value]) => `${key}=${value}`)
51
+ .join('');
52
+ return this._hash_string(attributes_string);
53
+ }
54
+ static _xpath_hash(xpath) {
55
+ return this._hash_string(xpath);
56
+ }
57
+ static _hash_string(value) {
58
+ return sha256(value);
59
+ }
60
+ }