mastracode 0.33.0-alpha.6 → 0.33.0-alpha.7
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 +12 -0
- package/dist/cli.cjs +2 -2
- package/dist/cli.js +2 -2
- package/dist/tui/commands/browser.d.ts.map +1 -1
- package/dist/{tui-ciIVmFuD.js → tui-IdBfDUUa.js} +104 -9
- package/dist/{tui-ciIVmFuD.js.map → tui-IdBfDUUa.js.map} +1 -1
- package/dist/{tui-BAjz-lln.cjs → tui-tFzKFnpk.cjs} +103 -8
- package/dist/tui-tFzKFnpk.cjs.map +1 -0
- package/dist/tui.cjs +1 -1
- package/dist/tui.js +1 -1
- package/package.json +10 -10
- package/dist/tui-BAjz-lln.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# mastracode
|
|
2
2
|
|
|
3
|
+
## 0.33.0-alpha.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add `/browser set viewport` and `/browser clear viewport`. Pass a preset (`desktop`, `desktop-hd`, `laptop`, `tablet`, `mobile`), a custom `WIDTHxHEIGHT` size, or `window` to match the real browser window; omit the value to pick a preset from a list. `window` is rejected on providers that cannot honor it. ([#21010](https://github.com/mastra-ai/mastra/pull/21010))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`f59032a`](https://github.com/mastra-ai/mastra/commit/f59032a73699443555a08a479e7ac578975784f2), [`f59032a`](https://github.com/mastra-ai/mastra/commit/f59032a73699443555a08a479e7ac578975784f2), [`f59032a`](https://github.com/mastra-ai/mastra/commit/f59032a73699443555a08a479e7ac578975784f2), [`3e50f63`](https://github.com/mastra-ai/mastra/commit/3e50f63db85e9fe365b4ce5daecb0ac0dc464d93), [`bf936e2`](https://github.com/mastra-ai/mastra/commit/bf936e2c89b2ff0dad5695b873ddc009ba96d41e)]:
|
|
10
|
+
- @mastra/code-sdk@1.2.0-alpha.7
|
|
11
|
+
- @mastra/core@1.58.0-alpha.6
|
|
12
|
+
- @mastra/agent-browser@0.5.1-alpha.0
|
|
13
|
+
- @mastra/stagehand@0.3.2-alpha.1
|
|
14
|
+
|
|
3
15
|
## 0.33.0-alpha.6
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_tui = require("./tui-
|
|
2
|
+
const require_tui = require("./tui-tFzKFnpk.cjs");
|
|
3
3
|
let _mastra_code_sdk = require("@mastra/code-sdk");
|
|
4
4
|
let fs = require("fs");
|
|
5
5
|
fs = require_tui.__toESM(fs, 1);
|
|
@@ -13,7 +13,7 @@ let _mastra_code_sdk_utils_stdin_pipe = require("@mastra/code-sdk/utils/stdin-pi
|
|
|
13
13
|
let _mastra_code_sdk_utils_thread_lock = require("@mastra/code-sdk/utils/thread-lock");
|
|
14
14
|
//#region src/version.ts
|
|
15
15
|
function getCurrentVersion() {
|
|
16
|
-
return "0.33.0-alpha.
|
|
16
|
+
return "0.33.0-alpha.7";
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/main.ts
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { d as detectTerminalTheme, f as applyThemeMode, t as MastraTUI, v as restoreTerminalForeground } from "./tui-
|
|
2
|
+
import { d as detectTerminalTheme, f as applyThemeMode, t as MastraTUI, v as restoreTerminalForeground } from "./tui-IdBfDUUa.js";
|
|
3
3
|
import { createMastraCode } from "@mastra/code-sdk";
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import { createMastraCodeAnalytics } from "@mastra/code-sdk/analytics";
|
|
@@ -12,7 +12,7 @@ import { drainPipedStdin, reopenStdinFromTTY } from "@mastra/code-sdk/utils/stdi
|
|
|
12
12
|
import { releaseAllThreadLocks } from "@mastra/code-sdk/utils/thread-lock";
|
|
13
13
|
//#region src/version.ts
|
|
14
14
|
function getCurrentVersion() {
|
|
15
|
-
return "0.33.0-alpha.
|
|
15
|
+
return "0.33.0-alpha.7";
|
|
16
16
|
}
|
|
17
17
|
//#endregion
|
|
18
18
|
//#region src/main.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/tui/commands/browser.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAuRtD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,mBAAmB,EAAE,IAAI,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAuoBvG"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs, { existsSync, readFileSync, statSync, unlinkSync } from "fs";
|
|
2
|
-
import { MASTRA_GATEWAY_DEFAULT_URL, MASTRA_GATEWAY_PROVIDER, OBSERVABILITY_AUTH_PREFIX, THREAD_ACTIVE_MODEL_PACK_ID_KEY, checkProfileProviderMismatch, createBrowserFromSettings, getCustomProviderId, loadSettings, resolveDefaultThinkingLevel, resolveThreadActiveModelPackId, saveSettings, setProfileProvider, stripMastraCodeCustomProviderPrefix, toCustomProviderModelId } from "@mastra/code-sdk/onboarding/settings";
|
|
2
|
+
import { MASTRA_GATEWAY_DEFAULT_URL, MASTRA_GATEWAY_PROVIDER, OBSERVABILITY_AUTH_PREFIX, THREAD_ACTIVE_MODEL_PACK_ID_KEY, VIEWPORT_PRESETS, checkProfileProviderMismatch, createBrowserFromSettings, getCustomProviderId, loadSettings, parseViewportInput, resolveDefaultThinkingLevel, resolveThreadActiveModelPackId, saveSettings, setProfileProvider, stripMastraCodeCustomProviderPrefix, toCustomProviderModelId } from "@mastra/code-sdk/onboarding/settings";
|
|
3
3
|
import { ThreadLockError } from "@mastra/code-sdk/utils/thread-lock";
|
|
4
4
|
import { mastraBrand } from "@mastra/code-sdk/theme-palette";
|
|
5
5
|
import chalk from "chalk";
|
|
@@ -13440,7 +13440,7 @@ const ACTIVE_BROWSER_KEY = "activeBrowserSettings";
|
|
|
13440
13440
|
* /browser status - Show current browser configuration
|
|
13441
13441
|
* /browser on - Enable browser with current settings
|
|
13442
13442
|
* /browser off - Disable browser
|
|
13443
|
-
* /browser set <k> <v> - Set a specific setting (profile, executablePath, storageState, cdpUrl, model)
|
|
13443
|
+
* /browser set <k> <v> - Set a specific setting (profile, executablePath, storageState, cdpUrl, model, viewport)
|
|
13444
13444
|
*/
|
|
13445
13445
|
/**
|
|
13446
13446
|
* Validate a `provider/model` id against the providers Stagehand can resolve.
|
|
@@ -13457,6 +13457,80 @@ function stagehandModelError(modelId) {
|
|
|
13457
13457
|
const provider = modelId.slice(0, slashIndex);
|
|
13458
13458
|
if (!STAGEHAND_MODEL_PROVIDERS.includes(provider)) return `Unsupported model provider: ${provider}. Supported providers: ${STAGEHAND_MODEL_PROVIDERS.join(", ")}.`;
|
|
13459
13459
|
}
|
|
13460
|
+
/** Render a viewport for status output and confirmations. */
|
|
13461
|
+
function formatViewport(viewport) {
|
|
13462
|
+
if (!viewport) return "default";
|
|
13463
|
+
if (viewport === "window") return "window (match browser window)";
|
|
13464
|
+
return `${viewport.width}x${viewport.height}`;
|
|
13465
|
+
}
|
|
13466
|
+
/**
|
|
13467
|
+
* `'window'` skips viewport emulation, which only works where the provider can
|
|
13468
|
+
* be told not to emulate. Stagehand overwrites an absent viewport with its own
|
|
13469
|
+
* default when it launches the browser itself, so it can only honor `'window'`
|
|
13470
|
+
* when connecting to an already-running browser over CDP.
|
|
13471
|
+
*/
|
|
13472
|
+
function windowViewportError(browser) {
|
|
13473
|
+
if (browser.provider !== "stagehand" || browser.cdpUrl) return void 0;
|
|
13474
|
+
return "viewport window is not supported when stagehand launches its own browser. Use the agent-browser provider, set a cdpUrl, or pick explicit dimensions.";
|
|
13475
|
+
}
|
|
13476
|
+
/** Preset choices offered by the `/browser set viewport` picker. */
|
|
13477
|
+
function viewportChoices(browser) {
|
|
13478
|
+
const choices = Object.entries(VIEWPORT_PRESETS).map(([name, size]) => ({
|
|
13479
|
+
label: name,
|
|
13480
|
+
description: `${size.width}x${size.height}`
|
|
13481
|
+
}));
|
|
13482
|
+
if (!windowViewportError(browser)) choices.push({
|
|
13483
|
+
label: "window",
|
|
13484
|
+
description: "Follow the real browser window (no emulation)"
|
|
13485
|
+
});
|
|
13486
|
+
choices.push({
|
|
13487
|
+
label: "custom",
|
|
13488
|
+
description: "Enter WIDTHxHEIGHT, e.g. 1600x1000"
|
|
13489
|
+
});
|
|
13490
|
+
return choices;
|
|
13491
|
+
}
|
|
13492
|
+
/**
|
|
13493
|
+
* Persist a viewport choice. Kept separate so the picker and the
|
|
13494
|
+
* `/browser set viewport <value>` path apply the same validation.
|
|
13495
|
+
*/
|
|
13496
|
+
function applyViewport(ctx, settings, viewport) {
|
|
13497
|
+
if (viewport === "window") {
|
|
13498
|
+
const error = windowViewportError(settings.browser);
|
|
13499
|
+
if (error) {
|
|
13500
|
+
ctx.showError(error);
|
|
13501
|
+
return false;
|
|
13502
|
+
}
|
|
13503
|
+
}
|
|
13504
|
+
settings.browser.viewport = viewport;
|
|
13505
|
+
saveSettings(settings);
|
|
13506
|
+
ctx.showInfo(`Set viewport = ${formatViewport(viewport)}\nRun /browser on to apply.`);
|
|
13507
|
+
return true;
|
|
13508
|
+
}
|
|
13509
|
+
/**
|
|
13510
|
+
* Ask for a viewport from a preset list rather than making the user recall
|
|
13511
|
+
* dimensions, falling back to a free-text prompt for a custom size.
|
|
13512
|
+
*/
|
|
13513
|
+
async function promptForViewport(ctx, settings) {
|
|
13514
|
+
const choice = await askInline(ctx, "Viewport size?", viewportChoices(settings.browser));
|
|
13515
|
+
if (!choice) return;
|
|
13516
|
+
if (choice === "custom") {
|
|
13517
|
+
const custom = await askText$1(ctx, "Viewport (WIDTHxHEIGHT):", formatViewport(settings.browser.viewport));
|
|
13518
|
+
if (!custom) return;
|
|
13519
|
+
const parsed = parseViewportInput(custom);
|
|
13520
|
+
if (!parsed) {
|
|
13521
|
+
ctx.showError(`Invalid viewport: ${custom}. Use WIDTHxHEIGHT, for example 1280x720.`);
|
|
13522
|
+
return;
|
|
13523
|
+
}
|
|
13524
|
+
applyViewport(ctx, settings, parsed);
|
|
13525
|
+
return;
|
|
13526
|
+
}
|
|
13527
|
+
const parsed = parseViewportInput(choice);
|
|
13528
|
+
if (!parsed) {
|
|
13529
|
+
ctx.showError(`Invalid viewport: ${choice}.`);
|
|
13530
|
+
return;
|
|
13531
|
+
}
|
|
13532
|
+
applyViewport(ctx, settings, parsed);
|
|
13533
|
+
}
|
|
13460
13534
|
/**
|
|
13461
13535
|
* Open the shared model picker, restricted to providers Stagehand can resolve,
|
|
13462
13536
|
* and persist the choice as the browser model.
|
|
@@ -13567,6 +13641,7 @@ function getBrowserConfigKey(settings) {
|
|
|
13567
13641
|
if (settings.provider === "stagehand" && settings.stagehand?.env) parts.push(settings.stagehand.env);
|
|
13568
13642
|
if (settings.provider === "stagehand" && settings.stagehand?.model) parts.push(`model:${settings.stagehand.model}`);
|
|
13569
13643
|
parts.push(settings.headless ? "headless" : "headed");
|
|
13644
|
+
if (settings.viewport) parts.push(`viewport:${formatViewport(settings.viewport)}`);
|
|
13570
13645
|
if (settings.profile) parts.push(`profile:${settings.profile}`);
|
|
13571
13646
|
if (settings.executablePath) parts.push(`exec:${settings.executablePath}`);
|
|
13572
13647
|
if (settings.cdpUrl) parts.push(`cdp:${settings.cdpUrl}`);
|
|
@@ -13589,7 +13664,7 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
13589
13664
|
const key = args[1]?.toLowerCase();
|
|
13590
13665
|
const value = args.slice(2).join(" ");
|
|
13591
13666
|
if (!key) {
|
|
13592
|
-
ctx.showInfo("Usage: /browser set <key> <value>\n\nKeys:\n profile <path> - Browser profile directory\n executablePath <path> - Browser executable path\n storageState <path> - Playwright storage state file (agent-browser only)\n cdpUrl <url> - CDP WebSocket URL\n model [provider/id] - Model Stagehand uses for AI operations (stagehand only).\n Omit the value to pick from a list.\n\nTo remove a setting, use: /browser clear <key>\n\nExamples:\n /browser set profile ~/.mastracode/browser-profile-stagehand\n /browser set model\n /browser set model anthropic/claude-sonnet-4-5\n /browser set executablePath /Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
|
|
13667
|
+
ctx.showInfo("Usage: /browser set <key> <value>\n\nKeys:\n profile <path> - Browser profile directory\n executablePath <path> - Browser executable path\n storageState <path> - Playwright storage state file (agent-browser only)\n cdpUrl <url> - CDP WebSocket URL\n model [provider/id] - Model Stagehand uses for AI operations (stagehand only).\n Omit the value to pick from a list.\n viewport [size] - Preset name, WIDTHxHEIGHT, or window.\n Omit the value to pick from a list.\n\nTo remove a setting, use: /browser clear <key>\n\nExamples:\n /browser set profile ~/.mastracode/browser-profile-stagehand\n /browser set model\n /browser set viewport 1920x1080\n /browser set viewport window\n /browser set model anthropic/claude-sonnet-4-5\n /browser set executablePath /Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
|
|
13593
13668
|
return;
|
|
13594
13669
|
}
|
|
13595
13670
|
if (![
|
|
@@ -13597,9 +13672,10 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
13597
13672
|
"executablepath",
|
|
13598
13673
|
"storagestate",
|
|
13599
13674
|
"cdpurl",
|
|
13600
|
-
"model"
|
|
13675
|
+
"model",
|
|
13676
|
+
"viewport"
|
|
13601
13677
|
].includes(key)) {
|
|
13602
|
-
ctx.showError(`Unknown key: ${args[1]}. Valid keys: profile, executablePath, storageState, cdpUrl, model`);
|
|
13678
|
+
ctx.showError(`Unknown key: ${args[1]}. Valid keys: profile, executablePath, storageState, cdpUrl, model, viewport`);
|
|
13603
13679
|
return;
|
|
13604
13680
|
}
|
|
13605
13681
|
if (!value) {
|
|
@@ -13607,6 +13683,10 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
13607
13683
|
await promptForStagehandModel(ctx, settings, browser);
|
|
13608
13684
|
return;
|
|
13609
13685
|
}
|
|
13686
|
+
if (key === "viewport") {
|
|
13687
|
+
await promptForViewport(ctx, settings);
|
|
13688
|
+
return;
|
|
13689
|
+
}
|
|
13610
13690
|
ctx.showError(`Missing value. Use: /browser set ${args[1]} <value>\nTo remove a setting, use: /browser clear ${args[1]}`);
|
|
13611
13691
|
return;
|
|
13612
13692
|
}
|
|
@@ -13661,6 +13741,15 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
13661
13741
|
ctx.showInfo(`Set model = ${modelId}\nRun /browser on to apply.`);
|
|
13662
13742
|
return;
|
|
13663
13743
|
}
|
|
13744
|
+
case "viewport": {
|
|
13745
|
+
const parsed = parseViewportInput(value);
|
|
13746
|
+
if (!parsed) {
|
|
13747
|
+
ctx.showError(`Invalid viewport: ${value.trim()}. Use WIDTHxHEIGHT, window, or a preset (${Object.keys(VIEWPORT_PRESETS).join(", ")}).`);
|
|
13748
|
+
return;
|
|
13749
|
+
}
|
|
13750
|
+
applyViewport(ctx, settings, parsed);
|
|
13751
|
+
return;
|
|
13752
|
+
}
|
|
13664
13753
|
case "cdpurl":
|
|
13665
13754
|
settings.browser.cdpUrl = expandedValue;
|
|
13666
13755
|
if (settings.browser.profile || settings.browser.executablePath) {
|
|
@@ -13689,6 +13778,7 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
13689
13778
|
if (activeSettings.stagehand.model) lines.push(` Model: ${activeSettings.stagehand.model}`);
|
|
13690
13779
|
}
|
|
13691
13780
|
if (!activeIsBrowserbase) lines.push(` Headless: ${activeSettings.headless ? "yes" : "no"}`);
|
|
13781
|
+
lines.push(` Viewport: ${formatViewport(activeSettings.viewport)}`);
|
|
13692
13782
|
if (activeSettings.executablePath) lines.push(` Executable: ${activeSettings.executablePath}`);
|
|
13693
13783
|
if (activeSettings.profile) lines.push(` Profile: ${activeSettings.profile}`);
|
|
13694
13784
|
if (activeSettings.agentBrowser?.storageState) lines.push(` Storage State: ${activeSettings.agentBrowser.storageState}`);
|
|
@@ -13703,6 +13793,7 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
13703
13793
|
if (browser.stagehand.model) lines.push(` Model: ${browser.stagehand.model}`);
|
|
13704
13794
|
}
|
|
13705
13795
|
if (!fileIsBrowserbase) lines.push(` Headless: ${browser.headless ? "yes" : "no"}`);
|
|
13796
|
+
lines.push(` Viewport: ${formatViewport(browser.viewport)}`);
|
|
13706
13797
|
if (browser.executablePath) lines.push(` Executable: ${browser.executablePath}`);
|
|
13707
13798
|
if (browser.profile) lines.push(` Profile: ${browser.profile}`);
|
|
13708
13799
|
if (browser.agentBrowser?.storageState) lines.push(` Storage State: ${browser.agentBrowser.storageState}`);
|
|
@@ -13720,6 +13811,7 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
13720
13811
|
if (browser.stagehand.model) lines.push(` Model: ${browser.stagehand.model}`);
|
|
13721
13812
|
}
|
|
13722
13813
|
if (!isBrowserbase) lines.push(` Headless: ${browser.headless ? "yes" : "no"}`);
|
|
13814
|
+
lines.push(` Viewport: ${formatViewport(browser.viewport)}`);
|
|
13723
13815
|
if (browser.executablePath) lines.push(` Executable: ${browser.executablePath}`);
|
|
13724
13816
|
if (browser.profile) lines.push(` Profile: ${browser.profile}`);
|
|
13725
13817
|
if (browser.agentBrowser?.storageState) lines.push(` Storage State: ${browser.agentBrowser.storageState}`);
|
|
@@ -13804,8 +13896,11 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
13804
13896
|
case "model":
|
|
13805
13897
|
if (settings.browser.stagehand) delete settings.browser.stagehand.model;
|
|
13806
13898
|
break;
|
|
13899
|
+
case "viewport":
|
|
13900
|
+
settings.browser.viewport = { ...VIEWPORT_PRESETS.desktop };
|
|
13901
|
+
break;
|
|
13807
13902
|
default:
|
|
13808
|
-
ctx.showError(`Unknown field: ${field}. Valid fields: profile, executablePath, storageState, cdpUrl, model`);
|
|
13903
|
+
ctx.showError(`Unknown field: ${field}. Valid fields: profile, executablePath, storageState, cdpUrl, model, viewport`);
|
|
13809
13904
|
return;
|
|
13810
13905
|
}
|
|
13811
13906
|
saveSettings(settings);
|
|
@@ -13868,8 +13963,8 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
13868
13963
|
" off, disable Disable browser",
|
|
13869
13964
|
" status Show current configuration",
|
|
13870
13965
|
" clear Reset all settings to defaults",
|
|
13871
|
-
" clear <key> Clear: profile, executablePath, storageState, cdpUrl, model",
|
|
13872
|
-
" set <key> <v> Set: profile, executablePath, storageState, cdpUrl, model",
|
|
13966
|
+
" clear <key> Clear: profile, executablePath, storageState, cdpUrl, model, viewport",
|
|
13967
|
+
" set <key> <v> Set: profile, executablePath, storageState, cdpUrl, model, viewport",
|
|
13873
13968
|
" export storageState <path> Export session cookies/localStorage (agent-browser)"
|
|
13874
13969
|
].join("\n"));
|
|
13875
13970
|
return;
|
|
@@ -22020,4 +22115,4 @@ var MastraTUI = class MastraTUI {
|
|
|
22020
22115
|
//#endregion
|
|
22021
22116
|
export { mastraBrand as _, OMProgressComponent as a, ToolExecutionComponentEnhanced as c, detectTerminalTheme as d, applyThemeMode as f, mastra as g, getThemeMode as h, LoginDialogComponent as i, AssistantMessageComponent as l, getMarkdownTheme as m, createTUIState as n, formatOMStatus as o, getEditorTheme as p, LoginSelectorComponent as r, UserMessageComponent as s, MastraTUI as t, ModelSelectorComponent as u, restoreTerminalForeground as v, theme as y };
|
|
22022
22117
|
|
|
22023
|
-
//# sourceMappingURL=tui-
|
|
22118
|
+
//# sourceMappingURL=tui-IdBfDUUa.js.map
|