@browserbasehq/orca 3.0.7-alpha-1 → 3.0.8-ca-ching

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 CHANGED
@@ -20,10 +20,10 @@
20
20
  <img alt="MIT License" src="../../media/light_license.svg" />
21
21
  </picture>
22
22
  </a>
23
- <a href="https://join.slack.com/t/stagehand-dev/shared_invite/zt-3kg9piw3m-rxqCIzeuYQMXG315yHigPQ">
23
+ <a href="https://stagehand.dev/discord">
24
24
  <picture>
25
- <source media="(prefers-color-scheme: dark)" srcset="../../media/dark_slack.svg" />
26
- <img alt="Slack Community" src="../../media/light_slack.svg" />
25
+ <source media="(prefers-color-scheme: dark)" srcset="../../media/dark_discord.svg" />
26
+ <img alt="Discord Community" src="../../media/light_discord.svg" />
27
27
  </picture>
28
28
  </a>
29
29
  </p>
@@ -136,10 +136,10 @@ In your project's `package.json` set:
136
136
 
137
137
  ## Contributing
138
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-3kg9piw3m-rxqCIzeuYQMXG315yHigPQ).
139
+ > [!NOTE]
140
+ > We highly value contributions to Stagehand! For questions or support, please join our [Discord community](https://stagehand.dev/discord).
141
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-3kg9piw3m-rxqCIzeuYQMXG315yHigPQ) before starting to ensure that your contribution aligns with our goals.
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 [Discord community](https://stagehand.dev/discord) before starting to ensure that your contribution aligns with our goals.
143
143
 
144
144
  <!-- For more information, please see our [Contributing Guide](https://docs.stagehand.dev/examples/contributing). -->
145
145
 
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ import { ClientOptions as ClientOptions$1 } from 'openai';
8
8
  import { Client, ClientOptions as ClientOptions$3 } from '@modelcontextprotocol/sdk/client/index.js';
9
9
  import * as ai from 'ai';
10
10
  import { ToolSet, ModelMessage, PrepareStepFunction, GenerateTextOnStepFinishCallback, StreamTextOnStepFinishCallback, StreamTextOnErrorCallback, StreamTextOnChunkCallback, StreamTextOnFinishCallback, StepResult, StreamTextResult, wrapLanguageModel, generateObject, generateText, streamText, streamObject, experimental_generateImage, embed, embedMany, experimental_transcribe, experimental_generateSpeech, InferUITools } from 'ai';
11
- export { ModelMessage } from 'ai';
11
+ export { ModelMessage, Tool, tool } from 'ai';
12
12
  import { Page as Page$1 } from 'playwright-core';
13
13
  export { Page as PlaywrightPage } from 'playwright-core';
14
14
  import { Page as Page$2 } from 'puppeteer-core';
@@ -712,12 +712,6 @@ declare const SessionHeadersSchema: z$1.ZodObject<{
712
712
  true: "true";
713
713
  false: "false";
714
714
  }>>;
715
- "x-language": z$1.ZodOptional<z$1.ZodEnum<{
716
- typescript: "typescript";
717
- python: "python";
718
- playground: "playground";
719
- }>>;
720
- "x-sdk-version": z$1.ZodOptional<z$1.ZodString>;
721
715
  "x-sent-at": z$1.ZodOptional<z$1.ZodString>;
722
716
  }, z$1.core.$strip>;
723
717
  /** Standard error response */
@@ -1069,6 +1063,10 @@ declare const SessionStartResponseSchema: z$1.ZodObject<{
1069
1063
  available: z$1.ZodBoolean;
1070
1064
  }, z$1.core.$strip>;
1071
1065
  }, z$1.core.$strip>;
1066
+ /** Session end request - empty JSON object (required). */
1067
+ declare const SessionEndRequestSchema: z$1.ZodObject<{
1068
+ _forceBody: z$1.ZodOptional<z$1.ZodUndefined>;
1069
+ }, z$1.core.$strict>;
1072
1070
  declare const SessionEndResultSchema: z$1.ZodObject<{}, z$1.core.$strict>;
1073
1071
  /** Session end response - just success flag, no data wrapper */
1074
1072
  declare const SessionEndResponseSchema: z$1.ZodObject<{
@@ -1330,6 +1328,10 @@ declare const AgentResultDataSchema: z$1.ZodObject<{
1330
1328
  inference_time_ms: z$1.ZodNumber;
1331
1329
  }, z$1.core.$strip>>;
1332
1330
  }, z$1.core.$strip>;
1331
+ declare const AgentCacheEntrySchema: z$1.ZodObject<{
1332
+ cacheKey: z$1.ZodString;
1333
+ entry: z$1.ZodUnknown;
1334
+ }, z$1.core.$strip>;
1333
1335
  declare const AgentExecuteOptionsSchema: z$1.ZodObject<{
1334
1336
  instruction: z$1.ZodString;
1335
1337
  maxSteps: z$1.ZodOptional<z$1.ZodNumber>;
@@ -1364,6 +1366,7 @@ declare const AgentExecuteRequestSchema: z$1.ZodObject<{
1364
1366
  }, z$1.core.$strip>;
1365
1367
  frameId: z$1.ZodOptional<z$1.ZodString>;
1366
1368
  streamResponse: z$1.ZodOptional<z$1.ZodBoolean>;
1369
+ shouldCache: z$1.ZodOptional<z$1.ZodBoolean>;
1367
1370
  }, z$1.core.$strip>;
