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
7 changes: 7 additions & 0 deletions .changeset/warm-pandas-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@browserbasehq/stagehand-python": minor
"@browserbasehq/stagehand-go": minor
"@browserbasehq/stagehand": minor
---

Expose Browserbase Search and Fetch through the Stagehand browserbase facade in TypeScript, Python, and Go.
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,21 @@ const {

See the [Python](./packages/sdk-python/README.md) and [Go](./packages/sdk-go/README.md) READMEs for equivalent examples.

The same `browserbase` facade also exposes Browserbase Search and Fetch without launching a browser:

```typescript
const results = await browserbase.search({
apiKey: BROWSERBASE_API_KEY,
query: "browser agent frameworks",
numResults: 5,
});
const fetchResult = await browserbase.fetch({
apiKey: BROWSERBASE_API_KEY,
url: results.results[0].url,
format: "markdown",
});
```

## Documentation

Visit [docs.stagehand.dev](https://docs.stagehand.dev) to view the full documentation.
Expand Down
4 changes: 2 additions & 2 deletions packages/extension/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const root = import.meta.dirname;
const outDir = path.join(root, "dist");
const artifactsDir = path.join(root, "artifacts");
const extensionArchivePath = path.join(artifactsDir, "stagehand-extension.zip");
const zipModifiedAt = new Date(1980, 0, 1);
const deterministicZipModifiedAt = new Date(1980, 0, 1);

function buildExtensionArtifacts() {
return {
Expand Down Expand Up @@ -99,7 +99,7 @@ async function readExtensionFiles(directory: string, relativeDirectory = ""): Pr
}
files[relativePath.split(path.sep).join("/")] = [
await readFile(path.join(directory, relativePath)),
{ attrs: 0o644 << 16, mtime: zipModifiedAt, os: 3 },
{ attrs: 0o644 << 16, mtime: deterministicZipModifiedAt, os: 3 },
];
}

Expand Down
30 changes: 30 additions & 0 deletions packages/sdk-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,36 @@ func run(ctx context.Context) (err error) {
}
```

Browserbase Search and Fetch are also available without launching a browser:

```go
numResults := 5
results, err := stagehand.SearchBrowserbase(ctx, stagehand.BrowserbaseSearchOptions{
APIKey: os.Getenv("BROWSERBASE_API_KEY"),
Query: "browser agent frameworks",
NumResults: &numResults,
})
if err != nil {
return err
}
if len(results.Results) == 0 {
return fmt.Errorf("search returned no results")
}
fetched, err := stagehand.FetchBrowserbase(ctx, stagehand.BrowserbaseFetchOptions{
APIKey: os.Getenv("BROWSERBASE_API_KEY"),
URL: results.Results[0].URL,
Format: stagehand.BrowserbaseFetchFormatMarkdown,
})
if err != nil {
return err
}
content, ok := fetched.Content.AsString()
if !ok {
return fmt.Errorf("fetch returned non-string content")
}
fmt.Println(content)
```

## Navigation

Navigation methods return the main-document response when the browser performs a network request:
Expand Down
Loading
Loading