@mastra/agent-browser 0.4.0 → 0.4.1-alpha.0
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/CHANGELOG.md +9 -0
- package/dist/index.cjs +16 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -608,6 +608,14 @@ declare class AgentBrowser extends MastraBrowser {
|
|
|
608
608
|
url: string;
|
|
609
609
|
title: string;
|
|
610
610
|
} | BrowserToolError>;
|
|
611
|
+
/**
|
|
612
|
+
* Start a `waitForNavigation` wait (when `waitUntil` is set) and immediately
|
|
613
|
+
* attach a noop catch handler so a navigation timeout/rejection can't become
|
|
614
|
+
* an unhandled rejection (crashing the process) while the caller's action is
|
|
615
|
+
* still pending. Callers should still `await` the returned promise to observe
|
|
616
|
+
* the original error.
|
|
617
|
+
*/
|
|
618
|
+
private startNavigationWait;
|
|
611
619
|
click(input: ClickInput, threadId?: string): Promise<{
|
|
612
620
|
success: true;
|
|
613
621
|
url: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -608,6 +608,14 @@ declare class AgentBrowser extends MastraBrowser {
|
|
|
608
608
|
url: string;
|
|
609
609
|
title: string;
|
|
610
610
|
} | BrowserToolError>;
|
|
611
|
+
/**
|
|
612
|
+
* Start a `waitForNavigation` wait (when `waitUntil` is set) and immediately
|
|
613
|
+
* attach a noop catch handler so a navigation timeout/rejection can't become
|
|
614
|
+
* an unhandled rejection (crashing the process) while the caller's action is
|
|
615
|
+
* still pending. Callers should still `await` the returned promise to observe
|
|
616
|
+
* the original error.
|
|
617
|
+
*/
|
|
618
|
+
private startNavigationWait;
|
|
611
619
|
click(input: ClickInput, threadId?: string): Promise<{
|
|
612
620
|
success: true;
|
|
613
621
|
url: string;
|
package/dist/index.js
CHANGED
|
@@ -1139,6 +1139,19 @@ var AgentBrowser = class extends MastraBrowser {
|
|
|
1139
1139
|
return this.createErrorFromException(error, "Screenshot");
|
|
1140
1140
|
}
|
|
1141
1141
|
}
|
|
1142
|
+
/**
|
|
1143
|
+
* Start a `waitForNavigation` wait (when `waitUntil` is set) and immediately
|
|
1144
|
+
* attach a noop catch handler so a navigation timeout/rejection can't become
|
|
1145
|
+
* an unhandled rejection (crashing the process) while the caller's action is
|
|
1146
|
+
* still pending. Callers should still `await` the returned promise to observe
|
|
1147
|
+
* the original error.
|
|
1148
|
+
*/
|
|
1149
|
+
startNavigationWait(page, waitUntil, timeout) {
|
|
1150
|
+
const navigation = waitUntil ? page.waitForNavigation({ waitUntil, timeout }) : void 0;
|
|
1151
|
+
navigation?.catch(() => {
|
|
1152
|
+
});
|
|
1153
|
+
return navigation;
|
|
1154
|
+
}
|
|
1142
1155
|
// ---------------------------------------------------------------------------
|
|
1143
1156
|
// 3. browser_click - Click on element
|
|
1144
1157
|
// ---------------------------------------------------------------------------
|
|
@@ -1154,7 +1167,7 @@ var AgentBrowser = class extends MastraBrowser {
|
|
|
1154
1167
|
);
|
|
1155
1168
|
}
|
|
1156
1169
|
const timeout = input.timeout ?? this.defaultTimeout;
|
|
1157
|
-
const navigation =
|
|
1170
|
+
const navigation = this.startNavigationWait(page, input.waitUntil, timeout);
|
|
1158
1171
|
await locator.click({
|
|
1159
1172
|
button: input.button ?? "left",
|
|
1160
1173
|
clickCount: input.clickCount ?? 1,
|
|
@@ -1231,7 +1244,7 @@ var AgentBrowser = class extends MastraBrowser {
|
|
|
1231
1244
|
try {
|
|
1232
1245
|
const page = await this.getPage(threadId);
|
|
1233
1246
|
const timeout = input.timeout ?? this.defaultTimeout;
|
|
1234
|
-
const navigation =
|
|
1247
|
+
const navigation = this.startNavigationWait(page, input.waitUntil, timeout);
|
|
1235
1248
|
await page.keyboard.press(input.key);
|
|
1236
1249
|
await navigation;
|
|
1237
1250
|
return {
|
|
@@ -1262,7 +1275,7 @@ var AgentBrowser = class extends MastraBrowser {
|
|
|
1262
1275
|
if (input.label) selectValue.label = input.label;
|
|
1263
1276
|
if (input.index !== void 0) selectValue.index = input.index;
|
|
1264
1277
|
const timeout = input.timeout ?? this.defaultTimeout;
|
|
1265
|
-
const navigation =
|
|
1278
|
+
const navigation = this.startNavigationWait(page, input.waitUntil, timeout);
|
|
1266
1279
|
const selected = await locator.selectOption(selectValue, { timeout });
|
|
1267
1280
|
await navigation;
|
|
1268
1281
|
return {
|