Skip to content

Commit 6a002b2

Browse files
authored
Remove Need to Add Project ID in Browserbase Params if Already Passed to Stagehand (#1056)
# why if you add custom browserbase create params, you need to include the project id even if the project id is already passed to the stagehand instance # what changed browserbaseSessionCreateParams type changed to omit project id # test plan build stagehand locally, use local stagehand to run sessions with - two project ids: one in Stagehand part, one in Browserbase Session Create Params - one project id: only in Stagehand part
1 parent c25a253 commit 6a002b2

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

.changeset/social-moles-wish.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@browserbasehq/stagehand": patch
3+
---
4+
5+
remove need for duplicate project id if already passed to Stagehand

lib/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async function getBrowser(
7373
env: "LOCAL" | "BROWSERBASE" = "LOCAL",
7474
headless: boolean = false,
7575
logger: (message: LogLine) => void,
76-
browserbaseSessionCreateParams?: Browserbase.Sessions.SessionCreateParams,
76+
browserbaseSessionCreateParams?: ConstructorParams["browserbaseSessionCreateParams"],
7777
browserbaseSessionID?: string,
7878
localBrowserLaunchOptions?: LocalBrowserLaunchOptions,
7979
): Promise<BrowserResult> {
@@ -166,6 +166,7 @@ async function getBrowser(
166166
stagehand: "true",
167167
},
168168
});
169+
// Final projectId used: browserbaseSessionCreateParams.projectId || projectId
169170

170171
sessionId = session.id;
171172
connectUrl = session.connectUrl;
@@ -377,7 +378,7 @@ export class Stagehand {
377378
protected apiKey: string | undefined;
378379
private projectId: string | undefined;
379380
private externalLogger?: (logLine: LogLine) => void;
380-
private browserbaseSessionCreateParams?: Browserbase.Sessions.SessionCreateParams;
381+
private browserbaseSessionCreateParams?: ConstructorParams["browserbaseSessionCreateParams"];
381382
public variables: { [key: string]: unknown };
382383
private contextPath?: string;
383384
public llmClient: LLMClient;

types/api.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export interface StartSessionParams {
2020
verbose: number;
2121
debugDom: boolean;
2222
systemPrompt?: string;
23-
browserbaseSessionCreateParams?: Browserbase.Sessions.SessionCreateParams;
23+
browserbaseSessionCreateParams?: Omit<
24+
Browserbase.Sessions.SessionCreateParams,
25+
"projectId"
26+
> & { projectId?: string };
2427
selfHeal?: boolean;
2528
waitForCaptchaSolves?: boolean;
2629
actionTimeoutMs?: number;

types/stagehand.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ export interface ConstructorParams {
4646
/**
4747
* The parameters to use for creating a Browserbase session
4848
* See https://docs.browserbase.com/reference/api/create-a-session
49+
* Note: projectId is optional here as it will use the main projectId parameter if not provided
4950
*/
50-
browserbaseSessionCreateParams?: Browserbase.Sessions.SessionCreateParams;
51+
browserbaseSessionCreateParams?: Omit<
52+
Browserbase.Sessions.SessionCreateParams,
53+
"projectId"
54+
> & { projectId?: string };
5155
/**
5256
* Enable caching of LLM responses
5357
* @default true

0 commit comments

Comments
 (0)