@@ -24,8 +24,6 @@ import {
24
24
ObserveResult ,
25
25
} from "../types/stagehand" ;
26
26
import { scriptContent } from "./dom/build/scriptContent" ;
27
- import { StagehandExtractHandler } from "./handlers/extractHandler" ;
28
- import { StagehandObserveHandler } from "./handlers/observeHandler" ;
29
27
import { LLMClient } from "./llm/LLMClient" ;
30
28
import { LLMProvider } from "./llm/LLMProvider" ;
31
29
import { logLineToString } from "./utils" ;
@@ -320,7 +318,6 @@ export class Stagehand {
320
318
public llmProvider : LLMProvider ;
321
319
public enableCaching : boolean ;
322
320
323
- private internalLogger : ( logLine : LogLine ) => void ;
324
321
private apiKey : string | undefined ;
325
322
private projectId : string | undefined ;
326
323
// We want external logger to accept async functions
@@ -330,9 +327,6 @@ export class Stagehand {
330
327
private contextPath ?: string ;
331
328
private llmClient : LLMClient ;
332
329
333
- private extractHandler ?: StagehandExtractHandler ;
334
- private observeHandler ?: StagehandObserveHandler ;
335
-
336
330
constructor (
337
331
{
338
332
env,
@@ -354,7 +348,6 @@ export class Stagehand {
354
348
} ,
355
349
) {
356
350
this . externalLogger = logger || defaultLogger ;
357
- this . internalLogger = this . log . bind ( this ) ;
358
351
this . enableCaching =
359
352
enableCaching ??
360
353
( process . env . ENABLE_CACHING && process . env . ENABLE_CACHING === "true" ) ;
@@ -400,6 +393,11 @@ export class Stagehand {
400
393
}
401
394
402
395
public get context ( ) : BrowserContext {
396
+ if ( ! this . stagehandContext ) {
397
+ throw new Error (
398
+ "Stagehand not initialized. Make sure to await stagehand.init() first." ,
399
+ ) ;
400
+ }
403
401
return this . stagehandContext . context ;
404
402
}
405
403
0 commit comments