1
+ /**
2
+ * Browser Automation Task Sequences
3
+ *
4
+ * This file defines task sequences for browser automation using the browser-use command.
5
+ * Each sequence represents a series of browser interactions that can be executed in order.
6
+ */
7
+
8
+ export interface BrowserCommand {
9
+ prompt : string ;
10
+ model ?: 'deepseek-chat' | 'gemini' | 'gpt-4' | 'claude-3' ;
11
+ headless ?: boolean ;
12
+ vision ?: boolean ;
13
+ keepSessionAlive ?: boolean ;
14
+ }
15
+
16
+ export interface BrowserTask {
17
+ description : string ;
18
+ command : BrowserCommand ;
19
+ subtasks ?: BrowserTask [ ] ;
20
+ }
21
+
22
+ export interface BrowserTaskSequence {
23
+ name : string ;
24
+ description : string ;
25
+ tasks : BrowserTask [ ] ;
26
+ }
27
+
28
+ // Example task sequences
29
+ export const browserTasks : BrowserTaskSequence [ ] = [
30
+ {
31
+ name : "Product Research" ,
32
+ description : "Compare product prices across multiple e-commerce sites" ,
33
+ tasks : [
34
+ {
35
+ description : "Search Amazon for wireless earbuds" ,
36
+ command : {
37
+ prompt : "go to amazon.com and search for 'wireless earbuds' and tell me the price of the top 3 results" ,
38
+ model : "gemini" ,
39
+ vision : true ,
40
+ keepSessionAlive : true
41
+ }
42
+ } ,
43
+ {
44
+ description : "Search Best Buy for comparison" ,
45
+ command : {
46
+ prompt : "go to bestbuy.com and search for 'wireless earbuds' and tell me the price of the top 3 results" ,
47
+ model : "gemini" ,
48
+ vision : true ,
49
+ keepSessionAlive : true
50
+ }
51
+ } ,
52
+ {
53
+ description : "Create price comparison" ,
54
+ command : {
55
+ prompt : "create a comparison table of the prices from both sites" ,
56
+ keepSessionAlive : false
57
+ }
58
+ }
59
+ ]
60
+ } ,
61
+ {
62
+ name : "Site Health Check" ,
63
+ description : "Monitor website availability and performance" ,
64
+ tasks : [
65
+ {
66
+ description : "Check main site" ,
67
+ command : {
68
+ prompt : "go to example.com and check if it loads properly" ,
69
+ headless : true
70
+ }
71
+ } ,
72
+ {
73
+ description : "Verify API health" ,
74
+ command : {
75
+ prompt : "go to api.example.com/health and tell me the status" ,
76
+ headless : true
77
+ }
78
+ } ,
79
+ {
80
+ description : "Test documentation site" ,
81
+ command : {
82
+ prompt : "go to docs.example.com and verify all navigation links are working" ,
83
+ headless : true
84
+ }
85
+ }
86
+ ]
87
+ } ,
88
+ {
89
+ name : "Content Analysis" ,
90
+ description : "Analyze blog content and engagement" ,
91
+ tasks : [
92
+ {
93
+ description : "List articles" ,
94
+ command : {
95
+ prompt : "go to blog.example.com and list all article titles from the homepage" ,
96
+ model : "gemini" ,
97
+ vision : true
98
+ }
99
+ } ,
100
+ {
101
+ description : "Analyze first article" ,
102
+ command : {
103
+ prompt : "click on the first article and summarize its main points"
104
+ } ,
105
+ subtasks : [
106
+ {
107
+ description : "Get metadata" ,
108
+ command : {
109
+ prompt : "tell me the author, publication date, and reading time"
110
+ }
111
+ } ,
112
+ {
113
+ description : "Analyze comments" ,
114
+ command : {
115
+ prompt : "scroll to the comments section and summarize the main discussion points" ,
116
+ vision : true
117
+ }
118
+ }
119
+ ]
120
+ }
121
+ ]
122
+ } ,
123
+ {
124
+ name : "Advanced Content Analysis" ,
125
+ description : "Analyze website content using different models for different tasks" ,
126
+ tasks : [
127
+ {
128
+ description : "Initial navigation and basic text extraction" ,
129
+ command : {
130
+ prompt : "go to docs.github.com and navigate to the Actions documentation" ,
131
+ model : "deepseek-chat" , // Use DeepSeek for basic navigation
132
+ keepSessionAlive : true
133
+ }
134
+ } ,
135
+ {
136
+ description : "Visual analysis of page structure" ,
137
+ command : {
138
+ prompt : "analyze the layout of the page and tell me how the documentation is structured, including sidebars, navigation, and content areas" ,
139
+ model : "gemini" , // Switch to Gemini for visual analysis
140
+ vision : true ,
141
+ keepSessionAlive : true
142
+ }
143
+ } ,
144
+ {
145
+ description : "Complex content summarization" ,
146
+ command : {
147
+ prompt : "summarize the key concepts of GitHub Actions based on the documentation" ,
148
+ model : "claude-3" , // Switch to Claude for complex summarization
149
+ keepSessionAlive : true
150
+ }
151
+ } ,
152
+ {
153
+ description : "Extract code examples" ,
154
+ command : {
155
+ prompt : "find and list all YAML workflow examples on the page" ,
156
+ model : "deepseek-chat" , // Back to DeepSeek for code extraction
157
+ keepSessionAlive : false // Close browser after final task
158
+ }
159
+ }
160
+ ]
161
+ }
162
+ ] ;
163
+
164
+ // Example of executing a task sequence
165
+ const executeTask = ( task : BrowserCommand ) : string => {
166
+ const options : string [ ] = [ ] ;
167
+ if ( task . model ) options . push ( `--model ${ task . model } ` ) ;
168
+ if ( task . headless ) options . push ( '--headless' ) ;
169
+ if ( task . vision ) options . push ( '--vision' ) ;
170
+ if ( task . keepSessionAlive ) options . push ( '--keep-browser-open' ) ;
171
+
172
+ return `browser-use "${ task . prompt } " ${ options . join ( ' ' ) } ` . trim ( ) ;
173
+ } ;
174
+
175
+ // Example usage:
176
+ const sequence = browserTasks [ 0 ] ; // Get Product Research sequence
177
+ console . log ( `Executing sequence: ${ sequence . name } ` ) ;
178
+ sequence . tasks . forEach ( task => {
179
+ console . log ( `\n${ task . description } :` ) ;
180
+ console . log ( executeTask ( task . command ) ) ;
181
+ } ) ;
0 commit comments