@mastra/agent-browser 0.2.0 → 0.2.1-alpha.1

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @mastra/agent-browser
2
2
 
3
+ ## 0.2.1-alpha.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Standardize `headless` default to `true` across all browser providers. Each provider now resolves `headless` once in its constructor and passes it to the thread manager via the base class getter, removing duplicate fallback logic. ([#15696](https://github.com/mastra-ai/mastra/pull/15696))
8
+
9
+ - Updated dependencies [[`750b4d3`](https://github.com/mastra-ai/mastra/commit/750b4d3d8231f92e769b2c485921ac5a8ca639b9)]:
10
+ - @mastra/core@1.28.0-alpha.1
11
+
12
+ ## 0.2.1-alpha.0
13
+
14
+ ### Patch Changes
15
+
16
+ - Fixed `browser_evaluate` so expression scripts now return their computed value instead of `undefined` (for example, `document.querySelectorAll('a').length`). ([#15689](https://github.com/mastra-ai/mastra/pull/15689))
17
+
18
+ - Updated dependencies [[`733bf53`](https://github.com/mastra-ai/mastra/commit/733bf53d9352aedd3ef38c3d501edb275b65b43c), [`5405b3b`](https://github.com/mastra-ai/mastra/commit/5405b3b35325c5b8fb34fc7ac109bd2feb7bb6fe), [`c321127`](https://github.com/mastra-ai/mastra/commit/c3211275fc195de9ad1ead2746b354beb8eae6e8), [`a07bcef`](https://github.com/mastra-ai/mastra/commit/a07bcefea77c03d6d322caad973dca49b4b15fa1), [`b084a80`](https://github.com/mastra-ai/mastra/commit/b084a800db0f82d62e1fc3d6e3e3480da1ba5a53), [`82b7a96`](https://github.com/mastra-ai/mastra/commit/82b7a964169636c1d1e0c694fc892a213b0179d5), [`df97812`](https://github.com/mastra-ai/mastra/commit/df97812bd949dcafeb074b80ecab501724b49c3b), [`8bbe360`](https://github.com/mastra-ai/mastra/commit/8bbe36042af7fc4be0244dffd8913f6795179421), [`f6b8ba8`](https://github.com/mastra-ai/mastra/commit/f6b8ba8dbf533b7a8db90c72b6805ddc804a3a72), [`a07bcef`](https://github.com/mastra-ai/mastra/commit/a07bcefea77c03d6d322caad973dca49b4b15fa1)]:
19
+ - @mastra/core@1.28.0-alpha.0
20
+
3
21
  ## 0.2.0
4
22
 
5
23
  ### Minor Changes
package/dist/index.cjs CHANGED
@@ -36,7 +36,7 @@ var AgentBrowserThreadManager = class extends browser.ThreadManager {
36
36
  if (this.scope === "thread") {
37
37
  const manager = new agentBrowser.BrowserManager();
38
38
  const launchOptions = {
39
- headless: this.browserConfig.headless ?? true,
39
+ headless: this.browserConfig.headless,
40
40
  viewport: this.browserConfig.viewport,
41
41
  profile: this.browserConfig.profile,
42
42
  executablePath: this.browserConfig.executablePath,
@@ -221,7 +221,9 @@ var dragInputSchema = zod.z.object({
221
221
  }
222
222
  });
223
223
  var evaluateInputSchema = zod.z.object({
224
- script: zod.z.string().describe("JavaScript code to execute"),
224
+ script: zod.z.string().describe(
225
+ "JavaScript expression to evaluate in the browser and return the result. Do not use `return` \u2014 write a bare expression like `document.title` or `1 + 1`. For async code, wrap in an async IIFE: `(async () => { ... })()`."
226
+ ),
225
227
  arg: zod.z.unknown().optional().describe("Argument to pass to the script (JSON-serializable)")
226
228
  });
227
229
  var browserSchemas = {
@@ -533,7 +535,7 @@ var AgentBrowser = class extends browser.MastraBrowser {
533
535
  const effectiveScope = config.cdpUrl ? config.scope ?? "shared" : config.scope ?? "thread";
534
536
  this.threadManager = new AgentBrowserThreadManager({
535
537
  scope: effectiveScope,
536
- browserConfig: config,
538
+ browserConfig: { ...config, headless: this.headless },
537
539
  resolveCdpUrl: this.resolveCdpUrl.bind(this),
538
540
  logger: this.logger,
539
541
  // When a new thread session is created, notify listeners so screencast can start
@@ -597,7 +599,7 @@ var AgentBrowser = class extends browser.MastraBrowser {
597
599
  this.sharedManager = new agentBrowser.BrowserManager();
598
600
  const localConfig = this.config;
599
601
  const launchOptions = {
600
- headless: localConfig.headless ?? true,
602
+ headless: this.headless,
601
603
  viewport: localConfig.viewport,
602
604
  profile: localConfig.profile,
603
605
  executablePath: localConfig.executablePath,
@@ -1463,8 +1465,7 @@ var AgentBrowser = class extends browser.MastraBrowser {
1463
1465
  async evaluate(input, threadId) {
1464
1466
  try {
1465
1467
  const page = await this.getPage(threadId);
1466
- const wrappedScript = `(async () => { ${input.script} })()`;
1467
- const result = await page.evaluate(wrappedScript);
1468
+ const result = await page.evaluate(input.script);
1468
1469
  return {
1469
1470
  success: true,
1470
1471
  result,