@mastra/agent-browser 0.5.4 → 0.5.5
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.cjs +27 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3710 -1171
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +3710 -1171
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +27 -50
- package/dist/index.js.map +1 -1
- package/package.json +11 -11
package/dist/index.cjs
CHANGED
|
@@ -3,7 +3,7 @@ let _mastra_core_browser = require("@mastra/core/browser");
|
|
|
3
3
|
let agent_browser = require("agent-browser");
|
|
4
4
|
let _mastra_core_tools = require("@mastra/core/tools");
|
|
5
5
|
let zod = require("zod");
|
|
6
|
-
|
|
6
|
+
// src/thread-manager.ts
|
|
7
7
|
/**
|
|
8
8
|
* AgentBrowserThreadManager - Thread scope management for AgentBrowser
|
|
9
9
|
*
|
|
@@ -125,8 +125,7 @@ var AgentBrowserThreadManager = class extends _mastra_core_browser.ThreadManager
|
|
|
125
125
|
await super.destroyAllSessions();
|
|
126
126
|
}
|
|
127
127
|
};
|
|
128
|
-
|
|
129
|
-
//#region src/schemas.ts
|
|
128
|
+
// src/schemas.ts
|
|
130
129
|
/**
|
|
131
130
|
* AgentBrowser Tool Schemas
|
|
132
131
|
*
|
|
@@ -342,8 +341,7 @@ const browserSchemas = {
|
|
|
342
341
|
screenshot: screenshotInputSchema,
|
|
343
342
|
evaluate: evaluateInputSchema
|
|
344
343
|
};
|
|
345
|
-
|
|
346
|
-
//#region src/tools/constants.ts
|
|
344
|
+
// src/tools/constants.ts
|
|
347
345
|
/**
|
|
348
346
|
* Browser Tool Constants
|
|
349
347
|
*/
|
|
@@ -365,8 +363,7 @@ const BROWSER_TOOLS = {
|
|
|
365
363
|
SCREENSHOT: "browser_screenshot",
|
|
366
364
|
EVALUATE: "browser_evaluate"
|
|
367
365
|
};
|
|
368
|
-
|
|
369
|
-
//#region src/tools/back.ts
|
|
366
|
+
// src/tools/back.ts
|
|
370
367
|
/**
|
|
371
368
|
* browser_back - Go back in browser history
|
|
372
369
|
*/
|
|
@@ -383,8 +380,7 @@ function createBackTool(browser) {
|
|
|
383
380
|
}
|
|
384
381
|
});
|
|
385
382
|
}
|
|
386
|
-
|
|
387
|
-
//#region src/tools/click.ts
|
|
383
|
+
// src/tools/click.ts
|
|
388
384
|
/**
|
|
389
385
|
* browser_click - Click an element
|
|
390
386
|
*/
|
|
@@ -401,8 +397,7 @@ function createClickTool(browser) {
|
|
|
401
397
|
}
|
|
402
398
|
});
|
|
403
399
|
}
|
|
404
|
-
|
|
405
|
-
//#region src/tools/close.ts
|
|
400
|
+
// src/tools/close.ts
|
|
406
401
|
/**
|
|
407
402
|
* browser_close - Close the browser
|
|
408
403
|
*/
|
|
@@ -432,8 +427,7 @@ function createCloseTool(browser) {
|
|
|
432
427
|
}
|
|
433
428
|
});
|
|
434
429
|
}
|
|
435
|
-
|
|
436
|
-
//#region src/tools/dialog.ts
|
|
430
|
+
// src/tools/dialog.ts
|
|
437
431
|
/**
|
|
438
432
|
* browser_dialog - Click element and handle resulting dialog
|
|
439
433
|
*/
|
|
@@ -450,8 +444,7 @@ function createDialogTool(browser) {
|
|
|
450
444
|
}
|
|
451
445
|
});
|
|
452
446
|
}
|
|
453
|
-
|
|
454
|
-
//#region src/tools/drag.ts
|
|
447
|
+
// src/tools/drag.ts
|
|
455
448
|
/**
|
|
456
449
|
* browser_drag - Drag an element to another element
|
|
457
450
|
*/
|
|
@@ -468,8 +461,7 @@ function createDragTool(browser) {
|
|
|
468
461
|
}
|
|
469
462
|
});
|
|
470
463
|
}
|
|
471
|
-
|
|
472
|
-
//#region src/tools/evaluate.ts
|
|
464
|
+
// src/tools/evaluate.ts
|
|
473
465
|
/**
|
|
474
466
|
* browser_evaluate - Execute JavaScript in the browser
|
|
475
467
|
*/
|
|
@@ -486,8 +478,7 @@ function createEvaluateTool(browser) {
|
|
|
486
478
|
}
|
|
487
479
|
});
|
|
488
480
|
}
|
|
489
|
-
|
|
490
|
-
//#region src/tools/goto.ts
|
|
481
|
+
// src/tools/goto.ts
|
|
491
482
|
/**
|
|
492
483
|
* browser_goto - Navigate to a URL
|
|
493
484
|
*/
|
|
@@ -504,8 +495,7 @@ function createGotoTool(browser) {
|
|
|
504
495
|
}
|
|
505
496
|
});
|
|
506
497
|
}
|
|
507
|
-
|
|
508
|
-
//#region src/tools/hover.ts
|
|
498
|
+
// src/tools/hover.ts
|
|
509
499
|
/**
|
|
510
500
|
* browser_hover - Hover over an element
|
|
511
501
|
*/
|
|
@@ -522,8 +512,7 @@ function createHoverTool(browser) {
|
|
|
522
512
|
}
|
|
523
513
|
});
|
|
524
514
|
}
|
|
525
|
-
|
|
526
|
-
//#region src/tools/press.ts
|
|
515
|
+
// src/tools/press.ts
|
|
527
516
|
/**
|
|
528
517
|
* browser_press - Press a keyboard key
|
|
529
518
|
*/
|
|
@@ -540,8 +529,7 @@ function createPressTool(browser) {
|
|
|
540
529
|
}
|
|
541
530
|
});
|
|
542
531
|
}
|
|
543
|
-
|
|
544
|
-
//#region src/tools/screenshot.ts
|
|
532
|
+
// src/tools/screenshot.ts
|
|
545
533
|
/**
|
|
546
534
|
* browser_screenshot - Capture a screenshot of the current page
|
|
547
535
|
*/
|
|
@@ -576,8 +564,7 @@ function createScreenshotTool(browser) {
|
|
|
576
564
|
}
|
|
577
565
|
});
|
|
578
566
|
}
|
|
579
|
-
|
|
580
|
-
//#region src/tools/scroll.ts
|
|
567
|
+
// src/tools/scroll.ts
|
|
581
568
|
/**
|
|
582
569
|
* browser_scroll - Scroll the page or element
|
|
583
570
|
*/
|
|
@@ -594,8 +581,7 @@ function createScrollTool(browser) {
|
|
|
594
581
|
}
|
|
595
582
|
});
|
|
596
583
|
}
|
|
597
|
-
|
|
598
|
-
//#region src/tools/select.ts
|
|
584
|
+
// src/tools/select.ts
|
|
599
585
|
/**
|
|
600
586
|
* browser_select - Select option from dropdown
|
|
601
587
|
*/
|
|
@@ -612,8 +598,7 @@ function createSelectTool(browser) {
|
|
|
612
598
|
}
|
|
613
599
|
});
|
|
614
600
|
}
|
|
615
|
-
|
|
616
|
-
//#region src/tools/snapshot.ts
|
|
601
|
+
// src/tools/snapshot.ts
|
|
617
602
|
/**
|
|
618
603
|
* browser_snapshot - Get accessibility tree snapshot
|
|
619
604
|
*/
|
|
@@ -630,8 +615,7 @@ function createSnapshotTool(browser) {
|
|
|
630
615
|
}
|
|
631
616
|
});
|
|
632
617
|
}
|
|
633
|
-
|
|
634
|
-
//#region src/tools/tabs.ts
|
|
618
|
+
// src/tools/tabs.ts
|
|
635
619
|
/**
|
|
636
620
|
* browser_tabs - Manage browser tabs
|
|
637
621
|
*/
|
|
@@ -648,8 +632,7 @@ function createTabsTool(browser) {
|
|
|
648
632
|
}
|
|
649
633
|
});
|
|
650
634
|
}
|
|
651
|
-
|
|
652
|
-
//#region src/tools/type.ts
|
|
635
|
+
// src/tools/type.ts
|
|
653
636
|
/**
|
|
654
637
|
* browser_type - Type text into an element
|
|
655
638
|
*/
|
|
@@ -666,8 +649,7 @@ function createTypeTool(browser) {
|
|
|
666
649
|
}
|
|
667
650
|
});
|
|
668
651
|
}
|
|
669
|
-
|
|
670
|
-
//#region src/tools/wait.ts
|
|
652
|
+
// src/tools/wait.ts
|
|
671
653
|
/**
|
|
672
654
|
* browser_wait - Wait for an element or condition
|
|
673
655
|
*/
|
|
@@ -684,8 +666,7 @@ function createWaitTool(browser) {
|
|
|
684
666
|
}
|
|
685
667
|
});
|
|
686
668
|
}
|
|
687
|
-
|
|
688
|
-
//#region src/tools/index.ts
|
|
669
|
+
// src/tools/index.ts
|
|
689
670
|
/**
|
|
690
671
|
* Creates all browser tools bound to an AgentBrowser instance.
|
|
691
672
|
* The browser is lazily initialized on first tool use.
|
|
@@ -710,8 +691,7 @@ function createAgentBrowserTools(browser) {
|
|
|
710
691
|
[BROWSER_TOOLS.EVALUATE]: createEvaluateTool(browser)
|
|
711
692
|
};
|
|
712
693
|
}
|
|
713
|
-
|
|
714
|
-
//#region src/utils.ts
|
|
694
|
+
// src/utils.ts
|
|
715
695
|
/**
|
|
716
696
|
* Get the browser process PID from a BrowserManager instance via CDP.
|
|
717
697
|
*
|
|
@@ -736,8 +716,7 @@ async function getBrowserPid(manager) {
|
|
|
736
716
|
return;
|
|
737
717
|
}
|
|
738
718
|
}
|
|
739
|
-
|
|
740
|
-
//#region src/agent-browser.ts
|
|
719
|
+
// src/agent-browser.ts
|
|
741
720
|
/**
|
|
742
721
|
* AgentBrowser - Browser automation using agent-browser (vercel-labs/agent-browser)
|
|
743
722
|
*
|
|
@@ -1456,13 +1435,12 @@ var AgentBrowser = class extends _mastra_core_browser.MastraBrowser {
|
|
|
1456
1435
|
success: true,
|
|
1457
1436
|
hint: `Element is now ${state}. Take a snapshot to continue.`
|
|
1458
1437
|
};
|
|
1459
|
-
} else {
|
|
1460
|
-
await (await this.getPage(threadId)).waitForTimeout(timeout);
|
|
1461
|
-
return {
|
|
1462
|
-
success: true,
|
|
1463
|
-
hint: "Wait complete. Take a snapshot to see current state."
|
|
1464
|
-
};
|
|
1465
1438
|
}
|
|
1439
|
+
await (await this.getPage(threadId)).waitForTimeout(timeout);
|
|
1440
|
+
return {
|
|
1441
|
+
success: true,
|
|
1442
|
+
hint: "Wait complete. Take a snapshot to see current state."
|
|
1443
|
+
};
|
|
1466
1444
|
} catch (error) {
|
|
1467
1445
|
return this.createErrorFromException(error, "Wait");
|
|
1468
1446
|
}
|
|
@@ -1672,7 +1650,6 @@ var AgentBrowser = class extends _mastra_core_browser.MastraBrowser {
|
|
|
1672
1650
|
});
|
|
1673
1651
|
}
|
|
1674
1652
|
};
|
|
1675
|
-
//#endregion
|
|
1676
1653
|
exports.AgentBrowser = AgentBrowser;
|
|
1677
1654
|
exports.AgentBrowserThreadManager = AgentBrowserThreadManager;
|
|
1678
1655
|
exports.BROWSER_TOOLS = BROWSER_TOOLS;
|