mastracode 0.31.0-alpha.3 → 0.31.0-alpha.5

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +7 -44
  3. package/dist/{chunk-TWIBIHJ5.cjs → chunk-KRJFHRGM.cjs} +106 -69
  4. package/dist/chunk-KRJFHRGM.cjs.map +1 -0
  5. package/dist/{chunk-TDSXKHR5.js → chunk-SSOBRPJ4.js} +105 -68
  6. package/dist/chunk-SSOBRPJ4.js.map +1 -0
  7. package/dist/cli.cjs +5 -5
  8. package/dist/cli.js +1 -1
  9. package/dist/tui/commands/login.d.ts.map +1 -1
  10. package/dist/tui/components/custom-editor.d.ts.map +1 -1
  11. package/dist/tui/components/judge-display.d.ts +3 -3
  12. package/dist/tui/components/judge-display.d.ts.map +1 -1
  13. package/dist/tui/components/notification.d.ts +4 -2
  14. package/dist/tui/components/notification.d.ts.map +1 -1
  15. package/dist/tui/components/om-output.d.ts +3 -3
  16. package/dist/tui/components/om-output.d.ts.map +1 -1
  17. package/dist/tui/components/shell-output.d.ts +3 -3
  18. package/dist/tui/components/shell-output.d.ts.map +1 -1
  19. package/dist/tui/components/slash-command.d.ts +3 -3
  20. package/dist/tui/components/slash-command.d.ts.map +1 -1
  21. package/dist/tui/components/subagent-execution.d.ts +3 -3
  22. package/dist/tui/components/subagent-execution.d.ts.map +1 -1
  23. package/dist/tui/components/system-reminder.d.ts +3 -3
  24. package/dist/tui/components/system-reminder.d.ts.map +1 -1
  25. package/dist/tui/components/task-progress.d.ts +3 -9
  26. package/dist/tui/components/task-progress.d.ts.map +1 -1
  27. package/dist/tui/components/tool-execution-enhanced.d.ts +3 -3
  28. package/dist/tui/components/tool-execution-enhanced.d.ts.map +1 -1
  29. package/dist/tui/components/width-aware-container.d.ts +10 -0
  30. package/dist/tui/components/width-aware-container.d.ts.map +1 -0
  31. package/dist/tui.cjs +18 -18
  32. package/dist/tui.js +1 -1
  33. package/package.json +11 -11
  34. package/dist/chunk-TDSXKHR5.js.map +0 -1
  35. package/dist/chunk-TWIBIHJ5.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,27 @@
1
1
  # mastracode
2
2
 
