mastracode 0.42.2-alpha.0 → 0.42.2
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/cli.cjs +15 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +16 -10
- package/dist/cli.js.map +1 -1
- package/dist/tui/commands/browser.d.ts.map +1 -1
- package/dist/tui/commands/settings.d.ts.map +1 -1
- package/dist/tui/components/notification-summary.d.ts +6 -0
- package/dist/tui/components/notification-summary.d.ts.map +1 -1
- package/dist/tui/components/notification.d.ts +8 -0
- package/dist/tui/components/notification.d.ts.map +1 -1
- package/dist/tui/components/tool-execution-enhanced.d.ts +13 -0
- package/dist/tui/components/tool-execution-enhanced.d.ts.map +1 -1
- package/dist/tui/mastra-tui.d.ts.map +1 -1
- package/dist/tui/quiet-mode.d.ts +9 -0
- package/dist/tui/quiet-mode.d.ts.map +1 -0
- package/dist/tui/render-messages.d.ts.map +1 -1
- package/dist/{tui-BS1IUTkx.js → tui-BNnzmiap.js} +187 -51
- package/dist/tui-BNnzmiap.js.map +1 -0
- package/dist/{tui-C79dD8X3.cjs → tui-CJ1G5lRF.cjs} +186 -50
- package/dist/tui-CJ1G5lRF.cjs.map +1 -0
- package/dist/tui.cjs +1 -1
- package/dist/tui.js +1 -1
- package/package.json +16 -16
- package/dist/tui-BS1IUTkx.js.map +0 -1
- package/dist/tui-C79dD8X3.cjs.map +0 -1
|
@@ -74,6 +74,7 @@ let _mastra_code_sdk_onboarding_custom_packs = require("@mastra/code-sdk/onboard
|
|
|
74
74
|
let _mastra_code_sdk_onboarding_custom_providers = require("@mastra/code-sdk/onboarding/custom-providers");
|
|
75
75
|
let _mastra_code_sdk_onboarding_om_settings = require("@mastra/code-sdk/onboarding/om-settings");
|
|
76
76
|
let fs_promises = require("fs/promises");
|
|
77
|
+
let _mastra_code_sdk_providers_model_ids = require("@mastra/code-sdk/providers/model-ids");
|
|
77
78
|
let _mastra_stagehand = require("@mastra/stagehand");
|
|
78
79
|
let _mastra_code_sdk_auth_index = require("@mastra/code-sdk/auth/index");
|
|
79
80
|
let _mastra_core_llm = require("@mastra/core/llm");
|
|
@@ -5689,12 +5690,27 @@ function getDecisionText(decision) {
|
|
|
5689
5690
|
//#endregion
|
|
5690
5691
|
//#region src/tui/components/notification-summary.ts
|
|
5691
5692
|
var NotificationSummaryComponent = class extends _earendil_works_pi_tui.Container {
|
|
5693
|
+
options;
|
|
5694
|
+
quietDisplayMode;
|
|
5692
5695
|
constructor(options) {
|
|
5693
5696
|
super();
|
|
5694
|
-
|
|
5695
|
-
this.
|
|
5697
|
+
this.options = options;
|
|
5698
|
+
this.quietDisplayMode = options.quietDisplayMode ?? "normal";
|
|
5699
|
+
this.rebuild();
|
|
5700
|
+
}
|
|
5701
|
+
setQuietModeDisplay(mode) {
|
|
5702
|
+
if (this.quietDisplayMode === mode) return;
|
|
5703
|
+
this.quietDisplayMode = mode;
|
|
5704
|
+
this.rebuild();
|
|
5705
|
+
}
|
|
5706
|
+
rebuild() {
|
|
5707
|
+
this.clear();
|
|
5708
|
+
const { options } = this;
|
|
5696
5709
|
const message = Object.entries(options.bySource).sort(([a], [b]) => a.localeCompare(b)).map(([source, count]) => `${source}: ${count}`).join(", ") || options.message.trim();
|
|
5710
|
+
const title = `Notification summary: ${options.pending} pending`;
|
|
5711
|
+
this.addChild(new _earendil_works_pi_tui.Text(chalk.default.hex(mastra.orange).bold(title), 0, 0));
|
|
5697
5712
|
if (message) this.addChild(new _earendil_works_pi_tui.Text(theme.fg("dim", message), 2, 0));
|
|
5713
|
+
if (this.quietDisplayMode === "quiet") return;
|
|
5698
5714
|
this.addChild(new _earendil_works_pi_tui.Text(theme.fg("dim", "Use notification_inbox to inspect pending notifications."), 2, 0));
|
|
5699
5715
|
}
|
|
5700
5716
|
getChatSpacingKind() {
|
|
@@ -5703,6 +5719,9 @@ var NotificationSummaryComponent = class extends _earendil_works_pi_tui.Containe
|
|
|
5703
5719
|
};
|
|
5704
5720
|
//#endregion
|
|
5705
5721
|
//#region src/tui/components/notification.ts
|
|
5722
|
+
function normalizeQuietPreviewLineLimit(limit) {
|
|
5723
|
+
return Math.min(8, Math.max(0, Math.floor(Number.isFinite(limit) ? limit : 2)));
|
|
5724
|
+
}
|
|
5706
5725
|
function priorityColor(priority) {
|
|
5707
5726
|
if (priority === "urgent" || priority === "high") return mastra.orange;
|
|
5708
5727
|
if (priority === "medium") return mastra.blue;
|
|
@@ -5748,10 +5767,25 @@ function wrapText(value, maxWidth) {
|
|
|
5748
5767
|
}
|
|
5749
5768
|
var NotificationComponent = class extends WidthAwareContainer {
|
|
5750
5769
|
options;
|
|
5770
|
+
quietDisplayMode;
|
|
5771
|
+
quietPreviewLineLimit;
|
|
5751
5772
|
expanded = false;
|
|
5752
5773
|
constructor(options) {
|
|
5753
5774
|
super();
|
|
5754
5775
|
this.options = options;
|
|
5776
|
+
this.quietDisplayMode = options.quietDisplayMode ?? "normal";
|
|
5777
|
+
this.quietPreviewLineLimit = normalizeQuietPreviewLineLimit(options.quietPreviewLineLimit);
|
|
5778
|
+
}
|
|
5779
|
+
setQuietModeDisplay(mode) {
|
|
5780
|
+
if (this.quietDisplayMode === mode) return;
|
|
5781
|
+
this.quietDisplayMode = mode;
|
|
5782
|
+
this.rebuild();
|
|
5783
|
+
}
|
|
5784
|
+
setQuietPreviewLineLimit(limit) {
|
|
5785
|
+
const normalized = normalizeQuietPreviewLineLimit(limit);
|
|
5786
|
+
if (this.quietPreviewLineLimit === normalized) return;
|
|
5787
|
+
this.quietPreviewLineLimit = normalized;
|
|
5788
|
+
this.rebuild();
|
|
5755
5789
|
}
|
|
5756
5790
|
setExpanded(expanded) {
|
|
5757
5791
|
this.expanded = expanded;
|
|
@@ -5760,6 +5794,7 @@ var NotificationComponent = class extends WidthAwareContainer {
|
|
|
5760
5794
|
rebuildForWidth(width) {
|
|
5761
5795
|
this.clear();
|
|
5762
5796
|
const options = this.options;
|
|
5797
|
+
const quiet = this.quietDisplayMode === "quiet" && !this.expanded;
|
|
5763
5798
|
if (options.backgroundCompletion && !this.expanded) {
|
|
5764
5799
|
const completion = options.backgroundCompletion;
|
|
5765
5800
|
const failed = options.status === "failed";
|
|
@@ -5772,7 +5807,7 @@ var NotificationComponent = class extends WidthAwareContainer {
|
|
|
5772
5807
|
return;
|
|
5773
5808
|
}
|
|
5774
5809
|
const titleText = options.source ? `notification from ${options.source}` : "notification";
|
|
5775
|
-
const details = [
|
|
5810
|
+
const details = quiet ? "" : [
|
|
5776
5811
|
options.priority,
|
|
5777
5812
|
options.kind,
|
|
5778
5813
|
options.status
|
|
@@ -5781,7 +5816,7 @@ var NotificationComponent = class extends WidthAwareContainer {
|
|
|
5781
5816
|
const maxContentWidth = Math.max(MIN_NOTIFICATION_CONTENT_WIDTH, Math.min(MAX_NOTIFICATION_CONTENT_WIDTH, width - 0 - 4));
|
|
5782
5817
|
const titleLines = wrapText(titleText, maxContentWidth);
|
|
5783
5818
|
const detailLines = details ? wrapText(details, maxContentWidth) : [];
|
|
5784
|
-
const messageLines = message ? wrapText(message, maxContentWidth) : [];
|
|
5819
|
+
const messageLines = message ? this.limitMessageLines(wrapText(message, maxContentWidth), quiet, maxContentWidth) : [];
|
|
5785
5820
|
const backgroundDetailLines = options.backgroundCompletion ? [
|
|
5786
5821
|
`task · ${options.backgroundCompletion.taskId}`,
|
|
5787
5822
|
options.backgroundCompletion.argsSummary ? `invocation · ${options.backgroundCompletion.argsSummary}` : void 0,
|
|
@@ -5804,6 +5839,14 @@ var NotificationComponent = class extends WidthAwareContainer {
|
|
|
5804
5839
|
for (const line of backgroundDetailLines) this.addChild(new _earendil_works_pi_tui.Text(`${borderColor("│")} ${theme.fg("dim", padLine$1(line, contentWidth))} ${borderColor("│")}`, 0, 0));
|
|
5805
5840
|
this.addChild(new _earendil_works_pi_tui.Text(borderColor(bottom), 0, 0));
|
|
5806
5841
|
}
|
|
5842
|
+
limitMessageLines(lines, quiet, maxWidth) {
|
|
5843
|
+
if (!quiet || lines.length <= this.quietPreviewLineLimit) return lines;
|
|
5844
|
+
const shown = lines.slice(0, this.quietPreviewLineLimit);
|
|
5845
|
+
if (shown.length === 0) return shown;
|
|
5846
|
+
const last = shown[shown.length - 1];
|
|
5847
|
+
shown[shown.length - 1] = (0, _earendil_works_pi_tui.visibleWidth)(last) < maxWidth ? `${last}…` : `${(0, _earendil_works_pi_tui.truncateToWidth)(last, maxWidth - 1, "")}…`;
|
|
5848
|
+
return shown;
|
|
5849
|
+
}
|
|
5807
5850
|
getChatSpacingKind() {
|
|
5808
5851
|
return "system";
|
|
5809
5852
|
}
|
|
@@ -7659,9 +7702,34 @@ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
|
|
|
7659
7702
|
addLeadingPadding() {
|
|
7660
7703
|
if (this.shouldShowLeadingPadding()) this.contentBox.addChild(new _earendil_works_pi_tui.Text("", 0, 0));
|
|
7661
7704
|
}
|
|
7705
|
+
/**
|
|
7706
|
+
* Quiet shell output follows the same rule as every other tool's preview:
|
|
7707
|
+
* `quietPreviewLineLimit` output lines (the tail, since that is where errors
|
|
7708
|
+
* land), or none at all when the limit is 0. Expanding (ctrl+e) shows everything.
|
|
7709
|
+
*/
|
|
7662
7710
|
limitQuietShellLines(lines) {
|
|
7663
|
-
if (this.quietDisplayMode !== "quiet" ||
|
|
7664
|
-
|
|
7711
|
+
if (this.quietDisplayMode !== "quiet" || this.expanded) return lines;
|
|
7712
|
+
const limit = this.quietPreviewLineLimit;
|
|
7713
|
+
if (limit <= 0) return [];
|
|
7714
|
+
if (this.fitsQuietLimit(lines.length, limit)) return lines;
|
|
7715
|
+
return [this.quietHiddenLinesMarker(lines.length - limit), ...lines.slice(-limit)];
|
|
7716
|
+
}
|
|
7717
|
+
/**
|
|
7718
|
+
* The command is the shell tool's header, so at least one line always shows;
|
|
7719
|
+
* the rest of a long command (heredocs, inline scripts) is capped like output.
|
|
7720
|
+
*/
|
|
7721
|
+
limitQuietShellCommandLines(lines) {
|
|
7722
|
+
if (this.quietDisplayMode !== "quiet" || this.expanded) return lines;
|
|
7723
|
+
const limit = Math.max(1, this.quietPreviewLineLimit);
|
|
7724
|
+
if (this.fitsQuietLimit(lines.length, limit)) return lines;
|
|
7725
|
+
return [...lines.slice(0, limit), this.quietHiddenLinesMarker(lines.length - limit)];
|
|
7726
|
+
}
|
|
7727
|
+
/** A `⋯ (+1 line)` marker costs the same row as the line it hides, so just show the line. */
|
|
7728
|
+
fitsQuietLimit(count, limit) {
|
|
7729
|
+
return count <= limit + 1;
|
|
7730
|
+
}
|
|
7731
|
+
quietHiddenLinesMarker(hidden) {
|
|
7732
|
+
return theme.fg("muted", `⋯ (+${hidden} ${hidden === 1 ? "line" : "lines"})`);
|
|
7665
7733
|
}
|
|
7666
7734
|
/**
|
|
7667
7735
|
* Full clear-and-rebuild. Called when:
|
|
@@ -8372,15 +8440,17 @@ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
|
|
|
8372
8440
|
this.contentBox.addChild(new _earendil_works_pi_tui.Text(displayOutput, 0, 0));
|
|
8373
8441
|
this.contentBox.addChild(new _earendil_works_pi_tui.Text(`${border("├")}${border(horizontal)}${border("┤")}`, 0, 0));
|
|
8374
8442
|
}
|
|
8375
|
-
const
|
|
8376
|
-
const
|
|
8443
|
+
const footerPromptWidth = (0, _earendil_works_pi_tui.visibleWidth)(footerPrompt);
|
|
8444
|
+
const footerWrapWidth = Math.max(1, contentWidth - 2 - footerPromptWidth);
|
|
8445
|
+
const footerLines = this.limitQuietShellCommandLines(this.wrapQuietShellCommand(command, footerWrapWidth));
|
|
8377
8446
|
const footerSuffixWidth = (0, _earendil_works_pi_tui.visibleWidth)(footerSuffix);
|
|
8447
|
+
const continuationIndent = " ".repeat(footerPromptWidth);
|
|
8378
8448
|
footerLines.forEach((footerLine, index) => {
|
|
8379
|
-
const prefix = index === 0 ? footerPrompt :
|
|
8449
|
+
const prefix = index === 0 ? footerPrompt : continuationIndent;
|
|
8380
8450
|
const suffix = index === footerLines.length - 1 && (0, _earendil_works_pi_tui.visibleWidth)(footerLine) + footerSuffixWidth <= footerWrapWidth ? footerSuffix : "";
|
|
8381
8451
|
this.contentBox.addChild(new _earendil_works_pi_tui.Text(renderLine(`${prefix}${footerLine}${suffix}`, (value) => value), 0, 0));
|
|
8382
8452
|
});
|
|
8383
|
-
if ((0, _earendil_works_pi_tui.visibleWidth)(footerLines[footerLines.length - 1] ?? "") + footerSuffixWidth > footerWrapWidth) this.contentBox.addChild(new _earendil_works_pi_tui.Text(renderLine(
|
|
8453
|
+
if ((0, _earendil_works_pi_tui.visibleWidth)(footerLines[footerLines.length - 1] ?? "") + footerSuffixWidth > footerWrapWidth) this.contentBox.addChild(new _earendil_works_pi_tui.Text(renderLine(`${continuationIndent}${footerSuffix}`, (value) => value), 0, 0));
|
|
8384
8454
|
this.contentBox.addChild(new _earendil_works_pi_tui.Text(`${border("╰")}${border(horizontal)}${border("╯")}`, 0, 0));
|
|
8385
8455
|
};
|
|
8386
8456
|
if (!this.result || this.isPartial) {
|
|
@@ -10640,6 +10710,8 @@ function renderSignalMessage(state, message) {
|
|
|
10640
10710
|
kind: notification.kind,
|
|
10641
10711
|
priority: notification.priority,
|
|
10642
10712
|
status: notification.status,
|
|
10713
|
+
quietDisplayMode: state.quietMode ? "quiet" : "normal",
|
|
10714
|
+
quietPreviewLineLimit: state.quietModeMaxToolPreviewLines,
|
|
10643
10715
|
backgroundCompletion
|
|
10644
10716
|
});
|
|
10645
10717
|
if (backgroundCompletion) state.allToolComponents.push(component);
|
|
@@ -10654,7 +10726,8 @@ function renderSignalMessage(state, message) {
|
|
|
10654
10726
|
const component = new NotificationSummaryComponent({
|
|
10655
10727
|
message: summary.message,
|
|
10656
10728
|
pending: summary.pending,
|
|
10657
|
-
bySource: summary.bySource
|
|
10729
|
+
bySource: summary.bySource,
|
|
10730
|
+
quietDisplayMode: state.quietMode ? "quiet" : "normal"
|
|
10658
10731
|
});
|
|
10659
10732
|
addChildBeforeFollowUps(state, component);
|
|
10660
10733
|
state.messageComponentsById.set(message.id, component);
|
|
@@ -15588,7 +15661,7 @@ var SettingsComponent = class extends _earendil_works_pi_tui.Box {
|
|
|
15588
15661
|
...config.quietMode ? [{
|
|
15589
15662
|
id: "quietModeMaxToolPreviewLines",
|
|
15590
15663
|
label: "Quiet mode tool preview lines",
|
|
15591
|
-
description: "
|
|
15664
|
+
description: "Preview lines shown under each tool, including shell output. Set to None to hide previews.",
|
|
15592
15665
|
currentValue: quietPreviewLinesLabel(config.quietModeMaxToolPreviewLines),
|
|
15593
15666
|
submenu: (_currentValue, done) => new SelectSubmenu([
|
|
15594
15667
|
0,
|
|
@@ -15599,7 +15672,7 @@ var SettingsComponent = class extends _earendil_works_pi_tui.Box {
|
|
|
15599
15672
|
].map((lines) => ({
|
|
15600
15673
|
value: String(lines),
|
|
15601
15674
|
label: ` ${quietPreviewLinesLabel(lines)}`,
|
|
15602
|
-
description: lines === 0 ? "Hide
|
|
15675
|
+
description: lines === 0 ? "Hide tool previews and shell output" : `Show up to ${lines} preview line${lines === 1 ? "" : "s"}`
|
|
15603
15676
|
})), String(config.quietModeMaxToolPreviewLines), (value) => {
|
|
15604
15677
|
config.quietModeMaxToolPreviewLines = Number(value);
|
|
15605
15678
|
callbacks.onQuietModeMaxToolPreviewLinesChange(config.quietModeMaxToolPreviewLines);
|
|
@@ -15726,6 +15799,27 @@ var SettingsComponent = class extends _earendil_works_pi_tui.Box {
|
|
|
15726
15799
|
}
|
|
15727
15800
|
};
|
|
15728
15801
|
//#endregion
|
|
15802
|
+
//#region src/tui/quiet-mode.ts
|
|
15803
|
+
/**
|
|
15804
|
+
* Pushes the current quiet-mode preference into every already-rendered component
|
|
15805
|
+
* that renders differently in quiet mode: tool executions, notifications, and
|
|
15806
|
+
* notification summaries. Both the onboarding prompt and the `/settings` overlay
|
|
15807
|
+
* route through here so the two paths cannot drift.
|
|
15808
|
+
*/
|
|
15809
|
+
function applyQuietModeToRenderedComponents(state, enabled, previewLineLimit, modeColor) {
|
|
15810
|
+
const mode = enabled ? "quiet" : "normal";
|
|
15811
|
+
const tools = state.allToolComponents.filter((tool) => typeof tool.setQuietModeDisplay === "function");
|
|
15812
|
+
for (const tool of tools) {
|
|
15813
|
+
tool.setCompactToolModeColor?.(modeColor);
|
|
15814
|
+
tool.setQuietModeDisplay?.(mode);
|
|
15815
|
+
tool.setQuietPreviewLineLimit?.(previewLineLimit);
|
|
15816
|
+
}
|
|
15817
|
+
for (const component of state.messageComponentsById?.values() ?? []) if (component instanceof NotificationComponent) {
|
|
15818
|
+
component.setQuietModeDisplay(mode);
|
|
15819
|
+
component.setQuietPreviewLineLimit(previewLineLimit);
|
|
15820
|
+
} else if (component instanceof NotificationSummaryComponent) component.setQuietModeDisplay(mode);
|
|
15821
|
+
}
|
|
15822
|
+
//#endregion
|
|
15729
15823
|
//#region src/tui/commands/api-keys.ts
|
|
15730
15824
|
/**
|
|
15731
15825
|
* /api-keys command: manage API keys for model providers.
|
|
@@ -16016,11 +16110,7 @@ async function ensureGitcrawlReady(ctx) {
|
|
|
16016
16110
|
}
|
|
16017
16111
|
}
|
|
16018
16112
|
function applyQuietModeToRenderedTools(ctx, enabled, previewLineLimit) {
|
|
16019
|
-
ctx.state
|
|
16020
|
-
tool.setCompactToolModeColor?.(getCurrentModeColor$1(ctx));
|
|
16021
|
-
tool.setQuietModeDisplay?.(enabled ? "quiet" : "normal");
|
|
16022
|
-
tool.setQuietPreviewLineLimit?.(previewLineLimit);
|
|
16023
|
-
});
|
|
16113
|
+
applyQuietModeToRenderedComponents(ctx.state, enabled, previewLineLimit, getCurrentModeColor$1(ctx));
|
|
16024
16114
|
ctx.state.ui.requestRender();
|
|
16025
16115
|
}
|
|
16026
16116
|
async function handleSettingsCommand(ctx) {
|
|
@@ -16152,17 +16242,39 @@ async function handleSettingsCommand(ctx) {
|
|
|
16152
16242
|
* which may differ from the settings file if another instance changed it.
|
|
16153
16243
|
*/
|
|
16154
16244
|
const ACTIVE_BROWSER_KEY = "activeBrowserSettings";
|
|
16245
|
+
const ACTIVE_BROWSER_MODEL_KEY = "activeBrowserModel";
|
|
16155
16246
|
/**
|
|
16156
16247
|
* /browser command - Configure browser automation for agents.
|
|
16157
16248
|
*
|
|
16158
16249
|
* Usage:
|
|
16159
16250
|
* /browser - Interactive setup wizard
|
|
16160
|
-
* /browser status
|
|
16251
|
+
* /browser status|info - Show current browser configuration
|
|
16161
16252
|
* /browser on - Enable browser with current settings
|
|
16162
16253
|
* /browser off - Disable browser
|
|
16163
16254
|
* /browser set <k> <v> - Set a specific setting (profile, executablePath, storageState, cdpUrl, model, viewport)
|
|
16164
16255
|
*/
|
|
16165
16256
|
/**
|
|
16257
|
+
* Chat model at the moment the browser is launched. Stagehand is fixed at
|
|
16258
|
+
* creation and shared by every thread, so later model switches don't affect it.
|
|
16259
|
+
*/
|
|
16260
|
+
function launchChatModelId(ctx) {
|
|
16261
|
+
return ctx.state.session.model.get();
|
|
16262
|
+
}
|
|
16263
|
+
/**
|
|
16264
|
+
* Human-readable line for the model Stagehand will actually use, including the
|
|
16265
|
+
* implicit chat-model / Codex fallbacks, so users can see it without reading the
|
|
16266
|
+
* settings file.
|
|
16267
|
+
*/
|
|
16268
|
+
function describeStagehandModel({ modelName, source, viaCodexOAuth }) {
|
|
16269
|
+
const codex = viaCodexOAuth ? " via OpenAI Codex login" : "";
|
|
16270
|
+
switch (source) {
|
|
16271
|
+
case "settings": return ` Model: ${modelName}${codex ? ` (${codex.trim()})` : ""}`;
|
|
16272
|
+
case "chat-model": return ` Model: ${modelName} (current chat model${codex}; override with /browser set model)`;
|
|
16273
|
+
case "codex-oauth": return ` Model: ${modelName} (OpenAI Codex login default; override with /browser set model)`;
|
|
16274
|
+
case "stagehand-default": return " Model: Stagehand default (set one with /browser set model)";
|
|
16275
|
+
}
|
|
16276
|
+
}
|
|
16277
|
+
/**
|
|
16166
16278
|
* Validate a `provider/model` id against the providers Stagehand can resolve.
|
|
16167
16279
|
*
|
|
16168
16280
|
* Stagehand splits the id on its first slash and throws during browser startup
|
|
@@ -16345,22 +16457,40 @@ function resolveModeAgent(mode, agentControllerState) {
|
|
|
16345
16457
|
const modeAgent = mode.agent;
|
|
16346
16458
|
return typeof modeAgent === "function" ? modeAgent(agentControllerState) : modeAgent;
|
|
16347
16459
|
}
|
|
16348
|
-
|
|
16460
|
+
/**
|
|
16461
|
+
* @param chatModelId the chat model passed to `createBrowserFromSettings` for
|
|
16462
|
+
* this browser, so the recorded model matches what was really launched.
|
|
16463
|
+
*/
|
|
16464
|
+
function applyBrowserToAgents(ctx, browser, browserSettings, chatModelId) {
|
|
16349
16465
|
const modes = ctx.controller.listModes();
|
|
16350
16466
|
let agentControllerState;
|
|
16351
16467
|
for (const mode of modes) resolveModeAgent(mode, agentControllerState ??= ctx.state.session.state.get())?.setBrowser?.(browser);
|
|
16352
16468
|
ctx.controller.setBrowser?.(browser);
|
|
16353
|
-
ctx.state.session.state.set({
|
|
16469
|
+
ctx.state.session.state.set({
|
|
16470
|
+
[ACTIVE_BROWSER_KEY]: browserSettings ? (0, _mastra_code_sdk_onboarding_settings.toActiveBrowserSettings)(browserSettings) : void 0,
|
|
16471
|
+
[ACTIVE_BROWSER_MODEL_KEY]: browserSettings?.enabled ? (0, _mastra_code_sdk_onboarding_settings.resolveStagehandModel)(browserSettings, { chatModelId }) : void 0
|
|
16472
|
+
});
|
|
16354
16473
|
}
|
|
16355
16474
|
/**
|
|
16356
16475
|
* Get a summary key for browser settings to detect config drift.
|
|
16476
|
+
*
|
|
16477
|
+
* `resolved` is the model resolution for these settings; when the configured
|
|
16478
|
+
* model is used it is canonicalized the way `createBrowserFromSettings` does
|
|
16479
|
+
* (Anthropic id normalization, `-codex` remaps over Codex OAuth) so that two
|
|
16480
|
+
* spellings of the same launched model don't read as pending changes.
|
|
16357
16481
|
*/
|
|
16358
|
-
function getBrowserConfigKey(settings) {
|
|
16482
|
+
function getBrowserConfigKey(settings, resolved) {
|
|
16359
16483
|
if (!settings.enabled) return "disabled";
|
|
16360
16484
|
const parts = [settings.provider];
|
|
16361
16485
|
if (settings.provider === "stagehand" && settings.stagehand?.env) parts.push(settings.stagehand.env);
|
|
16362
|
-
if (settings.provider === "stagehand" && settings.stagehand?.model)
|
|
16486
|
+
if (settings.provider === "stagehand" && settings.stagehand?.model) {
|
|
16487
|
+
const canonical = resolved?.source === "settings" && resolved.modelName ? resolved.viaCodexOAuth ? (0, _mastra_code_sdk_providers_model_ids.remapOpenAIModelForCodexOAuth)(resolved.modelName) : resolved.modelName : settings.stagehand.model;
|
|
16488
|
+
parts.push(`model:${canonical}`);
|
|
16489
|
+
}
|
|
16363
16490
|
parts.push(settings.headless ? "headless" : "headed");
|
|
16491
|
+
const effectiveScope = settings.profile || settings.cdpUrl ? "shared" : settings.scope;
|
|
16492
|
+
if (effectiveScope) parts.push(`scope:${effectiveScope}`);
|
|
16493
|
+
if (settings.provider === "stagehand" && !settings.cdpUrl && settings.stagehand?.preserveUserDataDir !== void 0) parts.push(`preserve:${settings.stagehand.preserveUserDataDir}`);
|
|
16364
16494
|
if (settings.viewport) parts.push(`viewport:${formatViewport(settings.viewport)}`);
|
|
16365
16495
|
if (settings.profile) parts.push(`profile:${settings.profile}`);
|
|
16366
16496
|
if (settings.executablePath) parts.push(`exec:${settings.executablePath}`);
|
|
@@ -16485,17 +16615,20 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
16485
16615
|
ctx.showInfo(`Set ${args[1]} = ${expandedValue}\nRun /browser on to apply.`);
|
|
16486
16616
|
return;
|
|
16487
16617
|
}
|
|
16488
|
-
if (arg === "status") {
|
|
16489
|
-
const
|
|
16490
|
-
|
|
16618
|
+
if (arg === "status" || arg === "info") {
|
|
16619
|
+
const state = ctx.state.session.state.get();
|
|
16620
|
+
const activeSettings = state?.[ACTIVE_BROWSER_KEY];
|
|
16621
|
+
const activeModel = state?.[ACTIVE_BROWSER_MODEL_KEY];
|
|
16622
|
+
const resolveNow = (settings) => (0, _mastra_code_sdk_onboarding_settings.resolveStagehandModel)(settings, { chatModelId: launchChatModelId(ctx) });
|
|
16623
|
+
if (activeSettings && getBrowserConfigKey(browser, resolveNow(browser)) !== getBrowserConfigKey(activeSettings, activeModel ?? resolveNow(activeSettings)) && activeSettings) {
|
|
16491
16624
|
const lines = [];
|
|
16492
16625
|
const activeProvider = activeSettings.provider === "stagehand" ? "Stagehand (AI-powered)" : "AgentBrowser (deterministic)";
|
|
16493
16626
|
const activeIsBrowserbase = activeSettings.provider === "stagehand" && activeSettings.stagehand?.env === "BROWSERBASE";
|
|
16494
16627
|
lines.push("Browser (active):");
|
|
16495
16628
|
lines.push(` Provider: ${activeProvider}`);
|
|
16496
|
-
if (activeSettings.provider === "stagehand"
|
|
16497
|
-
lines.push(` Environment: ${activeSettings.stagehand.env}`);
|
|
16498
|
-
|
|
16629
|
+
if (activeSettings.provider === "stagehand") {
|
|
16630
|
+
if (activeSettings.stagehand) lines.push(` Environment: ${activeSettings.stagehand.env}`);
|
|
16631
|
+
lines.push(describeStagehandModel(activeModel ?? resolveNow(activeSettings)));
|
|
16499
16632
|
}
|
|
16500
16633
|
if (!activeIsBrowserbase) lines.push(` Headless: ${activeSettings.headless ? "yes" : "no"}`);
|
|
16501
16634
|
lines.push(` Viewport: ${formatViewport(activeSettings.viewport)}`);
|
|
@@ -16508,9 +16641,9 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
16508
16641
|
const fileIsBrowserbase = browser.provider === "stagehand" && browser.stagehand?.env === "BROWSERBASE";
|
|
16509
16642
|
lines.push("Pending changes (not yet applied):");
|
|
16510
16643
|
lines.push(` Provider: ${fileProvider}`);
|
|
16511
|
-
if (browser.provider === "stagehand"
|
|
16512
|
-
lines.push(` Environment: ${browser.stagehand.env}`);
|
|
16513
|
-
|
|
16644
|
+
if (browser.provider === "stagehand") {
|
|
16645
|
+
if (browser.stagehand) lines.push(` Environment: ${browser.stagehand.env}`);
|
|
16646
|
+
lines.push(describeStagehandModel(resolveNow(browser)));
|
|
16514
16647
|
}
|
|
16515
16648
|
if (!fileIsBrowserbase) lines.push(` Headless: ${browser.headless ? "yes" : "no"}`);
|
|
16516
16649
|
lines.push(` Viewport: ${formatViewport(browser.viewport)}`);
|
|
@@ -16526,9 +16659,9 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
16526
16659
|
const providerLabel = browser.provider === "stagehand" ? "Stagehand (AI-powered)" : "AgentBrowser (deterministic)";
|
|
16527
16660
|
const isBrowserbase = browser.provider === "stagehand" && browser.stagehand?.env === "BROWSERBASE";
|
|
16528
16661
|
const lines = [`Browser: enabled`, ` Provider: ${providerLabel}`];
|
|
16529
|
-
if (browser.provider === "stagehand"
|
|
16530
|
-
lines.push(` Environment: ${browser.stagehand.env}`);
|
|
16531
|
-
|
|
16662
|
+
if (browser.provider === "stagehand") {
|
|
16663
|
+
if (browser.stagehand) lines.push(` Environment: ${browser.stagehand.env}`);
|
|
16664
|
+
lines.push(describeStagehandModel(activeModel ?? resolveNow(browser)));
|
|
16532
16665
|
}
|
|
16533
16666
|
if (!isBrowserbase) lines.push(` Headless: ${browser.headless ? "yes" : "no"}`);
|
|
16534
16667
|
lines.push(` Viewport: ${formatViewport(browser.viewport)}`);
|
|
@@ -16561,7 +16694,8 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
16561
16694
|
return;
|
|
16562
16695
|
}
|
|
16563
16696
|
try {
|
|
16564
|
-
|
|
16697
|
+
const chatModelId = launchChatModelId(ctx);
|
|
16698
|
+
applyBrowserToAgents(ctx, await (0, _mastra_code_sdk_onboarding_settings.createBrowserFromSettings)(nextBrowser, { chatModelId }), nextBrowser, chatModelId);
|
|
16565
16699
|
if (nextBrowser.profile && nextBrowser.provider) (0, _mastra_code_sdk_onboarding_settings.setProfileProvider)(nextBrowser.profile, nextBrowser.provider);
|
|
16566
16700
|
settings.browser = nextBrowser;
|
|
16567
16701
|
(0, _mastra_code_sdk_onboarding_settings.saveSettings)(settings);
|
|
@@ -16587,7 +16721,8 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
16587
16721
|
};
|
|
16588
16722
|
(0, _mastra_code_sdk_onboarding_settings.saveSettings)(settings);
|
|
16589
16723
|
if (wasEnabled) try {
|
|
16590
|
-
|
|
16724
|
+
const chatModelId = launchChatModelId(ctx);
|
|
16725
|
+
applyBrowserToAgents(ctx, await (0, _mastra_code_sdk_onboarding_settings.createBrowserFromSettings)(settings.browser, { chatModelId }), settings.browser, chatModelId);
|
|
16591
16726
|
} catch (err) {
|
|
16592
16727
|
settings.browser.enabled = false;
|
|
16593
16728
|
(0, _mastra_code_sdk_onboarding_settings.saveSettings)(settings);
|
|
@@ -16644,8 +16779,9 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
16644
16779
|
}
|
|
16645
16780
|
let browserInstance = resolveModeAgent(ctx.state.session.mode.resolve(), ctx.state.session.state.get())?.browser;
|
|
16646
16781
|
if (!browserInstance && browser.enabled) {
|
|
16647
|
-
|
|
16648
|
-
|
|
16782
|
+
const chatModelId = launchChatModelId(ctx);
|
|
16783
|
+
browserInstance = await (0, _mastra_code_sdk_onboarding_settings.createBrowserFromSettings)(browser, { chatModelId });
|
|
16784
|
+
applyBrowserToAgents(ctx, browserInstance, browser, chatModelId);
|
|
16649
16785
|
}
|
|
16650
16786
|
if (!browserInstance) {
|
|
16651
16787
|
ctx.showError("Browser not enabled. Run /browser on first.");
|
|
@@ -16669,6 +16805,7 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
16669
16805
|
if (arg && ![
|
|
16670
16806
|
"set",
|
|
16671
16807
|
"status",
|
|
16808
|
+
"info",
|
|
16672
16809
|
"on",
|
|
16673
16810
|
"off",
|
|
16674
16811
|
"enable",
|
|
@@ -16681,7 +16818,7 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
16681
16818
|
" (no command) Interactive setup wizard",
|
|
16682
16819
|
" on, enable Enable browser with current settings",
|
|
16683
16820
|
" off, disable Disable browser",
|
|
16684
|
-
" status
|
|
16821
|
+
" status, info Show current configuration (provider, model, profile, ...)",
|
|
16685
16822
|
" clear Reset all settings to defaults",
|
|
16686
16823
|
" clear <key> Clear: profile, executablePath, storageState, cdpUrl, model, viewport",
|
|
16687
16824
|
" set <key> <v> Set: profile, executablePath, storageState, cdpUrl, model, viewport",
|
|
@@ -16848,8 +16985,9 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
16848
16985
|
ctx.showInfo("Browser setup cancelled.");
|
|
16849
16986
|
return;
|
|
16850
16987
|
}
|
|
16988
|
+
const chatModelId = launchChatModelId(ctx);
|
|
16851
16989
|
try {
|
|
16852
|
-
applyBrowserToAgents(ctx, await (0, _mastra_code_sdk_onboarding_settings.createBrowserFromSettings)(nextBrowser), nextBrowser);
|
|
16990
|
+
applyBrowserToAgents(ctx, await (0, _mastra_code_sdk_onboarding_settings.createBrowserFromSettings)(nextBrowser, { chatModelId }), nextBrowser, chatModelId);
|
|
16853
16991
|
if (nextBrowser.profile && nextBrowser.provider) (0, _mastra_code_sdk_onboarding_settings.setProfileProvider)(nextBrowser.profile, nextBrowser.provider);
|
|
16854
16992
|
settings.browser = nextBrowser;
|
|
16855
16993
|
(0, _mastra_code_sdk_onboarding_settings.saveSettings)(settings);
|
|
@@ -16858,7 +16996,10 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
16858
16996
|
return;
|
|
16859
16997
|
}
|
|
16860
16998
|
const summary = ["Browser automation enabled:", ` Provider: ${provider === "stagehand" ? "Stagehand (AI-powered)" : "AgentBrowser (deterministic)"}`];
|
|
16861
|
-
if (provider === "stagehand"
|
|
16999
|
+
if (provider === "stagehand") {
|
|
17000
|
+
if (stagehandSettings) summary.push(` Environment: ${stagehandSettings.env}`);
|
|
17001
|
+
summary.push(describeStagehandModel((0, _mastra_code_sdk_onboarding_settings.resolveStagehandModel)(nextBrowser, { chatModelId })));
|
|
17002
|
+
}
|
|
16862
17003
|
if (!isBrowserbase) summary.push(` Headless: ${headless ? "yes" : "no"}`);
|
|
16863
17004
|
if (cdpUrl) summary.push(` CDP URL: ${cdpUrl}`);
|
|
16864
17005
|
if (executablePath) summary.push(` Executable: ${executablePath}`);
|
|
@@ -26814,14 +26955,9 @@ var MastraTUI = class MastraTUI {
|
|
|
26814
26955
|
this.state.quietMode = enabled;
|
|
26815
26956
|
this.state.quietModeMaxToolPreviewLines = previewLineLimit;
|
|
26816
26957
|
this.state.taskProgress?.setQuietMode(enabled);
|
|
26817
|
-
const tools = this.state.allToolComponents.filter((tool) => typeof tool.setQuietModeDisplay === "function");
|
|
26818
26958
|
const color = this.state.session?.mode.resolve().metadata?.color;
|
|
26819
26959
|
const modeColor = typeof color === "string" ? color : void 0;
|
|
26820
|
-
|
|
26821
|
-
tool.setCompactToolModeColor?.(modeColor);
|
|
26822
|
-
tool.setQuietModeDisplay?.(enabled ? "quiet" : "normal");
|
|
26823
|
-
tool.setQuietPreviewLineLimit?.(previewLineLimit);
|
|
26824
|
-
}
|
|
26960
|
+
applyQuietModeToRenderedComponents(this.state, enabled, previewLineLimit, modeColor);
|
|
26825
26961
|
flushRender(this.state);
|
|
26826
26962
|
}
|
|
26827
26963
|
parseQuietPreviewLineAnswer(answer) {
|
|
@@ -26852,7 +26988,7 @@ var MastraTUI = class MastraTUI {
|
|
|
26852
26988
|
options: [
|
|
26853
26989
|
{
|
|
26854
26990
|
label: "None",
|
|
26855
|
-
description: "Hide
|
|
26991
|
+
description: "Hide tool previews and shell output"
|
|
26856
26992
|
},
|
|
26857
26993
|
{
|
|
26858
26994
|
label: "1 line",
|
|
@@ -27078,4 +27214,4 @@ Object.defineProperty(exports, "theme", {
|
|
|
27078
27214
|
}
|
|
27079
27215
|
});
|
|
27080
27216
|
|
|
27081
|
-
//# sourceMappingURL=tui-
|
|
27217
|
+
//# sourceMappingURL=tui-CJ1G5lRF.cjs.map
|