@browserbasehq/orca 3.1.0-patch.1 → 3.1.0-patch.3
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/cjs/cli.js +45 -17
- package/dist/cjs/cli.js.map +2 -2
- package/dist/cjs/index.js +192 -123
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/lib/logger.d.ts +1 -1
- package/dist/cjs/lib/modelUtils.d.ts +3 -0
- package/dist/cjs/lib/v3/agent/tools/act.d.ts +2 -1
- package/dist/cjs/lib/v3/agent/tools/extract.d.ts +2 -1
- package/dist/cjs/lib/v3/agent/tools/fillform.d.ts +2 -1
- package/dist/cjs/lib/v3/agent/tools/index.d.ts +2 -2
- package/dist/cjs/lib/v3/api.d.ts +16 -1
- package/dist/cjs/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +0 -3
- package/dist/cjs/lib/v3/handlers/v3AgentHandler.d.ts +2 -2
- package/dist/cjs/lib/v3/tests/agent-callbacks.spec.js +12 -12
- package/dist/cjs/lib/v3/tests/agent-callbacks.spec.js.map +1 -1
- package/dist/cjs/lib/v3/tests/context-addInitScript.spec.js +2 -2
- package/dist/cjs/lib/v3/tests/context-addInitScript.spec.js.map +1 -1
- package/dist/cjs/lib/v3/tests/locator-content-methods.spec.js +1 -0
- package/dist/cjs/lib/v3/tests/locator-content-methods.spec.js.map +1 -1
- package/dist/cjs/lib/v3/tests/locator-fill.spec.js +1 -0
- package/dist/cjs/lib/v3/tests/locator-fill.spec.js.map +1 -1
- package/dist/cjs/lib/v3/tests/locator-input-methods.spec.js +1 -0
- package/dist/cjs/lib/v3/tests/locator-input-methods.spec.js.map +1 -1
- package/dist/cjs/lib/v3/tests/locator-select-option.spec.js +1 -0
- package/dist/cjs/lib/v3/tests/locator-select-option.spec.js.map +1 -1
- package/dist/cjs/lib/v3/tests/page-addInitScript.spec.js +2 -2
- package/dist/cjs/lib/v3/tests/page-addInitScript.spec.js.map +1 -1
- package/dist/cjs/lib/v3/types/public/api.d.ts +8 -0
- package/dist/cjs/lib/v3/types/public/index.d.ts +1 -0
- package/dist/cjs/lib/v3/types/public/sdkErrors.d.ts +3 -0
- package/dist/cjs/tests/agent-execution-model.test.js +139 -0
- package/dist/cjs/tests/agent-execution-model.test.js.map +7 -0
- package/dist/cjs/tests/api-multiregion.test.js +73 -0
- package/dist/cjs/tests/api-multiregion.test.js.map +7 -0
- package/dist/cjs/tests/model-utils.test.js +43 -0
- package/dist/cjs/tests/model-utils.test.js.map +7 -0
- package/dist/cjs/tests/public-api/export-surface.test.js +1 -0
- package/dist/cjs/tests/public-api/export-surface.test.js.map +1 -1
- package/dist/cjs/tests/public-api/llm-and-agents.test.js +1 -0
- package/dist/cjs/tests/public-api/llm-and-agents.test.js.map +1 -1
- package/dist/cjs/tests/public-api/public-error-types.test.js +3 -1
- package/dist/cjs/tests/public-api/public-error-types.test.js.map +2 -2
- package/dist/cjs/tests/public-api/v3-core.test.js +1 -0
- package/dist/cjs/tests/public-api/v3-core.test.js.map +1 -1
- package/dist/cjs/tests/snapshot-capture-orchestration.test.js +2 -0
- package/dist/cjs/tests/snapshot-capture-orchestration.test.js.map +1 -1
- package/dist/cjs/tests/understudy-command-exception.test.js +52 -0
- package/dist/cjs/tests/understudy-command-exception.test.js.map +7 -0
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/lib/logger.d.ts +1 -1
- package/dist/esm/lib/modelUtils.d.ts +3 -0
- package/dist/esm/lib/modelUtils.js +7 -2
- package/dist/esm/lib/modelUtils.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/act.d.ts +2 -1
- package/dist/esm/lib/v3/agent/tools/act.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/extract.d.ts +2 -1
- package/dist/esm/lib/v3/agent/tools/extract.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/fillform.d.ts +2 -1
- package/dist/esm/lib/v3/agent/tools/fillform.js.map +1 -1
- package/dist/esm/lib/v3/agent/tools/index.d.ts +2 -2
- package/dist/esm/lib/v3/agent/tools/index.js.map +1 -1
- package/dist/esm/lib/v3/api.d.ts +16 -1
- package/dist/esm/lib/v3/api.js +41 -5
- package/dist/esm/lib/v3/api.js.map +1 -1
- package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.d.ts +0 -3
- package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js +22 -20
- package/dist/esm/lib/v3/handlers/handlerUtils/actHandlerUtils.js.map +1 -1
- package/dist/esm/lib/v3/handlers/v3AgentHandler.d.ts +2 -2
- package/dist/esm/lib/v3/handlers/v3AgentHandler.js.map +1 -1
- package/dist/esm/lib/v3/llm/aisdk.js +5 -2
- package/dist/esm/lib/v3/llm/aisdk.js.map +1 -1
- package/dist/esm/lib/v3/shutdown/supervisor.js +36 -17
- package/dist/esm/lib/v3/shutdown/supervisor.js.map +1 -1
- package/dist/esm/lib/v3/shutdown/supervisorClient.js +2 -1
- package/dist/esm/lib/v3/shutdown/supervisorClient.js.map +1 -1
- package/dist/esm/lib/v3/tests/agent-callbacks.spec.js +12 -12
- package/dist/esm/lib/v3/tests/agent-callbacks.spec.js.map +1 -1
- package/dist/esm/lib/v3/tests/context-addInitScript.spec.js +2 -2
- package/dist/esm/lib/v3/tests/context-addInitScript.spec.js.map +1 -1
- package/dist/esm/lib/v3/tests/locator-content-methods.spec.js +1 -0
- package/dist/esm/lib/v3/tests/locator-content-methods.spec.js.map +1 -1
- package/dist/esm/lib/v3/tests/locator-fill.spec.js +1 -0
- package/dist/esm/lib/v3/tests/locator-fill.spec.js.map +1 -1
- package/dist/esm/lib/v3/tests/locator-input-methods.spec.js +1 -0
- package/dist/esm/lib/v3/tests/locator-input-methods.spec.js.map +1 -1
- package/dist/esm/lib/v3/tests/locator-select-option.spec.js +1 -0
- package/dist/esm/lib/v3/tests/locator-select-option.spec.js.map +1 -1
- package/dist/esm/lib/v3/tests/page-addInitScript.spec.js +2 -2
- package/dist/esm/lib/v3/tests/page-addInitScript.spec.js.map +1 -1
- package/dist/esm/lib/v3/types/public/api.d.ts +8 -0
- package/dist/esm/lib/v3/types/public/api.js +5 -3
- package/dist/esm/lib/v3/types/public/api.js.map +1 -1
- package/dist/esm/lib/v3/types/public/index.d.ts +1 -0
- package/dist/esm/lib/v3/types/public/index.js.map +1 -1
- package/dist/esm/lib/v3/types/public/sdkErrors.d.ts +3 -0
- package/dist/esm/lib/v3/types/public/sdkErrors.js +12 -6
- package/dist/esm/lib/v3/types/public/sdkErrors.js.map +1 -1
- package/dist/esm/lib/v3/v3.js +7 -8
- package/dist/esm/lib/v3/v3.js.map +1 -1
- package/dist/esm/tests/agent-execution-model.test.js +139 -0
- package/dist/esm/tests/agent-execution-model.test.js.map +7 -0
- package/dist/esm/tests/api-multiregion.test.js +73 -0
- package/dist/esm/tests/api-multiregion.test.js.map +7 -0
- package/dist/esm/tests/model-utils.test.js +43 -0
- package/dist/esm/tests/model-utils.test.js.map +7 -0
- package/dist/esm/tests/public-api/export-surface.test.js +1 -0
- package/dist/esm/tests/public-api/export-surface.test.js.map +1 -1
- package/dist/esm/tests/public-api/llm-and-agents.test.js +1 -0
- package/dist/esm/tests/public-api/llm-and-agents.test.js.map +1 -1
- package/dist/esm/tests/public-api/public-error-types.test.js +3 -1
- package/dist/esm/tests/public-api/public-error-types.test.js.map +2 -2
- package/dist/esm/tests/public-api/v3-core.test.js +1 -0
- package/dist/esm/tests/public-api/v3-core.test.js.map +1 -1
- package/dist/esm/tests/snapshot-capture-orchestration.test.js +2 -0
- package/dist/esm/tests/snapshot-capture-orchestration.test.js.map +1 -1
- package/dist/esm/tests/understudy-command-exception.test.js +55 -0
- package/dist/esm/tests/understudy-command-exception.test.js.map +7 -0
- package/package.json +1 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
var import_vitest = require("vitest");
|
|
2
|
+
var import_sdkErrors = require("../lib/v3/types/public/sdkErrors.js");
|
|
3
|
+
(0, import_vitest.describe)("UnderstudyCommandException", () => {
|
|
4
|
+
(0, import_vitest.it)("extends StagehandError", () => {
|
|
5
|
+
const err = new import_sdkErrors.UnderstudyCommandException("test");
|
|
6
|
+
(0, import_vitest.expect)(err).toBeInstanceOf(import_sdkErrors.StagehandError);
|
|
7
|
+
(0, import_vitest.expect)(err).toBeInstanceOf(Error);
|
|
8
|
+
});
|
|
9
|
+
(0, import_vitest.it)("has the correct name", () => {
|
|
10
|
+
const err = new import_sdkErrors.UnderstudyCommandException("test");
|
|
11
|
+
(0, import_vitest.expect)(err.name).toBe("UnderstudyCommandException");
|
|
12
|
+
});
|
|
13
|
+
(0, import_vitest.it)("preserves the message", () => {
|
|
14
|
+
const err = new import_sdkErrors.UnderstudyCommandException("something broke");
|
|
15
|
+
(0, import_vitest.expect)(err.message).toBe("something broke");
|
|
16
|
+
});
|
|
17
|
+
(0, import_vitest.it)("stores the original error as cause when provided", () => {
|
|
18
|
+
const original = new Error("root cause");
|
|
19
|
+
const err = new import_sdkErrors.UnderstudyCommandException("wrapper message", original);
|
|
20
|
+
(0, import_vitest.expect)(err.cause).toBe(original);
|
|
21
|
+
(0, import_vitest.expect)(err.cause.message).toBe("root cause");
|
|
22
|
+
(0, import_vitest.expect)(err.cause.stack).toBeDefined();
|
|
23
|
+
});
|
|
24
|
+
(0, import_vitest.it)("stores non-Error cause values", () => {
|
|
25
|
+
const err = new import_sdkErrors.UnderstudyCommandException("failed", "string cause");
|
|
26
|
+
(0, import_vitest.expect)(err.cause).toBe("string cause");
|
|
27
|
+
});
|
|
28
|
+
(0, import_vitest.it)("has undefined cause when none is provided", () => {
|
|
29
|
+
const err = new import_sdkErrors.UnderstudyCommandException("no cause");
|
|
30
|
+
(0, import_vitest.expect)(err.cause).toBeUndefined();
|
|
31
|
+
});
|
|
32
|
+
(0, import_vitest.it)("generates its own stack trace", () => {
|
|
33
|
+
const err = new import_sdkErrors.UnderstudyCommandException("test");
|
|
34
|
+
(0, import_vitest.expect)(err.stack).toBeDefined();
|
|
35
|
+
(0, import_vitest.expect)(err.stack).toContain("UnderstudyCommandException");
|
|
36
|
+
});
|
|
37
|
+
(0, import_vitest.it)("preserves the original stack via cause for debugging", () => {
|
|
38
|
+
function deepFunction() {
|
|
39
|
+
throw new Error("deep error");
|
|
40
|
+
}
|
|
41
|
+
let original;
|
|
42
|
+
try {
|
|
43
|
+
deepFunction();
|
|
44
|
+
} catch (e) {
|
|
45
|
+
original = e;
|
|
46
|
+
}
|
|
47
|
+
const wrapped = new import_sdkErrors.UnderstudyCommandException(original.message, original);
|
|
48
|
+
(0, import_vitest.expect)(wrapped.stack).toBeDefined();
|
|
49
|
+
(0, import_vitest.expect)(wrapped.cause.stack).toContain("deepFunction");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
//# sourceMappingURL=understudy-command-exception.test.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../tests/understudy-command-exception.test.ts"],
|
|
4
|
+
"sourcesContent": ["import { describe, expect, it } from \"vitest\";\nimport {\n UnderstudyCommandException,\n StagehandError,\n} from \"../lib/v3/types/public/sdkErrors.js\";\n\ndescribe(\"UnderstudyCommandException\", () => {\n it(\"extends StagehandError\", () => {\n const err = new UnderstudyCommandException(\"test\");\n expect(err).toBeInstanceOf(StagehandError);\n expect(err).toBeInstanceOf(Error);\n });\n\n it(\"has the correct name\", () => {\n const err = new UnderstudyCommandException(\"test\");\n expect(err.name).toBe(\"UnderstudyCommandException\");\n });\n\n it(\"preserves the message\", () => {\n const err = new UnderstudyCommandException(\"something broke\");\n expect(err.message).toBe(\"something broke\");\n });\n\n it(\"stores the original error as cause when provided\", () => {\n const original = new Error(\"root cause\");\n const err = new UnderstudyCommandException(\"wrapper message\", original);\n\n expect(err.cause).toBe(original);\n expect((err.cause as Error).message).toBe(\"root cause\");\n expect((err.cause as Error).stack).toBeDefined();\n });\n\n it(\"stores non-Error cause values\", () => {\n const err = new UnderstudyCommandException(\"failed\", \"string cause\");\n expect(err.cause).toBe(\"string cause\");\n });\n\n it(\"has undefined cause when none is provided\", () => {\n const err = new UnderstudyCommandException(\"no cause\");\n expect(err.cause).toBeUndefined();\n });\n\n it(\"generates its own stack trace\", () => {\n const err = new UnderstudyCommandException(\"test\");\n expect(err.stack).toBeDefined();\n expect(err.stack).toContain(\"UnderstudyCommandException\");\n });\n\n it(\"preserves the original stack via cause for debugging\", () => {\n function deepFunction() {\n throw new Error(\"deep error\");\n }\n\n let original: Error;\n try {\n deepFunction();\n } catch (e) {\n original = e as Error;\n }\n\n const wrapped = new UnderstudyCommandException(original!.message, original);\n\n // The wrapper has its own stack\n expect(wrapped.stack).toBeDefined();\n // The original stack is accessible via cause\n expect((wrapped.cause as Error).stack).toContain(\"deepFunction\");\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,oBAAqC;AACrC,uBAGO;AAAA,IAEP,wBAAS,8BAA8B,MAAM;AAC3C,wBAAG,0BAA0B,MAAM;AACjC,UAAM,MAAM,IAAI,4CAA2B,MAAM;AACjD,8BAAO,GAAG,EAAE,eAAe,+BAAc;AACzC,8BAAO,GAAG,EAAE,eAAe,KAAK;AAAA,EAClC,CAAC;AAED,wBAAG,wBAAwB,MAAM;AAC/B,UAAM,MAAM,IAAI,4CAA2B,MAAM;AACjD,8BAAO,IAAI,IAAI,EAAE,KAAK,4BAA4B;AAAA,EACpD,CAAC;AAED,wBAAG,yBAAyB,MAAM;AAChC,UAAM,MAAM,IAAI,4CAA2B,iBAAiB;AAC5D,8BAAO,IAAI,OAAO,EAAE,KAAK,iBAAiB;AAAA,EAC5C,CAAC;AAED,wBAAG,oDAAoD,MAAM;AAC3D,UAAM,WAAW,IAAI,MAAM,YAAY;AACvC,UAAM,MAAM,IAAI,4CAA2B,mBAAmB,QAAQ;AAEtE,8BAAO,IAAI,KAAK,EAAE,KAAK,QAAQ;AAC/B,8BAAQ,IAAI,MAAgB,OAAO,EAAE,KAAK,YAAY;AACtD,8BAAQ,IAAI,MAAgB,KAAK,EAAE,YAAY;AAAA,EACjD,CAAC;AAED,wBAAG,iCAAiC,MAAM;AACxC,UAAM,MAAM,IAAI,4CAA2B,UAAU,cAAc;AACnE,8BAAO,IAAI,KAAK,EAAE,KAAK,cAAc;AAAA,EACvC,CAAC;AAED,wBAAG,6CAA6C,MAAM;AACpD,UAAM,MAAM,IAAI,4CAA2B,UAAU;AACrD,8BAAO,IAAI,KAAK,EAAE,cAAc;AAAA,EAClC,CAAC;AAED,wBAAG,iCAAiC,MAAM;AACxC,UAAM,MAAM,IAAI,4CAA2B,MAAM;AACjD,8BAAO,IAAI,KAAK,EAAE,YAAY;AAC9B,8BAAO,IAAI,KAAK,EAAE,UAAU,4BAA4B;AAAA,EAC1D,CAAC;AAED,wBAAG,wDAAwD,MAAM;AAC/D,aAAS,eAAe;AACtB,YAAM,IAAI,MAAM,YAAY;AAAA,IAC9B;AAEA,QAAI;AACJ,QAAI;AACF,mBAAa;AAAA,IACf,SAAS,GAAG;AACV,iBAAW;AAAA,IACb;AAEA,UAAM,UAAU,IAAI,4CAA2B,SAAU,SAAS,QAAQ;AAG1E,8BAAO,QAAQ,KAAK,EAAE,YAAY;AAElC,8BAAQ,QAAQ,MAAgB,KAAK,EAAE,UAAU,cAAc;AAAA,EACjE,CAAC;AACH,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as Stagehand from "./lib/v3/index";
|
|
2
|
-
export * from "./lib/v3/index";
|
|
1
|
+
import * as Stagehand from "./lib/v3/index.js";
|
|
2
|
+
export * from "./lib/v3/index.js";
|
|
3
3
|
export default Stagehand;
|
package/dist/esm/lib/logger.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface LoggerOptions {
|
|
|
9
9
|
/**
|
|
10
10
|
* Creates a configured Pino logger instance
|
|
11
11
|
*/
|
|
12
|
-
export declare function createLogger(options?: LoggerOptions):
|
|
12
|
+
export declare function createLogger(options?: LoggerOptions): pino.Logger<never, boolean>;
|
|
13
13
|
/**
|
|
14
14
|
* StagehandLogger class that wraps Pino for our specific needs
|
|
15
15
|
*
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { ClientOptions, ModelConfiguration } from "./v3/types/public/model.js";
|
|
2
|
+
export declare function extractModelName(model?: string | {
|
|
3
|
+
modelName: string;
|
|
4
|
+
}): string | undefined;
|
|
2
5
|
export declare function splitModelName(model: string): {
|
|
3
6
|
provider: string;
|
|
4
7
|
modelName: string;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { AVAILABLE_CUA_MODELS, } from "./v3/types/public/agent.js";
|
|
2
|
+
//useful when resolving a model from string or object formats we accept
|
|
3
|
+
export function extractModelName(model) {
|
|
4
|
+
if (!model)
|
|
5
|
+
return undefined;
|
|
6
|
+
return typeof model === "string" ? model : model.modelName;
|
|
7
|
+
}
|
|
2
8
|
export function splitModelName(model) {
|
|
3
9
|
const firstSlashIndex = model.indexOf("/");
|
|
4
10
|
const provider = model.substring(0, firstSlashIndex);
|
|
@@ -6,8 +12,7 @@ export function splitModelName(model) {
|
|
|
6
12
|
return { provider, modelName };
|
|
7
13
|
}
|
|
8
14
|
export function resolveModel(model) {
|
|
9
|
-
|
|
10
|
-
const modelString = typeof model === "string" ? model : model.modelName;
|
|
15
|
+
const modelString = extractModelName(model);
|
|
11
16
|
const clientOptions = typeof model === "string"
|
|
12
17
|
? {}
|
|
13
18
|
: (() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modelUtils.js","sourceRoot":"","sources":["../../../lib/modelUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,oBAAoB,GAErB,MAAM,4BAA4B,CAAC;AAEpC,MAAM,UAAU,cAAc,CAAC,KAAa;IAI1C,MAAM,eAAe,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IAC3C,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,eAAe,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uDAAuD;IACvD,MAAM,mBAAmB,GAAG,aAAa,CAAC,QAAQ,KAAK,SAAS,CAAC;IAEjE,oFAAoF;IACpF,IAAI,QAAgB,CAAC;IACrB,IAAI,eAAuB,CAAC;IAE5B,IAAI,mBAAmB,EAAE,CAAC;QACxB,QAAQ,GAAG,aAAa,CAAC,QAAkB,CAAC;QAC5C,eAAe,GAAG,WAAW,CAAC,CAAC,2BAA2B;IAC5D,CAAC;SAAM,CAAC;QACN,kCAAkC;QAClC,MAAM,KAAK,GAAG,cAAc,CAAC,WAAW,CAAC,CAAC;QAC1C,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAC1B,eAAe,GAAG,KAAK,CAAC,SAAS,CAAC;IACpC,CAAC;IAED,4BAA4B;IAC5B,MAAM,KAAK,GACT,mBAAmB;QACnB,oBAAoB,CAAC,QAAQ,CAAC,WAAgC,CAAC,CAAC;IAElE,OAAO;QACL,QAAQ;QACR,SAAS,EAAE,eAAe;QAC1B,aAAa;QACb,KAAK;KACN,CAAC;AACJ,CAAC","sourcesContent":["import { ClientOptions, ModelConfiguration } from \"./v3/types/public/model.js\";\nimport {\n AVAILABLE_CUA_MODELS,\n AvailableCuaModel,\n} from \"./v3/types/public/agent.js\";\n\n//useful when resolving a model from string or object formats we accept\nexport function extractModelName(\n model?: string | { modelName: string },\n): string | undefined {\n if (!model) return undefined;\n return typeof model === \"string\" ? model : model.modelName;\n}\n\nexport function splitModelName(model: string): {\n provider: string;\n modelName: string;\n} {\n const firstSlashIndex = model.indexOf(\"/\");\n const provider = model.substring(0, firstSlashIndex);\n const modelName = model.substring(firstSlashIndex + 1);\n return { provider, modelName };\n}\n\nexport function resolveModel(model: string | ModelConfiguration): {\n provider: string;\n modelName: string;\n clientOptions: ClientOptions;\n isCua: boolean;\n} {\n const modelString = extractModelName(model)!;\n const clientOptions =\n typeof model === \"string\"\n ? {}\n : (() => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { modelName: _, ...rest } = model;\n return rest;\n })();\n\n // Check if provider is explicitly set in clientOptions\n const hasExplicitProvider = clientOptions.provider !== undefined;\n\n // If provider is explicitly set, don't split the model name - pass it through as-is\n let provider: string;\n let parsedModelName: string;\n\n if (hasExplicitProvider) {\n provider = clientOptions.provider as string;\n parsedModelName = modelString; // Keep the full model name\n } else {\n // Parse the model string normally\n const split = splitModelName(modelString);\n provider = split.provider;\n parsedModelName = split.modelName;\n }\n\n // Check if it's a CUA model\n const isCua =\n hasExplicitProvider ||\n AVAILABLE_CUA_MODELS.includes(modelString as AvailableCuaModel);\n\n return {\n provider,\n modelName: parsedModelName,\n clientOptions,\n isCua,\n };\n}\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { V3 } from "../../v3.js";
|
|
2
2
|
import type { Action } from "../../types/public/methods.js";
|
|
3
|
-
|
|
3
|
+
import type { AgentModelConfig } from "../../types/public/agent.js";
|
|
4
|
+
export declare const actTool: (v3: V3, executionModel?: string | AgentModelConfig) => import("ai").Tool<{
|
|
4
5
|
action: string;
|
|
5
6
|
}, {
|
|
6
7
|
success: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/act.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"act.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/act.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAM,EAAE,cAA0C,EAAE,EAAE,CAC5E,IAAI,CAAC;IACH,WAAW,EACT,+GAA+G;IACjH,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QAC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AAE,KAAK,EAAE,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACpE,CAAC;IACH,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport type { V3 } from \"../../v3.js\";\nimport type { Action } from \"../../types/public/methods.js\";\nimport type { AgentModelConfig } from \"../../types/public/agent.js\";\n\nexport const actTool = (v3: V3, executionModel?: string | AgentModelConfig) =>\n tool({\n description:\n \"Perform an action on the page (click, type). Provide a short, specific phrase that mentions the element type.\",\n inputSchema: z.object({\n action: z\n .string()\n .describe(\n 'Describe what to click or type, e.g. \"click the Login button\" or \"type \"John\" into the first name input\"',\n ),\n }),\n execute: async ({ action }) => {\n try {\n v3.logger({\n category: \"agent\",\n message: `Agent calling tool: act`,\n level: 1,\n auxiliary: {\n arguments: {\n value: action,\n type: \"string\",\n },\n },\n });\n const options = executionModel ? { model: executionModel } : undefined;\n const result = await v3.act(action, options);\n const actions = (result.actions as Action[] | undefined) ?? [];\n v3.recordAgentReplayStep({\n type: \"act\",\n instruction: action,\n actions,\n actionDescription: result.actionDescription,\n message: result.message,\n });\n // Only include playwrightArguments when actions exist\n // (undefined is not valid JSON and breaks AI SDK validation)\n const response: {\n success: boolean;\n action: string;\n playwrightArguments?: Action;\n } = {\n success: result.success ?? true,\n action: result?.actionDescription ?? action,\n };\n if (actions.length > 0) {\n response.playwrightArguments = actions[0];\n }\n return response;\n } catch (error) {\n return { success: false, error: error?.message ?? String(error) };\n }\n },\n });\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { V3 } from "../../v3.js";
|
|
2
|
-
|
|
2
|
+
import type { AgentModelConfig } from "../../types/public/agent.js";
|
|
3
|
+
export declare const extractTool: (v3: V3, executionModel?: string | AgentModelConfig) => import("ai").Tool<{
|
|
3
4
|
instruction: string;
|
|
4
5
|
schema?: {
|
|
5
6
|
[x: string]: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"extract.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/extract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAc,MAAM,KAAK,CAAC;AAYpC,SAAS,eAAe,CAAC,MAAkB;IACzC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,KAAK,GAA+B,EAAE,CAAC;YAC7C,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;gBACtB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;oBAC7D,KAAK,CAAC,GAAG,CAAC,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;gBACtC,CAAC;YACH,CAAC;YACD,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACzB,CAAC;QACD,KAAK,OAAO;YACV,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;QACzE,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC;YACnB,IAAI,MAAM,CAAC,MAAM,KAAK,KAAK;gBAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC;YACzC,IAAI,MAAM,CAAC,MAAM,KAAK,OA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IAAI,CAAC,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE;SACpD,CAAC;aACD,WAAW,EAAE;aACb,QAAQ,EAAE;aACV,QAAQ,CAAC,wDAAwD,CAAC;KACtE,CAAC;IACF,OAAO,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE;QACzC,IAAI,CAAC;YACH,MAAM,YAAY,GAAG,MAAM;gBACzB,CAAC,CAAC,eAAe,CAAC,MAAoB,CAAC;gBACvC,CAAC,CAAC,SAAS,CAAC;YACd,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,YAAY,EAAE;gBACzD,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACrD,CAAC,CAAC;YACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACnC,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,KAAc,CAAC;YAC3B,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QAClE,CAAC;IACH,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { tool } from \"ai\";\nimport { z, ZodTypeAny } from \"zod\";\nimport type { V3 } from \"../../v3.js\";\nimport type { AgentModelConfig } from \"../../types/public/agent.js\";\n\ninterface JsonSchema {\n type?: string;\n properties?: Record<string, JsonSchema>;\n items?: JsonSchema;\n enum?: string[];\n format?: \"url\" | \"email\" | \"uuid\";\n}\n\nfunction jsonSchemaToZod(schema: JsonSchema): ZodTypeAny {\n switch (schema.type) {\n case \"object\": {\n const shape: Record<string, ZodTypeAny> = {};\n if (schema.properties) {\n for (const [key, value] of Object.entries(schema.properties)) {\n shape[key] = jsonSchemaToZod(value);\n }\n }\n return z.object(shape);\n }\n case \"array\":\n return z.array(schema.items ? jsonSchemaToZod(schema.items) : z.any());\n case \"string\": {\n let s = z.string();\n if (schema.format === \"url\") s = s.url();\n if (schema.format === \"email\") s = s.email();\n if (schema.format === \"uuid\") s = s.uuid();\n if (schema.enum && schema.enum.length > 0)\n return z.enum(schema.enum as [string, ...string[]]);\n return s;\n }\n case \"number\":\n case \"integer\":\n return z.number();\n case \"boolean\":\n return z.boolean();\n case \"null\":\n return z.null();\n default:\n return z.any();\n }\n}\n\nexport const extractTool = (\n v3: V3,\n executionModel?: string | AgentModelConfig,\n) =>\n tool({\n description: `Extract structured data from the current page based on a provided schema.\n \n USAGE GUIDELINES:\n - Keep schemas MINIMAL - only include fields essential for the task\n - IMPORTANT: only use this if explicitly asked for structured output. In most scenarios, you should use the aria tree tool over this.\n - For URL fields, use format: \"url\"\n \n EXAMPLES:\n 1. Extract a single value:\n instruction: \"extract the product price\"\n schema: { type: \"object\", properties: { price: { type: \"number\" } } }\n \n 2. Extract multiple fields:\n instruction: \"extract product name and price\"\n schema: { type: \"object\", properties: { name: { type: \"string\" }, price: { type: \"number\" } } }\n \n 3. Extract arrays:\n instruction: \"extract all product names and prices\"\n schema: { type: \"object\", properties: { products: { type: \"array\", items: { type: \"object\", properties: { name: { type: \"string\" }, price: { type: \"number\" } } } } } }\n \n 4. Extract a URL:\n instruction: \"extract the link\"\n schema: { type: \"object\", properties: { url: { type: \"string\", format: \"url\" } } }`,\n inputSchema: z.object({\n instruction: z.string(),\n schema: z\n .object({\n type: z.string().optional(),\n properties: z.record(z.string(), z.unknown()).optional(),\n items: z.unknown().optional(),\n enum: z.array(z.string()).optional(),\n format: z.enum([\"url\", \"email\", \"uuid\"]).optional(),\n })\n .passthrough()\n .optional()\n .describe(\"JSON Schema object describing the structure to extract\"),\n }),\n execute: async ({ instruction, schema }) => {\n try {\n const parsedSchema = schema\n ? jsonSchemaToZod(schema as JsonSchema)\n : undefined;\n const result = await v3.extract(instruction, parsedSchema, {\n ...(executionModel ? { model: executionModel } : {}),\n });\n return { success: true, result };\n } catch (error) {\n const err = error as Error;\n return { success: false, error: err?.message ?? String(error) };\n }\n },\n });\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { V3 } from "../../v3.js";
|
|
2
2
|
import type { Action } from "../../types/public/methods.js";
|
|
3
|
-
|
|
3
|
+
import type { AgentModelConfig } from "../../types/public/agent.js";
|
|
4
|
+
export declare const fillFormTool: (v3: V3, executionModel?: string | AgentModelConfig) => import("ai").Tool<{
|
|
4
5
|
fields: {
|
|
5
6
|
action: string;
|
|
6
7
|
value: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fillform.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/fillform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"fillform.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/fillform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,EAAM,EACN,cAA0C,EAC1C,EAAE,CACF,IAAI,CAAC;IACH,WAAW,EAAE,8GAA8G;IAC3H,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;QACpB,MAAM,EAAE,CAAC;aACN,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;YACP,MAAM,EAAE,CAAC;iBACN,MAAM,EAAE;iBACR,QAAQ,CACP,oEAAoE,CACrE;YACH,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;SAC3D,CAAC,CACH;aACA,GAAG,CAAC,CAAC,EAAE,oCAAoC,CA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IAAI;YACb,OAAO,EAAE,SAAS;YAClB,mBAAmB,EAAE,iBAAiB;SACvC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { tool } from \"ai\";\nimport { z } from \"zod\";\nimport type { V3 } from \"../../v3.js\";\nimport type { Action } from \"../../types/public/methods.js\";\nimport type { AgentModelConfig } from \"../../types/public/agent.js\";\n\nexport const fillFormTool = (\n v3: V3,\n executionModel?: string | AgentModelConfig,\n) =>\n tool({\n description: `📝 FORM FILL - MULTI-FIELD INPUT TOOL\\nFor any form with 2+ inputs/textareas. Faster than individual typing.`,\n inputSchema: z.object({\n fields: z\n .array(\n z.object({\n action: z\n .string()\n .describe(\n 'Description of typing action, e.g. \"type foo into the email field\"',\n ),\n value: z.string().describe(\"Text to type into the target\"),\n }),\n )\n .min(1, \"Provide at least one field to fill\"),\n }),\n execute: async ({ fields }) => {\n v3.logger({\n category: \"agent\",\n message: `Agent calling tool: fillForm`,\n level: 1,\n auxiliary: {\n arguments: {\n value: JSON.stringify(fields),\n type: \"object\",\n },\n },\n });\n const instruction = `Return observation results for the following actions: ${fields\n .map((f) => f.action)\n .join(\", \")}`;\n\n const observeOptions = executionModel\n ? { model: executionModel }\n : undefined;\n const observeResults = await v3.observe(instruction, observeOptions);\n\n const completed = [] as unknown[];\n const replayableActions: Action[] = [];\n for (const res of observeResults) {\n const actResult = await v3.act(res);\n completed.push(actResult);\n if (Array.isArray(actResult.actions)) {\n replayableActions.push(...(actResult.actions as Action[]));\n }\n }\n v3.recordAgentReplayStep({\n type: \"fillForm\",\n fields,\n observeResults,\n actions: replayableActions,\n });\n return {\n success: true,\n actions: completed,\n playwrightArguments: replayableActions,\n };\n },\n });\n"]}
|
|
@@ -18,9 +18,9 @@ import { searchTool } from "./search.js";
|
|
|
18
18
|
import type { ToolSet, InferUITools } from "ai";
|
|
19
19
|
import type { V3 } from "../../v3.js";
|
|
20
20
|
import type { LogLine } from "../../types/public/logs.js";
|
|
21
|
-
import type { AgentToolMode } from "../../types/public/agent.js";
|
|
21
|
+
import type { AgentToolMode, AgentModelConfig } from "../../types/public/agent.js";
|
|
22
22
|
export interface V3AgentToolOptions {
|
|
23
|
-
executionModel?: string;
|
|
23
|
+
executionModel?: string | AgentModelConfig;
|
|
24
24
|
logger?: (message: LogLine) => void;
|
|
25
25
|
/**
|
|
26
26
|
* Tool mode determines which set of tools are available.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../lib/v3/agent/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","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9B,MAAM,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,gBAAgB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC;QAC3E,KAAK,EAAE,SAAS,EAAE;QAClB,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC;QAC5B,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;KACzB,CAAC;IAEF,0DAA0D;IAC1D,IAAI,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,CAAC;QAC9B,QAAQ,CAAC,MAAM,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,WAAW,CAAC,QAAQ,EAAE,IAAI,EAAE,YAAY,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import { gotoTool } from \"./goto.js\";\nimport { actTool } from \"./act.js\";\nimport { screenshotTool } from \"./screenshot.js\";\nimport { waitTool } from \"./wait.js\";\nimport { navBackTool } from \"./navback.js\";\nimport { ariaTreeTool } from \"./ariaTree.js\";\nimport { fillFormTool } from \"./fillform.js\";\nimport { scrollTool, scrollVisionTool } from \"./scroll.js\";\nimport { extractTool } from \"./extract.js\";\nimport { clickTool } from \"./click.js\";\nimport { typeTool } from \"./type.js\";\nimport { dragAndDropTool } from \"./dragAndDrop.js\";\nimport { clickAndHoldTool } from \"./clickAndHold.js\";\nimport { keysTool } from \"./keys.js\";\nimport { fillFormVisionTool } from \"./fillFormVision.js\";\nimport { thinkTool } from \"./think.js\";\nimport { searchTool } from \"./search.js\";\n\nimport type { ToolSet, InferUITools } from \"ai\";\nimport type { V3 } from \"../../v3.js\";\nimport type { LogLine } from \"../../types/public/logs.js\";\nimport type {\n AgentToolMode,\n AgentModelConfig,\n} from \"../../types/public/agent.js\";\n\nexport interface V3AgentToolOptions {\n executionModel?: string | AgentModelConfig;\n logger?: (message: LogLine) => void;\n /**\n * Tool mode determines which set of tools are available.\n * - 'dom' (default): Uses DOM-based tools (act, fillForm) - removes coordinate-based tools\n * - 'hybrid': Uses coordinate-based tools (click, type, dragAndDrop, etc.) - removes fillForm\n */\n mode?: AgentToolMode;\n /**\n * The model provider. Used for model-specific coordinate handling\n */\n provider?: string;\n /**\n * Tools to exclude from the available toolset.\n * These tools will be filtered out after mode-based filtering.\n */\n excludeTools?: string[];\n}\n\n/**\n * Filters tools based on mode and explicit exclusions.\n * - 'dom' mode: Removes coordinate-based tools (click, type, dragAndDrop, clickAndHold, fillFormVision)\n * - 'hybrid' mode: Removes DOM-based form tool (fillForm) in favor of coordinate-based fillFormVision\n * - excludeTools: Additional tools to remove from the toolset\n */\nfunction filterTools(\n tools: ToolSet,\n mode: AgentToolMode,\n excludeTools?: string[],\n): ToolSet {\n const filtered: ToolSet = { ...tools };\n\n // Mode-based filtering\n if (mode === \"hybrid\") {\n delete filtered.fillForm;\n } else {\n // DOM mode (default)\n delete filtered.click;\n delete filtered.type;\n delete filtered.dragAndDrop;\n delete filtered.clickAndHold;\n delete filtered.fillFormVision;\n }\n\n if (excludeTools) {\n for (const toolName of excludeTools) {\n delete filtered[toolName];\n }\n }\n\n return filtered;\n}\n\nexport function createAgentTools(v3: V3, options?: V3AgentToolOptions) {\n const executionModel = options?.executionModel;\n const mode = options?.mode ?? \"dom\";\n const provider = options?.provider;\n const excludeTools = options?.excludeTools;\n\n const allTools: ToolSet = {\n act: actTool(v3, executionModel),\n ariaTree: ariaTreeTool(v3),\n click: clickTool(v3, provider),\n clickAndHold: clickAndHoldTool(v3, provider),\n dragAndDrop: dragAndDropTool(v3, provider),\n extract: extractTool(v3, executionModel),\n fillForm: fillFormTool(v3, executionModel),\n fillFormVision: fillFormVisionTool(v3, provider),\n goto: gotoTool(v3),\n keys: keysTool(v3),\n navback: navBackTool(v3),\n screenshot: screenshotTool(v3),\n scroll: mode === \"hybrid\" ? scrollVisionTool(v3, provider) : scrollTool(v3),\n think: thinkTool(),\n type: typeTool(v3, provider),\n wait: waitTool(v3, mode),\n };\n\n // Only include search tool if BRAVE_API_KEY is configured\n if (process.env.BRAVE_API_KEY) {\n allTools.search = searchTool(v3);\n }\n\n return filterTools(allTools, mode, excludeTools);\n}\n\nexport type AgentTools = ReturnType<typeof createAgentTools>;\n\n/**\n * Type map of all agent tools for strong typing of tool calls and results.\n * Note: `search` is optional as it's only available when BRAVE_API_KEY is configured.\n */\nexport type AgentToolTypesMap = {\n act: ReturnType<typeof actTool>;\n ariaTree: ReturnType<typeof ariaTreeTool>;\n click: ReturnType<typeof clickTool>;\n clickAndHold: ReturnType<typeof clickAndHoldTool>;\n dragAndDrop: ReturnType<typeof dragAndDropTool>;\n extract: ReturnType<typeof extractTool>;\n fillForm: ReturnType<typeof fillFormTool>;\n fillFormVision: ReturnType<typeof fillFormVisionTool>;\n goto: ReturnType<typeof gotoTool>;\n keys: ReturnType<typeof keysTool>;\n navback: ReturnType<typeof navBackTool>;\n screenshot: ReturnType<typeof screenshotTool>;\n scroll: ReturnType<typeof scrollTool> | ReturnType<typeof scrollVisionTool>;\n search?: ReturnType<typeof searchTool>;\n think: ReturnType<typeof thinkTool>;\n type: ReturnType<typeof typeTool>;\n wait: ReturnType<typeof waitTool>;\n};\n\n/**\n * Inferred UI tools type for type-safe tool inputs and outputs.\n * Use with UIMessage for full type safety in UI contexts.\n */\nexport type AgentUITools = InferUITools<AgentToolTypesMap>;\n\n/**\n * Union type for all possible agent tool calls.\n * Provides type-safe access to tool call arguments.\n */\nexport type AgentToolCall = {\n [K in keyof AgentToolTypesMap]: {\n toolName: K;\n toolCallId: string;\n args: AgentUITools[K][\"input\"];\n };\n}[keyof AgentToolTypesMap];\n\n/**\n * Union type for all possible agent tool results.\n * Provides type-safe access to tool result values.\n */\nexport type AgentToolResult = {\n [K in keyof AgentToolTypesMap]: {\n toolName: K;\n toolCallId: string;\n result: AgentUITools[K][\"output\"];\n };\n}[keyof AgentToolTypesMap];\n"]}
|
package/dist/esm/lib/v3/api.d.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import type { Action, ActResult, AgentConfig, AgentExecuteOptions, AgentResult, ExtractResult, LogLine, StagehandMetrics, ActOptions, ExtractOptions, ObserveOptions, Api } from "./types/public/index.js";
|
|
1
|
+
import type { Action, ActResult, AgentConfig, AgentExecuteOptions, AgentResult, ExtractResult, LogLine, StagehandMetrics, BrowserbaseRegion, ActOptions, ExtractOptions, ObserveOptions, Api } from "./types/public/index.js";
|
|
2
2
|
import type { SerializableResponse, AgentCacheTransferPayload } from "./types/private/index.js";
|
|
3
3
|
import type { StagehandZodSchema } from "./zodCompat.js";
|
|
4
|
+
/**
|
|
5
|
+
* Mapping of Browserbase regions to their corresponding Stagehand API base URLs.
|
|
6
|
+
* Users should configure their client to hit the API endpoint that matches
|
|
7
|
+
* the region where their browser session is running.
|
|
8
|
+
*/
|
|
9
|
+
export declare const REGION_API_URLS: Record<BrowserbaseRegion, string>;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the full API URL (with /v1 suffix) for a given Browserbase region.
|
|
12
|
+
* If no region is specified or the region is unknown, defaults to us-west-2.
|
|
13
|
+
*
|
|
14
|
+
* @param region - The Browserbase region (e.g., "us-west-2", "eu-central-1")
|
|
15
|
+
* @returns The full API URL including /v1 suffix
|
|
16
|
+
*/
|
|
17
|
+
export declare function getApiUrlForRegion(region: BrowserbaseRegion | undefined): string;
|
|
4
18
|
/**
|
|
5
19
|
* Constructor parameters for StagehandAPIClient
|
|
6
20
|
*/
|
|
@@ -56,6 +70,7 @@ export declare class StagehandAPIClient {
|
|
|
56
70
|
private sessionId?;
|
|
57
71
|
private modelApiKey;
|
|
58
72
|
private modelProvider?;
|
|
73
|
+
private region?;
|
|
59
74
|
private logger;
|
|
60
75
|
private fetchWithCookies;
|
|
61
76
|
private lastFinishedEventData;
|
package/dist/esm/lib/v3/api.js
CHANGED
|
@@ -3,12 +3,39 @@ import { loadApiKeyFromEnv } from "../utils.js";
|
|
|
3
3
|
import { STAGEHAND_VERSION } from "../version.js";
|
|
4
4
|
import { StagehandAPIError, StagehandAPIUnauthorizedError, StagehandHttpError, StagehandResponseBodyError, StagehandResponseParseError, StagehandServerError, ExperimentalNotConfiguredError, } from "./types/public/index.js";
|
|
5
5
|
import { toJsonSchema } from "./zodCompat.js";
|
|
6
|
+
// =============================================================================
|
|
7
|
+
// Multi-region API URL mapping
|
|
8
|
+
// =============================================================================
|
|
9
|
+
/**
|
|
10
|
+
* Mapping of Browserbase regions to their corresponding Stagehand API base URLs.
|
|
11
|
+
* Users should configure their client to hit the API endpoint that matches
|
|
12
|
+
* the region where their browser session is running.
|
|
13
|
+
*/
|
|
14
|
+
export const REGION_API_URLS = {
|
|
15
|
+
"us-west-2": "https://api.stagehand.browserbase.com",
|
|
16
|
+
"us-east-1": "https://api.use1.stagehand.browserbase.com",
|
|
17
|
+
"eu-central-1": "https://api.euc1.stagehand.browserbase.com",
|
|
18
|
+
"ap-southeast-1": "https://api.apse1.stagehand.browserbase.com",
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Returns the full API URL (with /v1 suffix) for a given Browserbase region.
|
|
22
|
+
* If no region is specified or the region is unknown, defaults to us-west-2.
|
|
23
|
+
*
|
|
24
|
+
* @param region - The Browserbase region (e.g., "us-west-2", "eu-central-1")
|
|
25
|
+
* @returns The full API URL including /v1 suffix
|
|
26
|
+
*/
|
|
27
|
+
export function getApiUrlForRegion(region) {
|
|
28
|
+
const baseUrl = REGION_API_URLS[region] ??
|
|
29
|
+
REGION_API_URLS["us-west-2"];
|
|
30
|
+
return `${baseUrl}/v1`;
|
|
31
|
+
}
|
|
6
32
|
export class StagehandAPIClient {
|
|
7
33
|
apiKey;
|
|
8
34
|
projectId;
|
|
9
35
|
sessionId;
|
|
10
36
|
modelApiKey;
|
|
11
37
|
modelProvider;
|
|
38
|
+
region;
|
|
12
39
|
logger;
|
|
13
40
|
fetchWithCookies;
|
|
14
41
|
lastFinishedEventData = null;
|
|
@@ -31,10 +58,8 @@ export class StagehandAPIClient {
|
|
|
31
58
|
this.modelProvider = modelName?.includes("/")
|
|
32
59
|
? modelName.split("/")[0]
|
|
33
60
|
: undefined;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return { sessionId: browserbaseSessionID ?? null, available: false };
|
|
37
|
-
}
|
|
61
|
+
// Store the region for multi-region API URL resolution
|
|
62
|
+
this.region = browserbaseSessionCreateParams?.region;
|
|
38
63
|
this.logger({
|
|
39
64
|
category: "init",
|
|
40
65
|
message: "Creating new browserbase session...",
|
|
@@ -471,7 +496,18 @@ export class StagehandAPIClient {
|
|
|
471
496
|
if (options.method === "POST" && options.body) {
|
|
472
497
|
defaultHeaders["Content-Type"] = "application/json";
|
|
473
498
|
}
|
|
474
|
-
|
|
499
|
+
// Use STAGEHAND_API_URL env var if set, otherwise use region-based URL
|
|
500
|
+
// Ensure /v1 suffix is present for consistency
|
|
501
|
+
let baseUrl;
|
|
502
|
+
if (process.env.STAGEHAND_API_URL) {
|
|
503
|
+
const envUrl = process.env.STAGEHAND_API_URL.replace(/\/+$/, "");
|
|
504
|
+
// Append /v1 if not already present
|
|
505
|
+
baseUrl = envUrl.endsWith("/v1") ? envUrl : `${envUrl}/v1`;
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
baseUrl = getApiUrlForRegion(this.region);
|
|
509
|
+
}
|
|
510
|
+
const response = await this.fetchWithCookies(`${baseUrl}${path}`, {
|
|
475
511
|
...options,
|
|
476
512
|
headers: {
|
|
477
513
|
...defaultHeaders,
|