Skip to content
Closed
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/icy-toes-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Add playwright arguments to agent execute response
5 changes: 5 additions & 0 deletions .changeset/loud-waves-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

adds support for stagehand agent in the api
5 changes: 5 additions & 0 deletions .changeset/many-rats-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@browserbasehq/stagehand": patch
---

Fix for zod peer dependency support
20 changes: 4 additions & 16 deletions docs/configuration/browser.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ stagehand = Stagehand(
apiKey: process.env.BROWSERBASE_API_KEY,
projectId: process.env.BROWSERBASE_PROJECT_ID,
browserbaseSessionCreateParams: {
projectId: process.env.BROWSERBASE_PROJECT_ID!,
projectId: process.env.BROWSERBASE_PROJECT_ID!, // Optional: automatically set if given in environment variable or by Stagehand parameter
proxies: true,
region: "us-west-2",
timeout: 3600, // 1 hour session timeout
Expand All @@ -124,17 +124,11 @@ stagehand = Stagehand(
blockAds: true,
solveCaptchas: true,
recordSession: false,
os: "windows", // Valid: "windows" | "mac" | "linux" | "mobile" | "tablet"
viewport: {
width: 1920,
height: 1080,
},
fingerprint: {
browsers: ["chrome", "edge"],
devices: ["desktop"],
operatingSystems: ["windows", "macos"],
locales: ["en-US", "en-GB"],
httpVersion: 2,
},
},
userMetadata: {
userId: "automation-user-123",
Expand All @@ -149,7 +143,7 @@ stagehand = Stagehand(
api_key=os.getenv("BROWSERBASE_API_KEY"),
project_id=os.getenv("BROWSERBASE_PROJECT_ID"),
browserbase_session_create_params={
"project_id": os.getenv("BROWSERBASE_PROJECT_ID"),
"project_id": os.getenv("BROWSERBASE_PROJECT_ID"), # Optional: automatically set if given in environment or by Stagehand parameter
"proxies": True,
"region": "us-west-2",
"timeout": 3600, # 1 hour session timeout
Expand All @@ -159,17 +153,11 @@ stagehand = Stagehand(
"block_ads": True,
"solve_captchas": True,
"record_session": False,
"os": "windows", # "windows" | "mac" | "linux" | "mobile" | "tablet"
"viewport": {
"width": 1920,
"height": 1080,
},
"fingerprint": {
"browsers": ["chrome", "edge"],
"devices": ["desktop"],
"operating_systems": ["windows", "macos"],
"locales": ["en-US", "en-GB"],
"http_version": 2,
},
},
"user_metadata": {
"user_id": "automation-user-123",
Expand Down
6 changes: 3 additions & 3 deletions docs/configuration/models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Vercel AI SDK supports providers for OpenAI, Anthropic, and Google, along with s

To get started, you'll need to install the `ai` package and the provider you want to use. For example, to use Amazon Bedrock, you'll need to install the `@ai-sdk/amazon-bedrock` package.

You'll also need to use the [Vercel AI SDK external client](https://github.com/browserbase/stagehand/blob/main/examples/external_clients/aisdk.ts) as a template to create a client for your model.
You'll also need to import the [Vercel AI SDK external client](https://github.com/browserbase/stagehand/blob/main/lib/llm/aisdk.ts) which is exposed as `AISdkClient` to create a client for your model.

<Tabs>
<Tab title="npm">
Expand All @@ -190,13 +190,13 @@ You'll also need to use the [Vercel AI SDK external client](https://github.com/b
</Tab>
</Tabs>

To get started, you can use the [Vercel AI SDK external client](https://github.com/browserbase/stagehand/blob/84f810b4631291307a32a47addad7e26e9c1deb3/examples/external_clients/aisdk.ts) as a template to create a client for your model.
To get started, you can use the [Vercel AI SDK external client](https://github.com/browserbase/stagehand/blob/main/lib/llm/aisdk.ts) which is exposed as `AISdkClient` to create a client for your model.

```ts
// Install/import the provider you want to use.
// For example, to use OpenAI, import `openai` from @ai-sdk/openai
import { bedrock } from "@ai-sdk/amazon-bedrock";
import { AISdkClient } from "./external_clients/aisdk";
import { AISdkClient } from "@browserbasehq/stagehand";

const stagehand = new Stagehand({
llmClient: new AISdkClient({
Expand Down
62 changes: 62 additions & 0 deletions docs/configuration/observability.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -529,4 +529,66 @@ Each operation creates detailed logs for analysis:
</Accordion>
</AccordionGroup>

## Action History Tracking

Track all Stagehand operations with the built-in action history feature. The `stagehand.history` property provides a chronological record of every method call during your automation session.

### Accessing History Data

Get a complete history of all Stagehand operations performed in the current session:

<CodeGroup>
```typescript TypeScript
import { Stagehand } from "@browserbasehq/stagehand";

const stagehand = new Stagehand({ env: "LOCAL" });
await stagehand.init();

// Perform various operations
await stagehand.page.goto("https://example.com");
await stagehand.page.act("click the login button");
const userInfo = await stagehand.page.extract("extract user profile data");
const elements = await stagehand.page.observe("find all navigation links");

// Access complete operation history
const history = stagehand.history;
console.log('Total operations:', history.length);

// Examine individual entries
history.forEach((entry, index) => {
console.log(`Operation ${index + 1}:`, {
method: entry.method,
timestamp: entry.timestamp,
hasResult: entry.result !== null
});
});
```

```python Python
from stagehand import Stagehand

stagehand = Stagehand(env="LOCAL")
await stagehand.init()

# Perform various operations
await stagehand.page.goto("https://example.com")
await stagehand.page.act("click the login button")
user_info = await stagehand.page.extract("extract user profile data")
elements = await stagehand.page.observe("find all navigation links")

# Access complete operation history
history = stagehand.history
print(f'Total operations: {len(history)}')

# Examine individual entries
for index, entry in enumerate(history):
print(f"Operation {index + 1}:", {
'method': entry['method'],
'timestamp': entry['timestamp'],
'has_result': entry['result'] is not None
})
```
</CodeGroup>


For detailed logging and debugging capabilities, see [Logging](/configuration/logging).
6 changes: 6 additions & 0 deletions evals/evals.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,12 @@
"categories": [
"external_agent_benchmarks"
]
},
{
"name": "screenshot_cdp_toggle",
"categories": [
"regression"
]
}
]
}
Loading