3
+ ## 0.31.0-alpha.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed terminal output reflow and slash command input alignment when resizing. ([#19198](https://github.com/mastra-ai/mastra/pull/19198))
8
+
9
+ - Fixed the /login command changing your active model and model pack. Logging in to a provider now keeps your current model selection; the provider default is only auto-selected during onboarding or when no model has been chosen yet. ([#19250](https://github.com/mastra-ai/mastra/pull/19250))
10
+
11
+ - Updated dependencies [[`a5c6337`](https://github.com/mastra-ai/mastra/commit/a5c6337d23c7686c81a32ce62f550f610543a240), [`031931a`](https://github.com/mastra-ai/mastra/commit/031931a715405fb90759b1903c9c25cbf05994af), [`eb70da9`](https://github.com/mastra-ai/mastra/commit/eb70da98e1007b18e1463d75121bc07db55f8e09), [`8b97958`](https://github.com/mastra-ai/mastra/commit/8b979589f9aa59ba67cac565949475f2ffeb4ac3), [`8410541`](https://github.com/mastra-ai/mastra/commit/84105412c60ecd3bb33a9838146f59c4b588228f), [`01b338c`](https://github.com/mastra-ai/mastra/commit/01b338c56271f0219606710e3e8b26dee27ac6c2), [`8b7361d`](https://github.com/mastra-ai/mastra/commit/8b7361d35de68b80d05d30a74e0c69e7218fd612), [`85fb642`](https://github.com/mastra-ai/mastra/commit/85fb642f4d112d0da9f39808617397f7e47fe622), [`481c112`](https://github.com/mastra-ai/mastra/commit/481c1125b752489673ec671fcb7ca80f9c86ffb1), [`c43f3a9`](https://github.com/mastra-ai/mastra/commit/c43f3a9d1efde99b38789364ba4d0ba670f430e3), [`c43f3a9`](https://github.com/mastra-ai/mastra/commit/c43f3a9d1efde99b38789364ba4d0ba670f430e3)]:
12
+ - @mastra/core@1.51.0-alpha.4
13
+ - @mastra/memory@1.23.0-alpha.3
14
+ - @mastra/mcp@1.14.0-alpha.0
15
+ - @mastra/code-sdk@0.1.0-alpha.4
16
+
17
+ ## 0.31.0-alpha.4
18
+
19
+ ### Patch Changes
20
+
21
+ - Updated dependencies [[`177010f`](https://github.com/mastra-ai/mastra/commit/177010ff096d2e4b28d89803be5b1a4cad2a0d6b), [`54a51e0`](https://github.com/mastra-ai/mastra/commit/54a51e0a484fe1ebad3fb1f7ef5282a075709eb7)]:
22
+ - @mastra/core@1.51.0-alpha.3
23
+ - @mastra/code-sdk@0.1.0-alpha.3
24
+
3
25
  ## 0.31.0-alpha.3
4
26
 
5
27
  ### Minor Changes
package/README.md CHANGED
@@ -323,45 +323,17 @@ detects the stopped VM and re-provisions automatically.
323
323
  Without a sandbox provider, users can still connect GitHub and pick repos, but opening a repo
324
324
  project shows a clear "sandbox not configured" error.
325
325
 
326
- ### Per-(org,user) storage isolation
326
+ ### Storage
327
327
 
328
- When WorkOS web auth is enabled, the tenant boundary is the **(organization, user)** pair: each
329
- user in each org operates against their own dedicated libSQL database for all agent state (threads,
330
- messages, memory, observational memory, recall vectors) no tenant can read another tenant's data
331
- at the storage layer. Two users in the same org are isolated, and the same user across two orgs is
332
- also isolated. The database location is derived server-side from a hash of `(orgId, userId)` (no
333
- client-supplied paths); users without an org fall back to a user-only key.
334
-
335
- ```bash
336
- # Local files (default): one isolated DB dir per tenant under this root
337
- export MASTRACODE_TENANT_DB_ROOT=~/.mastracode/web/tenants # optional
338
-
339
- # Or remote libSQL/Turso per tenant ({id} = hashed (orgId, userId)). This mode
340
- # assumes each tenant DB already exists at the templated URL.
341
- export MASTRACODE_TENANT_DB_URL_TEMPLATE=libsql://{id}-org.turso.io # optional
342
- export MASTRACODE_TENANT_VECTOR_URL_TEMPLATE=libsql://{id}-vec-org.turso.io # optional
343
- export MASTRACODE_TENANT_DB_AUTH_TOKEN=... # optional
344
- export MASTRACODE_TENANT_VECTOR_AUTH_TOKEN=... # optional
345
-
346
- # Or auto-provision a Turso database per tenant on first access via the Turso
347
- # Platform API (no pre-created DBs needed). Requires APP_DATABASE_URL: the
348
- # stable db-name/hostname mapping is persisted there so replicas converge on
349
- # one DB and cold starts don't re-create it. A scoped token is minted fresh per
350
- # resolution, so no long-lived credential is stored.
351
- export MASTRACODE_TURSO_PLATFORM_TOKEN=... # optional
352
- export MASTRACODE_TURSO_ORG=my-org # optional
353
- export MASTRACODE_TURSO_GROUP=default # optional (default "default")
354
- ```
355
-
356
- Resolution priority: explicit `MASTRACODE_TENANT_DB_URL_TEMPLATE` → Turso
357
- auto-provisioning (when the platform token + org are set) → local libSQL files.
358
-
359
- When web auth is disabled the server uses a single shared store, exactly as before.
328
+ All agent state (threads, messages, memory, observational memory, recall vectors) persists in the
329
+ single application Postgres (`APP_DATABASE_URL`) alongside the GitHub project metadata one shared
330
+ database, with users separated by `resourceId` scoping. Without `APP_DATABASE_URL` (bare local
331
+ dev), agent state falls back to a local libSQL file.
360
332
 
361
333
  ### Multi-replica deployment
362
334
 
363
- The web server keeps each tenant's Mastra stack in an in-memory cache and serializes per-user git
364
- write operations. For hosted, multi-replica deployments a few settings make this safe and bounded:
335
+ The web server serializes per-user git write operations. For hosted, multi-replica deployments a
336
+ few settings make this safe and bounded:
365
337
 
366
338
  ```bash
367
339
  # Replica-stable state signing — REQUIRED across replicas. Without an explicit
@@ -373,15 +345,6 @@ export GITHUB_APP_WEBHOOK_SECRET=...
373
345
  # advisory locks (default on, requires APP_DATABASE_URL). Set 0 for local dev.
374
346
  export MASTRACODE_DISTRIBUTED_LOCK=1
375
347
 
376
- # Persist/share tenant DBs across replicas — fail/warn at startup if no remote
377
- # tenant DB backend (URL template OR Turso auto-provisioning) is configured
378
- # (local-file DBs don't survive restarts or sharing).
379
- export MASTRACODE_REQUIRE_REMOTE_TENANT_DB=1
380
-
381
- # Bound in-memory tenant caches as the team grows.
382
- export MASTRACODE_TENANT_IDLE_MINUTES=30 # idle eviction window (0 disables)
383
- export MASTRACODE_TENANT_MAX_APPS=100 # LRU cap on cached stacks (0 disables)
384
-
385
348
  # Per-replica cap on concurrently live sandboxes (0 / unset = unlimited).
386
349
  export MASTRACODE_MAX_SANDBOXES=50
387
350
  ```
@@ -3404,9 +3404,29 @@ async function handleModeCommand(ctx, args) {
3404
3404
  ${modeList}`);
3405
3405
  }
3406
3406
  }
3407
+ var WidthAwareContainer = class extends piTui.Container {
3408
+ builtWidth;
3409
+ get renderWidth() {
3410
+ return this.builtWidth;
3411
+ }
3412
+ rebuild() {
3413
+ if (this.builtWidth !== void 0) {
3414
+ this.rebuildForWidth(this.builtWidth);
3415
+ }
3416
+ }
3417
+ render(width) {
3418
+ if (this.builtWidth !== width) {
3419
+ this.builtWidth = width;
3420
+ this.rebuildForWidth(width);
3421
+ }
3422
+ return super.render(width);
3423
+ }
3424
+ };
3425
+
3426
+ // src/tui/components/slash-command.ts
3407
3427
  var MAX_COLLAPSED_LINES = 3;
3408
3428
  var getBorderColor = () => mastra.green;
3409
- var SlashCommandComponent = class extends piTui.Container {
3429
+ var SlashCommandComponent = class extends WidthAwareContainer {
3410
3430
  commandName;
3411
3431
  contentLines;
3412
3432
  expanded = false;
@@ -3424,11 +3444,10 @@ var SlashCommandComponent = class extends piTui.Container {
3424
3444
  this.expanded = expanded;
3425
3445
  this.rebuild();
3426
3446
  }
3427
- rebuild() {
3447
+ rebuildForWidth(termWidth) {
3428
3448
  this.clear();
3429
3449
  const border = (char) => chalk15__default.default.bold.hex(getBorderColor())(char);
3430
- const termWidth = getTermWidth();
3431
- const maxLineWidth = termWidth - 6 - BOX_INDENT * 2;
3450
+ const maxLineWidth = Math.max(1, termWidth - 6 - BOX_INDENT * 2);
3432
3451
  const heading = chalk15__default.default.hex(mastra.specialGray)(`/${this.commandName}`);
3433
3452
  if (this.contentLines.length === 0) {
3434
3453
  this.addChild(new piTui.Text(`${border("\u2570\u2500\u2500")} ${heading}`, BOX_INDENT, 0));
@@ -3993,7 +4012,7 @@ var JUDGE_COLOR = themePalette.mastraBrand.blue;
3993
4012
  var MUTED_COLOR = "#8a8a8a";
3994
4013
  var PAUSED_COLOR = "#f5a524";
3995
4014
  var WAITING_COLOR = "#8a8a8a";
3996
- var JudgeDisplayComponent = class extends piTui.Container {
4015
+ var JudgeDisplayComponent = class extends WidthAwareContainer {
3997
4016
  result;
3998
4017
  turnsUsed;
3999
4018
  maxTurns;
@@ -4004,7 +4023,7 @@ var JudgeDisplayComponent = class extends piTui.Container {
4004
4023
  this.result = result;
4005
4024
  this.turnsUsed = turnsUsed;
4006
4025
  this.maxTurns = maxTurns;
4007
- this.renderContent();
4026
+ this.rebuild();
4008
4027
  }
4009
4028
  addActivity(line) {
4010
4029
  if (this.activity[this.activity.length - 1] !== line) {
@@ -4013,18 +4032,18 @@ var JudgeDisplayComponent = class extends piTui.Container {
4013
4032
  if (this.activity.length > 6) {
4014
4033
  this.activity = this.activity.slice(-6);
4015
4034
  }
4016
- this.renderContent();
4035
+ this.rebuild();
4017
4036
  }
4018
4037
  setStreamingReason(reason) {
4019
4038
  this.streamingReason = reason;
4020
- this.renderContent();
4039
+ this.rebuild();
4021
4040
  }
4022
4041
  setResult(result, turnsUsed, maxTurns) {
4023
4042
  this.result = result;
4024
4043
  this.streamingReason = "";
4025
4044
  this.turnsUsed = turnsUsed;
4026
4045
  this.maxTurns = maxTurns;
4027
- this.renderContent();
4046
+ this.rebuild();
4028
4047
  }
4029
4048
  /** Render the result of an in-loop goal evaluation chunk. */
4030
4049
  setEvaluation(payload) {
@@ -4033,11 +4052,10 @@ var JudgeDisplayComponent = class extends piTui.Container {
4033
4052
  setInterrupted() {
4034
4053
  this.setResult({ decision: "paused", reason: "Judge evaluation was interrupted." }, this.turnsUsed, this.maxTurns);
4035
4054
  }
4036
- renderContent() {
4055
+ rebuildForWidth(termWidth) {
4037
4056
  this.clear();
4038
4057
  const border = (char) => chalk15__default.default.hex(JUDGE_COLOR)(char);
4039
4058
  const title = chalk15__default.default.hex(JUDGE_COLOR).bold("Goal");
4040
- const termWidth = getTermWidth();
4041
4059
  const innerWidth = Math.max(20, termWidth - BOX_INDENT * 2 - 4);
4042
4060
  const horizontal = "\u2500".repeat(innerWidth + 1);
4043
4061
  this.addChild(new piTui.Text(`${border("\u256D")}${border(horizontal)}${border("\u256E")}`, BOX_INDENT, 0));
@@ -4179,15 +4197,21 @@ function wrapText(value, maxWidth) {
4179
4197
  }
4180
4198
  return lines;
4181
4199
  }
4182
- var NotificationComponent = class extends piTui.Container {
4200
+ var NotificationComponent = class extends WidthAwareContainer {
4201
+ options;
4183
4202
  constructor(options) {
4184
4203
  super();
4204
+ this.options = options;
4205
+ }
4206
+ rebuildForWidth(width) {
4207
+ this.clear();
4208
+ const options = this.options;
4185
4209
  const titleText = options.source ? `notification from ${options.source}` : "notification";
4186
4210
  const details = [options.priority, options.kind, options.status].filter(Boolean).join(" \xB7 ");
4187
4211
  const message = options.message.trim();
4188
4212
  const maxContentWidth = Math.max(
4189
4213
  MIN_NOTIFICATION_CONTENT_WIDTH,
4190
- Math.min(MAX_NOTIFICATION_CONTENT_WIDTH, getTermWidth() - BOX_INDENT - 4)
4214
+ Math.min(MAX_NOTIFICATION_CONTENT_WIDTH, width - BOX_INDENT - 4)
4191
4215
  );
4192
4216
  const titleLines = wrapText(titleText, maxContentWidth);
4193
4217
  const detailLines = details ? wrapText(details, maxContentWidth) : [];
@@ -4382,7 +4406,7 @@ function softWrapLines(lines, maxWidth) {
4382
4406
  }
4383
4407
  return { groups, flat };
4384
4408
  }
4385
- var OMOutputComponent = class extends piTui.Container {
4409
+ var OMOutputComponent = class extends WidthAwareContainer {
4386
4410
  data;
4387
4411
  expanded = false;
4388
4412
  constructor(data) {
@@ -4397,12 +4421,11 @@ var OMOutputComponent = class extends piTui.Container {
4397
4421
  toggleExpanded() {
4398
4422
  this.setExpanded(!this.expanded);
4399
4423
  }
4400
- rebuild() {
4424
+ rebuildForWidth(termWidth) {
4401
4425
  this.clear();
4402
4426
  const isReflection = this.data.type === "reflection";
4403
4427
  const color = isReflection ? getReflectorColor() : getObserverColor();
4404
4428
  const border = (char) => chalk15__default.default.bold.hex(color)(char);
4405
- const termWidth = getTermWidth();
4406
4429
  const maxLineWidth = termWidth - 6 - BOX_INDENT * 2;
4407
4430
  const originalLines = this.data.observations.split("\n");
4408
4431
  const { groups, flat: wrappedLines } = softWrapLines(originalLines, maxLineWidth);
@@ -4786,7 +4809,7 @@ var StateSignalComponent = class extends piTui.Container {
4786
4809
  };
4787
4810
  var MAX_ACTIVITY_LINES = 15;
4788
4811
  var COLLAPSED_LINES2 = 15;
4789
- var SubagentExecutionComponent = class extends piTui.Container {
4812
+ var SubagentExecutionComponent = class extends WidthAwareContainer {
4790
4813
  ui;
4791
4814
  // State
4792
4815
  agentType;
@@ -4900,11 +4923,10 @@ var SubagentExecutionComponent = class extends piTui.Container {
4900
4923
  return "normal-tool";
4901
4924
  }
4902
4925
  // ── Rendering ──────────────────────────────────────────────────────────
4903
- rebuild() {
4926
+ rebuildForWidth(termWidth) {
4904
4927
  this.clear();
4905
4928
  const border = (char) => theme.bold(colorText(this.colors.border, char, (text) => theme.fg("accent", text)));
4906
- const termWidth = getTermWidth();
4907
- const maxLineWidth = termWidth - 6 - BOX_INDENT * 2;
4929
+ const maxLineWidth = Math.max(1, termWidth - 6 - BOX_INDENT * 2);
4908
4930
  const typeLabelText = this.forked ? "fork" : this.agentType;
4909
4931
  const typeLabel = theme.bold(
4910
4932
  colorText(this.colors.agentType, typeLabelText, (text) => theme.fg("accent", text))
@@ -5065,7 +5087,7 @@ function summarizeArgs(args, maxWidth = 40) {
5065
5087
  }
5066
5088
  var MAX_COLLAPSED_LINES2 = 10;
5067
5089
  var LOADED_INSTRUCTION_INDENT = BOX_INDENT + 2;
5068
- var SystemReminderComponent = class extends piTui.Container {
5090
+ var SystemReminderComponent = class extends WidthAwareContainer {
5069
5091
  messageLines;
5070
5092
  reminderType;
5071
5093
  path;
@@ -5097,7 +5119,7 @@ var SystemReminderComponent = class extends piTui.Container {
5097
5119
  getChatSpacingKind() {
5098
5120
  return "system";
5099
5121
  }
5100
- rebuild() {
5122
+ rebuildForWidth(termWidth) {
5101
5123
  this.clear();
5102
5124
  if (isLoadedInstructionPathReminder(this.reminderType, this.path)) {
5103
5125
  const path3 = formatReminderPath(this.path);
@@ -5114,7 +5136,6 @@ var SystemReminderComponent = class extends piTui.Container {
5114
5136
  const metadataColor = (text) => theme.fg("dim", text);
5115
5137
  const bodyColor = (text) => theme.fg("text", text);
5116
5138
  const hintColor = (text) => theme.fg("dim", text);
5117
- const termWidth = getTermWidth();
5118
5139
  const innerWidth = Math.max(20, termWidth - BOX_INDENT * 2 - 4);
5119
5140
  const horizontal = "\u2500".repeat(innerWidth + 1);
5120
5141
  const metadataLines = [this.path ? formatReminderPath(this.path) : void 0].filter(
@@ -5295,23 +5316,23 @@ function formatTaskProgressLine(task, indent = " ") {
5295
5316
  }
5296
5317
  }
5297
5318
  }
5298
- var TaskProgressComponent = class extends piTui.Container {
5319
+ var TaskProgressComponent = class extends WidthAwareContainer {
5299
5320
  tasks = [];
5300
5321
  quietMode = false;
5301
5322
  constructor() {
5302
5323
  super();
5303
- this.rebuildDisplay();
5324
+ this.rebuild();
5304
5325
  }
5305
5326
  /**
5306
5327
  * Replace the entire task list and re-render.
5307
5328
  */
5308
5329
  updateTasks(tasks) {
5309
5330
  this.tasks = tasks;
5310
- this.rebuildDisplay();
5331
+ this.rebuild();
5311
5332
  }
5312
5333
  setQuietMode(enabled) {
5313
5334
  this.quietMode = enabled;
5314
- this.rebuildDisplay();
5335
+ this.rebuild();
5315
5336
  }
5316
5337
  /**
5317
5338
  * Get the current task list (read-only copy).
@@ -5319,7 +5340,7 @@ var TaskProgressComponent = class extends piTui.Container {
5319
5340
  getTasks() {
5320
5341
  return [...this.tasks];
5321
5342
  }
5322
- rebuildDisplay() {
5343
+ rebuildForWidth(width) {
5323
5344
  this.clear();
5324
5345
  const completed = this.tasks.filter((t) => t.status === "completed").length;
5325
5346
  const total = this.tasks.length;
@@ -5330,7 +5351,7 @@ var TaskProgressComponent = class extends piTui.Container {
5330
5351
  }
5331
5352
  this.addChild(new piTui.Spacer(1));
5332
5353
  if (this.quietMode) {
5333
- for (const line of this.formatQuietTaskLines(completed, total)) {
5354
+ for (const line of this.formatQuietTaskLines(completed, total, width)) {
5334
5355
  this.addChild(new piTui.Text(line, 0, 0));
5335
5356
  }
5336
5357
  return;
@@ -5341,11 +5362,11 @@ var TaskProgressComponent = class extends piTui.Container {
5341
5362
  this.addChild(new piTui.Text(formatTaskProgressLine(task), 0, 0));
5342
5363
  }
5343
5364
  }
5344
- formatQuietTaskLines(completed, total) {
5365
+ formatQuietTaskLines(completed, total, width) {
5345
5366
  const prefix = " " + theme.fg("muted", `${completed}/${total}`);
5346
5367
  const prefixWidth = piTui.visibleWidth(prefix);
5347
5368
  const continuationPrefix = " ".repeat(prefixWidth);
5348
- const maxWidth = Math.max(20, getTermWidth());
5369
+ const maxWidth = Math.max(20, width);
5349
5370
  const itemSeparator = " ";
5350
5371
  const separatorWidth = itemSeparator.length;
5351
5372
  const lines = [prefix];
@@ -5889,7 +5910,7 @@ function extractContent(text) {
5889
5910
  }
5890
5911
  return { content: text, isError: false };
5891
5912
  }
5892
- var ToolExecutionComponentEnhanced = class extends piTui.Container {
5913
+ var ToolExecutionComponentEnhanced = class extends WidthAwareContainer {
5893
5914
  contentBox;
5894
5915
  toolName;
5895
5916
  args;
@@ -6045,7 +6066,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
6045
6066
  * - expand/collapse on a tool with no collapsible child
6046
6067
  * - initial construction
6047
6068
  */
6048
- rebuild() {
6069
+ rebuildForWidth(_width) {
6049
6070
  this.updateBgColor();
6050
6071
  this.contentBox.clear();
6051
6072
  if (this.quietDisplayMode === "quiet" && this.toolName !== toolNames.MC_TOOLS.EXECUTE_COMMAND) {
@@ -6087,7 +6108,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
6087
6108
  }
6088
6109
  }
6089
6110
  renderCompactTool() {
6090
- const termWidth = getTermWidth();
6111
+ const termWidth = this.renderWidth;
6091
6112
  const maxLineWidth = termWidth - BOX_INDENT * 2 - 2;
6092
6113
  const lines = this.getCompactToolSummaryLines();
6093
6114
  for (const line of lines) {
@@ -6246,7 +6267,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
6246
6267
  const toolLabel = this.getCompactToolLabel();
6247
6268
  const toolLabelColor = this.getCompactToolLabelColor();
6248
6269
  const summary = this.compactToolContinuation ? this.getCompactContinuationSummary() : this.getCompactToolSummary();
6249
- const detailLines = this.getQuietPreviewLines(getTermWidth() - BOX_INDENT * 2 - 2);
6270
+ const detailLines = this.getQuietPreviewLines(this.renderWidth - BOX_INDENT * 2 - 2);
6250
6271
  const firstLine = this.compactToolContinuation ? summary ? `${this.getCompactContinuationIndent()}${this.formatCompactContinuationLine(summary)}${status}` : this.compactToolPreviousSummary ? `${this.getCompactContinuationIndent()}${this.formatEmptyCompactContinuationLine()}${status}` : `${this.getCompactContinuationIndent()}${this.formatCompactToolHeader(toolLabel, toolLabelColor, "")}${status}` : `${this.formatCompactToolHeader(toolLabel, toolLabelColor, summary)}${status}`;
6251
6272
  if (detailLines.length === 0) return [firstLine];
6252
6273
  const previewLines = this.shouldCloseQuietPreview() ? [...detailLines, this.getQuietPreviewCapLine()] : detailLines;
@@ -6769,7 +6790,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
6769
6790
  return;
6770
6791
  }
6771
6792
  const status = this.getStatusIndicator();
6772
- const termWidth = getTermWidth();
6793
+ const termWidth = this.renderWidth;
6773
6794
  const fixedParts = "\u2570\u2500\u2500 view " + (rangeDisplay ? `:XXX,XXX` : "") + " \u2713";
6774
6795
  const availableForPath = termWidth - fixedParts.length - 6 - BOX_INDENT * 2;
6775
6796
  let path3 = argsObj?.path ? shortenPath(String(argsObj.path)) : "...";
@@ -6782,7 +6803,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
6782
6803
  this.contentBox.addChild(new piTui.Text(border("\u256D\u2500\u2500"), 0, 0));
6783
6804
  const output = this.getFormattedOutput();
6784
6805
  if (output) {
6785
- const termWidth2 = getTermWidth();
6806
+ const termWidth2 = this.renderWidth;
6786
6807
  const maxLineWidth = termWidth2 - 4 - BOX_INDENT * 2;
6787
6808
  const highlighted = highlightCode(output, fullPath, startLine);
6788
6809
  let lines = highlighted.split("\n");
@@ -6825,7 +6846,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
6825
6846
  const border = (char) => this.formatToolBorder(char);
6826
6847
  const footerPrompt = `${theme.bold(theme.fg("toolTitle", "$"))} `;
6827
6848
  const footerSuffix = `${cwdSuffix}${timeSuffix}${status2}`;
6828
- const termWidth = getTermWidth();
6849
+ const termWidth = this.renderWidth;
6829
6850
  const contentWidth = Math.max(20, termWidth - BOX_INDENT * 2 - 4);
6830
6851
  const horizontal = "\u2500".repeat(contentWidth + 2);
6831
6852
  const renderLine = (line, color = (value) => theme.fg("toolOutput", value)) => {
@@ -6929,7 +6950,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
6929
6950
  const border = (char) => this.formatToolBorder(char);
6930
6951
  const footerText = `${theme.bold(theme.fg("toolTitle", label))} ${theme.fg("toolArgs", `PID ${pid}`)}${timeSuffix}${status2}`;
6931
6952
  this.contentBox.addChild(new piTui.Text(border("\u256D\u2500\u2500"), 0, 0));
6932
- const termWidth = getTermWidth();
6953
+ const termWidth = this.renderWidth;
6933
6954
  const maxLineWidth = termWidth - 4 - BOX_INDENT * 2;
6934
6955
  const borderedLines = outputLines.map((line) => {
6935
6956
  const truncated = truncateAnsi2(line, maxLineWidth);
@@ -6974,7 +6995,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
6974
6995
  const newStr = argsObj?.new_str ?? argsObj?.new_string;
6975
6996
  if (oldStr != null && newStr != null) {
6976
6997
  const border2 = (char) => this.formatToolBorder(char);
6977
- const termWidth2 = getTermWidth();
6998
+ const termWidth2 = this.renderWidth;
6978
6999
  const maxLineWidth = termWidth2 - 4 - BOX_INDENT * 2;
6979
7000
  const footerText2 = `${theme.bold(theme.fg("toolTitle", "edit"))} ${pathDisplay2}${theme.fg("muted", startLine)}${status2}`;
6980
7001
  this.addLeadingPadding();
@@ -7010,7 +7031,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
7010
7031
  }
7011
7032
  const border = (char) => this.formatToolBorder(char);
7012
7033
  const status = this.getStatusIndicator();
7013
- const termWidth = getTermWidth();
7034
+ const termWidth = this.renderWidth;
7014
7035
  const fixedParts = "\u2570\u2500\u2500 edit " + startLine + " \u2713";
7015
7036
  const availableForPath = termWidth - fixedParts.length - 6 - BOX_INDENT * 2;
7016
7037
  let path3 = argsObj?.path ? shortenPath(String(argsObj.path)) : "...";
@@ -7174,7 +7195,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
7174
7195
  }
7175
7196
  const border2 = (char) => this.formatToolBorder(char);
7176
7197
  const status2 = this.getStatusIndicator();
7177
- const termWidth2 = getTermWidth();
7198
+ const termWidth2 = this.renderWidth;
7178
7199
  const maxLineWidth2 = termWidth2 - 4 - BOX_INDENT * 2;
7179
7200
  let path4 = argsObj?.path ? shortenPath(String(argsObj.path)) : "...";
7180
7201
  const fixedParts2 = "\u2570\u2500\u2500 write \u22EF";
@@ -7211,7 +7232,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
7211
7232
  }
7212
7233
  const border = (char) => this.formatToolBorder(char);
7213
7234
  const status = this.getStatusIndicator();
7214
- const termWidth = getTermWidth();
7235
+ const termWidth = this.renderWidth;
7215
7236
  const maxLineWidth = termWidth - 4 - BOX_INDENT * 2;
7216
7237
  let path3 = argsObj?.path ? shortenPath(String(argsObj.path)) : "...";
7217
7238
  const fixedParts = "\u2570\u2500\u2500 write \u2713";
@@ -7264,7 +7285,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
7264
7285
  const patternDisplay = pattern ? " " + theme.fg("muted", pattern) : "";
7265
7286
  const border = (char) => this.formatToolBorder(char);
7266
7287
  const status = this.getStatusIndicator();
7267
- const termWidth = getTermWidth();
7288
+ const termWidth = this.renderWidth;
7268
7289
  const maxLineWidth = termWidth - 4 - BOX_INDENT * 2;
7269
7290
  if (!this.result || this.isPartial) {
7270
7291
  const pathDisplay = fullPath ? fileLink(theme.fg("toolArgs", path3), fullPath) : theme.fg("toolArgs", path3);
@@ -7309,7 +7330,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
7309
7330
  renderLspInspectEnhanced() {
7310
7331
  const border = (char) => this.formatToolBorder(char);
7311
7332
  const status = this.getStatusIndicator();
7312
- const termWidth = getTermWidth();
7333
+ const termWidth = this.renderWidth;
7313
7334
  const maxLineWidth = termWidth - 4 - BOX_INDENT * 2;
7314
7335
  const argsObj = this.args;
7315
7336
  const path_ = argsObj?.path;
@@ -7504,7 +7525,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
7504
7525
  }
7505
7526
  const output = this.formatWebSearchResults();
7506
7527
  if (output) {
7507
- const termWidth = getTermWidth();
7528
+ const termWidth = this.renderWidth;
7508
7529
  const maxLineWidth = termWidth - 4 - BOX_INDENT * 2;
7509
7530
  this.addLeadingPadding();
7510
7531
  this.contentBox.addChild(new piTui.Text(border("\u256D\u2500\u2500"), 0, 0));
@@ -7606,7 +7627,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
7606
7627
  }
7607
7628
  const output = this.getFormattedOutput();
7608
7629
  if (output) {
7609
- const termWidth = getTermWidth();
7630
+ const termWidth = this.renderWidth;
7610
7631
  const maxLineWidth = termWidth - 4 - BOX_INDENT * 2;
7611
7632
  this.addLeadingPadding();
7612
7633
  this.contentBox.addChild(new piTui.Text(border("\u256D\u2500\u2500"), 0, 0));
@@ -7643,7 +7664,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
7643
7664
  const argsObj = this.args;
7644
7665
  const keys = Object.keys(argsObj);
7645
7666
  if (keys.length === 0) return [];
7646
- const termWidth = getTermWidth();
7667
+ const termWidth = this.renderWidth;
7647
7668
  const maxLineWidth = termWidth - 4 - BOX_INDENT * 2 - 2;
7648
7669
  const lines = [];
7649
7670
  for (let i = 0; i < keys.length; i++) {
@@ -7690,7 +7711,7 @@ var ToolExecutionComponentEnhanced = class extends piTui.Container {
7690
7711
  const argsObj = this.args;
7691
7712
  const entries = Object.entries(argsObj).filter(([, v]) => v !== void 0);
7692
7713
  if (entries.length === 0) return "";
7693
- const termWidth = getTermWidth();
7714
+ const termWidth = this.renderWidth;
7694
7715
  const maxLen = Math.max(20, termWidth - this.toolName.length - 15 - BOX_INDENT * 2);
7695
7716
  const parts = [];
7696
7717
  let currentLen = 0;
@@ -13733,8 +13754,9 @@ async function performLogin(ctx, providerId) {
13733
13754
  authMode
13734
13755
  }).then(async () => {
13735
13756
  ctx.state.ui.hideOverlay();
13757
+ const hasSelectedModel = ctx.state.session.model.get() !== "";
13736
13758
  const defaultModel = storage.PROVIDER_DEFAULT_MODELS[providerId];
13737
- if (defaultModel) {
13759
+ if (defaultModel && !hasSelectedModel) {
13738
13760
  await ctx.state.session.model.switch({ modelId: defaultModel });
13739
13761
  ctx.showInfo(`Logged in to ${providerName} - switched to ${defaultModel}`);
13740
13762
  } else {
@@ -16691,8 +16713,6 @@ var SPACE_REPEAT_MAX_GAP_MS = 180;
16691
16713
  var SPACE_HOLD_REPEAT_THRESHOLD = 3;
16692
16714
  var SPACE_RELEASE_IDLE_MS = 250;
16693
16715
  var ANSI_STRIP_RE2 = /\x1b\[[0-9;]*m/g;
16694
- var SLASH_CURSOR_RE = /\x1b\[7m\/\x1b\[0m/;
16695
- var AT_CURSOR_RE = /\x1b\[7m@\x1b\[0m/;
16696
16716
  function parseHex2(hex) {
16697
16717
  const h = hex.replace("#", "");
16698
16718
  return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
@@ -16861,7 +16881,35 @@ var CustomEditor = class extends piTui.Editor {
16861
16881
  }
16862
16882
  const promptWidth = 4;
16863
16883
  const contentWidth = width - 6;
16864
- const editorLines = super.render(contentWidth);
16884
+ const editorState = this.state;
16885
+ const decorativePrompt = isSlash ? "/" : isAt ? "@" : void 0;
16886
+ const firstLine = editorState.lines[0];
16887
+ const markerIndex = firstLine?.search(/\S/) ?? -1;
16888
+ const shouldHideDecorativePrompt = decorativePrompt !== void 0 && firstLine !== void 0 && firstLine[markerIndex] === decorativePrompt;
16889
+ const cursorLine = editorState.cursorLine;
16890
+ const cursorCol = editorState.cursorCol;
16891
+ const cursorOnDecorativePrompt = shouldHideDecorativePrompt && cursorLine === 0 && cursorCol === markerIndex;
16892
+ if (cursorOnDecorativePrompt && !this.voiceListening) {
16893
+ prompt = `\x1B[7m${prompt}\x1B[0m`;
16894
+ }
16895
+ let editorLines;
16896
+ if (shouldHideDecorativePrompt) {
16897
+ editorState.lines[0] = firstLine.slice(0, markerIndex) + firstLine.slice(markerIndex + 1);
16898
+ if (cursorOnDecorativePrompt) {
16899
+ editorState.cursorLine = -1;
16900
+ } else if (editorState.cursorLine === 0 && cursorCol > markerIndex) {
16901
+ editorState.cursorCol = cursorCol - 1;
16902
+ }
16903
+ try {
16904
+ editorLines = super.render(contentWidth);
16905
+ } finally {
16906
+ editorState.lines[0] = firstLine;
16907
+ editorState.cursorLine = cursorLine;
16908
+ editorState.cursorCol = cursorCol;
16909
+ }
16910
+ } else {
16911
+ editorLines = super.render(contentWidth);
16912
+ }
16865
16913
  const contentLines = [];
16866
16914
  const scrollIndicators = [];
16867
16915
  let isTop = true;
@@ -16880,16 +16928,6 @@ var CustomEditor = class extends piTui.Editor {
16880
16928
  }
16881
16929
  contentLines.push(line);
16882
16930
  }
16883
- if ((isSlash || isAt) && contentLines.length > 0) {
16884
- let l = contentLines[0];
16885
- const char = isSlash ? "/" : "@";
16886
- l = l.replace(isSlash ? SLASH_CURSOR_RE : AT_CURSOR_RE, "");
16887
- const idx = l.indexOf(char);
16888
- if (idx !== -1) {
16889
- l = l.slice(0, idx) + l.slice(idx + 1);
16890
- }
16891
- contentLines[0] = l;
16892
- }
16893
16931
  const result = [];
16894
16932
  const hBarLen = width - 2;
16895
16933
  const top = b("\u256D") + b("\u2500").repeat(hBarLen) + b("\u256E");
@@ -17746,7 +17784,7 @@ function inertSession() {
17746
17784
  };
17747
17785
  }
17748
17786
  function resolveAsset(name) {
17749
- const here = path2.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-TWIBIHJ5.cjs', document.baseURI).href))));
17787
+ const here = path2.dirname(url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-KRJFHRGM.cjs', document.baseURI).href))));
17750
17788
  const candidates = [
17751
17789
  path2.join(here, name),
17752
17790
  // dev: src/tui/voice/native/<name>
@@ -20118,7 +20156,7 @@ function formatDuration3(ms) {
20118
20156
  const seconds = ms / 1e3;
20119
20157
  return seconds < 60 ? `${seconds.toFixed(1)}s` : `${Math.floor(seconds / 60)}m${Math.floor(seconds % 60)}s`;
20120
20158
  }
20121
- var ShellStreamComponent = class extends piTui.Container {
20159
+ var ShellStreamComponent = class extends WidthAwareContainer {
20122
20160
  command;
20123
20161
  lines = [];
20124
20162
  trailingPartial = "";
@@ -20158,10 +20196,9 @@ var ShellStreamComponent = class extends piTui.Container {
20158
20196
  this.exitCode = exitCode;
20159
20197
  this.rebuild();
20160
20198
  }
20161
- rebuild() {
20199
+ rebuildForWidth(termWidth) {
20162
20200
  this.clear();
20163
20201
  const border = (char) => theme.bold(theme.fg("accent", char));
20164
- const termWidth = getTermWidth();
20165
20202
  const maxLineWidth = termWidth - 6;
20166
20203
  const done = this.exitCode !== void 0;
20167
20204
  const statusIcon = done ? this.exitCode === 0 ? theme.fg("success", " \u2713") : theme.fg("error", " \u2717") : theme.fg("muted", " \u22EF");
@@ -21604,5 +21641,5 @@ exports.getThemeMode = getThemeMode;
21604
21641
  exports.mastra = mastra;
21605
21642
  exports.restoreTerminalForeground = restoreTerminalForeground;
21606
21643
  exports.theme = theme;
21607
- //# sourceMappingURL=chunk-TWIBIHJ5.cjs.map
21608
- //# sourceMappingURL=chunk-TWIBIHJ5.cjs.map
21644
+ //# sourceMappingURL=chunk-KRJFHRGM.cjs.map
21645
+ //# sourceMappingURL=chunk-KRJFHRGM.cjs.map