@browserbasehq/orca 3.0.0-test.1 → 3.0.1-zod4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +164 -0
- package/dist/index.d.ts +253 -11
- package/dist/index.js +1513 -63
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
<div id="toc" align="center" style="margin-bottom: 0;">
|
|
2
|
+
<ul style="list-style: none; margin: 0; padding: 0;">
|
|
3
|
+
<a href="https://stagehand.dev">
|
|
4
|
+
<picture>
|
|
5
|
+
<source media="(prefers-color-scheme: dark)" srcset="../../media/dark_logo.png" />
|
|
6
|
+
<img alt="Stagehand" src="../../media/light_logo.png" width="200" style="margin-right: 30px;" />
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
</ul>
|
|
10
|
+
</div>
|
|
11
|
+
<p align="center">
|
|
12
|
+
<strong>The AI Browser Automation Framework</strong><br>
|
|
13
|
+
<a href="https://docs.stagehand.dev">Read the Docs</a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<p align="center">
|
|
17
|
+
<a href="https://github.com/browserbase/stagehand/tree/main?tab=MIT-1-ov-file#MIT-1-ov-file">
|
|
18
|
+
<picture>
|
|
19
|
+
<source media="(prefers-color-scheme: dark)" srcset="../../media/dark_license.svg" />
|
|
20
|
+
<img alt="MIT License" src="../../media/light_license.svg" />
|
|
21
|
+
</picture>
|
|
22
|
+
</a>
|
|
23
|
+
<a href="https://join.slack.com/t/stagehand-dev/shared_invite/zt-3hgv6bwqu-s7MXXgPd7_rD53aViGo1MQ">
|
|
24
|
+
<picture>
|
|
25
|
+
<source media="(prefers-color-scheme: dark)" srcset="../../media/dark_slack.svg" />
|
|
26
|
+
<img alt="Slack Community" src="../../media/light_slack.svg" />
|
|
27
|
+
</picture>
|
|
28
|
+
</a>
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<p align="center">
|
|
32
|
+
<a href="https://trendshift.io/repositories/12122" target="_blank"><img src="https://trendshift.io/api/badge/repositories/12122" alt="browserbase%2Fstagehand | Trendshift" style="width: 250px; height: 55px;" width="250" height="55"/></a>
|
|
33
|
+
</p>
|
|
34
|
+
|
|
35
|
+
<p align="center">
|
|
36
|
+
<a href="https://deepwiki.com/browserbase/stagehand">
|
|
37
|
+
<img alt="Ask DeepWiki" src="https://deepwiki.com/badge.svg" />
|
|
38
|
+
</a>
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
If you're looking for the Python implementation, you can find it
|
|
43
|
+
<a href="https://github.com/browserbase/stagehand-python"> here</a>
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
<div align="center" style="display: flex; align-items: center; justify-content: center; gap: 4px; margin-bottom: 0;">
|
|
47
|
+
<b>Vibe code</b>
|
|
48
|
+
<span style="font-size: 1.05em;"> Stagehand with </span>
|
|
49
|
+
<a href="https://director.ai" style="display: flex; align-items: center;">
|
|
50
|
+
<span>Director</span>
|
|
51
|
+
</a>
|
|
52
|
+
<span> </span>
|
|
53
|
+
<picture>
|
|
54
|
+
<img alt="Director" src="../../media/director_icon.svg" width="25" />
|
|
55
|
+
</picture>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
## What is Stagehand?
|
|
59
|
+
|
|
60
|
+
Stagehand is a browser automation framework used to control web browsers with natural language and code. By combining the power of AI with the precision of code, Stagehand makes web automation flexible, maintainable, and actually reliable.
|
|
61
|
+
|
|
62
|
+
## Why Stagehand?
|
|
63
|
+
|
|
64
|
+
Most existing browser automation tools either require you to write low-level code in a framework like Selenium, Playwright, or Puppeteer, or use high-level agents that can be unpredictable in production. By letting developers choose what to write in code vs. natural language (and bridging the gap between the two) Stagehand is the natural choice for browser automations in production.
|
|
65
|
+
|
|
66
|
+
1. **Choose when to write code vs. natural language**: use AI when you want to navigate unfamiliar pages, and use code when you know exactly what you want to do.
|
|
67
|
+
|
|
68
|
+
2. **Go from AI-driven to repeatable workflows**: Stagehand lets you preview AI actions before running them, and also helps you easily cache repeatable actions to save time and tokens.
|
|
69
|
+
|
|
70
|
+
3. **Write once, run forever**: Stagehand's auto-caching combined with self-healing remembers previous actions, runs without LLM inference, and knows when to involve AI whenever the website changes and your automation breaks.
|
|
71
|
+
|
|
72
|
+
## Getting Started
|
|
73
|
+
|
|
74
|
+
Start with Stagehand with one line of code, or check out our [Quickstart Guide](https://docs.stagehand.dev/v3/first-steps/quickstart) for more information:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npx create-browser-app
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Example
|
|
81
|
+
|
|
82
|
+
Here's how to build a sample browser automation with Stagehand:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
// Stagehand's CDP engine provides an optimized, low level interface to the browser built for automation
|
|
86
|
+
const page = stagehand.context.pages()[0];
|
|
87
|
+
await page.goto("https://github.com/browserbase");
|
|
88
|
+
|
|
89
|
+
// Use act() to execute individual actions
|
|
90
|
+
await stagehand.act("click on the stagehand repo");
|
|
91
|
+
|
|
92
|
+
// Use agent() for multi-step tasks
|
|
93
|
+
const agent = stagehand.agent();
|
|
94
|
+
await agent.execute("Get to the latest PR");
|
|
95
|
+
|
|
96
|
+
// Use extract() to get structured data from the page
|
|
97
|
+
const { author, title } = await stagehand.extract(
|
|
98
|
+
"extract the author and title of the PR",
|
|
99
|
+
z.object({
|
|
100
|
+
author: z.string().describe("The username of the PR author"),
|
|
101
|
+
title: z.string().describe("The title of the PR"),
|
|
102
|
+
}),
|
|
103
|
+
);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Documentation
|
|
107
|
+
|
|
108
|
+
Visit [docs.stagehand.dev](https://docs.stagehand.dev) to view the full documentation.
|
|
109
|
+
|
|
110
|
+
### Build and Run from Source
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
git clone https://github.com/browserbase/stagehand.git
|
|
114
|
+
cd stagehand
|
|
115
|
+
pnpm install
|
|
116
|
+
pnpm run build
|
|
117
|
+
pnpm run example # run the blank script at ./examples/example.ts
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Stagehand is best when you have an API key for an LLM provider and Browserbase credentials. To add these to your project, run:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
cp .env.example .env
|
|
124
|
+
nano .env # Edit the .env file to add API keys
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Installing from a branch
|
|
128
|
+
|
|
129
|
+
You can install and build Stagehand directly from a github branch using [gitpkg](https://github.com/EqualMa/gitpkg)
|
|
130
|
+
|
|
131
|
+
In your project's `package.json` set:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
"@browserbasehq/stagehand": "https://gitpkg.now.sh/browserbase/stagehand/packages/core?<branchName>",
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Contributing
|
|
138
|
+
|
|
139
|
+
> [!NOTE]
|
|
140
|
+
> We highly value contributions to Stagehand! For questions or support, please join our [Slack community](https://join.slack.com/t/stagehand-dev/shared_invite/zt-3hgv6bwqu-s7MXXgPd7_rD53aViGo1MQ).
|
|
141
|
+
|
|
142
|
+
At a high level, we're focused on improving reliability, extensibility, speed, and cost in that order of priority. If you're interested in contributing, **bug fixes and small improvements are the best way to get started**. For more involved features, we strongly recommend reaching out to [Miguel Gonzalez](https://x.com/miguel_gonzf) or [Paul Klein](https://x.com/pk_iv) in our [Slack community](https://join.slack.com/t/stagehand-dev/shared_invite/zt-3hgv6bwqu-s7MXXgPd7_rD53aViGo1MQ) before starting to ensure that your contribution aligns with our goals.
|
|
143
|
+
|
|
144
|
+
<!-- For more information, please see our [Contributing Guide](https://docs.stagehand.dev/examples/contributing). -->
|
|
145
|
+
|
|
146
|
+
## Acknowledgements
|
|
147
|
+
|
|
148
|
+
We'd like to thank the following people for their major contributions to Stagehand:
|
|
149
|
+
|
|
150
|
+
- [Paul Klein](https://github.com/pkiv)
|
|
151
|
+
- [Sean McGuire](https://github.com/seanmcguire12)
|
|
152
|
+
- [Miguel Gonzalez](https://github.com/miguelg719)
|
|
153
|
+
- [Sameel Arif](https://github.com/sameelarif)
|
|
154
|
+
- [Thomas Katwan](https://github.com/tkattkat)
|
|
155
|
+
- [Filip Michalsky](https://github.com/filip-michalsky)
|
|
156
|
+
- [Anirudh Kamath](https://github.com/kamath)
|
|
157
|
+
- [Jeremy Press](https://x.com/jeremypress)
|
|
158
|
+
- [Navid Pour](https://github.com/navidpour)
|
|
159
|
+
|
|
160
|
+
## License
|
|
161
|
+
|
|
162
|
+
Licensed under the MIT License.
|
|
163
|
+
|
|
164
|
+
Copyright 2025 Browserbase, Inc.
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export { Page as PatchrightPage } from 'patchright-core';
|
|
|
13
13
|
import { Protocol } from 'devtools-protocol';
|
|
14
14
|
import { Buffer as Buffer$1 } from 'buffer';
|
|
15
15
|
import Browserbase from '@browserbasehq/sdk';
|
|
16
|
+
import { ChatCompletion } from 'openai/resources';
|
|
16
17
|
import { ToolSet as ToolSet$1 } from 'ai/dist';
|
|
17
18
|
import { Schema } from '@google/genai';
|
|
18
19
|
|
|
@@ -280,6 +281,9 @@ declare class Frame implements FrameManager {
|
|
|
280
281
|
width: number;
|
|
281
282
|
height: number;
|
|
282
283
|
};
|
|
284
|
+
type?: "png" | "jpeg";
|
|
285
|
+
quality?: number;
|
|
286
|
+
scale?: number;
|
|
283
287
|
}): Promise<Buffer>;
|
|
284
288
|
/** Child frames via Page.getFrameTree */
|
|
285
289
|
childFrames(): Promise<Frame[]>;
|
|
@@ -593,7 +597,152 @@ declare class LocatorDelegate {
|
|
|
593
597
|
first(): LocatorDelegate;
|
|
594
598
|
}
|
|
595
599
|
|
|
600
|
+
type RemoteObject = Protocol.Runtime.RemoteObject;
|
|
601
|
+
type ConsoleListener = (message: ConsoleMessage) => void;
|
|
602
|
+
declare class ConsoleMessage {
|
|
603
|
+
private readonly event;
|
|
604
|
+
private readonly pageRef?;
|
|
605
|
+
constructor(event: Protocol.Runtime.ConsoleAPICalledEvent, pageRef?: Page);
|
|
606
|
+
type(): Protocol.Runtime.ConsoleAPICalledEvent["type"];
|
|
607
|
+
text(): string;
|
|
608
|
+
args(): RemoteObject[];
|
|
609
|
+
location(): {
|
|
610
|
+
url?: string;
|
|
611
|
+
lineNumber?: number;
|
|
612
|
+
columnNumber?: number;
|
|
613
|
+
};
|
|
614
|
+
page(): Page | undefined;
|
|
615
|
+
timestamp(): number | undefined;
|
|
616
|
+
raw(): Protocol.Runtime.ConsoleAPICalledEvent;
|
|
617
|
+
toString(): string;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Response
|
|
622
|
+
* -----------------
|
|
623
|
+
*
|
|
624
|
+
* This module implements a Playwright-inspired response wrapper that exposes
|
|
625
|
+
* navigation metadata and helpers for retrieving HTTP response bodies. The
|
|
626
|
+
* abstraction is consumed by navigation routines (e.g. `Page.goto`) so callers
|
|
627
|
+
* can synchronously inspect status codes, lazily fetch body text, or await the
|
|
628
|
+
* network layer finishing the request. The implementation is built directly on
|
|
629
|
+
* Chrome DevTools Protocol primitives – it holds the originating `requestId`
|
|
630
|
+
* so it can request payloads via `Network.getResponseBody`, and it listens for
|
|
631
|
+
* `responseReceivedExtraInfo`, `loadingFinished`, and `loadingFailed` events to
|
|
632
|
+
* hydrate the richer header view and resolve callers waiting on completion.
|
|
633
|
+
*/
|
|
634
|
+
|
|
635
|
+
type ServerAddr = {
|
|
636
|
+
ipAddress: string;
|
|
637
|
+
port: number;
|
|
638
|
+
};
|
|
639
|
+
/**
|
|
640
|
+
* Thin wrapper around CDP response metadata that mirrors the ergonomics of
|
|
641
|
+
* Playwright's `Response` class. The class intentionally keeps the same method
|
|
642
|
+
* names so upstream integrations can transition with minimal code changes.
|
|
643
|
+
*/
|
|
644
|
+
declare class Response$1 {
|
|
645
|
+
private readonly page;
|
|
646
|
+
private readonly session;
|
|
647
|
+
private readonly requestId;
|
|
648
|
+
private readonly frameId?;
|
|
649
|
+
private readonly loaderId?;
|
|
650
|
+
private readonly response;
|
|
651
|
+
private readonly fromServiceWorkerFlag;
|
|
652
|
+
private readonly serverAddress?;
|
|
653
|
+
private headersObject;
|
|
654
|
+
private headersArrayCache;
|
|
655
|
+
private allHeadersCache;
|
|
656
|
+
private readonly headerValuesMap;
|
|
657
|
+
private finishedDeferred;
|
|
658
|
+
private finishedSettled;
|
|
659
|
+
private extraInfoHeaders;
|
|
660
|
+
private extraInfoHeadersText;
|
|
661
|
+
/**
|
|
662
|
+
* Build a response wrapper from the CDP notification associated with a
|
|
663
|
+
* navigation. The constructor captures the owning page/session so follow-up
|
|
664
|
+
* methods (body/text/json) can query CDP on-demand. The `response` payload is
|
|
665
|
+
* the raw `Protocol.Network.Response` object emitted by Chrome.
|
|
666
|
+
*/
|
|
667
|
+
constructor(params: {
|
|
668
|
+
page: Page;
|
|
669
|
+
session: CDPSessionLike;
|
|
670
|
+
requestId: string;
|
|
671
|
+
frameId?: string;
|
|
672
|
+
loaderId?: string;
|
|
673
|
+
response: Protocol.Network.Response;
|
|
674
|
+
fromServiceWorker: boolean;
|
|
675
|
+
});
|
|
676
|
+
/** URL associated with the navigation request. */
|
|
677
|
+
url(): string;
|
|
678
|
+
/** HTTP status code reported by Chrome. */
|
|
679
|
+
status(): number;
|
|
680
|
+
/** Human-readable status text that accompanied the response. */
|
|
681
|
+
statusText(): string;
|
|
682
|
+
/** Convenience predicate that checks for 2xx statuses. */
|
|
683
|
+
ok(): boolean;
|
|
684
|
+
/** Returns the Stagehand frame object that initiated the navigation. */
|
|
685
|
+
frame(): Frame | null;
|
|
686
|
+
/** Indicates whether the response was serviced by a Service Worker. */
|
|
687
|
+
fromServiceWorker(): boolean;
|
|
688
|
+
/**
|
|
689
|
+
* Returns TLS security metadata when provided by the browser. In practice
|
|
690
|
+
* this includes certificate issuer, protocol, and validity interval.
|
|
691
|
+
*/
|
|
692
|
+
securityDetails(): Promise<Protocol.Network.SecurityDetails | null>;
|
|
693
|
+
/** Returns the resolved server address for the navigation when available. */
|
|
694
|
+
serverAddr(): Promise<ServerAddr | null>;
|
|
695
|
+
/**
|
|
696
|
+
* Returns the response headers normalised to lowercase keys. Matches the
|
|
697
|
+
* behaviour of Playwright's `headers()` by eliding duplicate header entries.
|
|
698
|
+
*/
|
|
699
|
+
headers(): Record<string, string>;
|
|
700
|
+
/**
|
|
701
|
+
* Returns all headers including those only surfaced through
|
|
702
|
+
* `responseReceivedExtraInfo` such as `set-cookie`. Values are reported as the
|
|
703
|
+
* browser sends them (no further splitting or concatenation).
|
|
704
|
+
*/
|
|
705
|
+
allHeaders(): Promise<Record<string, string>>;
|
|
706
|
+
/** Returns a concatenated header string for the supplied header name. */
|
|
707
|
+
headerValue(name: string): Promise<string | null>;
|
|
708
|
+
/** Returns all values for a header (case-insensitive lookup). */
|
|
709
|
+
headerValues(name: string): Promise<string[]>;
|
|
710
|
+
/**
|
|
711
|
+
* Returns header entries preserving their original wire casing and ordering.
|
|
712
|
+
* Falls back to the CDP object when the raw header text is unavailable.
|
|
713
|
+
*/
|
|
714
|
+
headersArray(): Promise<Array<{
|
|
715
|
+
name: string;
|
|
716
|
+
value: string;
|
|
717
|
+
}>>;
|
|
718
|
+
/**
|
|
719
|
+
* Requests the raw response body from Chrome DevTools Protocol. The method is
|
|
720
|
+
* intentionally lazy because not every caller needs the payload, and CDP only
|
|
721
|
+
* allows retrieving it once the response completes.
|
|
722
|
+
*/
|
|
723
|
+
body(): Promise<Buffer>;
|
|
724
|
+
/** Decodes the response body as UTF-8 text. */
|
|
725
|
+
text(): Promise<string>;
|
|
726
|
+
/** Parses the response body as JSON and throws if parsing fails. */
|
|
727
|
+
json<T = unknown>(): Promise<T>;
|
|
728
|
+
/**
|
|
729
|
+
* Resolves once the underlying network request completes or fails. Mirrors
|
|
730
|
+
* Playwright's behaviour by resolving to `null` on success and to an `Error`
|
|
731
|
+
* instance when Chrome reports `Network.loadingFailed`.
|
|
732
|
+
*/
|
|
733
|
+
finished(): Promise<null | Error>;
|
|
734
|
+
/**
|
|
735
|
+
* Internal helper invoked by the navigation tracker when CDP reports extra
|
|
736
|
+
* header information. This keeps the cached header views in sync with the
|
|
737
|
+
* richer metadata.
|
|
738
|
+
*/
|
|
739
|
+
applyExtraInfo(event: Protocol.Network.ResponseReceivedExtraInfoEvent): void;
|
|
740
|
+
/** Marks the response as finished and resolves the `finished()` promise. */
|
|
741
|
+
markFinished(error: Error | null): void;
|
|
742
|
+
}
|
|
743
|
+
|
|
596
744
|
type AnyPage = Page$1 | Page$2 | Page$3 | Page;
|
|
745
|
+
|
|
597
746
|
type LoadState = "load" | "domcontentloaded" | "networkidle";
|
|
598
747
|
|
|
599
748
|
declare class StagehandAPIClient {
|
|
@@ -613,10 +762,36 @@ declare class StagehandAPIClient {
|
|
|
613
762
|
}, frameId?: string): Promise<void>;
|
|
614
763
|
agentExecute(agentConfig: AgentConfig, executeOptions: AgentExecuteOptions | string, frameId?: string): Promise<AgentResult>;
|
|
615
764
|
end(): Promise<Response>;
|
|
765
|
+
getReplayMetrics(): Promise<StagehandMetrics>;
|
|
616
766
|
private execute;
|
|
617
767
|
private request;
|
|
618
768
|
}
|
|
619
769
|
|
|
770
|
+
type ScreenshotAnimationsOption = "disabled" | "allow";
|
|
771
|
+
type ScreenshotCaretOption = "hide" | "initial";
|
|
772
|
+
type ScreenshotScaleOption = "css" | "device";
|
|
773
|
+
interface ScreenshotClip {
|
|
774
|
+
x: number;
|
|
775
|
+
y: number;
|
|
776
|
+
width: number;
|
|
777
|
+
height: number;
|
|
778
|
+
}
|
|
779
|
+
interface ScreenshotOptions {
|
|
780
|
+
animations?: ScreenshotAnimationsOption;
|
|
781
|
+
caret?: ScreenshotCaretOption;
|
|
782
|
+
clip?: ScreenshotClip;
|
|
783
|
+
fullPage?: boolean;
|
|
784
|
+
mask?: Locator[];
|
|
785
|
+
maskColor?: string;
|
|
786
|
+
omitBackground?: boolean;
|
|
787
|
+
path?: string;
|
|
788
|
+
quality?: number;
|
|
789
|
+
scale?: ScreenshotScaleOption;
|
|
790
|
+
style?: string;
|
|
791
|
+
timeout?: number;
|
|
792
|
+
type?: "png" | "jpeg";
|
|
793
|
+
}
|
|
794
|
+
|
|
620
795
|
declare class Page {
|
|
621
796
|
private readonly conn;
|
|
622
797
|
private readonly mainSession;
|
|
@@ -641,6 +816,8 @@ declare class Page {
|
|
|
641
816
|
private readonly networkManager;
|
|
642
817
|
/** Optional API client for routing page operations to the API */
|
|
643
818
|
private readonly apiClient;
|
|
819
|
+
private readonly consoleListeners;
|
|
820
|
+
private readonly consoleHandlers;
|
|
644
821
|
private constructor();
|
|
645
822
|
private cursorEnabled;
|
|
646
823
|
private ensureCursorScript;
|
|
@@ -681,7 +858,30 @@ declare class Page {
|
|
|
681
858
|
getSessionById(id: string): CDPSessionLike | undefined;
|
|
682
859
|
registerSessionForNetwork(session: CDPSessionLike): void;
|
|
683
860
|
unregisterSessionForNetwork(sessionId: string | undefined): void;
|
|
861
|
+
on(event: "console", listener: ConsoleListener): Page;
|
|
862
|
+
once(event: "console", listener: ConsoleListener): Page;
|
|
863
|
+
off(event: "console", listener: ConsoleListener): Page;
|
|
684
864
|
targetId(): string;
|
|
865
|
+
/**
|
|
866
|
+
* Send a CDP command through the main session.
|
|
867
|
+
* Allows external consumers to execute arbitrary Chrome DevTools Protocol commands.
|
|
868
|
+
*
|
|
869
|
+
* @param method - The CDP method name (e.g., "Page.enable", "Runtime.evaluate")
|
|
870
|
+
* @param params - Optional parameters for the CDP command
|
|
871
|
+
* @returns Promise resolving to the typed CDP response
|
|
872
|
+
*
|
|
873
|
+
* @example
|
|
874
|
+
* // Enable the Runtime domain
|
|
875
|
+
* await page.sendCDP("Runtime.enable");
|
|
876
|
+
*
|
|
877
|
+
* @example
|
|
878
|
+
* // Evaluate JavaScript with typed response
|
|
879
|
+
* const result = await page.sendCDP<Protocol.Runtime.EvaluateResponse>(
|
|
880
|
+
* "Runtime.evaluate",
|
|
881
|
+
* { expression: "1 + 1" }
|
|
882
|
+
* );
|
|
883
|
+
*/
|
|
884
|
+
sendCDP<T = unknown>(method: string, params?: object): Promise<T>;
|
|
685
885
|
/** Seed the cached URL before navigation events converge. */
|
|
686
886
|
seedCurrentUrl(url: string | undefined | null): void;
|
|
687
887
|
mainFrameId(): string;
|
|
@@ -696,6 +896,13 @@ declare class Page {
|
|
|
696
896
|
/** Public getter for snapshot code / handlers. */
|
|
697
897
|
getOrdinal(frameId: string): number;
|
|
698
898
|
listAllFrameIds(): string[];
|
|
899
|
+
private ensureConsoleTaps;
|
|
900
|
+
private installConsoleTap;
|
|
901
|
+
private sessionKey;
|
|
902
|
+
private resolveSessionByKey;
|
|
903
|
+
private teardownConsoleTap;
|
|
904
|
+
private removeAllConsoleTaps;
|
|
905
|
+
private emitConsole;
|
|
699
906
|
/**
|
|
700
907
|
* Navigate the page; optionally wait for a lifecycle state.
|
|
701
908
|
* Waits on the **current** main frame and follows root swaps during navigation.
|
|
@@ -703,7 +910,7 @@ declare class Page {
|
|
|
703
910
|
goto(url: string, options?: {
|
|
704
911
|
waitUntil?: LoadState;
|
|
705
912
|
timeoutMs?: number;
|
|
706
|
-
}): Promise<
|
|
913
|
+
}): Promise<Response$1 | null>;
|
|
707
914
|
/**
|
|
708
915
|
* Reload the page; optionally wait for a lifecycle state.
|
|
709
916
|
*/
|
|
@@ -711,21 +918,21 @@ declare class Page {
|
|
|
711
918
|
waitUntil?: LoadState;
|
|
712
919
|
timeoutMs?: number;
|
|
713
920
|
ignoreCache?: boolean;
|
|
714
|
-
}): Promise<
|
|
921
|
+
}): Promise<Response$1 | null>;
|
|
715
922
|
/**
|
|
716
923
|
* Navigate back in history if possible; optionally wait for a lifecycle state.
|
|
717
924
|
*/
|
|
718
925
|
goBack(options?: {
|
|
719
926
|
waitUntil?: LoadState;
|
|
720
927
|
timeoutMs?: number;
|
|
721
|
-
}): Promise<
|
|
928
|
+
}): Promise<Response$1 | null>;
|
|
722
929
|
/**
|
|
723
930
|
* Navigate forward in history if possible; optionally wait for a lifecycle state.
|
|
724
931
|
*/
|
|
725
932
|
goForward(options?: {
|
|
726
933
|
waitUntil?: LoadState;
|
|
727
934
|
timeoutMs?: number;
|
|
728
|
-
}): Promise<
|
|
935
|
+
}): Promise<Response$1 | null>;
|
|
729
936
|
/**
|
|
730
937
|
* Return the current page URL (synchronous, cached from navigation events).
|
|
731
938
|
*/
|
|
@@ -739,11 +946,36 @@ declare class Page {
|
|
|
739
946
|
*/
|
|
740
947
|
title(): Promise<string>;
|
|
741
948
|
/**
|
|
742
|
-
* Capture a screenshot
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
949
|
+
* Capture a screenshot with Playwright-style options.
|
|
950
|
+
*
|
|
951
|
+
* @param options Optional screenshot configuration.
|
|
952
|
+
* @param options.animations Control CSS/Web animations during capture. Use
|
|
953
|
+
* "disabled" to fast-forward finite animations and pause infinite ones.
|
|
954
|
+
* @param options.caret Either hide the text caret (default) or leave it
|
|
955
|
+
* visible via "initial".
|
|
956
|
+
* @param options.clip Restrict capture to a specific rectangle (in CSS
|
|
957
|
+
* pixels). Cannot be combined with `fullPage`.
|
|
958
|
+
* @param options.fullPage Capture the full scrollable page instead of the
|
|
959
|
+
* current viewport.
|
|
960
|
+
* @param options.mask Array of locators that should be covered with an
|
|
961
|
+
* overlay while the screenshot is taken.
|
|
962
|
+
* @param options.maskColor CSS color used for the mask overlay (default
|
|
963
|
+
* `#FF00FF`).
|
|
964
|
+
* @param options.omitBackground Make the default page background transparent
|
|
965
|
+
* (PNG only).
|
|
966
|
+
* @param options.path File path to write the screenshot to. The file extension
|
|
967
|
+
* determines the image type when `type` is not explicitly provided.
|
|
968
|
+
* @param options.quality JPEG quality (0–100). Only applies when
|
|
969
|
+
* `type === "jpeg"`.
|
|
970
|
+
* @param options.scale Render scale: use "css" for one pixel per CSS pixel,
|
|
971
|
+
* otherwise the default "device" leverages the current device pixel ratio.
|
|
972
|
+
* @param options.style Additional CSS text injected into every frame before
|
|
973
|
+
* capture (removed afterwards).
|
|
974
|
+
* @param options.timeout Maximum capture duration in milliseconds before a
|
|
975
|
+
* timeout error is thrown.
|
|
976
|
+
* @param options.type Image format (`"png"` by default).
|
|
977
|
+
*/
|
|
978
|
+
screenshot(options?: ScreenshotOptions): Promise<Buffer>;
|
|
747
979
|
/**
|
|
748
980
|
* Create a locator bound to the current main frame.
|
|
749
981
|
*/
|
|
@@ -1297,6 +1529,15 @@ declare class StagehandShadowSegmentNotFoundError extends StagehandError {
|
|
|
1297
1529
|
constructor(segment: string, hint?: string);
|
|
1298
1530
|
}
|
|
1299
1531
|
|
|
1532
|
+
declare class AISdkClient extends LLMClient {
|
|
1533
|
+
type: "aisdk";
|
|
1534
|
+
private model;
|
|
1535
|
+
constructor({ model }: {
|
|
1536
|
+
model: LanguageModelV2;
|
|
1537
|
+
});
|
|
1538
|
+
createChatCompletion<T = ChatCompletion>({ options, }: CreateChatCompletionOptions): Promise<T>;
|
|
1539
|
+
}
|
|
1540
|
+
|
|
1300
1541
|
interface StagehandAPIConstructorParams {
|
|
1301
1542
|
apiKey: string;
|
|
1302
1543
|
projectId: string;
|
|
@@ -1591,6 +1832,7 @@ declare class V3 {
|
|
|
1591
1832
|
private readonly domSettleTimeoutMs?;
|
|
1592
1833
|
private _isClosing;
|
|
1593
1834
|
browserbaseSessionId?: string;
|
|
1835
|
+
get browserbaseSessionID(): string | undefined;
|
|
1594
1836
|
private _onCdpClosed;
|
|
1595
1837
|
readonly experimental: boolean;
|
|
1596
1838
|
readonly logInferenceToFile: boolean;
|
|
@@ -1610,7 +1852,7 @@ declare class V3 {
|
|
|
1610
1852
|
constructor(opts: V3Options);
|
|
1611
1853
|
/**
|
|
1612
1854
|
* Async property for metrics so callers can `await v3.metrics`.
|
|
1613
|
-
*
|
|
1855
|
+
* When using API mode, fetches metrics from the API. Otherwise returns local metrics.
|
|
1614
1856
|
*/
|
|
1615
1857
|
get metrics(): Promise<StagehandMetrics>;
|
|
1616
1858
|
private resolveLlmClient;
|
|
@@ -1822,4 +2064,4 @@ declare class V3Evaluator {
|
|
|
1822
2064
|
private _evaluateWithMultipleScreenshots;
|
|
1823
2065
|
}
|
|
1824
2066
|
|
|
1825
|
-
export { type AISDKCustomProvider, type AISDKProvider, AVAILABLE_CUA_MODELS, type ActOptions, type ActResult, type Action, type ActionExecutionResult, type AgentAction, type AgentConfig, type AgentExecuteOptions, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type AgentResult, AgentScreenshotProviderError, type AgentType, AnnotatedScreenshotText, type AnthropicContentBlock, type AnthropicJsonSchemaObject, type AnthropicMessage, type AnthropicTextBlock, type AnthropicToolResult, type AnyPage, type AvailableCuaModel, type AvailableModel, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, type ChatCompletionOptions, type ChatMessage, type ChatMessageContent, type ChatMessageImageContent, type ChatMessageTextContent, type ClientOptions, type ComputerCallItem, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, type FunctionCallItem, HandlerNotInitializedError, type HistoryEntry, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaProperty, LLMClient, type LLMParsedResponse, type LLMResponse, LLMResponseError, type LLMTool, LOG_LEVEL_NAMES, type LoadState, type LocalBrowserLaunchOptions, type LogLevel, type LogLine, type Logger, MCPConnectionError, MissingEnvironmentVariableError, MissingLLMConfigurationError, type ModelConfiguration, type ModelProvider, type ObserveOptions, type ResponseInputItem, type ResponseItem, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, type StagehandMetrics, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, type ToolUseItem, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type V3Options, XPathResolutionError, ZodSchemaValidationError, connectToMCPServer, defaultExtractSchema, getZodType, injectUrls, isRunningInBun, jsonSchemaToZod, loadApiKeyFromEnv, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, transformSchema, trimTrailingTextNode, validateZodSchema };
|
|
2067
|
+
export { type AISDKCustomProvider, type AISDKProvider, AISdkClient, AVAILABLE_CUA_MODELS, type ActOptions, type ActResult, type Action, type ActionExecutionResult, type AgentAction, type AgentConfig, type AgentExecuteOptions, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type AgentResult, AgentScreenshotProviderError, type AgentType, AnnotatedScreenshotText, type AnthropicContentBlock, type AnthropicJsonSchemaObject, type AnthropicMessage, type AnthropicTextBlock, type AnthropicToolResult, type AnyPage, type AvailableCuaModel, type AvailableModel, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, type ChatCompletionOptions, type ChatMessage, type ChatMessageContent, type ChatMessageImageContent, type ChatMessageTextContent, type ClientOptions, type ComputerCallItem, type ConsoleListener, ConsoleMessage, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, type FunctionCallItem, HandlerNotInitializedError, type HistoryEntry, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaProperty, LLMClient, type LLMParsedResponse, type LLMResponse, LLMResponseError, type LLMTool, LOG_LEVEL_NAMES, type LoadState, type LocalBrowserLaunchOptions, type LogLevel, type LogLine, type Logger, MCPConnectionError, MissingEnvironmentVariableError, MissingLLMConfigurationError, type ModelConfiguration, type ModelProvider, type ObserveOptions, Page, Response$1 as Response, type ResponseInputItem, type ResponseItem, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, type StagehandMetrics, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, type ToolUseItem, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type V3Options, XPathResolutionError, ZodSchemaValidationError, connectToMCPServer, defaultExtractSchema, getZodType, injectUrls, isRunningInBun, jsonSchemaToZod, loadApiKeyFromEnv, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, transformSchema, trimTrailingTextNode, validateZodSchema };
|