@browserbasehq/stagehand 3.0.7-alpha-934f492ec587bef81f0ce75b45a35b44ab545712 → 3.0.7-alpha-6a5496f17dbb716be1ee1aaa4e5ba9d8c723b30b
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/dist/index.d.ts +4 -1
- package/dist/index.js +36 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -817,6 +817,9 @@ declare class AgentAbortError extends StagehandError {
|
|
|
817
817
|
readonly reason: string;
|
|
818
818
|
constructor(reason?: string);
|
|
819
819
|
}
|
|
820
|
+
declare class StagehandClosedError extends StagehandError {
|
|
821
|
+
constructor();
|
|
822
|
+
}
|
|
820
823
|
|
|
821
824
|
declare class AISdkClient extends LLMClient {
|
|
822
825
|
type: "aisdk";
|
|
@@ -2474,4 +2477,4 @@ declare class V3Evaluator {
|
|
|
2474
2477
|
private _evaluateWithMultipleScreenshots;
|
|
2475
2478
|
}
|
|
2476
2479
|
|
|
2477
|
-
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 AgentType, AnnotatedScreenshotText, type AnthropicClientOptions, 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, 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, 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 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, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, toJsonSchema, transformSchema, trimTrailingTextNode, validateZodSchema };
|
|
2480
|
+
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 AgentType, AnnotatedScreenshotText, type AnthropicClientOptions, 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, 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, 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, modelToAgentProviderMap, pageTextSchema, providerEnvVarMap, toGeminiSchema, toJsonSchema, transformSchema, trimTrailingTextNode, validateZodSchema };
|
package/dist/index.js
CHANGED
|
@@ -179,12 +179,12 @@ var __forAwait = (obj, it, method) => (it = obj[__knownSymbol("asyncIterator")])
|
|
|
179
179
|
var STAGEHAND_VERSION;
|
|
180
180
|
var init_version = __esm({
|
|
181
181
|
"lib/version.ts"() {
|
|
182
|
-
STAGEHAND_VERSION = "3.0.7-alpha-
|
|
182
|
+
STAGEHAND_VERSION = "3.0.7-alpha-6a5496f17dbb716be1ee1aaa4e5ba9d8c723b30b";
|
|
183
183
|
}
|
|
184
184
|
});
|
|
185
185
|
|
|
186
186
|
// lib/v3/types/public/sdkErrors.ts
|
|
187
|
-
var StagehandError, StagehandDefaultError, StagehandEnvironmentError, MissingEnvironmentVariableError, UnsupportedModelError, UnsupportedModelProviderError, UnsupportedAISDKModelProviderError, InvalidAISDKModelFormatError, StagehandNotInitializedError, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, MissingLLMConfigurationError, HandlerNotInitializedError, StagehandInvalidArgumentError, StagehandElementNotFoundError, AgentScreenshotProviderError, StagehandMissingArgumentError, CreateChatCompletionResponseError, StagehandEvalError, StagehandDomProcessError, StagehandClickError, LLMResponseError, StagehandIframeError, ContentFrameNotFoundError, XPathResolutionError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, CuaModelRequiredError, ZodSchemaValidationError, StagehandInitError, MCPConnectionError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, ElementNotVisibleError, ResponseBodyError, ResponseParseError, TimeoutError, ActTimeoutError, ExtractTimeoutError, ObserveTimeoutError, PageNotFoundError, ConnectionTimeoutError, StreamingCallbacksInNonStreamingModeError, AgentAbortError;
|
|
187
|
+
var StagehandError, StagehandDefaultError, StagehandEnvironmentError, MissingEnvironmentVariableError, UnsupportedModelError, UnsupportedModelProviderError, UnsupportedAISDKModelProviderError, InvalidAISDKModelFormatError, StagehandNotInitializedError, BrowserbaseSessionNotFoundError, CaptchaTimeoutError, MissingLLMConfigurationError, HandlerNotInitializedError, StagehandInvalidArgumentError, StagehandElementNotFoundError, AgentScreenshotProviderError, StagehandMissingArgumentError, CreateChatCompletionResponseError, StagehandEvalError, StagehandDomProcessError, StagehandClickError, LLMResponseError, StagehandIframeError, ContentFrameNotFoundError, XPathResolutionError, ExperimentalApiConflictError, ExperimentalNotConfiguredError, CuaModelRequiredError, ZodSchemaValidationError, StagehandInitError, MCPConnectionError, StagehandShadowRootMissingError, StagehandShadowSegmentEmptyError, StagehandShadowSegmentNotFoundError, ElementNotVisibleError, ResponseBodyError, ResponseParseError, TimeoutError, ActTimeoutError, ExtractTimeoutError, ObserveTimeoutError, PageNotFoundError, ConnectionTimeoutError, StreamingCallbacksInNonStreamingModeError, AgentAbortError, StagehandClosedError;
|
|
188
188
|
var init_sdkErrors = __esm({
|
|
189
189
|
"lib/v3/types/public/sdkErrors.ts"() {
|
|
190
190
|
init_version();
|
|
@@ -477,6 +477,11 @@ ${JSON.stringify(issues, null, 2)}`);
|
|
|
477
477
|
this.reason = reason || "aborted";
|
|
478
478
|
}
|
|
479
479
|
};
|
|
480
|
+
StagehandClosedError = class extends StagehandError {
|
|
481
|
+
constructor() {
|
|
482
|
+
super("Stagehand session was closed");
|
|
483
|
+
}
|
|
484
|
+
};
|
|
480
485
|
}
|
|
481
486
|
});
|
|
482
487
|
|
|
@@ -26869,6 +26874,7 @@ __export(v3_exports, {
|
|
|
26869
26874
|
StagehandAPIError: () => StagehandAPIError,
|
|
26870
26875
|
StagehandAPIUnauthorizedError: () => StagehandAPIUnauthorizedError,
|
|
26871
26876
|
StagehandClickError: () => StagehandClickError,
|
|
26877
|
+
StagehandClosedError: () => StagehandClosedError,
|
|
26872
26878
|
StagehandDefaultError: () => StagehandDefaultError,
|
|
26873
26879
|
StagehandDomProcessError: () => StagehandDomProcessError,
|
|
26874
26880
|
StagehandElementNotFoundError: () => StagehandElementNotFoundError,
|
|
@@ -31924,6 +31930,9 @@ var AnthropicCUAClient = class extends AgentClient {
|
|
|
31924
31930
|
});
|
|
31925
31931
|
yield this.actionHandler(action);
|
|
31926
31932
|
} catch (error) {
|
|
31933
|
+
if (error instanceof StagehandClosedError) {
|
|
31934
|
+
throw error;
|
|
31935
|
+
}
|
|
31927
31936
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
31928
31937
|
logger({
|
|
31929
31938
|
category: "agent",
|
|
@@ -32763,6 +32772,9 @@ var OpenAICUAClient = class extends AgentClient {
|
|
|
32763
32772
|
}
|
|
32764
32773
|
nextInputItems.push(outputItem);
|
|
32765
32774
|
} catch (error) {
|
|
32775
|
+
if (error instanceof StagehandClosedError) {
|
|
32776
|
+
throw error;
|
|
32777
|
+
}
|
|
32766
32778
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
32767
32779
|
logger({
|
|
32768
32780
|
category: "agent",
|
|
@@ -32790,6 +32802,9 @@ var OpenAICUAClient = class extends AgentClient {
|
|
|
32790
32802
|
}
|
|
32791
32803
|
nextInputItems.push(errorOutputItem);
|
|
32792
32804
|
} catch (screenshotError) {
|
|
32805
|
+
if (screenshotError instanceof StagehandClosedError) {
|
|
32806
|
+
throw screenshotError;
|
|
32807
|
+
}
|
|
32793
32808
|
logger({
|
|
32794
32809
|
category: "agent",
|
|
32795
32810
|
message: `Error capturing screenshot: ${String(screenshotError)}`,
|
|
@@ -32845,6 +32860,9 @@ var OpenAICUAClient = class extends AgentClient {
|
|
|
32845
32860
|
};
|
|
32846
32861
|
nextInputItems.push(outputItem);
|
|
32847
32862
|
} catch (error) {
|
|
32863
|
+
if (error instanceof StagehandClosedError) {
|
|
32864
|
+
throw error;
|
|
32865
|
+
}
|
|
32848
32866
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
32849
32867
|
logger({
|
|
32850
32868
|
category: "agent",
|
|
@@ -33396,6 +33414,9 @@ var GoogleCUAClient = class extends AgentClient {
|
|
|
33396
33414
|
yield new Promise((resolve3) => setTimeout(resolve3, delay2));
|
|
33397
33415
|
}
|
|
33398
33416
|
} catch (actionError) {
|
|
33417
|
+
if (actionError instanceof StagehandClosedError) {
|
|
33418
|
+
throw actionError;
|
|
33419
|
+
}
|
|
33399
33420
|
logger({
|
|
33400
33421
|
category: "agent",
|
|
33401
33422
|
message: `Error executing action ${action.type}: ${actionError}`,
|
|
@@ -34522,6 +34543,7 @@ var AgentProvider = class _AgentProvider {
|
|
|
34522
34543
|
|
|
34523
34544
|
// lib/v3/handlers/v3CuaAgentHandler.ts
|
|
34524
34545
|
init_flowLogger();
|
|
34546
|
+
init_sdkErrors();
|
|
34525
34547
|
var V3CuaAgentHandler = class {
|
|
34526
34548
|
constructor(v3, logger, options, tools) {
|
|
34527
34549
|
this.v3 = v3;
|
|
@@ -34538,14 +34560,25 @@ var V3CuaAgentHandler = class {
|
|
|
34538
34560
|
this.setupAgentClient();
|
|
34539
34561
|
this.agent = client;
|
|
34540
34562
|
}
|
|
34563
|
+
/**
|
|
34564
|
+
* Ensures the V3 context is still available (not closed).
|
|
34565
|
+
* Throws StagehandClosedError if stagehand.close() was called.
|
|
34566
|
+
*/
|
|
34567
|
+
ensureNotClosed() {
|
|
34568
|
+
if (!this.v3.context) {
|
|
34569
|
+
throw new StagehandClosedError();
|
|
34570
|
+
}
|
|
34571
|
+
}
|
|
34541
34572
|
setupAgentClient() {
|
|
34542
34573
|
this.agentClient.setScreenshotProvider(() => __async(this, null, function* () {
|
|
34574
|
+
this.ensureNotClosed();
|
|
34543
34575
|
const page = yield this.v3.context.awaitActivePage();
|
|
34544
34576
|
const base64 = yield page.screenshot({ fullPage: false });
|
|
34545
34577
|
return base64.toString("base64");
|
|
34546
34578
|
}));
|
|
34547
34579
|
this.agentClient.setActionHandler((action) => __async(this, null, function* () {
|
|
34548
34580
|
var _a4, _b, _c;
|
|
34581
|
+
this.ensureNotClosed();
|
|
34549
34582
|
action.pageUrl = (yield this.v3.context.awaitActivePage()).url();
|
|
34550
34583
|
const defaultDelay = 500;
|
|
34551
34584
|
const waitBetween = ((_a4 = this.options.clientOptions) == null ? void 0 : _a4.waitBetweenActions) || defaultDelay;
|
|
@@ -66078,6 +66111,7 @@ I'm providing ${screenshots.length} screenshots showing the progression of the t
|
|
|
66078
66111
|
StagehandAPIError,
|
|
66079
66112
|
StagehandAPIUnauthorizedError,
|
|
66080
66113
|
StagehandClickError,
|
|
66114
|
+
StagehandClosedError,
|
|
66081
66115
|
StagehandDefaultError,
|
|
66082
66116
|
StagehandDomProcessError,
|
|
66083
66117
|
StagehandElementNotFoundError,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@browserbasehq/stagehand",
|
|
3
|
-
"version": "3.0.7-alpha-
|
|
3
|
+
"version": "3.0.7-alpha-6a5496f17dbb716be1ee1aaa4e5ba9d8c723b30b",
|
|
4
4
|
"description": "An AI web browsing framework focused on simplicity and extensibility.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|