Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/social-moles-wish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

remove need for duplicate project id if already passed to Stagehand
5 changes: 3 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function getBrowser(
env: "LOCAL" | "BROWSERBASE" = "LOCAL",
headless: boolean = false,
logger: (message: LogLine) => void,
browserbaseSessionCreateParams?: Browserbase.Sessions.SessionCreateParams,
browserbaseSessionCreateParams?: ConstructorParams["browserbaseSessionCreateParams"],
browserbaseSessionID?: string,
localBrowserLaunchOptions?: LocalBrowserLaunchOptions,
): Promise<BrowserResult> {
Expand Down Expand Up @@ -166,6 +166,7 @@ async function getBrowser(
stagehand: "true",
},
});
// Final projectId used: browserbaseSessionCreateParams.projectId || projectId

sessionId = session.id;
connectUrl = session.connectUrl;
Expand Down Expand Up @@ -377,7 +378,7 @@ export class Stagehand {
protected apiKey: string | undefined;
private projectId: string | undefined;
private externalLogger?: (logLine: LogLine) => void;
private browserbaseSessionCreateParams?: Browserbase.Sessions.SessionCreateParams;
private browserbaseSessionCreateParams?: ConstructorParams["browserbaseSessionCreateParams"];
public variables: { [key: string]: unknown };
private contextPath?: string;
public llmClient: LLMClient;
Expand Down
5 changes: 4 additions & 1 deletion types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export interface StartSessionParams {
verbose: number;
debugDom: boolean;
systemPrompt?: string;
browserbaseSessionCreateParams?: Browserbase.Sessions.SessionCreateParams;
browserbaseSessionCreateParams?: Omit<
Browserbase.Sessions.SessionCreateParams,
"projectId"
> & { projectId?: string };
selfHeal?: boolean;
waitForCaptchaSolves?: boolean;
actionTimeoutMs?: number;
Expand Down
6 changes: 5 additions & 1 deletion types/stagehand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,12 @@ export interface ConstructorParams {
/**
* The parameters to use for creating a Browserbase session
* See https://docs.browserbase.com/reference/api/create-a-session
* Note: projectId is optional here as it will use the main projectId parameter if not provided
*/
browserbaseSessionCreateParams?: Browserbase.Sessions.SessionCreateParams;
browserbaseSessionCreateParams?: Omit<
Browserbase.Sessions.SessionCreateParams,
"projectId"
> & { projectId?: string };
/**
* Enable caching of LLM responses
* @default true
Expand Down