browser-use 0.2.0 → 0.3.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.
- package/README.md +295 -686
- package/dist/actor/element.d.ts +19 -0
- package/dist/actor/element.js +46 -0
- package/dist/actor/index.d.ts +4 -0
- package/dist/actor/index.js +4 -0
- package/dist/actor/mouse.d.ts +19 -0
- package/dist/actor/mouse.js +39 -0
- package/dist/actor/page.d.ts +29 -0
- package/dist/actor/page.js +88 -0
- package/dist/actor/utils.d.ts +4 -0
- package/dist/actor/utils.js +35 -0
- package/dist/agent/cloud-events.d.ts +18 -0
- package/dist/agent/cloud-events.js +65 -2
- package/dist/agent/gif.d.ts +1 -0
- package/dist/agent/gif.js +24 -2
- package/dist/agent/judge.d.ts +17 -0
- package/dist/agent/judge.js +197 -0
- package/dist/agent/message-manager/service.d.ts +12 -4
- package/dist/agent/message-manager/service.js +205 -39
- package/dist/agent/message-manager/utils.js +0 -1
- package/dist/agent/message-manager/views.d.ts +4 -0
- package/dist/agent/message-manager/views.js +11 -7
- package/dist/agent/prompts.d.ts +24 -3
- package/dist/agent/prompts.js +274 -59
- package/dist/agent/service.d.ts +99 -41
- package/dist/agent/service.js +2266 -472
- package/dist/agent/variable-detector.d.ts +12 -0
- package/dist/agent/variable-detector.js +211 -0
- package/dist/agent/views.d.ts +237 -18
- package/dist/agent/views.js +446 -33
- package/dist/browser/cloud/cloud.d.ts +20 -0
- package/dist/browser/cloud/cloud.js +129 -0
- package/dist/browser/cloud/index.d.ts +2 -0
- package/dist/browser/cloud/index.js +2 -0
- package/dist/browser/cloud/views.d.ts +41 -0
- package/dist/browser/cloud/views.js +35 -0
- package/dist/browser/events.d.ts +345 -0
- package/dist/browser/events.js +566 -0
- package/dist/browser/extensions.js +17 -17
- package/dist/browser/index.d.ts +4 -0
- package/dist/browser/index.js +4 -0
- package/dist/browser/profile.d.ts +8 -2
- package/dist/browser/profile.js +79 -12
- package/dist/browser/session-manager.d.ts +85 -0
- package/dist/browser/session-manager.js +208 -0
- package/dist/browser/session.d.ts +100 -8
- package/dist/browser/session.js +1097 -58
- package/dist/browser/types.d.ts +0 -2
- package/dist/browser/views.d.ts +39 -0
- package/dist/browser/views.js +32 -0
- package/dist/browser/watchdogs/aboutblank-watchdog.d.ts +12 -0
- package/dist/browser/watchdogs/aboutblank-watchdog.js +131 -0
- package/dist/browser/watchdogs/base.d.ts +21 -0
- package/dist/browser/watchdogs/base.js +81 -0
- package/dist/browser/watchdogs/cdp-session-watchdog.d.ts +14 -0
- package/dist/browser/watchdogs/cdp-session-watchdog.js +177 -0
- package/dist/browser/watchdogs/crash-watchdog.d.ts +38 -0
- package/dist/browser/watchdogs/crash-watchdog.js +296 -0
- package/dist/browser/watchdogs/default-action-watchdog.d.ts +49 -0
- package/dist/browser/watchdogs/default-action-watchdog.js +212 -0
- package/dist/browser/watchdogs/dom-watchdog.d.ts +8 -0
- package/dist/browser/watchdogs/dom-watchdog.js +31 -0
- package/dist/browser/watchdogs/downloads-watchdog.d.ts +77 -0
- package/dist/browser/watchdogs/downloads-watchdog.js +409 -0
- package/dist/browser/watchdogs/har-recording-watchdog.d.ts +19 -0
- package/dist/browser/watchdogs/har-recording-watchdog.js +317 -0
- package/dist/browser/watchdogs/index.d.ts +15 -0
- package/dist/browser/watchdogs/index.js +15 -0
- package/dist/browser/watchdogs/local-browser-watchdog.d.ts +10 -0
- package/dist/browser/watchdogs/local-browser-watchdog.js +32 -0
- package/dist/browser/watchdogs/permissions-watchdog.d.ts +8 -0
- package/dist/browser/watchdogs/permissions-watchdog.js +73 -0
- package/dist/browser/watchdogs/popups-watchdog.d.ts +13 -0
- package/dist/browser/watchdogs/popups-watchdog.js +77 -0
- package/dist/browser/watchdogs/recording-watchdog.d.ts +27 -0
- package/dist/browser/watchdogs/recording-watchdog.js +249 -0
- package/dist/browser/watchdogs/screenshot-watchdog.d.ts +6 -0
- package/dist/browser/watchdogs/screenshot-watchdog.js +13 -0
- package/dist/browser/watchdogs/security-watchdog.d.ts +10 -0
- package/dist/browser/watchdogs/security-watchdog.js +84 -0
- package/dist/browser/watchdogs/storage-state-watchdog.d.ts +24 -0
- package/dist/browser/watchdogs/storage-state-watchdog.js +288 -0
- package/dist/cli.d.ts +7 -2
- package/dist/cli.js +182 -25
- package/dist/code-use/formatting.d.ts +3 -0
- package/dist/code-use/formatting.js +18 -0
- package/dist/code-use/index.d.ts +6 -0
- package/dist/code-use/index.js +6 -0
- package/dist/code-use/namespace.d.ts +5 -0
- package/dist/code-use/namespace.js +81 -0
- package/dist/code-use/notebook-export.d.ts +3 -0
- package/dist/code-use/notebook-export.js +56 -0
- package/dist/code-use/service.d.ts +24 -0
- package/dist/code-use/service.js +104 -0
- package/dist/code-use/utils.d.ts +4 -0
- package/dist/code-use/utils.js +98 -0
- package/dist/code-use/views.d.ts +108 -0
- package/dist/code-use/views.js +165 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +69 -3
- package/dist/controller/registry/service.d.ts +10 -1
- package/dist/controller/registry/service.js +266 -10
- package/dist/controller/registry/views.d.ts +4 -1
- package/dist/controller/registry/views.js +25 -2
- package/dist/controller/service.d.ts +10 -1
- package/dist/controller/service.js +1807 -268
- package/dist/controller/views.d.ts +78 -155
- package/dist/controller/views.js +61 -12
- package/dist/dom/history-tree-processor/service.d.ts +5 -0
- package/dist/dom/history-tree-processor/service.js +169 -14
- package/dist/dom/history-tree-processor/view.d.ts +7 -1
- package/dist/dom/history-tree-processor/view.js +10 -1
- package/dist/dom/markdown-extractor.d.ts +37 -0
- package/dist/dom/markdown-extractor.js +345 -0
- package/dist/dom/service.d.ts +3 -1
- package/dist/dom/service.js +76 -0
- package/dist/dom/views.d.ts +1 -0
- package/dist/dom/views.js +45 -0
- package/dist/event-bus.d.ts +107 -7
- package/dist/event-bus.js +313 -10
- package/dist/exceptions.d.ts +0 -3
- package/dist/exceptions.js +0 -7
- package/dist/filesystem/file-system.d.ts +18 -0
- package/dist/filesystem/file-system.js +503 -42
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/integrations/gmail/actions.d.ts +3 -3
- package/dist/integrations/gmail/actions.js +4 -4
- package/dist/llm/anthropic/chat.d.ts +18 -1
- package/dist/llm/anthropic/chat.js +123 -55
- package/dist/llm/anthropic/serializer.d.ts +2 -0
- package/dist/llm/anthropic/serializer.js +81 -9
- package/dist/llm/aws/chat-anthropic.d.ts +17 -0
- package/dist/llm/aws/chat-anthropic.js +126 -26
- package/dist/llm/aws/chat-bedrock.d.ts +28 -1
- package/dist/llm/aws/chat-bedrock.js +161 -34
- package/dist/llm/aws/serializer.d.ts +13 -1
- package/dist/llm/aws/serializer.js +56 -17
- package/dist/llm/azure/chat.d.ts +53 -2
- package/dist/llm/azure/chat.js +366 -54
- package/dist/llm/base.d.ts +2 -0
- package/dist/llm/browser-use/chat.d.ts +40 -0
- package/dist/llm/browser-use/chat.js +305 -0
- package/dist/llm/browser-use/index.d.ts +1 -0
- package/dist/llm/browser-use/index.js +1 -0
- package/dist/llm/cerebras/chat.d.ts +39 -0
- package/dist/llm/cerebras/chat.js +178 -0
- package/dist/llm/cerebras/index.d.ts +2 -0
- package/dist/llm/cerebras/index.js +2 -0
- package/dist/llm/cerebras/serializer.d.ts +7 -0
- package/dist/llm/cerebras/serializer.js +82 -0
- package/dist/llm/deepseek/chat.d.ts +19 -2
- package/dist/llm/deepseek/chat.js +138 -25
- package/dist/llm/google/chat.d.ts +46 -2
- package/dist/llm/google/chat.js +267 -64
- package/dist/llm/google/serializer.d.ts +9 -1
- package/dist/llm/google/serializer.js +141 -34
- package/dist/llm/groq/chat.d.ts +21 -2
- package/dist/llm/groq/chat.js +125 -26
- package/dist/llm/groq/parser.js +3 -1
- package/dist/llm/mistral/chat.d.ts +43 -0
- package/dist/llm/mistral/chat.js +154 -0
- package/dist/llm/mistral/index.d.ts +2 -0
- package/dist/llm/mistral/index.js +2 -0
- package/dist/llm/mistral/schema.d.ts +8 -0
- package/dist/llm/mistral/schema.js +27 -0
- package/dist/llm/models.d.ts +2 -0
- package/dist/llm/models.js +317 -0
- package/dist/llm/ollama/chat.d.ts +13 -1
- package/dist/llm/ollama/chat.js +110 -19
- package/dist/llm/ollama/serializer.d.ts +1 -0
- package/dist/llm/ollama/serializer.js +34 -12
- package/dist/llm/openai/chat.d.ts +16 -0
- package/dist/llm/openai/chat.js +94 -44
- package/dist/llm/openai/like.d.ts +5 -3
- package/dist/llm/openai/like.js +7 -3
- package/dist/llm/openai/responses-serializer.d.ts +18 -0
- package/dist/llm/openai/responses-serializer.js +72 -0
- package/dist/llm/openrouter/chat.d.ts +28 -2
- package/dist/llm/openrouter/chat.js +115 -29
- package/dist/llm/schema.d.ts +11 -1
- package/dist/llm/schema.js +81 -1
- package/dist/llm/vercel/chat.d.ts +50 -0
- package/dist/llm/vercel/chat.js +276 -0
- package/dist/llm/vercel/index.d.ts +1 -0
- package/dist/llm/vercel/index.js +1 -0
- package/dist/llm/vercel/serializer.d.ts +5 -0
- package/dist/llm/vercel/serializer.js +7 -0
- package/dist/llm/views.d.ts +2 -1
- package/dist/llm/views.js +3 -1
- package/dist/logging-config.d.ts +2 -0
- package/dist/logging-config.js +82 -29
- package/dist/mcp/client.d.ts +10 -5
- package/dist/mcp/client.js +14 -9
- package/dist/mcp/controller.d.ts +42 -3
- package/dist/mcp/controller.js +56 -31
- package/dist/mcp/server.d.ts +14 -0
- package/dist/mcp/server.js +255 -52
- package/dist/observability.js +10 -4
- package/dist/sandbox/index.d.ts +2 -0
- package/dist/sandbox/index.js +2 -0
- package/dist/sandbox/sandbox.d.ts +19 -0
- package/dist/sandbox/sandbox.js +140 -0
- package/dist/sandbox/views.d.ts +67 -0
- package/dist/sandbox/views.js +121 -0
- package/dist/skill-cli/index.d.ts +3 -0
- package/dist/skill-cli/index.js +3 -0
- package/dist/skill-cli/protocol.d.ts +30 -0
- package/dist/skill-cli/protocol.js +48 -0
- package/dist/skill-cli/server.d.ts +11 -0
- package/dist/skill-cli/server.js +85 -0
- package/dist/skill-cli/sessions.d.ts +24 -0
- package/dist/skill-cli/sessions.js +47 -0
- package/dist/skills/index.d.ts +3 -0
- package/dist/skills/index.js +3 -0
- package/dist/skills/service.d.ts +27 -0
- package/dist/skills/service.js +266 -0
- package/dist/skills/utils.d.ts +6 -0
- package/dist/skills/utils.js +53 -0
- package/dist/skills/views.d.ts +40 -0
- package/dist/skills/views.js +10 -0
- package/dist/sync/auth.js +8 -3
- package/dist/sync/service.d.ts +6 -6
- package/dist/sync/service.js +54 -89
- package/dist/telemetry/views.d.ts +20 -6
- package/dist/telemetry/views.js +23 -5
- package/dist/tokens/custom-pricing.d.ts +2 -0
- package/dist/tokens/custom-pricing.js +22 -0
- package/dist/tokens/index.d.ts +2 -0
- package/dist/tokens/index.js +2 -0
- package/dist/tokens/mappings.d.ts +1 -0
- package/dist/tokens/mappings.js +3 -0
- package/dist/tokens/service.js +27 -8
- package/dist/tools/extraction/index.d.ts +2 -0
- package/dist/tools/extraction/index.js +2 -0
- package/dist/tools/extraction/schema-utils.d.ts +6 -0
- package/dist/tools/extraction/schema-utils.js +237 -0
- package/dist/tools/extraction/views.d.ts +7 -0
- package/dist/tools/index.d.ts +5 -0
- package/dist/tools/index.js +5 -0
- package/dist/tools/registry/index.d.ts +2 -0
- package/dist/tools/registry/index.js +2 -0
- package/dist/tools/registry/service.d.ts +1 -0
- package/dist/tools/registry/service.js +1 -0
- package/dist/tools/registry/views.d.ts +1 -0
- package/dist/tools/registry/views.js +1 -0
- package/dist/tools/service.d.ts +2 -0
- package/dist/tools/service.js +1 -0
- package/dist/tools/utils.d.ts +2 -0
- package/dist/tools/utils.js +57 -0
- package/dist/tools/views.d.ts +1 -0
- package/dist/tools/views.js +1 -0
- package/dist/utils.d.ts +10 -1
- package/dist/utils.js +70 -3
- package/package.json +87 -26
- package/dist/dom/playground/process-dom.js +0 -5
- package/dist/dom/playground/test-accessibility.d.ts +0 -44
- package/dist/dom/playground/test-accessibility.js +0 -111
- /package/dist/{dom/playground/process-dom.d.ts → tools/extraction/views.js} +0 -0
|
@@ -1,241 +1,164 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const SearchGoogleActionSchema: z.ZodObject<{
|
|
3
3
|
query: z.ZodString;
|
|
4
|
-
},
|
|
5
|
-
query: string;
|
|
6
|
-
}, {
|
|
7
|
-
query: string;
|
|
8
|
-
}>;
|
|
4
|
+
}, z.core.$strip>;
|
|
9
5
|
export type SearchGoogleAction = z.infer<typeof SearchGoogleActionSchema>;
|
|
6
|
+
export declare const SearchActionSchema: z.ZodObject<{
|
|
7
|
+
query: z.ZodString;
|
|
8
|
+
engine: z.ZodDefault<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type SearchAction = z.infer<typeof SearchActionSchema>;
|
|
10
11
|
export declare const GoToUrlActionSchema: z.ZodObject<{
|
|
11
12
|
url: z.ZodString;
|
|
12
13
|
new_tab: z.ZodDefault<z.ZodBoolean>;
|
|
13
|
-
},
|
|
14
|
-
url: string;
|
|
15
|
-
new_tab: boolean;
|
|
16
|
-
}, {
|
|
17
|
-
url: string;
|
|
18
|
-
new_tab?: boolean | undefined;
|
|
19
|
-
}>;
|
|
14
|
+
}, z.core.$strip>;
|
|
20
15
|
export type GoToUrlAction = z.infer<typeof GoToUrlActionSchema>;
|
|
21
16
|
export declare const WaitActionSchema: z.ZodObject<{
|
|
22
17
|
seconds: z.ZodDefault<z.ZodNumber>;
|
|
23
|
-
},
|
|
24
|
-
seconds: number;
|
|
25
|
-
}, {
|
|
26
|
-
seconds?: number | undefined;
|
|
27
|
-
}>;
|
|
18
|
+
}, z.core.$strip>;
|
|
28
19
|
export type WaitAction = z.infer<typeof WaitActionSchema>;
|
|
29
20
|
export declare const ClickElementActionSchema: z.ZodObject<{
|
|
30
|
-
index: z.ZodNumber
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
index: number;
|
|
35
|
-
}>;
|
|
21
|
+
index: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
coordinate_x: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
coordinate_y: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
}, z.core.$strip>;
|
|
36
25
|
export type ClickElementAction = z.infer<typeof ClickElementActionSchema>;
|
|
26
|
+
export declare const ClickElementActionIndexOnlySchema: z.ZodObject<{
|
|
27
|
+
index: z.ZodNumber;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
export type ClickElementActionIndexOnly = z.infer<typeof ClickElementActionIndexOnlySchema>;
|
|
37
30
|
export declare const InputTextActionSchema: z.ZodObject<{
|
|
38
31
|
index: z.ZodNumber;
|
|
39
32
|
text: z.ZodString;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
text: string;
|
|
43
|
-
}, {
|
|
44
|
-
index: number;
|
|
45
|
-
text: string;
|
|
46
|
-
}>;
|
|
33
|
+
clear: z.ZodDefault<z.ZodBoolean>;
|
|
34
|
+
}, z.core.$strip>;
|
|
47
35
|
export type InputTextAction = z.infer<typeof InputTextActionSchema>;
|
|
48
36
|
export declare const DoneActionSchema: z.ZodObject<{
|
|
49
37
|
text: z.ZodString;
|
|
50
|
-
success: z.ZodBoolean
|
|
51
|
-
files_to_display: z.ZodDefault<z.ZodArray<z.ZodString
|
|
52
|
-
},
|
|
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
|
-
}>;
|
|
38
|
+
success: z.ZodDefault<z.ZodBoolean>;
|
|
39
|
+
files_to_display: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
40
|
+
}, z.core.$strip>;
|
|
61
41
|
export type DoneAction = z.infer<typeof DoneActionSchema>;
|
|
62
42
|
export declare const StructuredOutputActionSchema: <T extends z.ZodTypeAny>(dataSchema: T) => z.ZodObject<{
|
|
63
43
|
success: z.ZodDefault<z.ZodBoolean>;
|
|
64
44
|
data: T;
|
|
65
|
-
},
|
|
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>;
|
|
45
|
+
}, z.core.$strip>;
|
|
72
46
|
export type StructuredOutputAction<T> = {
|
|
73
47
|
success: boolean;
|
|
74
48
|
data: T;
|
|
75
49
|
};
|
|
76
50
|
export declare const SwitchTabActionSchema: z.ZodObject<{
|
|
77
|
-
page_id: z.ZodNumber
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}, {
|
|
81
|
-
page_id: number;
|
|
82
|
-
}>;
|
|
51
|
+
page_id: z.ZodOptional<z.ZodNumber>;
|
|
52
|
+
tab_id: z.ZodOptional<z.ZodString>;
|
|
53
|
+
}, z.core.$strip>;
|
|
83
54
|
export type SwitchTabAction = z.infer<typeof SwitchTabActionSchema>;
|
|
84
55
|
export declare const CloseTabActionSchema: z.ZodObject<{
|
|
85
|
-
page_id: z.ZodNumber
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}, {
|
|
89
|
-
page_id: number;
|
|
90
|
-
}>;
|
|
56
|
+
page_id: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
tab_id: z.ZodOptional<z.ZodString>;
|
|
58
|
+
}, z.core.$strip>;
|
|
91
59
|
export type CloseTabAction = z.infer<typeof CloseTabActionSchema>;
|
|
92
60
|
export declare const ScrollActionSchema: z.ZodObject<{
|
|
93
61
|
down: z.ZodDefault<z.ZodBoolean>;
|
|
94
62
|
num_pages: z.ZodDefault<z.ZodNumber>;
|
|
63
|
+
pages: z.ZodOptional<z.ZodNumber>;
|
|
95
64
|
index: z.ZodOptional<z.ZodNumber>;
|
|
96
|
-
},
|
|
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
|
-
}>;
|
|
65
|
+
}, z.core.$strip>;
|
|
105
66
|
export type ScrollAction = z.infer<typeof ScrollActionSchema>;
|
|
106
67
|
export declare const SendKeysActionSchema: z.ZodObject<{
|
|
107
68
|
keys: z.ZodString;
|
|
108
|
-
},
|
|
109
|
-
keys: string;
|
|
110
|
-
}, {
|
|
111
|
-
keys: string;
|
|
112
|
-
}>;
|
|
69
|
+
}, z.core.$strip>;
|
|
113
70
|
export type SendKeysAction = z.infer<typeof SendKeysActionSchema>;
|
|
114
71
|
export declare const UploadFileActionSchema: z.ZodObject<{
|
|
115
72
|
index: z.ZodNumber;
|
|
116
73
|
path: z.ZodString;
|
|
117
|
-
},
|
|
118
|
-
index: number;
|
|
119
|
-
path: string;
|
|
120
|
-
}, {
|
|
121
|
-
index: number;
|
|
122
|
-
path: string;
|
|
123
|
-
}>;
|
|
74
|
+
}, z.core.$strip>;
|
|
124
75
|
export type UploadFileAction = z.infer<typeof UploadFileActionSchema>;
|
|
76
|
+
export declare const ScreenshotActionSchema: z.ZodObject<{
|
|
77
|
+
file_name: z.ZodOptional<z.ZodString>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
export type ScreenshotAction = z.infer<typeof ScreenshotActionSchema>;
|
|
80
|
+
export declare const EvaluateActionSchema: z.ZodObject<{
|
|
81
|
+
code: z.ZodString;
|
|
82
|
+
}, z.core.$strip>;
|
|
83
|
+
export type EvaluateAction = z.infer<typeof EvaluateActionSchema>;
|
|
125
84
|
export declare const ExtractPageContentActionSchema: z.ZodObject<{
|
|
126
85
|
value: z.ZodString;
|
|
127
|
-
},
|
|
128
|
-
value: string;
|
|
129
|
-
}, {
|
|
130
|
-
value: string;
|
|
131
|
-
}>;
|
|
86
|
+
}, z.core.$strip>;
|
|
132
87
|
export type ExtractPageContentAction = z.infer<typeof ExtractPageContentActionSchema>;
|
|
133
88
|
export declare const ExtractStructuredDataActionSchema: z.ZodObject<{
|
|
134
89
|
query: z.ZodString;
|
|
135
90
|
extract_links: z.ZodDefault<z.ZodBoolean>;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}, {
|
|
140
|
-
query: string;
|
|
141
|
-
extract_links?: boolean | undefined;
|
|
142
|
-
}>;
|
|
91
|
+
start_from_char: z.ZodDefault<z.ZodNumber>;
|
|
92
|
+
output_schema: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
93
|
+
}, z.core.$strip>;
|
|
143
94
|
export type ExtractStructuredDataAction = z.infer<typeof ExtractStructuredDataActionSchema>;
|
|
95
|
+
export declare const SearchPageActionSchema: z.ZodObject<{
|
|
96
|
+
pattern: z.ZodString;
|
|
97
|
+
regex: z.ZodDefault<z.ZodBoolean>;
|
|
98
|
+
case_sensitive: z.ZodDefault<z.ZodBoolean>;
|
|
99
|
+
context_chars: z.ZodDefault<z.ZodNumber>;
|
|
100
|
+
css_scope: z.ZodOptional<z.ZodString>;
|
|
101
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
export type SearchPageAction = z.infer<typeof SearchPageActionSchema>;
|
|
104
|
+
export declare const FindElementsActionSchema: z.ZodObject<{
|
|
105
|
+
selector: z.ZodString;
|
|
106
|
+
attributes: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
107
|
+
max_results: z.ZodDefault<z.ZodNumber>;
|
|
108
|
+
include_text: z.ZodDefault<z.ZodBoolean>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
export type FindElementsAction = z.infer<typeof FindElementsActionSchema>;
|
|
144
111
|
export declare const ReadFileActionSchema: z.ZodObject<{
|
|
145
112
|
file_name: z.ZodString;
|
|
146
|
-
},
|
|
147
|
-
file_name: string;
|
|
148
|
-
}, {
|
|
149
|
-
file_name: string;
|
|
150
|
-
}>;
|
|
113
|
+
}, z.core.$strip>;
|
|
151
114
|
export type ReadFileAction = z.infer<typeof ReadFileActionSchema>;
|
|
115
|
+
export declare const ReadLongContentActionSchema: z.ZodObject<{
|
|
116
|
+
goal: z.ZodString;
|
|
117
|
+
source: z.ZodDefault<z.ZodString>;
|
|
118
|
+
context: z.ZodDefault<z.ZodString>;
|
|
119
|
+
}, z.core.$strip>;
|
|
120
|
+
export type ReadLongContentAction = z.infer<typeof ReadLongContentActionSchema>;
|
|
152
121
|
export declare const WriteFileActionSchema: z.ZodObject<{
|
|
153
122
|
file_name: z.ZodString;
|
|
154
123
|
content: z.ZodString;
|
|
155
124
|
append: z.ZodOptional<z.ZodBoolean>;
|
|
156
125
|
trailing_newline: z.ZodOptional<z.ZodBoolean>;
|
|
157
126
|
leading_newline: z.ZodOptional<z.ZodBoolean>;
|
|
158
|
-
},
|
|
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
|
-
}>;
|
|
127
|
+
}, z.core.$strip>;
|
|
171
128
|
export type WriteFileAction = z.infer<typeof WriteFileActionSchema>;
|
|
172
129
|
export declare const ReplaceFileStrActionSchema: z.ZodObject<{
|
|
173
130
|
file_name: z.ZodString;
|
|
174
131
|
old_str: z.ZodString;
|
|
175
132
|
new_str: z.ZodString;
|
|
176
|
-
},
|
|
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
|
-
}>;
|
|
133
|
+
}, z.core.$strip>;
|
|
185
134
|
export type ReplaceFileStrAction = z.infer<typeof ReplaceFileStrActionSchema>;
|
|
186
135
|
export declare const ScrollToTextActionSchema: z.ZodObject<{
|
|
187
136
|
text: z.ZodString;
|
|
188
|
-
},
|
|
189
|
-
text: string;
|
|
190
|
-
}, {
|
|
191
|
-
text: string;
|
|
192
|
-
}>;
|
|
137
|
+
}, z.core.$strip>;
|
|
193
138
|
export type ScrollToTextAction = z.infer<typeof ScrollToTextActionSchema>;
|
|
194
139
|
export declare const DropdownOptionsActionSchema: z.ZodObject<{
|
|
195
140
|
index: z.ZodNumber;
|
|
196
|
-
},
|
|
197
|
-
index: number;
|
|
198
|
-
}, {
|
|
199
|
-
index: number;
|
|
200
|
-
}>;
|
|
141
|
+
}, z.core.$strip>;
|
|
201
142
|
export type DropdownOptionsAction = z.infer<typeof DropdownOptionsActionSchema>;
|
|
202
143
|
export declare const SelectDropdownActionSchema: z.ZodObject<{
|
|
203
144
|
index: z.ZodNumber;
|
|
204
145
|
text: z.ZodString;
|
|
205
|
-
},
|
|
206
|
-
index: number;
|
|
207
|
-
text: string;
|
|
208
|
-
}, {
|
|
209
|
-
index: number;
|
|
210
|
-
text: string;
|
|
211
|
-
}>;
|
|
146
|
+
}, z.core.$strip>;
|
|
212
147
|
export type SelectDropdownAction = z.infer<typeof SelectDropdownActionSchema>;
|
|
213
148
|
export declare const SheetsRangeActionSchema: z.ZodObject<{
|
|
214
149
|
cell_or_range: z.ZodString;
|
|
215
|
-
},
|
|
216
|
-
cell_or_range: string;
|
|
217
|
-
}, {
|
|
218
|
-
cell_or_range: string;
|
|
219
|
-
}>;
|
|
150
|
+
}, z.core.$strip>;
|
|
220
151
|
export type SheetsRangeAction = z.infer<typeof SheetsRangeActionSchema>;
|
|
221
152
|
export declare const SheetsUpdateActionSchema: z.ZodObject<{
|
|
222
153
|
cell_or_range: z.ZodString;
|
|
223
154
|
value: z.ZodString;
|
|
224
|
-
},
|
|
225
|
-
value: string;
|
|
226
|
-
cell_or_range: string;
|
|
227
|
-
}, {
|
|
228
|
-
value: string;
|
|
229
|
-
cell_or_range: string;
|
|
230
|
-
}>;
|
|
155
|
+
}, z.core.$strip>;
|
|
231
156
|
export type SheetsUpdateAction = z.infer<typeof SheetsUpdateActionSchema>;
|
|
232
157
|
export declare const SheetsInputActionSchema: z.ZodObject<{
|
|
233
158
|
text: z.ZodString;
|
|
234
|
-
},
|
|
235
|
-
text: string;
|
|
236
|
-
}, {
|
|
237
|
-
text: string;
|
|
238
|
-
}>;
|
|
159
|
+
}, z.core.$strip>;
|
|
239
160
|
export type SheetsInputAction = z.infer<typeof SheetsInputActionSchema>;
|
|
240
|
-
export declare const NoParamsActionSchema: z.ZodObject<{
|
|
161
|
+
export declare const NoParamsActionSchema: z.ZodObject<{
|
|
162
|
+
description: z.ZodOptional<z.ZodString>;
|
|
163
|
+
}, z.core.$loose>;
|
|
241
164
|
export type NoParamsAction = z.infer<typeof NoParamsActionSchema>;
|
package/dist/controller/views.js
CHANGED
|
@@ -2,6 +2,10 @@ import { z } from 'zod';
|
|
|
2
2
|
export const SearchGoogleActionSchema = z.object({
|
|
3
3
|
query: z.string(),
|
|
4
4
|
});
|
|
5
|
+
export const SearchActionSchema = z.object({
|
|
6
|
+
query: z.string(),
|
|
7
|
+
engine: z.string().default('duckduckgo'),
|
|
8
|
+
});
|
|
5
9
|
export const GoToUrlActionSchema = z.object({
|
|
6
10
|
url: z.string(),
|
|
7
11
|
new_tab: z.boolean().default(false),
|
|
@@ -10,30 +14,44 @@ export const WaitActionSchema = z.object({
|
|
|
10
14
|
seconds: z.number().default(3),
|
|
11
15
|
});
|
|
12
16
|
export const ClickElementActionSchema = z.object({
|
|
13
|
-
index: z.number().int(),
|
|
17
|
+
index: z.number().int().min(1).optional(),
|
|
18
|
+
coordinate_x: z.number().int().optional(),
|
|
19
|
+
coordinate_y: z.number().int().optional(),
|
|
20
|
+
});
|
|
21
|
+
export const ClickElementActionIndexOnlySchema = z.object({
|
|
22
|
+
index: z.number().int().min(1),
|
|
14
23
|
});
|
|
15
24
|
export const InputTextActionSchema = z.object({
|
|
16
|
-
index: z.number().int(),
|
|
25
|
+
index: z.number().int().min(0),
|
|
17
26
|
text: z.string(),
|
|
27
|
+
clear: z.boolean().default(true),
|
|
18
28
|
});
|
|
19
29
|
export const DoneActionSchema = z.object({
|
|
20
30
|
text: z.string(),
|
|
21
|
-
success: z.boolean(),
|
|
31
|
+
success: z.boolean().default(true),
|
|
22
32
|
files_to_display: z.array(z.string()).default([]),
|
|
23
33
|
});
|
|
24
34
|
export const StructuredOutputActionSchema = (dataSchema) => z.object({
|
|
25
|
-
success: z
|
|
35
|
+
success: z
|
|
36
|
+
.boolean()
|
|
37
|
+
.default(true)
|
|
38
|
+
.describe('True if user_request completed successfully'),
|
|
26
39
|
data: dataSchema,
|
|
27
40
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
41
|
+
const TabIdentifierActionSchema = z
|
|
42
|
+
.object({
|
|
43
|
+
page_id: z.number().int().optional(),
|
|
44
|
+
tab_id: z.string().trim().length(4).optional(),
|
|
45
|
+
})
|
|
46
|
+
.refine((value) => value.page_id != null || value.tab_id != null, {
|
|
47
|
+
message: 'Provide tab_id or page_id',
|
|
33
48
|
});
|
|
49
|
+
export const SwitchTabActionSchema = TabIdentifierActionSchema;
|
|
50
|
+
export const CloseTabActionSchema = TabIdentifierActionSchema;
|
|
34
51
|
export const ScrollActionSchema = z.object({
|
|
35
52
|
down: z.boolean().default(true), // Default to scroll down
|
|
36
53
|
num_pages: z.number().default(1), // Default to 1 page
|
|
54
|
+
pages: z.number().optional(), // Alias for num_pages
|
|
37
55
|
index: z.number().int().optional(),
|
|
38
56
|
});
|
|
39
57
|
export const SendKeysActionSchema = z.object({
|
|
@@ -43,16 +61,43 @@ export const UploadFileActionSchema = z.object({
|
|
|
43
61
|
index: z.number().int(),
|
|
44
62
|
path: z.string(),
|
|
45
63
|
});
|
|
64
|
+
export const ScreenshotActionSchema = z.object({
|
|
65
|
+
file_name: z.string().optional(),
|
|
66
|
+
});
|
|
67
|
+
export const EvaluateActionSchema = z.object({
|
|
68
|
+
code: z.string(),
|
|
69
|
+
});
|
|
46
70
|
export const ExtractPageContentActionSchema = z.object({
|
|
47
71
|
value: z.string(),
|
|
48
72
|
});
|
|
49
73
|
export const ExtractStructuredDataActionSchema = z.object({
|
|
50
74
|
query: z.string(),
|
|
51
75
|
extract_links: z.boolean().default(false),
|
|
76
|
+
start_from_char: z.number().int().default(0),
|
|
77
|
+
output_schema: z.record(z.string(), z.unknown()).nullable().optional(),
|
|
78
|
+
});
|
|
79
|
+
export const SearchPageActionSchema = z.object({
|
|
80
|
+
pattern: z.string(),
|
|
81
|
+
regex: z.boolean().default(false),
|
|
82
|
+
case_sensitive: z.boolean().default(false),
|
|
83
|
+
context_chars: z.number().int().default(150),
|
|
84
|
+
css_scope: z.string().optional(),
|
|
85
|
+
max_results: z.number().int().default(25),
|
|
86
|
+
});
|
|
87
|
+
export const FindElementsActionSchema = z.object({
|
|
88
|
+
selector: z.string(),
|
|
89
|
+
attributes: z.array(z.string()).optional(),
|
|
90
|
+
max_results: z.number().int().default(50),
|
|
91
|
+
include_text: z.boolean().default(true),
|
|
52
92
|
});
|
|
53
93
|
export const ReadFileActionSchema = z.object({
|
|
54
94
|
file_name: z.string(),
|
|
55
95
|
});
|
|
96
|
+
export const ReadLongContentActionSchema = z.object({
|
|
97
|
+
goal: z.string(),
|
|
98
|
+
source: z.string().default('page'),
|
|
99
|
+
context: z.string().default(''),
|
|
100
|
+
});
|
|
56
101
|
export const WriteFileActionSchema = z.object({
|
|
57
102
|
file_name: z.string(),
|
|
58
103
|
content: z.string(),
|
|
@@ -69,10 +114,10 @@ export const ScrollToTextActionSchema = z.object({
|
|
|
69
114
|
text: z.string(),
|
|
70
115
|
});
|
|
71
116
|
export const DropdownOptionsActionSchema = z.object({
|
|
72
|
-
index: z.number().int(),
|
|
117
|
+
index: z.number().int().min(1),
|
|
73
118
|
});
|
|
74
119
|
export const SelectDropdownActionSchema = z.object({
|
|
75
|
-
index: z.number().int(),
|
|
120
|
+
index: z.number().int().min(1),
|
|
76
121
|
text: z.string(),
|
|
77
122
|
});
|
|
78
123
|
export const SheetsRangeActionSchema = z.object({
|
|
@@ -85,4 +130,8 @@ export const SheetsUpdateActionSchema = z.object({
|
|
|
85
130
|
export const SheetsInputActionSchema = z.object({
|
|
86
131
|
text: z.string(),
|
|
87
132
|
});
|
|
88
|
-
export const NoParamsActionSchema = z
|
|
133
|
+
export const NoParamsActionSchema = z
|
|
134
|
+
.object({
|
|
135
|
+
description: z.string().optional(),
|
|
136
|
+
})
|
|
137
|
+
.passthrough();
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { DOMHistoryElement, HashedDomElement } from './view.js';
|
|
2
2
|
import { DOMElementNode } from '../views.js';
|
|
3
3
|
export declare class HistoryTreeProcessor {
|
|
4
|
+
static get_accessible_name(dom_element: DOMElementNode): string | null;
|
|
5
|
+
static compute_element_hash(dom_element: DOMElementNode): string;
|
|
6
|
+
static compute_stable_hash(dom_element: DOMElementNode): string;
|
|
7
|
+
static _filter_dynamic_classes(class_value: string): string;
|
|
8
|
+
static _compute_element_hash(dom_element: DOMElementNode, stable: boolean): string;
|
|
4
9
|
static convert_dom_element_to_history_element(dom_element: DOMElementNode, css_selector?: string | null): DOMHistoryElement;
|
|
5
10
|
static find_history_element_in_tree(dom_history_element: DOMHistoryElement, tree: DOMElementNode): DOMElementNode | null;
|
|
6
11
|
static compare_history_element_and_dom_element(dom_history_element: DOMHistoryElement, dom_element: DOMElementNode): boolean;
|
|
@@ -2,33 +2,188 @@ import crypto from 'node:crypto';
|
|
|
2
2
|
import { DOMHistoryElement, HashedDomElement } from './view.js';
|
|
3
3
|
import { DOMElementNode } from '../views.js';
|
|
4
4
|
const sha256 = (value) => crypto.createHash('sha256').update(value).digest('hex');
|
|
5
|
+
const STATIC_HASH_ATTRIBUTES = new Set([
|
|
6
|
+
'class',
|
|
7
|
+
'id',
|
|
8
|
+
'name',
|
|
9
|
+
'type',
|
|
10
|
+
'placeholder',
|
|
11
|
+
'aria-label',
|
|
12
|
+
'title',
|
|
13
|
+
'role',
|
|
14
|
+
'data-testid',
|
|
15
|
+
'data-test',
|
|
16
|
+
'data-cy',
|
|
17
|
+
'for',
|
|
18
|
+
'required',
|
|
19
|
+
'disabled',
|
|
20
|
+
'readonly',
|
|
21
|
+
'checked',
|
|
22
|
+
'selected',
|
|
23
|
+
'multiple',
|
|
24
|
+
'href',
|
|
25
|
+
'target',
|
|
26
|
+
'rel',
|
|
27
|
+
'aria-describedby',
|
|
28
|
+
'aria-labelledby',
|
|
29
|
+
'aria-controls',
|
|
30
|
+
'aria-owns',
|
|
31
|
+
'aria-live',
|
|
32
|
+
'aria-atomic',
|
|
33
|
+
'aria-busy',
|
|
34
|
+
'aria-disabled',
|
|
35
|
+
'aria-hidden',
|
|
36
|
+
'aria-pressed',
|
|
37
|
+
'aria-autocomplete',
|
|
38
|
+
'aria-checked',
|
|
39
|
+
'aria-selected',
|
|
40
|
+
'list',
|
|
41
|
+
'tabindex',
|
|
42
|
+
'alt',
|
|
43
|
+
'src',
|
|
44
|
+
'lang',
|
|
45
|
+
'itemscope',
|
|
46
|
+
'itemtype',
|
|
47
|
+
'itemprop',
|
|
48
|
+
'aria-valuemin',
|
|
49
|
+
'aria-valuemax',
|
|
50
|
+
'aria-valuenow',
|
|
51
|
+
'aria-placeholder',
|
|
52
|
+
]);
|
|
53
|
+
const DYNAMIC_CLASS_PATTERNS = [
|
|
54
|
+
'focus',
|
|
55
|
+
'hover',
|
|
56
|
+
'active',
|
|
57
|
+
'selected',
|
|
58
|
+
'disabled',
|
|
59
|
+
'animation',
|
|
60
|
+
'transition',
|
|
61
|
+
'loading',
|
|
62
|
+
'open',
|
|
63
|
+
'closed',
|
|
64
|
+
'expanded',
|
|
65
|
+
'collapsed',
|
|
66
|
+
'visible',
|
|
67
|
+
'hidden',
|
|
68
|
+
'pressed',
|
|
69
|
+
'checked',
|
|
70
|
+
'highlighted',
|
|
71
|
+
'current',
|
|
72
|
+
'entering',
|
|
73
|
+
'leaving',
|
|
74
|
+
];
|
|
5
75
|
export class HistoryTreeProcessor {
|
|
76
|
+
static get_accessible_name(dom_element) {
|
|
77
|
+
const ariaLabel = dom_element.attributes?.['aria-label']?.trim();
|
|
78
|
+
if (ariaLabel) {
|
|
79
|
+
return ariaLabel;
|
|
80
|
+
}
|
|
81
|
+
const title = dom_element.attributes?.title?.trim();
|
|
82
|
+
if (title) {
|
|
83
|
+
return title;
|
|
84
|
+
}
|
|
85
|
+
const text = dom_element.get_all_text_till_next_clickable_element().trim();
|
|
86
|
+
return text ? text : null;
|
|
87
|
+
}
|
|
88
|
+
static compute_element_hash(dom_element) {
|
|
89
|
+
return this._compute_element_hash(dom_element, false);
|
|
90
|
+
}
|
|
91
|
+
static compute_stable_hash(dom_element) {
|
|
92
|
+
return this._compute_element_hash(dom_element, true);
|
|
93
|
+
}
|
|
94
|
+
static _filter_dynamic_classes(class_value) {
|
|
95
|
+
const classes = class_value
|
|
96
|
+
.split(/\s+/)
|
|
97
|
+
.map((value) => value.trim())
|
|
98
|
+
.filter(Boolean);
|
|
99
|
+
const stable = classes.filter((cls) => !DYNAMIC_CLASS_PATTERNS.some((pattern) => cls.toLowerCase().includes(pattern)));
|
|
100
|
+
return stable.sort().join(' ');
|
|
101
|
+
}
|
|
102
|
+
static _compute_element_hash(dom_element, stable) {
|
|
103
|
+
const parent_branch_path = this._get_parent_branch_path(dom_element);
|
|
104
|
+
const parent_branch_path_string = parent_branch_path.join('/');
|
|
105
|
+
const normalized_attributes = Object.entries(dom_element.attributes ?? {})
|
|
106
|
+
.filter(([key, value]) => {
|
|
107
|
+
if (!STATIC_HASH_ATTRIBUTES.has(key)) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return String(value).trim().length > 0;
|
|
111
|
+
})
|
|
112
|
+
.map(([key, value]) => {
|
|
113
|
+
if (stable && key === 'class') {
|
|
114
|
+
const filtered = this._filter_dynamic_classes(String(value));
|
|
115
|
+
return [key, filtered];
|
|
116
|
+
}
|
|
117
|
+
return [key, String(value)];
|
|
118
|
+
})
|
|
119
|
+
.filter(([, value]) => value.length > 0)
|
|
120
|
+
.sort(([a], [b]) => a.localeCompare(b));
|
|
121
|
+
const attributes_string = normalized_attributes
|
|
122
|
+
.map(([key, value]) => `${key}=${value}`)
|
|
123
|
+
.join('');
|
|
124
|
+
const ax_name = this.get_accessible_name(dom_element);
|
|
125
|
+
const ax_suffix = ax_name ? `|ax_name=${ax_name}` : '';
|
|
126
|
+
const combined_string = `${parent_branch_path_string}|${attributes_string}${ax_suffix}`;
|
|
127
|
+
return sha256(combined_string).slice(0, 16);
|
|
128
|
+
}
|
|
6
129
|
static convert_dom_element_to_history_element(dom_element, css_selector = null) {
|
|
7
130
|
const parent_branch_path = this._get_parent_branch_path(dom_element);
|
|
8
|
-
|
|
131
|
+
const axName = this.get_accessible_name(dom_element);
|
|
132
|
+
const elementHash = this.compute_element_hash(dom_element);
|
|
133
|
+
const stableHash = this.compute_stable_hash(dom_element);
|
|
134
|
+
return new DOMHistoryElement(dom_element.tag_name, dom_element.xpath, dom_element.highlight_index ?? null, parent_branch_path, dom_element.attributes, dom_element.shadow_root, css_selector, dom_element.page_coordinates, dom_element.viewport_coordinates, dom_element.viewport_info, elementHash, stableHash, axName);
|
|
9
135
|
}
|
|
10
136
|
static find_history_element_in_tree(dom_history_element, tree) {
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return node;
|
|
17
|
-
}
|
|
137
|
+
const process_node = (node, matcher) => {
|
|
138
|
+
if (node.highlight_index !== null &&
|
|
139
|
+
node.highlight_index !== undefined &&
|
|
140
|
+
matcher(node)) {
|
|
141
|
+
return node;
|
|
18
142
|
}
|
|
19
143
|
for (const child of node.children) {
|
|
20
|
-
if (child instanceof DOMElementNode) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
144
|
+
if (!(child instanceof DOMElementNode)) {
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
const result = process_node(child, matcher);
|
|
148
|
+
if (result) {
|
|
149
|
+
return result;
|
|
25
150
|
}
|
|
26
151
|
}
|
|
27
152
|
return null;
|
|
28
153
|
};
|
|
29
|
-
|
|
154
|
+
if (dom_history_element.element_hash) {
|
|
155
|
+
const exact = process_node(tree, (candidate) => this.compute_element_hash(candidate) ===
|
|
156
|
+
dom_history_element.element_hash);
|
|
157
|
+
if (exact) {
|
|
158
|
+
return exact;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (dom_history_element.stable_hash) {
|
|
162
|
+
const stable = process_node(tree, (candidate) => this.compute_stable_hash(candidate) ===
|
|
163
|
+
dom_history_element.stable_hash);
|
|
164
|
+
if (stable) {
|
|
165
|
+
return stable;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
const hashed = this._hash_dom_history_element(dom_history_element);
|
|
169
|
+
return process_node(tree, (candidate) => {
|
|
170
|
+
const hashed_node = this._hash_dom_element(candidate);
|
|
171
|
+
return hashed_node.equals(hashed);
|
|
172
|
+
});
|
|
30
173
|
}
|
|
31
174
|
static compare_history_element_and_dom_element(dom_history_element, dom_element) {
|
|
175
|
+
if (dom_history_element.element_hash) {
|
|
176
|
+
if (this.compute_element_hash(dom_element) ===
|
|
177
|
+
dom_history_element.element_hash) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (dom_history_element.stable_hash) {
|
|
182
|
+
if (this.compute_stable_hash(dom_element) ===
|
|
183
|
+
dom_history_element.stable_hash) {
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
32
187
|
const hashed_history = this._hash_dom_history_element(dom_history_element);
|
|
33
188
|
const hashed_dom = this._hash_dom_element(dom_element);
|
|
34
189
|
return hashed_history.equals(hashed_dom);
|
|
@@ -38,7 +38,10 @@ export declare class DOMHistoryElement {
|
|
|
38
38
|
page_coordinates: CoordinateSet | null;
|
|
39
39
|
viewport_coordinates: CoordinateSet | null;
|
|
40
40
|
viewport_info: ViewportInfo | null;
|
|
41
|
-
|
|
41
|
+
element_hash: string | null;
|
|
42
|
+
stable_hash: string | null;
|
|
43
|
+
ax_name: string | null;
|
|
44
|
+
constructor(tag_name: string, xpath: string, highlight_index: number | null, entire_parent_branch_path: string[], attributes: Record<string, string>, shadow_root?: boolean, css_selector?: string | null, page_coordinates?: CoordinateSet | null, viewport_coordinates?: CoordinateSet | null, viewport_info?: ViewportInfo | null, element_hash?: string | null, stable_hash?: string | null, ax_name?: string | null);
|
|
42
45
|
to_dict(): {
|
|
43
46
|
tag_name: string;
|
|
44
47
|
xpath: string;
|
|
@@ -50,5 +53,8 @@ export declare class DOMHistoryElement {
|
|
|
50
53
|
page_coordinates: CoordinateSet | null;
|
|
51
54
|
viewport_coordinates: CoordinateSet | null;
|
|
52
55
|
viewport_info: ViewportInfo | null;
|
|
56
|
+
element_hash: string | null;
|
|
57
|
+
stable_hash: string | null;
|
|
58
|
+
ax_name: string | null;
|
|
53
59
|
};
|
|
54
60
|
}
|