mastracode 0.48.0-alpha.8 → 0.48.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 +109 -0
- package/dist/cli.cjs +4 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +4 -3
- package/dist/cli.js.map +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/login-command-DmwsIJrs.cjs.map +1 -1
- package/dist/tui/commands/browser.d.ts.map +1 -1
- package/dist/tui/components/collapsible.d.ts.map +1 -1
- package/dist/tui/components/tool-execution-enhanced.d.ts.map +1 -1
- package/dist/tui/syntax-highlight.d.ts +22 -0
- package/dist/tui/syntax-highlight.d.ts.map +1 -0
- package/dist/tui/voice/transcribe.d.ts.map +1 -1
- package/dist/{tui-Bdb-MfGN.js → tui-NWh1Dtvz.js} +243 -113
- package/dist/tui-NWh1Dtvz.js.map +1 -0
- package/dist/{tui-Cwh6G2Fw.cjs → tui-cKViKRi_.cjs} +272 -142
- package/dist/tui-cKViKRi_.cjs.map +1 -0
- package/dist/tui.cjs +7 -2
- package/dist/tui.js +1 -2
- package/package.json +20 -20
- package/dist/tui-Bdb-MfGN.js.map +0 -1
- package/dist/tui-Cwh6G2Fw.cjs.map +0 -1
|
@@ -15,7 +15,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
@@ -50,8 +50,6 @@ let _mastra_code_sdk_agents_instructions = require("@mastra/code-sdk/agents/inst
|
|
|
50
50
|
let _mastra_core_processors = require("@mastra/core/processors");
|
|
51
51
|
let _mastra_code_sdk_voice_stt_registry = require("@mastra/code-sdk/voice/stt-registry");
|
|
52
52
|
let stream = require("stream");
|
|
53
|
-
let _mastra_voice_deepgram = require("@mastra/voice-deepgram");
|
|
54
|
-
let _mastra_voice_openai = require("@mastra/voice-openai");
|
|
55
53
|
let _mastra_code_sdk_thinking = require("@mastra/code-sdk/thinking");
|
|
56
54
|
let _mastra_code_sdk_thinking_catalog = require("@mastra/code-sdk/thinking-catalog");
|
|
57
55
|
let _mastra_code_sdk_hooks_index = require("@mastra/code-sdk/hooks/index");
|
|
@@ -67,7 +65,7 @@ let _mastra_core_utils = require("@mastra/core/utils");
|
|
|
67
65
|
let process$1 = require("process");
|
|
68
66
|
process$1 = __toESM(process$1, 1);
|
|
69
67
|
let _mastra_code_sdk_tool_names = require("@mastra/code-sdk/tool-names");
|
|
70
|
-
let
|
|
68
|
+
let module$1 = require("module");
|
|
71
69
|
let _mastra_code_sdk_permissions = require("@mastra/code-sdk/permissions");
|
|
72
70
|
let jsonriver = require("jsonriver");
|
|
73
71
|
let _mastra_code_sdk_utils_project = require("@mastra/code-sdk/utils/project");
|
|
@@ -81,7 +79,6 @@ let _mastra_code_sdk_agents_model = require("@mastra/code-sdk/agents/model");
|
|
|
81
79
|
let _mastra_code_sdk_onboarding_custom_providers = require("@mastra/code-sdk/onboarding/custom-providers");
|
|
82
80
|
let _mastra_code_sdk_onboarding_om_settings = require("@mastra/code-sdk/onboarding/om-settings");
|
|
83
81
|
let _mastra_code_sdk_providers_model_ids = require("@mastra/code-sdk/providers/model-ids");
|
|
84
|
-
let _mastra_stagehand = require("@mastra/stagehand");
|
|
85
82
|
let _mastra_code_sdk_auth_index = require("@mastra/code-sdk/auth/index");
|
|
86
83
|
let _mastra_code_sdk_factory_client = require("@mastra/code-sdk/factory/client");
|
|
87
84
|
let _mastra_core_llm = require("@mastra/core/llm");
|
|
@@ -2888,15 +2885,16 @@ var ModelSelectorComponent = class extends _earendil_works_pi_tui.Box {
|
|
|
2888
2885
|
this.selectedIndex = this.selectedIndex === totalItems - 1 ? 0 : this.selectedIndex + 1;
|
|
2889
2886
|
this.updateList();
|
|
2890
2887
|
this.tui.requestRender();
|
|
2891
|
-
} else if (kb.matches(keyData, "tui.select.confirm"))
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2888
|
+
} else if (kb.matches(keyData, "tui.select.confirm")) {
|
|
2889
|
+
if (this.hasCustomItem && this.selectedIndex === 0) {
|
|
2890
|
+
const query = this.searchInput.getValue().trim();
|
|
2891
|
+
if (query) this.handleSelect(this.makeCustomModelItem(query));
|
|
2892
|
+
} else {
|
|
2893
|
+
const modelIndex = this.hasCustomItem ? this.selectedIndex - 1 : this.selectedIndex;
|
|
2894
|
+
const selected = this.filteredModels[modelIndex];
|
|
2895
|
+
if (selected) this.handleSelect(selected);
|
|
2896
|
+
}
|
|
2897
|
+
} else if (kb.matches(keyData, "tui.select.cancel")) this.onCancelCallback();
|
|
2900
2898
|
else {
|
|
2901
2899
|
this.searchInput.handleInput(keyData);
|
|
2902
2900
|
this.filterModels(this.searchInput.getValue());
|
|
@@ -3891,7 +3889,8 @@ async function collectSkillsCatalog(ctx) {
|
|
|
3891
3889
|
const listed = await workspace.skills.list();
|
|
3892
3890
|
if (listed.length === 0) return void 0;
|
|
3893
3891
|
const skills = (await Promise.all(listed.map((meta) => workspace.skills.get(meta.path)))).filter((skill) => !!skill);
|
|
3894
|
-
|
|
3892
|
+
const deduped = Array.from(new Map(skills.map((skill) => [skill.path, skill])).values());
|
|
3893
|
+
return (0, _mastra_core_processors.formatSkillsCatalog)(deduped.map((skill) => ({
|
|
3895
3894
|
name: skill.name,
|
|
3896
3895
|
description: skill.description,
|
|
3897
3896
|
location: `${skill.path}/SKILL.md`,
|
|
@@ -4150,8 +4149,10 @@ var WrappingSelectList = class {
|
|
|
4150
4149
|
this.notifySelectionChange();
|
|
4151
4150
|
} else if (this.multiSelect && keyData === " ") {
|
|
4152
4151
|
const current = this.filteredItems[this.selectedIndex];
|
|
4153
|
-
if (current)
|
|
4154
|
-
|
|
4152
|
+
if (current) {
|
|
4153
|
+
if (this.checkedValues.has(current.value)) this.checkedValues.delete(current.value);
|
|
4154
|
+
else this.checkedValues.add(current.value);
|
|
4155
|
+
}
|
|
4155
4156
|
} else if (kb.matches(keyData, "tui.select.confirm")) {
|
|
4156
4157
|
if (this.multiSelect) {
|
|
4157
4158
|
const checked = this.items.filter((item) => this.checkedValues.has(item.value));
|
|
@@ -4165,7 +4166,8 @@ var WrappingSelectList = class {
|
|
|
4165
4166
|
renderItem(item, isSelected, width) {
|
|
4166
4167
|
const labelText = this.getDisplayValue(item);
|
|
4167
4168
|
const checkboxWidth = this.multiSelect ? CHECKBOX_WIDTH : 0;
|
|
4168
|
-
const
|
|
4169
|
+
const labelWidth = Math.max(1, width - PREFIX_WIDTH - checkboxWidth);
|
|
4170
|
+
const wrapped = (0, _earendil_works_pi_tui.wrapTextWithAnsi)(labelText, labelWidth);
|
|
4169
4171
|
const checkbox = this.multiSelect ? this.checkedValues.has(item.value) ? CHECKBOX_CHECKED : CHECKBOX_UNCHECKED : "";
|
|
4170
4172
|
if (this.cardStyle) {
|
|
4171
4173
|
const style = this.cardStyle;
|
|
@@ -4458,12 +4460,16 @@ function resolveProviderApiKey(provider, authStorage) {
|
|
|
4458
4460
|
* - everything else: `OpenAIVoice`, where `listeningModel.name` is the model id
|
|
4459
4461
|
* and `options.baseURL` redirects OpenAI-compatible hosts at their endpoint.
|
|
4460
4462
|
*/
|
|
4461
|
-
function buildVoice(entry, apiKey) {
|
|
4462
|
-
if (entry.resolver === "deepgram")
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4463
|
+
async function buildVoice(entry, apiKey) {
|
|
4464
|
+
if (entry.resolver === "deepgram") {
|
|
4465
|
+
const { DeepgramVoice } = await import("@mastra/voice-deepgram");
|
|
4466
|
+
return new DeepgramVoice({ listeningModel: {
|
|
4467
|
+
name: entry.model,
|
|
4468
|
+
apiKey
|
|
4469
|
+
} });
|
|
4470
|
+
}
|
|
4471
|
+
const { OpenAIVoice } = await import("@mastra/voice-openai");
|
|
4472
|
+
return new OpenAIVoice({ listeningModel: {
|
|
4467
4473
|
name: entry.model,
|
|
4468
4474
|
apiKey,
|
|
4469
4475
|
...entry.resolver === "openai-compatible" && entry.baseURL ? { options: { baseURL: entry.baseURL } } : {}
|
|
@@ -4480,8 +4486,9 @@ function createTranscriber(options = {}) {
|
|
|
4480
4486
|
const apiKey = resolveProviderApiKey(entry.provider, options.authStorage);
|
|
4481
4487
|
if (!apiKey) throw new VoiceCredentialError(entry.provider);
|
|
4482
4488
|
const voice = buildVoice(entry, apiKey);
|
|
4489
|
+
voice.catch(() => {});
|
|
4483
4490
|
return { async transcribe(audio) {
|
|
4484
|
-
return normalizeTranscript(await voice.listen(stream.Readable.from(audio), { filetype: "wav" }));
|
|
4491
|
+
return normalizeTranscript(await (await voice).listen(stream.Readable.from(audio), { filetype: "wav" }));
|
|
4485
4492
|
} };
|
|
4486
4493
|
}
|
|
4487
4494
|
/**
|
|
@@ -5423,7 +5430,6 @@ var McpSelectorComponent = class extends _earendil_works_pi_tui.Box {
|
|
|
5423
5430
|
case "inherit":
|
|
5424
5431
|
this.subMenuOpen = false;
|
|
5425
5432
|
this.doInheritServer(status);
|
|
5426
|
-
break;
|
|
5427
5433
|
}
|
|
5428
5434
|
}
|
|
5429
5435
|
doSetServerDisabled(status, disabled, global) {
|
|
@@ -5660,7 +5666,10 @@ function sendNotification(reason, opts) {
|
|
|
5660
5666
|
hookManager?.runNotification(reason, message);
|
|
5661
5667
|
}
|
|
5662
5668
|
function sendSystemNotification(reason, message) {
|
|
5663
|
-
if (process.platform === "darwin")
|
|
5669
|
+
if (process.platform === "darwin") {
|
|
5670
|
+
const script = `display notification "${(message || reasonToMessage(reason)).replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}" with title "Mastra Code"`;
|
|
5671
|
+
(0, child_process.execFile)("osascript", ["-e", script], () => {});
|
|
5672
|
+
}
|
|
5664
5673
|
}
|
|
5665
5674
|
function reasonToMessage(reason) {
|
|
5666
5675
|
switch (reason) {
|
|
@@ -7682,9 +7691,7 @@ var PlanApprovalInlineComponent = class PlanApprovalInlineComponent extends _ear
|
|
|
7682
7691
|
case "goal":
|
|
7683
7692
|
this.handleGoal();
|
|
7684
7693
|
break;
|
|
7685
|
-
case "changes":
|
|
7686
|
-
this.handleReject();
|
|
7687
|
-
break;
|
|
7694
|
+
case "changes": this.handleReject();
|
|
7688
7695
|
}
|
|
7689
7696
|
}
|
|
7690
7697
|
handleApprove() {
|
|
@@ -8425,6 +8432,161 @@ function formatStatusDuration(ms, opts = {}) {
|
|
|
8425
8432
|
return `${Math.max(1, minutes)}m`;
|
|
8426
8433
|
}
|
|
8427
8434
|
//#endregion
|
|
8435
|
+
//#region src/tui/syntax-highlight.ts
|
|
8436
|
+
/**
|
|
8437
|
+
* Terminal syntax highlighting on highlight.js core.
|
|
8438
|
+
*
|
|
8439
|
+
* `cli-highlight` loads every highlight.js language (192 files) and parse5 up front, about 23 MB per
|
|
8440
|
+
* session. This registers a language (and the languages it embeds) the first time a file of that kind
|
|
8441
|
+
* is shown, and colors highlight.js's HTML with the same rules cli-highlight used, so previews look
|
|
8442
|
+
* the same.
|
|
8443
|
+
*/
|
|
8444
|
+
const require$1 = (0, module$1.createRequire)(require("url").pathToFileURL(__filename).href);
|
|
8445
|
+
/**
|
|
8446
|
+
* Syntax roles mapped onto the theme's semantic colors. theme.fg resolves the
|
|
8447
|
+
* active theme lazily and contrast-adapts, so code previews recolor with
|
|
8448
|
+
* custom themes and stay readable on any background.
|
|
8449
|
+
*/
|
|
8450
|
+
const CODE_HIGHLIGHT_THEME = {
|
|
8451
|
+
default: (text) => theme.fg("toolArgs", text),
|
|
8452
|
+
keyword: (text) => theme.fg("textHighlight", text),
|
|
8453
|
+
built_in: (text) => theme.fg("function", text),
|
|
8454
|
+
type: (text) => theme.fg("function", text),
|
|
8455
|
+
literal: (text) => theme.fg("error", text),
|
|
8456
|
+
number: (text) => theme.fg("number", text),
|
|
8457
|
+
string: (text) => theme.fg("success", text),
|
|
8458
|
+
regexp: (text) => theme.fg("error", text),
|
|
8459
|
+
title: (text) => theme.fg("function", text),
|
|
8460
|
+
function: (text) => theme.fg("function", text),
|
|
8461
|
+
params: (text) => theme.fg("secondary", text),
|
|
8462
|
+
comment: (text) => theme.fg("muted", text),
|
|
8463
|
+
meta: (text) => theme.fg("muted", text),
|
|
8464
|
+
attr: (text) => theme.fg("number", text),
|
|
8465
|
+
variable: (text) => theme.fg("secondary", text),
|
|
8466
|
+
tag: (text) => theme.fg("textHighlight", text),
|
|
8467
|
+
name: (text) => theme.fg("textHighlight", text)
|
|
8468
|
+
};
|
|
8469
|
+
const plain = (text) => text;
|
|
8470
|
+
/** cli-highlight's DEFAULT_THEME: what a scope gets when the theme above doesn't name it. */
|
|
8471
|
+
const FALLBACK_THEME = {
|
|
8472
|
+
keyword: chalk.default.blue,
|
|
8473
|
+
built_in: chalk.default.cyan,
|
|
8474
|
+
type: chalk.default.cyan.dim,
|
|
8475
|
+
literal: chalk.default.blue,
|
|
8476
|
+
number: chalk.default.green,
|
|
8477
|
+
regexp: chalk.default.red,
|
|
8478
|
+
string: chalk.default.red,
|
|
8479
|
+
class: chalk.default.blue,
|
|
8480
|
+
function: chalk.default.yellow,
|
|
8481
|
+
comment: chalk.default.green,
|
|
8482
|
+
doctag: chalk.default.green,
|
|
8483
|
+
meta: chalk.default.grey,
|
|
8484
|
+
tag: chalk.default.grey,
|
|
8485
|
+
name: chalk.default.blue,
|
|
8486
|
+
attr: chalk.default.cyan,
|
|
8487
|
+
emphasis: chalk.default.italic,
|
|
8488
|
+
strong: chalk.default.bold,
|
|
8489
|
+
link: chalk.default.underline,
|
|
8490
|
+
addition: chalk.default.green,
|
|
8491
|
+
deletion: chalk.default.red
|
|
8492
|
+
};
|
|
8493
|
+
let hljs;
|
|
8494
|
+
function getHljs() {
|
|
8495
|
+
hljs ??= require$1("highlight.js/lib/core");
|
|
8496
|
+
return hljs;
|
|
8497
|
+
}
|
|
8498
|
+
/** Names highlight.js only knows as an alias of another language's file. */
|
|
8499
|
+
const LANGUAGE_FILES = { html: "xml" };
|
|
8500
|
+
/** Languages a grammar hands parts of the code to (`<script>` in HTML, `RUN` in a Dockerfile). */
|
|
8501
|
+
function subLanguagesOf(language) {
|
|
8502
|
+
const found = /* @__PURE__ */ new Set();
|
|
8503
|
+
const seen = /* @__PURE__ */ new Set();
|
|
8504
|
+
const visit = (mode) => {
|
|
8505
|
+
if (!mode || typeof mode !== "object" || seen.has(mode)) return;
|
|
8506
|
+
seen.add(mode);
|
|
8507
|
+
const { subLanguage, contains, variants, starts } = mode;
|
|
8508
|
+
for (const name of [subLanguage].flat()) if (typeof name === "string") found.add(name);
|
|
8509
|
+
for (const child of [contains, variants].flat()) visit(child);
|
|
8510
|
+
visit(starts);
|
|
8511
|
+
};
|
|
8512
|
+
visit(language);
|
|
8513
|
+
return [...found];
|
|
8514
|
+
}
|
|
8515
|
+
/**
|
|
8516
|
+
* Register a language on first use, along with the languages it embeds, so they highlight as they
|
|
8517
|
+
* did when every language was loaded. False when highlight.js has no such language.
|
|
8518
|
+
*/
|
|
8519
|
+
function ensureLanguage(language) {
|
|
8520
|
+
const core = getHljs();
|
|
8521
|
+
if (core.getLanguage(language)) return true;
|
|
8522
|
+
const file = LANGUAGE_FILES[language] ?? language;
|
|
8523
|
+
try {
|
|
8524
|
+
core.registerLanguage(file, require$1(`highlight.js/lib/languages/${file}`));
|
|
8525
|
+
} catch {
|
|
8526
|
+
return false;
|
|
8527
|
+
}
|
|
8528
|
+
const registered = core.getLanguage(language);
|
|
8529
|
+
if (!registered) return false;
|
|
8530
|
+
for (const embedded of subLanguagesOf(registered)) ensureLanguage(embedded);
|
|
8531
|
+
return true;
|
|
8532
|
+
}
|
|
8533
|
+
const ENTITIES = {
|
|
8534
|
+
amp: "&",
|
|
8535
|
+
lt: "<",
|
|
8536
|
+
gt: ">",
|
|
8537
|
+
quot: "\"",
|
|
8538
|
+
"#x27": "'",
|
|
8539
|
+
"#39": "'"
|
|
8540
|
+
};
|
|
8541
|
+
/** Parse highlight.js output, which only ever contains `<span class="…">` and escaped text. */
|
|
8542
|
+
function parseHighlightHtml(html) {
|
|
8543
|
+
const root = [];
|
|
8544
|
+
const stack = [root];
|
|
8545
|
+
for (const match of html.matchAll(/<span class="([^"]*)">|<\/span>|&(amp|lt|gt|quot|#x27|#39);|[^<&]+|[<&]/g)) {
|
|
8546
|
+
const children = stack[stack.length - 1];
|
|
8547
|
+
if (match[1] !== void 0) {
|
|
8548
|
+
const span = {
|
|
8549
|
+
className: match[1],
|
|
8550
|
+
children: []
|
|
8551
|
+
};
|
|
8552
|
+
children.push(span);
|
|
8553
|
+
stack.push(span.children);
|
|
8554
|
+
} else if (match[0] === "</span>") {
|
|
8555
|
+
if (stack.length > 1) stack.pop();
|
|
8556
|
+
} else {
|
|
8557
|
+
const text = match[2] ? ENTITIES[match[2]] : match[0];
|
|
8558
|
+
const last = children.length - 1;
|
|
8559
|
+
if (typeof children[last] === "string") children[last] += text;
|
|
8560
|
+
else children.push(text);
|
|
8561
|
+
}
|
|
8562
|
+
}
|
|
8563
|
+
return root;
|
|
8564
|
+
}
|
|
8565
|
+
/**
|
|
8566
|
+
* cli-highlight's colorizer: text outside any scope takes `default`; a scope colors everything
|
|
8567
|
+
* inside it (inner scopes keep their own color); an embedded language's wrapper (`<span
|
|
8568
|
+
* class="javascript">`) starts over as if at the top level.
|
|
8569
|
+
*/
|
|
8570
|
+
function colorize(node, colors, insideScope) {
|
|
8571
|
+
if (typeof node === "string") return insideScope ? node : (colors.default ?? plain)(node);
|
|
8572
|
+
const token = /hljs-(\w+)/.exec(node.className)?.[1];
|
|
8573
|
+
if (!token) return node.children.map((child) => colorize(child, colors, false)).join("");
|
|
8574
|
+
const text = node.children.map((child) => colorize(child, colors, true)).join("");
|
|
8575
|
+
return (colors[token] ?? FALLBACK_THEME[token] ?? plain)(text);
|
|
8576
|
+
}
|
|
8577
|
+
/**
|
|
8578
|
+
* Highlight `code` as `language`. Unknown or missing languages come back in the theme's default
|
|
8579
|
+
* color (no auto-detection, which would need every language loaded).
|
|
8580
|
+
*/
|
|
8581
|
+
function highlightCode(code, language, colors = CODE_HIGHLIGHT_THEME) {
|
|
8582
|
+
if (!language || !ensureLanguage(language)) return (colors.default ?? plain)(code);
|
|
8583
|
+
const html = getHljs().highlight(code, {
|
|
8584
|
+
language,
|
|
8585
|
+
ignoreIllegals: true
|
|
8586
|
+
}).value;
|
|
8587
|
+
return parseHighlightHtml(html).map((node) => colorize(node, colors, false)).join("");
|
|
8588
|
+
}
|
|
8589
|
+
//#endregion
|
|
8428
8590
|
//#region src/tui/components/collapsible.ts
|
|
8429
8591
|
/**
|
|
8430
8592
|
* Generic collapsible container component.
|
|
@@ -8758,31 +8920,6 @@ function normalizeHexColor(color) {
|
|
|
8758
8920
|
if (!color || !/^#[0-9a-f]{6}$/i.test(color)) return void 0;
|
|
8759
8921
|
return color;
|
|
8760
8922
|
}
|
|
8761
|
-
/**
|
|
8762
|
-
* Syntax roles mapped onto the theme's semantic colors. theme.fg resolves the
|
|
8763
|
-
* active theme lazily and contrast-adapts, so code previews recolor with
|
|
8764
|
-
* custom themes and stay readable on any background.
|
|
8765
|
-
*/
|
|
8766
|
-
const CODE_HIGHLIGHT_THEME = {
|
|
8767
|
-
default: (text) => theme.fg("toolArgs", text),
|
|
8768
|
-
keyword: (text) => theme.fg("textHighlight", text),
|
|
8769
|
-
built_in: (text) => theme.fg("function", text),
|
|
8770
|
-
type: (text) => theme.fg("function", text),
|
|
8771
|
-
literal: (text) => theme.fg("error", text),
|
|
8772
|
-
number: (text) => theme.fg("number", text),
|
|
8773
|
-
string: (text) => theme.fg("success", text),
|
|
8774
|
-
regexp: (text) => theme.fg("error", text),
|
|
8775
|
-
title: (text) => theme.fg("function", text),
|
|
8776
|
-
function: (text) => theme.fg("function", text),
|
|
8777
|
-
params: (text) => theme.fg("secondary", text),
|
|
8778
|
-
comment: (text) => theme.fg("muted", text),
|
|
8779
|
-
meta: (text) => theme.fg("muted", text),
|
|
8780
|
-
attr: (text) => theme.fg("number", text),
|
|
8781
|
-
variable: (text) => theme.fg("secondary", text),
|
|
8782
|
-
tag: (text) => theme.fg("textHighlight", text),
|
|
8783
|
-
name: (text) => theme.fg("textHighlight", text)
|
|
8784
|
-
};
|
|
8785
|
-
const codeHighlightTheme = () => CODE_HIGHLIGHT_THEME;
|
|
8786
8923
|
const SHELL_CONTROL_WORDS = /* @__PURE__ */ new Set([
|
|
8787
8924
|
"if",
|
|
8788
8925
|
"then",
|
|
@@ -8829,10 +8966,10 @@ function parseErrorMessage(output) {
|
|
|
8829
8966
|
}
|
|
8830
8967
|
/** Room kept for the right-aligned time so a ticking counter never changes the box width. */
|
|
8831
8968
|
const SHELL_TIME_WIDTH = 7;
|
|
8832
|
-
function shortenPath(path
|
|
8969
|
+
function shortenPath(path) {
|
|
8833
8970
|
const home = os.homedir();
|
|
8834
|
-
if (path
|
|
8835
|
-
return path
|
|
8971
|
+
if (path.startsWith(home)) return `~${path.slice(home.length)}`;
|
|
8972
|
+
return path;
|
|
8836
8973
|
}
|
|
8837
8974
|
/** Check if a tool name is a web search provider tool (e.g. web_search, web_search_20250305) */
|
|
8838
8975
|
function isWebSearchTool(name) {
|
|
@@ -9050,7 +9187,8 @@ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
|
|
|
9050
9187
|
const { cdPath } = this.parseShellCommand();
|
|
9051
9188
|
if (!cwd || !cdPath) return cwd || cdPath;
|
|
9052
9189
|
if (cdPath.startsWith("/") || cdPath === "~" || cdPath.startsWith("~/")) return cdPath;
|
|
9053
|
-
|
|
9190
|
+
const expandedCwd = cwd === "~" || cwd.startsWith("~/") ? os.homedir() + cwd.slice(1) : cwd;
|
|
9191
|
+
return (0, path.join)(expandedCwd, cdPath);
|
|
9054
9192
|
}
|
|
9055
9193
|
/** The directory a compact shell group shows in its `$ <path>` header, resolved the way the sandbox resolves it. */
|
|
9056
9194
|
getShellHeaderPath() {
|
|
@@ -9208,13 +9346,15 @@ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
|
|
|
9208
9346
|
if (this.fullRender || this.toolName === _mastra_code_sdk_tool_names.MC_TOOLS.EXECUTE_COMMAND || this.previewLineLimit <= 0) return [];
|
|
9209
9347
|
const preview = this.getActivePreview();
|
|
9210
9348
|
let lines = [];
|
|
9211
|
-
if (preview)
|
|
9212
|
-
|
|
9213
|
-
|
|
9214
|
-
|
|
9215
|
-
|
|
9216
|
-
|
|
9217
|
-
|
|
9349
|
+
if (preview) {
|
|
9350
|
+
if (this.isCodePreviewTool()) lines = this.getCodePreviewLines(preview, maxLineWidth);
|
|
9351
|
+
else {
|
|
9352
|
+
const firstLineWidth = Math.max(10, maxLineWidth - 4);
|
|
9353
|
+
const continuationWidth = Math.max(10, maxLineWidth - 4);
|
|
9354
|
+
lines = (this.toolName === _mastra_code_sdk_tool_names.MC_TOOLS.AGENT_SIGNAL_SEND ? this.wrapAgentSignalMessageLines(preview, Math.max(1, firstLineWidth - 2)).slice(0, this.previewLineLimit) : this.wrapPreviewLines(preview, firstLineWidth, continuationWidth).slice(-this.previewLineLimit)).map((line) => {
|
|
9355
|
+
return truncateAnsi(`${` ${chalk.default.hex(this.getToolRailColor())("│")} `}${this.formatActivePreview(line)}`, maxLineWidth);
|
|
9356
|
+
});
|
|
9357
|
+
}
|
|
9218
9358
|
}
|
|
9219
9359
|
this.previewRowFloor = Math.min(this.previewLineLimit, Math.max(this.previewRowFloor, lines.length));
|
|
9220
9360
|
return [...Array.from({ length: this.previewRowFloor - lines.length }, () => {
|
|
@@ -9242,13 +9382,9 @@ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
|
|
|
9242
9382
|
return theme.fg("text", preview);
|
|
9243
9383
|
}
|
|
9244
9384
|
highlightCodePreview(preview) {
|
|
9245
|
-
const path
|
|
9385
|
+
const path = this.getFirstStringArg("path");
|
|
9246
9386
|
try {
|
|
9247
|
-
return (
|
|
9248
|
-
language: getLanguageFromPath(path$4),
|
|
9249
|
-
ignoreIllegals: true,
|
|
9250
|
-
theme: codeHighlightTheme()
|
|
9251
|
-
});
|
|
9387
|
+
return highlightCode(preview, getLanguageFromPath(path));
|
|
9252
9388
|
} catch {
|
|
9253
9389
|
return theme.fg("toolArgs", preview);
|
|
9254
9390
|
}
|
|
@@ -9597,16 +9733,16 @@ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
|
|
|
9597
9733
|
}
|
|
9598
9734
|
getImmediateDirnameStart(summary) {
|
|
9599
9735
|
const pathEnd = summary.indexOf(":");
|
|
9600
|
-
const path
|
|
9601
|
-
const filenameSlashIndex = path
|
|
9736
|
+
const path = pathEnd >= 0 ? summary.slice(0, pathEnd) : summary;
|
|
9737
|
+
const filenameSlashIndex = path.lastIndexOf("/");
|
|
9602
9738
|
if (filenameSlashIndex < 0) return void 0;
|
|
9603
|
-
const dirnameSlashIndex = path
|
|
9739
|
+
const dirnameSlashIndex = path.lastIndexOf("/", filenameSlashIndex - 1);
|
|
9604
9740
|
return dirnameSlashIndex >= 0 ? dirnameSlashIndex : filenameSlashIndex;
|
|
9605
9741
|
}
|
|
9606
9742
|
hasCompletePathSegment(summary) {
|
|
9607
9743
|
const pathEnd = summary.indexOf(":");
|
|
9608
|
-
const path
|
|
9609
|
-
const lastSegment = path
|
|
9744
|
+
const path = pathEnd >= 0 ? summary.slice(0, pathEnd) : summary;
|
|
9745
|
+
const lastSegment = path.slice(path.lastIndexOf("/") + 1);
|
|
9610
9746
|
return lastSegment.length > 0 && (pathEnd >= 0 || lastSegment.includes("."));
|
|
9611
9747
|
}
|
|
9612
9748
|
formatSharedPrefixPlaceholder(summary, sharedPrefixLength) {
|
|
@@ -9618,11 +9754,11 @@ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
|
|
|
9618
9754
|
let i = 0;
|
|
9619
9755
|
while (i < a.length && i < b.length && a[i] === b[i]) i++;
|
|
9620
9756
|
const pathEnd = b.indexOf(":");
|
|
9621
|
-
const path
|
|
9622
|
-
const sharedPathLength = Math.min(i, path
|
|
9757
|
+
const path = pathEnd >= 0 ? b.slice(0, pathEnd) : b;
|
|
9758
|
+
const sharedPathLength = Math.min(i, path.length);
|
|
9623
9759
|
if (sharedPathLength === 0) return 0;
|
|
9624
|
-
const matchingSegmentBoundary = path
|
|
9625
|
-
const currentSegmentStart = path
|
|
9760
|
+
const matchingSegmentBoundary = path.lastIndexOf("/", sharedPathLength - 1);
|
|
9761
|
+
const currentSegmentStart = path.lastIndexOf("/", Math.max(0, sharedPathLength - 1));
|
|
9626
9762
|
if (i === b.length && i === a.length) return this.getImmediateDirnameStart(b) ?? b.length;
|
|
9627
9763
|
if (i === b.length || i === a.length) return b.length;
|
|
9628
9764
|
if (i < b.length && i < a.length) {
|
|
@@ -9683,17 +9819,17 @@ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
|
|
|
9683
9819
|
const line = typeof argsObj?.line === "number" ? argsObj.line : void 0;
|
|
9684
9820
|
const start = viewRange?.[0] ?? offset ?? line;
|
|
9685
9821
|
const end = viewRange?.[1] ?? (offset !== void 0 && limit !== void 0 ? offset + limit - 1 : line);
|
|
9686
|
-
const path
|
|
9687
|
-
if (start === void 0) return path
|
|
9688
|
-
return end !== void 0 && end !== start ? `${path
|
|
9822
|
+
const path = rawPath;
|
|
9823
|
+
if (start === void 0) return path;
|
|
9824
|
+
return end !== void 0 && end !== start ? `${path}:${start}-${end}` : `${path}:${start}`;
|
|
9689
9825
|
}
|
|
9690
9826
|
formatEditSummary() {
|
|
9691
|
-
const path
|
|
9692
|
-
if (!path
|
|
9827
|
+
const path = this.getFirstStringArg("path");
|
|
9828
|
+
if (!path) return "";
|
|
9693
9829
|
const output = this.getFormattedOutput();
|
|
9694
|
-
const escapedPath = path
|
|
9830
|
+
const escapedPath = path.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9695
9831
|
const match = output.match(new RegExp(`Replaced \\d+ occurrences? in ${escapedPath} \\(lines ([^)]+)\\)`));
|
|
9696
|
-
return match?.[1] ? `${path
|
|
9832
|
+
return match?.[1] ? `${path}:${match[1]}` : path;
|
|
9697
9833
|
}
|
|
9698
9834
|
formatListSummary() {
|
|
9699
9835
|
const target = this.getFirstStringArg("path") || this.getFirstStringArg("pattern");
|
|
@@ -10211,8 +10347,8 @@ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
|
|
|
10211
10347
|
}
|
|
10212
10348
|
};
|
|
10213
10349
|
/** Map file extensions to highlight.js language names */
|
|
10214
|
-
function getLanguageFromPath(path
|
|
10215
|
-
const ext = path
|
|
10350
|
+
function getLanguageFromPath(path) {
|
|
10351
|
+
const ext = path.split(".").pop()?.toLowerCase();
|
|
10216
10352
|
return ext ? {
|
|
10217
10353
|
ts: "typescript",
|
|
10218
10354
|
tsx: "typescript",
|
|
@@ -10342,7 +10478,7 @@ var BorderedBox = class {
|
|
|
10342
10478
|
renderUncached(width) {
|
|
10343
10479
|
const prefix = this.label ? theme.fg("dim", `${this.label} · `) : "";
|
|
10344
10480
|
const prefixWidth = this.label ? (0, _earendil_works_pi_tui.visibleWidth)(this.label) + 3 : 0;
|
|
10345
|
-
const contentWidth = Math.max(1, width - 0 - prefixWidth -
|
|
10481
|
+
const contentWidth = Math.max(1, width - 0 - prefixWidth - 4);
|
|
10346
10482
|
const childLines = this.child.render(contentWidth);
|
|
10347
10483
|
if (childLines.length === 0) return [];
|
|
10348
10484
|
const rows = childLines.map((line, i) => {
|
|
@@ -10544,9 +10680,7 @@ var ToolApprovalDialogComponent = class {
|
|
|
10544
10680
|
case "a":
|
|
10545
10681
|
this.emit({ type: "always_allow_category" });
|
|
10546
10682
|
break;
|
|
10547
|
-
case "Y":
|
|
10548
|
-
this.emit({ type: "yolo" });
|
|
10549
|
-
break;
|
|
10683
|
+
case "Y": this.emit({ type: "yolo" });
|
|
10550
10684
|
}
|
|
10551
10685
|
}
|
|
10552
10686
|
};
|
|
@@ -10864,9 +10998,7 @@ function handleSubagentProgress(ctx, toolCallId, progress) {
|
|
|
10864
10998
|
case "tool_end":
|
|
10865
10999
|
component.addToolEnd(progress.toolName, progress.result, progress.isError ?? false);
|
|
10866
11000
|
break;
|
|
10867
|
-
case "finish":
|
|
10868
|
-
component.finish(progress.isError ?? false, progress.durationMs, progress.result);
|
|
10869
|
-
break;
|
|
11001
|
+
case "finish": component.finish(progress.isError ?? false, progress.durationMs, progress.result);
|
|
10870
11002
|
}
|
|
10871
11003
|
reconcileToolBoundaries(ctx);
|
|
10872
11004
|
requestRender(state);
|
|
@@ -11754,8 +11886,8 @@ var CustomEditor = class extends _earendil_works_pi_tui.Editor {
|
|
|
11754
11886
|
normalizePastedImageUrl(pasteContent) {
|
|
11755
11887
|
if (!/^https?:\/\//i.test(pasteContent)) return null;
|
|
11756
11888
|
try {
|
|
11757
|
-
const url
|
|
11758
|
-
return this.getImageMimeType(url
|
|
11889
|
+
const url = new URL(pasteContent);
|
|
11890
|
+
return this.getImageMimeType(url.toString()) ? url.toString() : null;
|
|
11759
11891
|
} catch {
|
|
11760
11892
|
return null;
|
|
11761
11893
|
}
|
|
@@ -11996,7 +12128,7 @@ var CustomEditor = class extends _earendil_works_pi_tui.Editor {
|
|
|
11996
12128
|
if (gap <= SPACE_REPEAT_MAX_GAP_MS) this.spaceRepeatCount += 1;
|
|
11997
12129
|
else this.spaceRepeatCount = 1;
|
|
11998
12130
|
if (this.spaceRepeatCount >= SPACE_HOLD_REPEAT_THRESHOLD) {
|
|
11999
|
-
const typedSpaces =
|
|
12131
|
+
const typedSpaces = 2;
|
|
12000
12132
|
for (let i = 0; i < typedSpaces; i++) super.handleInput("");
|
|
12001
12133
|
this.spaceRepeatCount = 0;
|
|
12002
12134
|
this.voiceRecordingActive = true;
|
|
@@ -12200,7 +12332,8 @@ function detectRecorder() {
|
|
|
12200
12332
|
}
|
|
12201
12333
|
function commandExists$1(bin) {
|
|
12202
12334
|
try {
|
|
12203
|
-
|
|
12335
|
+
const probe = process.platform === "win32" ? "where" : "which";
|
|
12336
|
+
(0, child_process.execFileSync)(probe, [bin], {
|
|
12204
12337
|
stdio: [
|
|
12205
12338
|
"ignore",
|
|
12206
12339
|
"ignore",
|
|
@@ -12630,11 +12763,12 @@ const PLIST_PATH = resolveAsset("macos-stt.plist");
|
|
|
12630
12763
|
const APP_NAME = "MastraCodeVoice";
|
|
12631
12764
|
const BUNDLE_ID = "ai.mastra.mastracode.voice";
|
|
12632
12765
|
function cacheDir() {
|
|
12633
|
-
|
|
12766
|
+
const base = process.env.XDG_CACHE_HOME?.trim() || (0, path.join)((0, os.homedir)(), "Library", "Caches");
|
|
12767
|
+
return (0, path.join)(base, "mastracode", "voice");
|
|
12634
12768
|
}
|
|
12635
|
-
async function exists(path
|
|
12769
|
+
async function exists(path) {
|
|
12636
12770
|
try {
|
|
12637
|
-
await (0, fs_promises.stat)(path
|
|
12771
|
+
await (0, fs_promises.stat)(path);
|
|
12638
12772
|
return true;
|
|
12639
12773
|
} catch {
|
|
12640
12774
|
return false;
|
|
@@ -13060,10 +13194,7 @@ var MacosNativeSession = class {
|
|
|
13060
13194
|
this.callbacks.onFinal(event.text ?? "");
|
|
13061
13195
|
this.settle();
|
|
13062
13196
|
break;
|
|
13063
|
-
case "error":
|
|
13064
|
-
this.fail(new Error(event.message ?? "macOS speech recognition failed."));
|
|
13065
|
-
break;
|
|
13066
|
-
default: break;
|
|
13197
|
+
case "error": this.fail(new Error(event.message ?? "macOS speech recognition failed."));
|
|
13067
13198
|
}
|
|
13068
13199
|
}
|
|
13069
13200
|
fail(error) {
|
|
@@ -15571,7 +15702,8 @@ async function handleModelCommand(ctx) {
|
|
|
15571
15702
|
});
|
|
15572
15703
|
const settings = (0, _mastra_code_sdk_onboarding_settings.loadSettings)();
|
|
15573
15704
|
const threadId = ctx.state.session.thread.getId?.();
|
|
15574
|
-
const
|
|
15705
|
+
const thread = threadId ? (await ctx.state.session.thread.list()).find((item) => item.id === threadId) : void 0;
|
|
15706
|
+
const activePackId = (0, _mastra_code_sdk_onboarding_settings.parseThreadSettings)(thread?.metadata).activeModelPackId ?? settings.models.activeModelPackId;
|
|
15575
15707
|
const builtinPack = activePackId ? (0, _mastra_code_sdk_onboarding_packs.getBuiltinModePack)(activePackId) : void 0;
|
|
15576
15708
|
const selectableModels = builtinPack ? connected.filter((model) => model.provider === builtinPack.providerId) : connected;
|
|
15577
15709
|
if (selectableModels.length === 0) {
|
|
@@ -15832,12 +15964,13 @@ var OMProgressComponent = class extends _earendil_works_pi_tui.Container {
|
|
|
15832
15964
|
return this.state.status;
|
|
15833
15965
|
}
|
|
15834
15966
|
updateDisplay() {
|
|
15835
|
-
if (this.state.status === "idle")
|
|
15836
|
-
|
|
15837
|
-
|
|
15838
|
-
|
|
15839
|
-
|
|
15840
|
-
|
|
15967
|
+
if (this.state.status === "idle") {
|
|
15968
|
+
if (this.state.thresholdPercent > 0) {
|
|
15969
|
+
const percent = Math.round(this.state.thresholdPercent);
|
|
15970
|
+
const bar = this.renderProgressBar(percent, 10);
|
|
15971
|
+
this.statusText.setText(theme.fg("muted", `OM ${bar} ${percent}%`));
|
|
15972
|
+
} else this.statusText.setText("");
|
|
15973
|
+
} else if (this.state.status === "observing") {
|
|
15841
15974
|
const elapsed = this.state.startTime ? Math.round((Date.now() - this.state.startTime) / 1e3) : 0;
|
|
15842
15975
|
const spinner = this.getSpinner();
|
|
15843
15976
|
this.statusText.setText(chalk.default.hex(mastra.orange)(`${spinner} Observing... ${elapsed}s`));
|
|
@@ -15934,7 +16067,7 @@ function formatOMStatus(state) {
|
|
|
15934
16067
|
*/
|
|
15935
16068
|
function getEffectiveOMRoleModelId(session, role) {
|
|
15936
16069
|
const routeMemoryModelId = (0, _mastra_code_sdk_agents_model.getActiveRouteMemoryModelId)(session.state.get(), session.thread.getId());
|
|
15937
|
-
if (routeMemoryModelId === "auto") return (0, _mastra_code_sdk_onboarding_packs.resolveAutoOMModelId)(session.model.get() ?? void 0);
|
|
16070
|
+
if (routeMemoryModelId === "auto") return (0, _mastra_code_sdk_onboarding_packs.resolveAutoOMModelId)(session.model.get() ?? void 0, _mastra_code_sdk_agents_model.canUseProvider);
|
|
15938
16071
|
return routeMemoryModelId ?? session.om[role].modelId();
|
|
15939
16072
|
}
|
|
15940
16073
|
//#endregion
|
|
@@ -16256,7 +16389,7 @@ function updateActivityLine(state, modeColor, now) {
|
|
|
16256
16389
|
}
|
|
16257
16390
|
const spinner = pulseDot(modeColor ?? theme.getTheme().accent, now);
|
|
16258
16391
|
const elapsed = formatStatusDuration(now - state.agentRunStartedAt, { includeSeconds: true });
|
|
16259
|
-
const stale = state.agentRunLastStreamPartAt !== void 0 && now - state.agentRunLastStreamPartAt >
|
|
16392
|
+
const stale = state.agentRunLastStreamPartAt !== void 0 && now - state.agentRunLastStreamPartAt > 18e4 ? formatStatusDuration(now - state.agentRunLastStreamPartAt, { includeSeconds: false }) : null;
|
|
16260
16393
|
const parts = [theme.fg(stale ? "error" : "dim", elapsed)];
|
|
16261
16394
|
if (stale) parts.push(theme.fg("warning", `no output for ${stale}`));
|
|
16262
16395
|
if (state.tokensPerSec > 0) parts.push(theme.fg("dim", `${state.tokensPerSec} tok/s`));
|
|
@@ -17289,7 +17422,8 @@ async function handleModelsPackCommand(ctx) {
|
|
|
17289
17422
|
return;
|
|
17290
17423
|
}
|
|
17291
17424
|
const threadId = ctx.state.session.thread.getId();
|
|
17292
|
-
const
|
|
17425
|
+
const thread = threadId ? (await ctx.state.session.thread.list()).find((t) => t.id === threadId) : void 0;
|
|
17426
|
+
const currentPackId = (0, _mastra_code_sdk_onboarding_settings.resolveThreadActiveModelPackId)(settings, packs, thread?.metadata);
|
|
17293
17427
|
const items = packs.map((p) => ({
|
|
17294
17428
|
value: p.id,
|
|
17295
17429
|
label: ` ${p.name}${modifiedPackIds.has(p.id) ? theme.fg("warning", " (modified)") : ""} ${theme.fg("dim", p.description)}${p.id === currentPackId ? theme.fg("dim", " (current)") : ""}`
|
|
@@ -17528,10 +17662,11 @@ async function createProviderFlow(ctx) {
|
|
|
17528
17662
|
ctx.showError("Invalid URL. Use a full http(s) URL.");
|
|
17529
17663
|
return;
|
|
17530
17664
|
}
|
|
17665
|
+
const apiKey = await askOptionalText(ctx, "API key");
|
|
17531
17666
|
(0, _mastra_code_sdk_onboarding_custom_providers.upsertCustomProviderInSettings)(settings, {
|
|
17532
17667
|
name,
|
|
17533
17668
|
url,
|
|
17534
|
-
apiKey
|
|
17669
|
+
apiKey,
|
|
17535
17670
|
models: []
|
|
17536
17671
|
});
|
|
17537
17672
|
(0, _mastra_code_sdk_onboarding_settings.saveSettings)(settings);
|
|
@@ -17657,7 +17792,6 @@ async function manageProviderFlow(ctx, providerId) {
|
|
|
17657
17792
|
ctx.showInfo(`Deleted custom provider: ${provider.name}`);
|
|
17658
17793
|
break;
|
|
17659
17794
|
}
|
|
17660
|
-
default: break;
|
|
17661
17795
|
}
|
|
17662
17796
|
}
|
|
17663
17797
|
async function handleCustomProvidersCommand(ctx) {
|
|
@@ -18162,7 +18296,7 @@ async function handleOMCommand(ctx) {
|
|
|
18162
18296
|
const observerModelId = getEffectiveOMRoleModelId(session, "observer") ?? "";
|
|
18163
18297
|
const reflectorModelId = getEffectiveOMRoleModelId(session, "reflector") ?? "";
|
|
18164
18298
|
const packMemoryModelId = (0, _mastra_code_sdk_agents_model.getActiveRouteMemoryModelId)(agentControllerState, ctx.state.session.thread.getId());
|
|
18165
|
-
const autoModelId = (0, _mastra_code_sdk_onboarding_packs.resolveAutoOMModelId)(ctx.state.session.model.get() ?? void 0);
|
|
18299
|
+
const autoModelId = (0, _mastra_code_sdk_onboarding_packs.resolveAutoOMModelId)(ctx.state.session.model.get() ?? void 0, _mastra_code_sdk_agents_model.canUseProvider);
|
|
18166
18300
|
const config = {
|
|
18167
18301
|
observerModel: session.om.observer.model() ?? "auto",
|
|
18168
18302
|
observerModelId,
|
|
@@ -19588,6 +19722,7 @@ async function handleSettingsCommand(ctx) {
|
|
|
19588
19722
|
}
|
|
19589
19723
|
//#endregion
|
|
19590
19724
|
//#region src/tui/commands/browser.ts
|
|
19725
|
+
const STAGEHAND_MODEL_PROVIDERS = Object.keys(_mastra_code_sdk_onboarding_settings.STAGEHAND_PROVIDER_ENV_VARS).sort();
|
|
19591
19726
|
/**
|
|
19592
19727
|
* Key used to store the active browser settings in controller state.
|
|
19593
19728
|
* This tracks what browser config is actually running in this instance,
|
|
@@ -19639,7 +19774,7 @@ function stagehandModelError(modelId) {
|
|
|
19639
19774
|
const slashIndex = modelId.indexOf("/");
|
|
19640
19775
|
if (slashIndex <= 0 || slashIndex === modelId.length - 1) return `Invalid model: ${modelId}. Use <provider>/<model>, for example anthropic/claude-sonnet-4-5.`;
|
|
19641
19776
|
const provider = modelId.slice(0, slashIndex);
|
|
19642
|
-
if (!
|
|
19777
|
+
if (!STAGEHAND_MODEL_PROVIDERS.includes(provider)) return `Unsupported model provider: ${provider}. Supported providers: ${STAGEHAND_MODEL_PROVIDERS.join(", ")}.`;
|
|
19643
19778
|
}
|
|
19644
19779
|
/** Render a viewport for status output and confirmations. */
|
|
19645
19780
|
function formatViewport(viewport) {
|
|
@@ -19724,10 +19859,10 @@ async function promptForStagehandModel(ctx, settings, browser) {
|
|
|
19724
19859
|
ctx.showError("model is only supported by the stagehand provider.");
|
|
19725
19860
|
return;
|
|
19726
19861
|
}
|
|
19727
|
-
const supported = new Set(
|
|
19862
|
+
const supported = new Set(STAGEHAND_MODEL_PROVIDERS);
|
|
19728
19863
|
const models = (await ctx.state.controller.listAvailableModels()).filter((m) => supported.has(m.provider));
|
|
19729
19864
|
if (models.length === 0) {
|
|
19730
|
-
ctx.showError(`No models available for Stagehand. Supported providers: ${
|
|
19865
|
+
ctx.showError(`No models available for Stagehand. Supported providers: ${STAGEHAND_MODEL_PROVIDERS.join(", ")}.\nYou can also set one directly: /browser set model anthropic/claude-sonnet-4-5`);
|
|
19731
19866
|
return;
|
|
19732
19867
|
}
|
|
19733
19868
|
await new Promise((resolve) => {
|
|
@@ -19961,7 +20096,6 @@ async function handleBrowserCommand(ctx, args = []) {
|
|
|
19961
20096
|
ctx.showInfo(`Note: Cleared profile and executablePath (ignored when using cdpUrl).`);
|
|
19962
20097
|
}
|
|
19963
20098
|
if (settings.browser.agentBrowser?.storageState) delete settings.browser.agentBrowser.storageState;
|
|
19964
|
-
break;
|
|
19965
20099
|
}
|
|
19966
20100
|
(0, _mastra_code_sdk_onboarding_settings.saveSettings)(settings);
|
|
19967
20101
|
ctx.showInfo(`Set ${args[1]} = ${expandedValue}\nRun /browser on to apply.`);
|
|
@@ -20531,8 +20665,10 @@ var LoginAccountManagerComponent = class extends _earendil_works_pi_tui.Box {
|
|
|
20531
20665
|
this.selectedIndex = Math.min(rows.length - 1, this.selectedIndex + 1);
|
|
20532
20666
|
this.updateList();
|
|
20533
20667
|
} else if (kb.matches(keyData, "tui.select.confirm")) rows[this.selectedIndex]?.action();
|
|
20534
|
-
else if (kb.matches(keyData, "tui.select.cancel"))
|
|
20535
|
-
|
|
20668
|
+
else if (kb.matches(keyData, "tui.select.cancel")) {
|
|
20669
|
+
if (this.mode === "account" || this.mode === "confirm-remove") this.backToMenu();
|
|
20670
|
+
else this.callbacks.onBack();
|
|
20671
|
+
}
|
|
20536
20672
|
}
|
|
20537
20673
|
};
|
|
20538
20674
|
//#endregion
|
|
@@ -22973,9 +23109,7 @@ async function showGithubActionMenu(ctx) {
|
|
|
22973
23109
|
case "Sync now":
|
|
22974
23110
|
await syncGithubSubscriptions(ctx);
|
|
22975
23111
|
break;
|
|
22976
|
-
case "Debug":
|
|
22977
|
-
ctx.showInfo(await describeGithubSubscriptions(ctx));
|
|
22978
|
-
break;
|
|
23112
|
+
case "Debug": ctx.showInfo(await describeGithubSubscriptions(ctx));
|
|
22979
23113
|
}
|
|
22980
23114
|
}
|
|
22981
23115
|
async function handleInlineGithubOperation(ctx, input) {
|
|
@@ -24745,13 +24879,14 @@ async function handlePackFallbackState(ectx, event) {
|
|
|
24745
24879
|
if (!isOriginThreadActive()) return;
|
|
24746
24880
|
const sessionOverride = ectx.state.session.state.get()?.thinkingLevel;
|
|
24747
24881
|
const currentModeId = ectx.state.session.mode.get();
|
|
24748
|
-
const
|
|
24882
|
+
const runtimeSettings = {
|
|
24749
24883
|
...settings,
|
|
24750
24884
|
models: {
|
|
24751
24885
|
...settings.models,
|
|
24752
24886
|
activeModelPackId: pending.toEntryId
|
|
24753
24887
|
}
|
|
24754
|
-
}
|
|
24888
|
+
};
|
|
24889
|
+
const defaultThinking = (0, _mastra_code_sdk_onboarding_settings.resolveDefaultThinkingLevel)(runtimeSettings, currentModeId);
|
|
24755
24890
|
const effectiveThinking = sessionOverride ?? defaultThinking.level;
|
|
24756
24891
|
if (selection.modelRoute.entries.some((entry) => entry.modelId.startsWith("openai/")) && sessionOverride === void 0 && defaultThinking.source === "global" && defaultThinking.level === "off") await ectx.state.session.state.set({ thinkingLevel: "low" });
|
|
24757
24892
|
else if (selection.modelId.startsWith("openai/") && effectiveThinking === "max") await ectx.state.session.state.set({ thinkingLevel: "xhigh" });
|
|
@@ -25718,8 +25853,7 @@ async function dispatchEvent(event, ectx, state) {
|
|
|
25718
25853
|
const decodeSec = (state.decodeLastDeltaAt - state.decodeStartedAt) / 1e3;
|
|
25719
25854
|
if (state.decodeStartedAt > 0 && decodeSec >= MIN_DECODE_WINDOW_SEC && stepTokens > 0) {
|
|
25720
25855
|
const instantaneous = stepTokens / decodeSec;
|
|
25721
|
-
const
|
|
25722
|
-
const ema = state.tokensPerSec > 0 ? alpha * instantaneous + (1 - alpha) * state.tokensPerSec : instantaneous;
|
|
25856
|
+
const ema = state.tokensPerSec > 0 ? .3 * instantaneous + .7 * state.tokensPerSec : instantaneous;
|
|
25723
25857
|
state.tokensPerSec = Math.round(ema);
|
|
25724
25858
|
}
|
|
25725
25859
|
state.decodeMessageId = void 0;
|
|
@@ -25829,9 +25963,7 @@ async function dispatchEvent(event, ectx, state) {
|
|
|
25829
25963
|
case "state_changed":
|
|
25830
25964
|
await handlePackFallbackState(ectx, event);
|
|
25831
25965
|
break;
|
|
25832
|
-
case "display_state_changed":
|
|
25833
|
-
ectx.updateStatusLine();
|
|
25834
|
-
break;
|
|
25966
|
+
case "display_state_changed": ectx.updateStatusLine();
|
|
25835
25967
|
}
|
|
25836
25968
|
}
|
|
25837
25969
|
//#endregion
|
|
@@ -27592,7 +27724,7 @@ const USER_MESSAGE_APPROVAL_INTERRUPT = {
|
|
|
27592
27724
|
message: "The pending tool approval was declined because the user sent a new message."
|
|
27593
27725
|
};
|
|
27594
27726
|
/** How often to recheck for updates during a long-running session (ms). */
|
|
27595
|
-
const UPDATE_RECHECK_INTERVAL_MS =
|
|
27727
|
+
const UPDATE_RECHECK_INTERVAL_MS = 27e5;
|
|
27596
27728
|
const IMAGE_PLACEHOLDER_PATTERN = /\[image\]\s*/g;
|
|
27597
27729
|
const CAFFEINATE_ARGS = ["-i", "-m"];
|
|
27598
27730
|
function fallbackStatusFromMetadata(metadata) {
|
|
@@ -28381,9 +28513,7 @@ var MastraTUI = class MastraTUI {
|
|
|
28381
28513
|
case "subagent_start":
|
|
28382
28514
|
hookMgr.runSubagentStart(event.toolCallId, event.agentType, event.task, event.modelId, event.forked).catch(() => {});
|
|
28383
28515
|
break;
|
|
28384
|
-
case "subagent_end":
|
|
28385
|
-
hookMgr.runSubagentEnd(event.toolCallId, event.agentType, event.result, event.isError, event.durationMs).catch(() => {});
|
|
28386
|
-
break;
|
|
28516
|
+
case "subagent_end": hookMgr.runSubagentEnd(event.toolCallId, event.agentType, event.result, event.isError, event.durationMs).catch(() => {});
|
|
28387
28517
|
}
|
|
28388
28518
|
}
|
|
28389
28519
|
async runAgentEndHook(reason) {
|
|
@@ -28937,4 +29067,4 @@ Object.defineProperty(exports, "theme", {
|
|
|
28937
29067
|
}
|
|
28938
29068
|
});
|
|
28939
29069
|
|
|
28940
|
-
//# sourceMappingURL=tui-
|
|
29070
|
+
//# sourceMappingURL=tui-cKViKRi_.cjs.map
|