@@ -25,6 +25,7 @@ import {
25
25
fallbackLocatorMethod ,
26
26
} from "./handlerUtils/actHandlerUtils" ;
27
27
import { Stagehand } from "@/lib" ;
28
+ import { StagehandObserveHandler } from "@/lib/handlers/observeHandler" ;
28
29
/**
29
30
* NOTE: Vision support has been removed from this version of Stagehand.
30
31
* If useVision or verifierUseVision is set to true, a warning is logged and
@@ -211,8 +212,13 @@ export class StagehandActHandler {
211
212
* Perform an act based on an instruction.
212
213
* This method will observe the page and then perform the act on the first element returned.
213
214
*/
214
- public async observeAct ( actionOrOptions : ActOptions ) : Promise < ActResult > {
215
- // Extract action string and observe options
215
+ public async observeAct (
216
+ actionOrOptions : ActOptions ,
217
+ observeHandler : StagehandObserveHandler ,
218
+ llmClient : LLMClient ,
219
+ requestId : string ,
220
+ ) : Promise < ActResult > {
221
+ // Extract the action string
216
222
let action : string ;
217
223
const observeOptions : Partial < ObserveOptions > = { } ;
218
224
@@ -251,9 +257,13 @@ export class StagehandActHandler {
251
257
) ;
252
258
253
259
// Call observe with the instruction and extracted options
254
- const observeResults = await this . stagehandPage . observe ( {
260
+ const observeResults = await observeHandler . observe ( {
255
261
instruction,
256
- ...observeOptions ,
262
+ llmClient : llmClient ,
263
+ requestId,
264
+ onlyVisible : false ,
265
+ drawOverlay : false ,
266
+ returnAction : true ,
257
267
} ) ;
258
268
259
269
if ( observeResults . length === 0 ) {
@@ -265,7 +275,7 @@ export class StagehandActHandler {
265
275
}
266
276
267
277
// Perform the action on the first observed element
268
- const element = observeResults [ 0 ] ;
278
+ const element : ObserveResult = observeResults [ 0 ] ;
269
279
// Replace the arguments with the variables if any
270
280
if ( actionOrOptions . variables ) {
271
281
Object . keys ( actionOrOptions . variables ) . forEach ( ( key ) => {
0 commit comments