Skip to content

Commit ce50fa2

Browse files
committed
add optional context to stagehand
1 parent 89bb233 commit ce50fa2

File tree

2 files changed

+8
-70
lines changed

2 files changed

+8
-70
lines changed

stagehand/src/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ import {
1414
import { Stagehand } from "@browserbasehq/stagehand";
1515
import type { ConstructorParams, LogLine } from "@browserbasehq/stagehand";
1616

17-
import { AnyZodObject } from "zod";
18-
import { jsonSchemaToZod } from "./utils.js";
1917
import fs from 'fs';
2018
import path from 'path';
2119
import { fileURLToPath } from 'url';
@@ -57,6 +55,12 @@ const stagehandConfig: ConstructorParams = {
5755
domSettleTimeoutMs: 30_000 /* Timeout for DOM to settle in milliseconds */,
5856
browserbaseSessionCreateParams: {
5957
projectId: process.env.BROWSERBASE_PROJECT_ID!,
58+
browserSettings: process.env.CONTEXT_ID ? {
59+
context: {
60+
id: process.env.CONTEXT_ID,
61+
persist: true
62+
}
63+
} : undefined
6064
},
6165
enableCaching: true /* Enable caching functionality */,
6266
browserbaseSessionID:
@@ -253,11 +257,12 @@ async function handleToolCall(
253257
case "stagehand_navigate":
254258
try {
255259
await stagehand.page.goto(args.url);
260+
console.log(process.env.CONTEXT_ID);
256261
return {
257262
content: [
258263
{
259264
type: "text",
260-
text: `Navigated to: ${args.url}`,
265+
text: `Navigateddfsfsrsg to: ${args.url} with context id: ${process.env.CONTEXT_ID}`,
261266
},
262267
],
263268
isError: false,

stagehand/src/utils.ts

Lines changed: 0 additions & 67 deletions
This file was deleted.

0 commit comments

Comments
 (0)