1368
1371
  declare const AgentExecuteResultSchema: z$1.ZodObject<{
1369
1372
  result: z$1.ZodObject<{
@@ -1389,6 +1392,10 @@ declare const AgentExecuteResultSchema: z$1.ZodObject<{
1389
1392
  inference_time_ms: z$1.ZodNumber;
1390
1393
  }, z$1.core.$strip>>;
1391
1394
  }, z$1.core.$strip>;
1395
+ cacheEntry: z$1.ZodOptional<z$1.ZodObject<{
1396
+ cacheKey: z$1.ZodString;
1397
+ entry: z$1.ZodUnknown;
1398
+ }, z$1.core.$strip>>;
1392
1399
  }, z$1.core.$strip>;
1393
1400
  declare const AgentExecuteResponseSchema: z$1.ZodObject<{
1394
1401
  success: z$1.ZodBoolean;
@@ -1416,6 +1423,10 @@ declare const AgentExecuteResponseSchema: z$1.ZodObject<{
1416
1423
  inference_time_ms: z$1.ZodNumber;
1417
1424
  }, z$1.core.$strip>>;
1418
1425
  }, z$1.core.$strip>;
1426
+ cacheEntry: z$1.ZodOptional<z$1.ZodObject<{
1427
+ cacheKey: z$1.ZodString;
1428
+ entry: z$1.ZodUnknown;
1429
+ }, z$1.core.$strip>>;
1419
1430
  }, z$1.core.$strip>;
1420
1431
  }, z$1.core.$strip>;
