mastracode 0.49.0 → 0.49.1-alpha.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.
@@ -4262,10 +4262,15 @@ var AskQuestionDialogComponent = class AskQuestionDialogComponent extends Box {
4262
4262
  else this.buildInputMode();
4263
4263
  }
4264
4264
  buildSelectMode(opts) {
4265
- const items = opts.map((opt) => ({
4266
- value: opt.label,
4267
- label: opt.description ? ` ${opt.label} ${theme.fg("dim", opt.description)}` : ` ${opt.label}`
4268
- }));
4265
+ const singleLine = (text) => text.replace(/\s*[\r\n]+\s*/g, " ").trim();
4266
+ const items = opts.map((opt) => {
4267
+ const label = singleLine(opt.label);
4268
+ const description = opt.description ? singleLine(opt.description) : "";
4269
+ return {
4270
+ value: opt.label,
4271
+ label: description ? ` ${label} ${theme.fg("dim", description)}` : ` ${label}`
4272
+ };
4273
+ });
4269
4274
  if (this.allowCustomResponse && !this.multiSelect) items.push({
4270
4275
  value: AskQuestionDialogComponent.CUSTOM_RESPONSE_VALUE,
4271
4276
  label: ` ${theme.fg("dim", "✎ Custom response...")}`
@@ -8485,6 +8490,24 @@ function highlightCode(code, language, colors = CODE_HIGHLIGHT_THEME) {
8485
8490
  }).value;
8486
8491
  return parseHighlightHtml(html).map((node) => colorize(node, colors, false)).join("");
8487
8492
  }
8493
+ // src/tui/utils/bounded-output.ts
8494
+ /** Live shell output kept for display, in string code units. Matches the controller's display state. */
8495
+ const MAX_DISPLAYED_SHELL_OUTPUT = 1048576;
8496
+ /**
8497
+ * Appends `chunk` to `existing`, keeping only the last `limit` code units. Slices before
8498
+ * concatenating so an oversized chunk never builds an even larger intermediate string.
8499
+ */
8500
+ function appendBoundedOutput(existing, chunk, limit = MAX_DISPLAYED_SHELL_OUTPUT) {
8501
+ if (chunk.length >= limit) return copyTail(chunk, limit);
8502
+ return existing.slice(-(limit - chunk.length)) + chunk;
8503
+ }
8504
+ /**
8505
+ * Returns the last `length` code units as an independent string. A plain `slice` can share the
8506
+ * parent's memory, which would keep an oversized chunk alive after it has been trimmed.
8507
+ */
8508
+ function copyTail(text, length) {
8509
+ return JSON.parse(JSON.stringify(text.slice(-length)));
8510
+ }
8488
8511
  // src/tui/components/collapsible.ts
8489
8512
  /**
8490
8513
  * Generic collapsible container component.
@@ -9012,7 +9035,7 @@ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
9012
9035
  */
9013
9036
  appendStreamingOutput(output) {
9014
9037
  if (this.toolName !== MC_TOOLS.EXECUTE_COMMAND && this.toolName !== MC_TOOLS.GET_PROCESS_OUTPUT && this.toolName !== MC_TOOLS.KILL_PROCESS) return;
9015
- this.streamingOutput += sanitizeAnsiForRendering(output);
9038
+ this.streamingOutput = appendBoundedOutput(this.streamingOutput, sanitizeAnsiForRendering(output));
9016
9039
  this.rebuild();
9017
9040
  }
9018
9041
  setExpanded(expanded) {
@@ -11107,7 +11130,7 @@ function flushPendingShellOutput(ctx, toolCallId) {
11107
11130
  function handleShellOutput(ctx, toolCallId, output, _stream) {
11108
11131
  const pending = pendingShellOutputs.get(toolCallId);
11109
11132
  if (pending) {
11110
- pending.output += output;
11133
+ pending.output = appendBoundedOutput(pending.output, output);
11111
11134
  return;
11112
11135
  }
11113
11136
  pendingShellOutputs.set(toolCallId, {
@@ -28774,4 +28797,4 @@ var MastraTUI = class MastraTUI {
28774
28797
  };
28775
28798
  export { mastraBrand as C, closeActiveBrowser as D, activeBrowserGeneration as E, discardBrowser as O, mastra as S, TUI_CO_AUTHOR as T, normalizeThemePreference as _, formatUpdateHeader as a, getMarkdownTheme as b, LoginDialogComponent as c, createTUIState as d, UserMessageComponent as f, applyThemePreference as g, AssistantMessageComponent as h, formatUpToDate as i, replaceActiveBrowser as k, OMProgressComponent as l, ModelSelectorComponent as m, formatInstallingLabel as n, formatUpdateOutcome as o, ToolExecutionComponentEnhanced as p, formatRegistryError as r, LoginSelectorComponent as s, MastraTUI as t, formatOMStatus as u, applyThemeMode as v, theme as w, getThemeMode as x, getEditorTheme as y };
28776
28799
 
28777
- //# sourceMappingURL=tui-oSQAQVok.js.map
28800
+ //# sourceMappingURL=tui-D5ou9NB5.js.map