Skip to content

Commit 78cf457

Browse files
committed
only pass bb config w/ keys
1 parent e63f9e8 commit 78cf457

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

stagehand/src/server.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,20 @@ export const stagehandConfig: ConstructorParams = {
4040
logLineToString(message)
4141
) /* Custom logging function to stderr */,
4242
domSettleTimeoutMs: 30_000 /* Timeout for DOM to settle in milliseconds */,
43-
browserbaseSessionCreateParams: {
44-
projectId: process.env.BROWSERBASE_PROJECT_ID!,
45-
browserSettings: process.env.CONTEXT_ID
43+
browserbaseSessionCreateParams:
44+
process.env.BROWSERBASE_API_KEY && process.env.BROWSERBASE_PROJECT_ID
4645
? {
47-
context: {
48-
id: process.env.CONTEXT_ID,
49-
persist: true,
50-
},
46+
projectId: process.env.BROWSERBASE_PROJECT_ID!,
47+
browserSettings: process.env.CONTEXT_ID
48+
? {
49+
context: {
50+
id: process.env.CONTEXT_ID,
51+
persist: true,
52+
},
53+
}
54+
: undefined,
5155
}
5256
: undefined,
53-
},
5457
localBrowserLaunchOptions: process.env.LOCAL_CDP_URL
5558
? {
5659
cdpUrl: process.env.LOCAL_CDP_URL,
@@ -168,7 +171,11 @@ export function createServer() {
168171
content: [
169172
{
170173
type: "text",
171-
text: `Failed to initialize Stagehand: ${errorMsg}`,
174+
text: `Failed to initialize Stagehand: ${errorMsg}. Config: ${JSON.stringify(
175+
stagehandConfig,
176+
null,
177+
2
178+
)}`,
172179
},
173180
{
174181
type: "text",

0 commit comments

Comments
 (0)