1421
1432
  declare const NavigateOptionsSchema: z$1.ZodOptional<z$1.ZodObject<{
@@ -1751,6 +1762,7 @@ declare const api_ActResultDataSchema: typeof ActResultDataSchema;
1751
1762
  declare const api_ActResultSchema: typeof ActResultSchema;
1752
1763
  declare const api_ActionSchema: typeof ActionSchema;
1753
1764
  declare const api_AgentActionSchema: typeof AgentActionSchema;
1765
+ declare const api_AgentCacheEntrySchema: typeof AgentCacheEntrySchema;
1754
1766
  declare const api_AgentConfigSchema: typeof AgentConfigSchema;
1755
1767
  declare const api_AgentExecuteOptionsSchema: typeof AgentExecuteOptionsSchema;
1756
1768
  type api_AgentExecuteRequest = AgentExecuteRequest;
@@ -1819,6 +1831,7 @@ type api_ReplayResponse = ReplayResponse;
1819
1831
  declare const api_ReplayResponseSchema: typeof ReplayResponseSchema;
1820
1832
  type api_ReplayResult = ReplayResult;
1821
1833
  declare const api_ReplayResultSchema: typeof ReplayResultSchema;
1834
+ declare const api_SessionEndRequestSchema: typeof SessionEndRequestSchema;
1822
1835
  type api_SessionEndResponse = SessionEndResponse;
1823
1836
  declare const api_SessionEndResponseSchema: typeof SessionEndResponseSchema;
1824
1837
  type api_SessionEndResult = SessionEndResult;
@@ -1848,7 +1861,7 @@ declare const api_TokenUsageSchema: typeof TokenUsageSchema;
1848
1861
  declare const api_openApiLinks: typeof openApiLinks;
1849
1862
  declare const api_openApiSecuritySchemes: typeof openApiSecuritySchemes;
1850
1863
  declare namespace api {
1851
- export { api_ActOptionsSchema as ActOptionsSchema, type api_ActRequest as ActRequest, api_ActRequestSchema as ActRequestSchema, type api_ActResponse as ActResponse, api_ActResponseSchema as ActResponseSchema, type ActResult$1 as ActResult, type api_ActResultData as ActResultData, api_ActResultDataSchema as ActResultDataSchema, api_ActResultSchema as ActResultSchema, type Action$1 as Action, api_ActionSchema as ActionSchema, type AgentAction$1 as AgentAction, api_AgentActionSchema as AgentActionSchema, api_AgentConfigSchema as AgentConfigSchema, api_AgentExecuteOptionsSchema as AgentExecuteOptionsSchema, type api_AgentExecuteRequest as AgentExecuteRequest, api_AgentExecuteRequestSchema as AgentExecuteRequestSchema, type api_AgentExecuteResponse as AgentExecuteResponse, api_AgentExecuteResponseSchema as AgentExecuteResponseSchema, type api_AgentExecuteResult as AgentExecuteResult, api_AgentExecuteResultSchema as AgentExecuteResultSchema, type api_AgentResultData as AgentResultData, api_AgentResultDataSchema as AgentResultDataSchema, type api_AgentUsage as AgentUsage, api_AgentUsageSchema as AgentUsageSchema, type api_BrowserConfig as BrowserConfig, api_BrowserConfigSchema as BrowserConfigSchema, type api_BrowserbaseBrowserSettings as BrowserbaseBrowserSettings, api_BrowserbaseBrowserSettingsSchema as BrowserbaseBrowserSettingsSchema, type api_BrowserbaseContext as BrowserbaseContext, api_BrowserbaseContextSchema as BrowserbaseContextSchema, type api_BrowserbaseFingerprint as BrowserbaseFingerprint, api_BrowserbaseFingerprintSchema as BrowserbaseFingerprintSchema, type api_BrowserbaseFingerprintScreen as BrowserbaseFingerprintScreen, api_BrowserbaseFingerprintScreenSchema as BrowserbaseFingerprintScreenSchema, type api_BrowserbaseProxyConfig as BrowserbaseProxyConfig, api_BrowserbaseProxyConfigSchema as BrowserbaseProxyConfigSchema, type api_BrowserbaseProxyGeolocation as BrowserbaseProxyGeolocation, api_BrowserbaseProxyGeolocationSchema as BrowserbaseProxyGeolocationSchema, type api_BrowserbaseSessionCreateParams as BrowserbaseSessionCreateParams, api_BrowserbaseSessionCreateParamsSchema as BrowserbaseSessionCreateParamsSchema, type api_BrowserbaseViewport as BrowserbaseViewport, api_BrowserbaseViewportSchema as BrowserbaseViewportSchema, api_ErrorResponseSchema as ErrorResponseSchema, type api_ExternalProxyConfig as ExternalProxyConfig, api_ExternalProxyConfigSchema as ExternalProxyConfigSchema, api_ExtractOptionsSchema as ExtractOptionsSchema, type api_ExtractRequest as ExtractRequest, api_ExtractRequestSchema as ExtractRequestSchema, type api_ExtractResponse as ExtractResponse, api_ExtractResponseSchema as ExtractResponseSchema, type ExtractResult$1 as ExtractResult, api_ExtractResultSchema as ExtractResultSchema, api_LocalBrowserLaunchOptionsSchema as LocalBrowserLaunchOptionsSchema, type api_ModelConfig as ModelConfig, api_ModelConfigObjectSchema as ModelConfigObjectSchema, api_ModelConfigSchema as ModelConfigSchema, api_ModelNameSchema as ModelNameSchema, api_NavigateOptionsSchema as NavigateOptionsSchema, type api_NavigateRequest as NavigateRequest, api_NavigateRequestSchema as NavigateRequestSchema, type api_NavigateResponse as NavigateResponse, api_NavigateResponseSchema as NavigateResponseSchema, type api_NavigateResult as NavigateResult, api_NavigateResultSchema as NavigateResultSchema, api_ObserveOptionsSchema as ObserveOptionsSchema, type api_ObserveRequest as ObserveRequest, api_ObserveRequestSchema as ObserveRequestSchema, type api_ObserveResponse as ObserveResponse, api_ObserveResponseSchema as ObserveResponseSchema, type api_ObserveResult as ObserveResult, api_ObserveResultSchema as ObserveResultSchema, api_Operations as Operations, api_ProxyConfigSchema as ProxyConfigSchema, type api_ReplayAction as ReplayAction, api_ReplayActionSchema as ReplayActionSchema, type api_ReplayPage as ReplayPage, api_ReplayPageSchema as ReplayPageSchema, type api_ReplayResponse as ReplayResponse, api_ReplayResponseSchema as ReplayResponseSchema, type api_ReplayResult as ReplayResult, api_ReplayResultSchema as ReplayResultSchema, type api_SessionEndResponse as SessionEndResponse, api_SessionEndResponseSchema as SessionEndResponseSchema, type api_SessionEndResult as SessionEndResult, api_SessionEndResultSchema as SessionEndResultSchema, type api_SessionHeaders as SessionHeaders, api_SessionHeadersSchema as SessionHeadersSchema, type api_SessionIdParams as SessionIdParams, api_SessionIdParamsSchema as SessionIdParamsSchema, type api_SessionStartRequest as SessionStartRequest, api_SessionStartRequestSchema as SessionStartRequestSchema, type api_SessionStartResponse as SessionStartResponse, api_SessionStartResponseSchema as SessionStartResponseSchema, type api_SessionStartResult as SessionStartResult, api_SessionStartResultSchema as SessionStartResultSchema, type api_StreamEvent as StreamEvent, type api_StreamEventLogData as StreamEventLogData, api_StreamEventLogDataSchema as StreamEventLogDataSchema, api_StreamEventSchema as StreamEventSchema, type api_StreamEventStatus as StreamEventStatus, api_StreamEventStatusSchema as StreamEventStatusSchema, type api_StreamEventSystemData as StreamEventSystemData, api_StreamEventSystemDataSchema as StreamEventSystemDataSchema, type api_StreamEventType as StreamEventType, api_StreamEventTypeSchema as StreamEventTypeSchema, type api_TokenUsage as TokenUsage, api_TokenUsageSchema as TokenUsageSchema, api_openApiLinks as openApiLinks, api_openApiSecuritySchemes as openApiSecuritySchemes };
1864
+ export { api_ActOptionsSchema as ActOptionsSchema, type api_ActRequest as ActRequest, api_ActRequestSchema as ActRequestSchema, type api_ActResponse as ActResponse, api_ActResponseSchema as ActResponseSchema, type ActResult$1 as ActResult, type api_ActResultData as ActResultData, api_ActResultDataSchema as ActResultDataSchema, api_ActResultSchema as ActResultSchema, type Action$1 as Action, api_ActionSchema as ActionSchema, type AgentAction$1 as AgentAction, api_AgentActionSchema as AgentActionSchema, api_AgentCacheEntrySchema as AgentCacheEntrySchema, api_AgentConfigSchema as AgentConfigSchema, api_AgentExecuteOptionsSchema as AgentExecuteOptionsSchema, type api_AgentExecuteRequest as AgentExecuteRequest, api_AgentExecuteRequestSchema as AgentExecuteRequestSchema, type api_AgentExecuteResponse as AgentExecuteResponse, api_AgentExecuteResponseSchema as AgentExecuteResponseSchema, type api_AgentExecuteResult as AgentExecuteResult, api_AgentExecuteResultSchema as AgentExecuteResultSchema, type api_AgentResultData as AgentResultData, api_AgentResultDataSchema as AgentResultDataSchema, type api_AgentUsage as AgentUsage, api_AgentUsageSchema as AgentUsageSchema, type api_BrowserConfig as BrowserConfig, api_BrowserConfigSchema as BrowserConfigSchema, type api_BrowserbaseBrowserSettings as BrowserbaseBrowserSettings, api_BrowserbaseBrowserSettingsSchema as BrowserbaseBrowserSettingsSchema, type api_BrowserbaseContext as BrowserbaseContext, api_BrowserbaseContextSchema as BrowserbaseContextSchema, type api_BrowserbaseFingerprint as BrowserbaseFingerprint, api_BrowserbaseFingerprintSchema as BrowserbaseFingerprintSchema, type api_BrowserbaseFingerprintScreen as BrowserbaseFingerprintScreen, api_BrowserbaseFingerprintScreenSchema as BrowserbaseFingerprintScreenSchema, type api_BrowserbaseProxyConfig as BrowserbaseProxyConfig, api_BrowserbaseProxyConfigSchema as BrowserbaseProxyConfigSchema, type api_BrowserbaseProxyGeolocation as BrowserbaseProxyGeolocation, api_BrowserbaseProxyGeolocationSchema as BrowserbaseProxyGeolocationSchema, type api_BrowserbaseSessionCreateParams as BrowserbaseSessionCreateParams, api_BrowserbaseSessionCreateParamsSchema as BrowserbaseSessionCreateParamsSchema, type api_BrowserbaseViewport as BrowserbaseViewport, api_BrowserbaseViewportSchema as BrowserbaseViewportSchema, api_ErrorResponseSchema as ErrorResponseSchema, type api_ExternalProxyConfig as ExternalProxyConfig, api_ExternalProxyConfigSchema as ExternalProxyConfigSchema, api_ExtractOptionsSchema as ExtractOptionsSchema, type api_ExtractRequest as ExtractRequest, api_ExtractRequestSchema as ExtractRequestSchema, type api_ExtractResponse as ExtractResponse, api_ExtractResponseSchema as ExtractResponseSchema, type ExtractResult$1 as ExtractResult, api_ExtractResultSchema as ExtractResultSchema, api_LocalBrowserLaunchOptionsSchema as LocalBrowserLaunchOptionsSchema, type api_ModelConfig as ModelConfig, api_ModelConfigObjectSchema as ModelConfigObjectSchema, api_ModelConfigSchema as ModelConfigSchema, api_ModelNameSchema as ModelNameSchema, api_NavigateOptionsSchema as NavigateOptionsSchema, type api_NavigateRequest as NavigateRequest, api_NavigateRequestSchema as NavigateRequestSchema, type api_NavigateResponse as NavigateResponse, api_NavigateResponseSchema as NavigateResponseSchema, type api_NavigateResult as NavigateResult, api_NavigateResultSchema as NavigateResultSchema, api_ObserveOptionsSchema as ObserveOptionsSchema, type api_ObserveRequest as ObserveRequest, api_ObserveRequestSchema as ObserveRequestSchema, type api_ObserveResponse as ObserveResponse, api_ObserveResponseSchema as ObserveResponseSchema, type api_ObserveResult as ObserveResult, api_ObserveResultSchema as ObserveResultSchema, api_Operations as Operations, api_ProxyConfigSchema as ProxyConfigSchema, type api_ReplayAction as ReplayAction, api_ReplayActionSchema as ReplayActionSchema, type api_ReplayPage as ReplayPage, api_ReplayPageSchema as ReplayPageSchema, type api_ReplayResponse as ReplayResponse, api_ReplayResponseSchema as ReplayResponseSchema, type api_ReplayResult as ReplayResult, api_ReplayResultSchema as ReplayResultSchema, api_SessionEndRequestSchema as SessionEndRequestSchema, type api_SessionEndResponse as SessionEndResponse, api_SessionEndResponseSchema as SessionEndResponseSchema, type api_SessionEndResult as SessionEndResult, api_SessionEndResultSchema as SessionEndResultSchema, type api_SessionHeaders as SessionHeaders, api_SessionHeadersSchema as SessionHeadersSchema, type api_SessionIdParams as SessionIdParams, api_SessionIdParamsSchema as SessionIdParamsSchema, type api_SessionStartRequest as SessionStartRequest, api_SessionStartRequestSchema as SessionStartRequestSchema, type api_SessionStartResponse as SessionStartResponse, api_SessionStartResponseSchema as SessionStartResponseSchema, type api_SessionStartResult as SessionStartResult, api_SessionStartResultSchema as SessionStartResultSchema, type api_StreamEvent as StreamEvent, type api_StreamEventLogData as StreamEventLogData, api_StreamEventLogDataSchema as StreamEventLogDataSchema, api_StreamEventSchema as StreamEventSchema, type api_StreamEventStatus as StreamEventStatus, api_StreamEventStatusSchema as StreamEventStatusSchema, type api_StreamEventSystemData as StreamEventSystemData, api_StreamEventSystemDataSchema as StreamEventSystemDataSchema, type api_StreamEventType as StreamEventType, api_StreamEventTypeSchema as StreamEventTypeSchema, type api_TokenUsage as TokenUsage, api_TokenUsageSchema as TokenUsageSchema, api_openApiLinks as openApiLinks, api_openApiSecuritySchemes as openApiSecuritySchemes };
1852
1865
  }
1853
1866
 
1854
1867
  declare class StagehandAPIError extends Error {
@@ -2009,7 +2022,8 @@ interface V3Options {
2009
2022
  }
2010
2023
 
2011
2024
  declare class StagehandError extends Error {
2012
- constructor(message: string);
2025
+ readonly cause?: unknown;
2026
+ constructor(message: string, cause?: unknown);
2013
2027
  }
2014
2028
  declare class StagehandDefaultError extends StagehandError {
2015
2029
  constructor(error?: unknown);
@@ -2152,6 +2166,9 @@ declare class AgentAbortError extends StagehandError {
2152
2166
  declare class StagehandClosedError extends StagehandError {
2153
2167
  constructor();
2154
2168
  }
2169
+ declare class StagehandSnapshotError extends StagehandError {
2170
+ constructor(cause?: unknown);
2171
+ }
2155
2172
 
2156
2173
  declare class AISdkClient extends LLMClient {
2157
2174
  type: "aisdk";
@@ -2219,13 +2236,16 @@ declare class StagehandAPIClient {
2219
2236
  private modelProvider?;
2220
2237
  private logger;
2221
2238
  private fetchWithCookies;
2239
+ private lastFinishedEventData;
2240
+ private latestAgentCacheEntry;
2222
2241
  constructor({ apiKey, projectId, logger }: StagehandAPIConstructorParams);
2223
2242
  init({ modelName, modelApiKey, domSettleTimeoutMs, verbose, systemPrompt, selfHeal, browserbaseSessionCreateParams, browserbaseSessionID, }: ClientSessionStartParams): Promise<SessionStartResult>;
2224
2243
  act({ input, options, frameId, }: ClientActParameters): Promise<ActResult>;
2225
2244
  extract<T extends StagehandZodSchema>({ instruction, schema: zodSchema, options, frameId, }: ClientExtractParameters): Promise<ExtractResult<T>>;
2226
2245
  observe({ instruction, options, frameId, }: ClientObserveParameters): Promise<Action[]>;
2227
2246
  goto(url: string, options?: NavigateRequest["options"], frameId?: string): Promise<SerializableResponse | null>;
2228
- agentExecute(agentConfig: AgentConfig, executeOptions: AgentExecuteOptions | string, frameId?: string): Promise<AgentResult>;
2247
+ agentExecute(agentConfig: AgentConfig, executeOptions: AgentExecuteOptions | string, frameId?: string, shouldCache?: boolean): Promise<AgentResult>;
2248
+ consumeLatestAgentCacheEntry(): AgentCacheTransferPayload | null;
2229
2249
  end(): Promise<Response>;
2230
2250
  getReplayMetrics(): Promise<StagehandMetrics>;
2231
2251
  /**
@@ -2237,6 +2257,7 @@ declare class StagehandAPIClient {
2237
2257
  * model provider differs from the one used to init the session.
2238
2258
  */
2239
2259
  private prepareModelConfig;
2260
+ private consumeFinishedEventData;
2240
2261
  private execute;
2241
2262
  private request;
2242
2263
  }
@@ -2368,6 +2389,10 @@ declare class V3Context {
2368
2389
  awaitActivePage(timeoutMs?: number): Promise<Page>;
2369
2390
  }
2370
2391
 
2392
+ type AgentCacheTransferPayload = {
2393
+ cacheKey: string;
2394
+ entry: CachedAgentEntry;
2395
+ };
2371
2396
  type AgentReplayStep = AgentReplayActStep | AgentReplayFillFormStep | AgentReplayGotoStep | AgentReplayScrollStep | AgentReplayWaitStep | AgentReplayNavBackStep | AgentReplayKeysStep | {
2372
2397
  type: string;
2373
2398
  [key: string]: unknown;
@@ -2421,6 +2446,20 @@ interface AgentReplayKeysStep {
2421
2446
  times?: number;
2422
2447
  };
2423
2448
  }
2449
+ interface SanitizedAgentExecuteOptions {
2450
+ maxSteps?: number;
2451
+ highlightCursor?: boolean;
2452
+ }
2453
+ interface CachedAgentEntry {
2454
+ version: 1;
2455
+ instruction: string;
2456
+ startUrl: string;
2457
+ options: SanitizedAgentExecuteOptions;
2458
+ configSignature: string;
2459
+ steps: AgentReplayStep[];
2460
+ result: AgentResult;
2461
+ timestamp: string;
2462
+ }
2424
2463
 
2425
2464
  /**
2426
2465
  * Response
@@ -2558,6 +2597,12 @@ type AnyPage = Page$1 | Page$2 | Page$3 | Page;
2558
2597
 
2559
2598
  type LoadState = "load" | "domcontentloaded" | "networkidle";
2560
2599
 
2600
+ type SnapshotResult = {
2601
+ formattedTree: string;
2602
+ xpathMap: Record<string, string>;
2603
+ urlMap: Record<string, string>;
2604
+ };
2605
+
2561
2606
  type ScreenshotAnimationsOption = "disabled" | "allow";
2562
2607
  type ScreenshotCaretOption = "hide" | "initial";
2563
2608
  type ScreenshotScaleOption = "css" | "device";
@@ -2800,6 +2845,30 @@ declare class Page {
2800
2845
  * Mirrors Playwright's API signatures.
2801
2846
  */
2802
2847
  waitForLoadState(state: LoadState, timeoutMs?: number): Promise<void>;
2848
+ /**
2849
+ * Wait for a specified amount of time.
2850
+ *
2851
+ * @param ms The number of milliseconds to wait.
2852
+ */
2853
+ waitForTimeout(ms: number): Promise<void>;
2854
+ /**
2855
+ * Wait for an element matching the selector to appear in the DOM.
2856
+ * Uses MutationObserver for efficiency
2857
+ * Pierces shadow DOM by default.
2858
+ * Supports iframe hop notation with '>>' (e.g., 'iframe#checkout >> .submit-btn').
2859
+ *
2860
+ * @param selector CSS selector to wait for (supports '>>' for iframe hops)
2861
+ * @param options.state Element state to wait for: 'attached' | 'detached' | 'visible' | 'hidden' (default: 'visible')
2862
+ * @param options.timeout Maximum time to wait in milliseconds (default: 30000)
2863
+ * @param options.pierceShadow Whether to search inside shadow DOM (default: true)
2864
+ * @returns True when the condition is met
2865
+ * @throws Error if timeout is reached before the condition is met
2866
+ */
2867
+ waitForSelector(selector: string, options?: {
2868
+ state?: "attached" | "detached" | "visible" | "hidden";
2869
+ timeout?: number;
2870
+ pierceShadow?: boolean;
2871
+ }): Promise<boolean>;
2803
2872
  /**
2804
2873
  * Evaluate a function or expression in the current main frame's main world.
2805
2874
  * - If a string is provided, it is treated as a JS expression.
@@ -2865,6 +2934,7 @@ declare class Page {
2865
2934
  keyPress(key: string, options?: {
2866
2935
  delay?: number;
2867
2936
  }): Promise<void>;
2937
+ snapshot(): Promise<SnapshotResult>;
2868
2938
  private _pressedModifiers;
2869
2939
  /** Press a key down without releasing it */
2870
2940
  private keyDown;
@@ -2944,6 +3014,12 @@ interface AgentResult {
2944
3014
  * @experimental
2945
3015
  */
2946
3016
  messages?: ModelMessage[];
3017
+ /**
3018
+ * Custom output data extracted based on the `output` schema provided in execute options.
3019
+ * Only populated if an `output` schema was provided.
3020
+ * @experimental
3021
+ */
3022
+ output?: Record<string, unknown>;
2947
3023
  }
2948
3024
  type AgentStreamResult = StreamTextResult<ToolSet, never> & {
2949
3025
  result: Promise<AgentResult>;
@@ -3166,6 +3242,26 @@ interface AgentExecuteOptionsBase {
3166
3242
  * ```
3167
3243
  */
3168
3244
  excludeTools?: string[];
3245
+ /**
3246
+ * A Zod schema defining custom output data to return when the task completes.
3247
+ * The agent will populate this data in the final close tool call.
3248
+ *
3249
+ * @experimental
3250
+ * @example
3251
+ * ```typescript
3252
+ * const result = await agent.execute({
3253
+ * instruction: "Find the cheapest flight from NYC to LA",
3254
+ * output: z.object({
3255
+ * price: z.string().describe("The price of the flight"),
3256
+ * airline: z.string().describe("The airline name"),
3257
+ * departureTime: z.string().describe("Departure time"),
3258
+ * }),
3259
+ * });
3260
+ *
3261
+ * console.log(result.output); // { price: "$199", airline: "Delta", departureTime: "8:00 AM" }
3262
+ * ```
3263
+ */
3264
+ output?: StagehandZodObject;
3169
3265
  }
3170
3266
  /**
3171
3267
  * Options for non-streaming agent execution.
@@ -3397,6 +3493,63 @@ interface StreamingAgentInstance {
3397
3493
  interface NonStreamingAgentInstance {
3398
3494
  execute: (instructionOrOptions: string | AgentExecuteOptions) => Promise<AgentResult>;
3399
3495
  }
3496
+ /**
3497
+ * Content item type for toModelOutput return values.
3498
+ * Used in tool definitions to return text and/or media to the model.
3499
+ */
3500
+ type ModelOutputContentItem = {
3501
+ type: "text";
3502
+ text: string;
3503
+ } | {
3504
+ type: "media";
3505
+ mediaType: string;
3506
+ data: string;
3507
+ };
3508
+ interface ClickToolResult {
3509
+ success: boolean;
3510
+ describe?: string;
3511
+ coordinates?: number[];
3512
+ error?: string;
3513
+ screenshotBase64?: string;
3514
+ }
3515
+ interface TypeToolResult {
3516
+ success: boolean;
3517
+ describe?: string;
3518
+ text?: string;
3519
+ error?: string;
3520
+ screenshotBase64?: string;
3521
+ }
3522
+ interface DragAndDropToolResult {
3523
+ success: boolean;
3524
+ describe?: string;
3525
+ error?: string;
3526
+ screenshotBase64?: string;
3527
+ }
3528
+ interface FillFormField {
3529
+ action: string;
3530
+ value: string;
3531
+ coordinates: {
3532
+ x: number;
3533
+ y: number;
3534
+ };
3535
+ }
3536
+ interface FillFormVisionToolResult {
3537
+ success: boolean;
3538
+ playwrightArguments?: FillFormField[];
3539
+ error?: string;
3540
+ screenshotBase64?: string;
3541
+ }
3542
+ interface ScrollVisionToolResult {
3543
+ success: boolean;
3544
+ message: string;
3545
+ scrolledPixels: number;
3546
+ screenshotBase64?: string;
3547
+ }
3548
+ interface WaitToolResult {
3549
+ success: boolean;
3550
+ waited: number;
3551
+ screenshotBase64?: string;
3552
+ }
3400
3553
 
3401
3554
  type OpenAIClientOptions = Pick<ClientOptions$1, "baseURL" | "apiKey">;
3402
3555
  type AnthropicClientOptions = Pick<ClientOptions$2, "baseURL" | "apiKey">;
@@ -3809,12 +3962,9 @@ declare const screenshotTool: (v3: V3) => ai.Tool<Record<string, never>, {
3809
3962
  pageUrl: string;
3810
3963
  }>;
3811
3964
 
3812
- declare const waitTool: (v3: V3) => ai.Tool<{
3965
+ declare const waitTool: (v3: V3, mode?: AgentToolMode) => ai.Tool<{
3813
3966
  timeMs: number;
3814
- }, {
3815
- success: boolean;
3816
- waited: number;
3817
- }>;
3967
+ }, WaitToolResult>;
3818
3968
 
3819
3969
  declare const navBackTool: (v3: V3) => ai.Tool<{
3820
3970
  reasoningText: string;
@@ -3822,15 +3972,6 @@ declare const navBackTool: (v3: V3) => ai.Tool<{
3822
3972
  success: boolean;
3823
3973
  }>;
3824
3974
 
3825
- declare const closeTool: () => ai.Tool<{
3826
- reasoning: string;
3827
- taskComplete: boolean;
3828
- }, {
3829
- success: boolean;
3830
- reasoning: string;
3831
- taskComplete: boolean;
3832
- }>;
3833
-
3834
3975
  declare const ariaTreeTool: (v3: V3) => ai.Tool<Record<string, never>, {
3835
3976
  content: string;
3836
3977
  pageUrl: string;
@@ -3867,11 +4008,7 @@ declare const scrollVisionTool: (v3: V3, provider?: string) => ai.Tool<{
3867
4008
  direction: "up" | "down";
3868
4009
  coordinates?: number[];
3869
4010
  percentage?: number;
3870
- }, {
3871
- success: boolean;
3872
- message: string;
3873
- scrolledPixels: number;
3874
- }>;
4011
+ }, ScrollVisionToolResult>;
3875
4012
 
3876
4013
  declare const extractTool: (v3: V3, executionModel?: string, logger?: (message: LogLine) => void) => ai.Tool<{
3877
4014
  instruction: string;
@@ -3889,47 +4026,19 @@ declare const extractTool: (v3: V3, executionModel?: string, logger?: (message:
3889
4026
  declare const clickTool: (v3: V3, provider?: string) => ai.Tool<{
3890
4027
  describe: string;
3891
4028
  coordinates: number[];
3892
- }, {
3893
- success: boolean;
3894
- describe: string;
3895
- coordinates: number[];
3896
- error?: undefined;
3897
- } | {
3898
- success: boolean;
3899
- error: string;
3900
- describe?: undefined;
3901
- coordinates?: undefined;
3902
- }>;
4029
+ }, ClickToolResult>;
3903
4030
 
3904
4031
  declare const typeTool: (v3: V3, provider?: string) => ai.Tool<{
3905
4032
  describe: string;
3906
4033
  text: string;
3907
4034
  coordinates: number[];
3908
- }, {
3909
- success: boolean;
3910
- describe: string;
3911
- text: string;
3912
- error?: undefined;
3913
- } | {
3914
- success: boolean;
3915
- error: string;
3916
- describe?: undefined;
3917
- text?: undefined;
3918
- }>;
4035
+ }, TypeToolResult>;
3919
4036
 
3920
4037
  declare const dragAndDropTool: (v3: V3, provider?: string) => ai.Tool<{
3921
4038
  describe: string;
3922
4039
  startCoordinates: number[];
3923
4040
  endCoordinates: number[];
3924
- }, {
3925
- success: boolean;
3926
- describe: string;
3927
- error?: undefined;
3928
- } | {
3929
- success: boolean;
3930
- error: string;
3931
- describe?: undefined;
3932
- }>;
4041
+ }, DragAndDropToolResult>;
3933
4042
 
3934
4043
  declare const clickAndHoldTool: (v3: V3, provider?: string) => ai.Tool<{
3935
4044
  describe: string;
@@ -3978,22 +4087,7 @@ declare const fillFormVisionTool: (v3: V3, provider?: string) => ai.Tool<{
3978
4087
  y: number;
3979
4088
  };
3980
4089
  }[];
3981
- }, {
3982
- success: boolean;
3983
- playwrightArguments: {
3984
- coordinates: {
3985
- x: number;
3986
- y: number;
3987
- };
3988
- action: string;
3989
- value: string;
3990
- }[];
3991
- error?: undefined;
3992
- } | {
3993
- success: boolean;
3994
- error: string;
3995
- playwrightArguments?: undefined;
3996
- }>;
4090
+ }, FillFormVisionToolResult>;
3997
4091
 
3998
4092
  declare const thinkTool: () => ai.Tool<{
3999
4093
  reasoning: string;
@@ -4047,7 +4141,6 @@ type AgentToolTypesMap = {
4047
4141
  ariaTree: ReturnType<typeof ariaTreeTool>;
4048
4142
  click: ReturnType<typeof clickTool>;
4049
4143
  clickAndHold: ReturnType<typeof clickAndHoldTool>;
4050
- close: ReturnType<typeof closeTool>;
4051
4144
  dragAndDrop: ReturnType<typeof dragAndDropTool>;
4052
4145
  extract: ReturnType<typeof extractTool>;
4053
4146
  fillForm: ReturnType<typeof fillFormTool>;
@@ -4181,4 +4274,10 @@ declare class V3Evaluator {
4181
4274
  private _evaluateWithMultipleScreenshots;
4182
4275
  }
4183
4276
 
4184
- export { type AISDKCustomProvider, type AISDKProvider, AISdkClient, AVAILABLE_CUA_MODELS, type ActOptions, type ActResult, ActTimeoutError, type Action, type ActionExecutionResult, AgentAbortError, type AgentAction, type AgentCallbacks, type AgentConfig, type AgentContext, type AgentExecuteCallbacks, type AgentExecuteOptions, type AgentExecuteOptionsBase, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type AgentResult, AgentScreenshotProviderError, type AgentState, type AgentStreamCallbacks, type AgentStreamExecuteOptions, type AgentStreamResult, type AgentToolCall, type AgentToolMode, type AgentToolResult, type AgentToolTypesMap, type AgentTools, type AgentType, type AgentUITools, AnnotatedScreenshotText, type AnthropicClientOptions, type AnthropicContentBlock, type AnthropicJsonSchemaObject, type AnthropicMessage, type AnthropicTextBlock, type AnthropicToolResult, type AnyPage, api as Api, type AvailableCuaModel, type AvailableModel, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, type ChatCompletionOptions, type ChatMessage, type ChatMessageContent, type ChatMessageImageContent, type ChatMessageTextContent, type ClientOptions, type ComputerCallItem, ConnectionTimeoutError, type ConsoleListener, ConsoleMessage, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, CuaModelRequiredError, ElementNotVisibleError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, ExtractTimeoutError, type FunctionCallItem, type GoogleServiceAccountCredentials, type GoogleVertexProviderSettings, HandlerNotInitializedError, type HistoryEntry, type InferStagehandSchema, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaDocument, type JsonSchemaProperty, LLMClient, type LLMParsedResponse, type LLMResponse, LLMResponseError, type LLMTool, type LLMUsage, LOG_LEVEL_NAMES, type LoadState, type LocalBrowserLaunchOptions, type LogLevel, type LogLine, type Logger, MCPConnectionError, MissingEnvironmentVariableError, MissingLLMConfigurationError, type ModelConfiguration, type ModelProvider, type NonStreamingAgentInstance, type ObserveOptions, ObserveTimeoutError, type OpenAIClientOptions, Page, PageNotFoundError, Response$1 as Response, ResponseBodyError, type ResponseInputItem, type ResponseItem, ResponseParseError, type SafetyCheck, type SafetyConfirmationHandler, type SafetyConfirmationResponse, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandClosedError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, type StagehandMetrics, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, type StagehandZodObject, type StagehandZodSchema, type StreamingAgentInstance, StreamingCallbacksInNonStreamingModeError, TimeoutError, type ToolUseItem, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type V3Options, XPathResolutionError, ZodSchemaValidationError, connectToMCPServer, defaultExtractSchema, getZodType, injectUrls, isRunningInBun, isZod3Schema, isZod4Schema, jsonSchemaToZod, loadApiKeyFromEnv, localBrowserLaunchOptionsSchema, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, toJsonSchema, transformSchema, trimTrailingTextNode, validateZodSchema };
4277
+ interface ServerAgentCacheHandle {
4278
+ complete(): AgentCacheTransferPayload | null;
4279
+ discard(): void;
4280
+ }
4281
+ declare function __internalCreateInMemoryAgentCacheHandle(stagehand: V3): ServerAgentCacheHandle;
4282
+
4283
+ export { type AISDKCustomProvider, type AISDKProvider, AISdkClient, AVAILABLE_CUA_MODELS, type ActOptions, type ActResult, ActTimeoutError, type Action, type ActionExecutionResult, AgentAbortError, type AgentAction, type AgentCallbacks, type AgentConfig, type AgentContext, type AgentExecuteCallbacks, type AgentExecuteOptions, type AgentExecuteOptionsBase, type AgentExecutionOptions, type AgentHandlerOptions, type AgentInstance, type AgentModelConfig, AgentProvider, type AgentProviderType, type AgentResult, AgentScreenshotProviderError, type AgentState, type AgentStreamCallbacks, type AgentStreamExecuteOptions, type AgentStreamResult, type AgentToolCall, type AgentToolMode, type AgentToolResult, type AgentToolTypesMap, type AgentTools, type AgentType, type AgentUITools, AnnotatedScreenshotText, type AnthropicClientOptions, type AnthropicContentBlock, type AnthropicJsonSchemaObject, type AnthropicMessage, type AnthropicTextBlock, type AnthropicToolResult, type AnyPage, api as Api, type AvailableCuaModel, type AvailableModel, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, type ChatCompletionOptions, type ChatMessage, type ChatMessageContent, type ChatMessageImageContent, type ChatMessageTextContent, type ClickToolResult, type ClientOptions, type ComputerCallItem, ConnectionTimeoutError, type ConsoleListener, ConsoleMessage, ContentFrameNotFoundError, type CreateChatCompletionOptions, CreateChatCompletionResponseError, CuaModelRequiredError, type DragAndDropToolResult, ElementNotVisibleError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, type ExtractOptions, type ExtractResult, ExtractTimeoutError, type FillFormField, type FillFormVisionToolResult, type FunctionCallItem, type GoogleServiceAccountCredentials, type GoogleVertexProviderSettings, HandlerNotInitializedError, type HistoryEntry, type InferStagehandSchema, InvalidAISDKModelFormatError, type JsonSchema, type JsonSchemaDocument, type JsonSchemaProperty, LLMClient, type LLMParsedResponse, type LLMResponse, LLMResponseError, type LLMTool, type LLMUsage, LOG_LEVEL_NAMES, type LoadState, type LocalBrowserLaunchOptions, type LogLevel, type LogLine, type Logger, MCPConnectionError, MissingEnvironmentVariableError, MissingLLMConfigurationError, type ModelConfiguration, type ModelOutputContentItem, type ModelProvider, type NonStreamingAgentInstance, type ObserveOptions, ObserveTimeoutError, type OpenAIClientOptions, Page, PageNotFoundError, Response$1 as Response, ResponseBodyError, type ResponseInputItem, type ResponseItem, ResponseParseError, type SafetyCheck, type SafetyConfirmationHandler, type SafetyConfirmationResponse, type ScrollVisionToolResult, type ServerAgentCacheHandle, type SnapshotResult, V3 as Stagehand, StagehandAPIError, StagehandAPIUnauthorizedError, StagehandClickError, StagehandClosedError, StagehandDefaultError, StagehandDomProcessError, StagehandElementNotFoundError, StagehandEnvironmentError, StagehandError, StagehandEvalError, StagehandHttpError, StagehandIframeError, StagehandInitError, StagehandInvalidArgumentError, type StagehandMetrics, StagehandMissingArgumentError, StagehandNotInitializedError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, StagehandSnapshotError, type StagehandZodObject, type StagehandZodSchema, type StreamingAgentInstance, StreamingCallbacksInNonStreamingModeError, TimeoutError, type ToolUseItem, type TypeToolResult, UnsupportedAISDKModelProviderError, UnsupportedModelError, UnsupportedModelProviderError, V3, type V3Env, V3Evaluator, V3FunctionName, type V3Options, type WaitToolResult, XPathResolutionError, ZodSchemaValidationError, __internalCreateInMemoryAgentCacheHandle, connectToMCPServer, defaultExtractSchema, getZodType, injectUrls, isRunningInBun, isZod3Schema, isZod4Schema, jsonSchemaToZod, loadApiKeyFromEnv, localBrowserLaunchOptionsSchema, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, toJsonSchema, transformSchema, trimTrailingTextNode, validateZodSchema };