mixdog 1.3.2 → 1.3.4

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 (182) hide show
  1. package/package.json +8 -8
  2. package/scripts/verify-runtime-dependency-versions.mjs +158 -0
  3. package/src/agents/reviewer/AGENT.md +5 -7
  4. package/src/agents/reviewer/agent.json +1 -1
  5. package/src/defaults/shipped-history.json +4 -0
  6. package/src/defaults/skills/browser-use/SKILL.md +6 -3
  7. package/src/defaults/skills/local-provider/SKILL.md +33 -6
  8. package/src/rules/lead/LEAD.md +5 -8
  9. package/src/rules/shared/45-destructive.md +5 -1
  10. package/src/rules/shared/60-verification.md +6 -4
  11. package/src/runtime/agent/orchestrator/providers/anthropic-api-request.mjs +4 -1
  12. package/src/runtime/agent/orchestrator/providers/anthropic-max-tokens.mjs +38 -11
  13. package/src/runtime/agent/orchestrator/providers/anthropic-messages.mjs +15 -3
  14. package/src/runtime/agent/orchestrator/providers/anthropic-oauth-client-version.mjs +1 -1
  15. package/src/runtime/agent/orchestrator/providers/anthropic-oauth.mjs +17 -4
  16. package/src/runtime/agent/orchestrator/providers/anthropic.mjs +14 -1
  17. package/src/runtime/agent/orchestrator/providers/cursor-client-version.mjs +1 -1
  18. package/src/runtime/agent/orchestrator/providers/custom-provider-config.mjs +14 -1
  19. package/src/runtime/agent/orchestrator/providers/grok-client-version.mjs +1 -1
  20. package/src/runtime/agent/orchestrator/providers/registry.mjs +10 -0
  21. package/src/runtime/agent/orchestrator/providers/wire-gateway.mjs +13 -1
  22. package/src/runtime/agent/orchestrator/runtime-core/goal-runtime.mjs +5 -0
  23. package/src/runtime/agent/orchestrator/runtime-core/goal-turns.mjs +10 -1
  24. package/src/runtime/agent/orchestrator/runtime-core/tool-catalog.mjs +40 -5
  25. package/src/runtime/agent/orchestrator/runtime-core/tool-defs.mjs +32 -11
  26. package/src/runtime/agent/orchestrator/runtime-core/workflow.mjs +6 -3
  27. package/src/runtime/agent/orchestrator/session/agent-loop.mjs +1 -1
  28. package/src/runtime/agent/orchestrator/session/agent-room.d.mts +13 -0
  29. package/src/runtime/agent/orchestrator/session/agent-room.mjs +68 -12
  30. package/src/runtime/agent/orchestrator/session/compact/continuation.mjs +15 -6
  31. package/src/runtime/agent/orchestrator/session/compact/execution-tail.mjs +31 -8
  32. package/src/runtime/agent/orchestrator/session/compact/messages.mjs +44 -0
  33. package/src/runtime/agent/orchestrator/session/compact/runner.mjs +117 -19
  34. package/src/runtime/agent/orchestrator/session/compact/text-utils.mjs +1 -1
  35. package/src/runtime/agent/orchestrator/session/compact/user-message-kind.mjs +3 -0
  36. package/src/runtime/agent/orchestrator/session/human-gate/delegation.mjs +147 -137
  37. package/src/runtime/agent/orchestrator/session/human-gate/gate.mjs +37 -74
  38. package/src/runtime/agent/orchestrator/session/human-gate/requests.mjs +0 -2
  39. package/src/runtime/agent/orchestrator/session/human-gate/run-policy.mjs +2 -2
  40. package/src/runtime/agent/orchestrator/session/loop/fresh-context.mjs +13 -7
  41. package/src/runtime/agent/orchestrator/session/loop/loop-state.mjs +5 -0
  42. package/src/runtime/agent/orchestrator/session/loop/no-tool-turn/continuation.mjs +2 -0
  43. package/src/runtime/agent/orchestrator/session/loop/no-tool-turn/empty-nudge.mjs +1 -1
  44. package/src/runtime/agent/orchestrator/session/loop/no-tool-turn/output-limit.mjs +62 -13
  45. package/src/runtime/agent/orchestrator/session/loop/no-tool-turn.mjs +22 -6
  46. package/src/runtime/agent/orchestrator/session/loop/send-phase.mjs +7 -0
  47. package/src/runtime/agent/orchestrator/session/loop/tool-exec/before-hook.mjs +12 -20
  48. package/src/runtime/agent/orchestrator/session/loop/tool-exec/call-prep.mjs +5 -0
  49. package/src/runtime/agent/orchestrator/session/loop/tool-exec/dispatch.mjs +11 -5
  50. package/src/runtime/agent/orchestrator/session/manager/agent-listing-notice.mjs +102 -0
  51. package/src/runtime/agent/orchestrator/session/manager/ask-queue.mjs +2 -0
  52. package/src/runtime/agent/orchestrator/session/manager/ask-session.mjs +13 -1
  53. package/src/runtime/agent/orchestrator/session/manager/ask-turn-execute.mjs +24 -15
  54. package/src/runtime/agent/orchestrator/session/manager/ask-turn-prepare.mjs +8 -0
  55. package/src/runtime/agent/orchestrator/session/manager/ask-turn-steering-drain.mjs +1 -0
  56. package/src/runtime/agent/orchestrator/session/manager/idle-cleanup.mjs +32 -1
  57. package/src/runtime/agent/orchestrator/session/manager/orchestration-mode-switch-notice.mjs +17 -1
  58. package/src/runtime/agent/orchestrator/session/manager/pending-message-entry.mjs +6 -0
  59. package/src/runtime/agent/orchestrator/session/manager/prompt-utils.mjs +36 -0
  60. package/src/runtime/agent/orchestrator/session/manager/session-crud.mjs +28 -9
  61. package/src/runtime/agent/orchestrator/session/manager/session-prompt-composition.mjs +1 -1
  62. package/src/runtime/agent/orchestrator/session/manager/session-record.mjs +7 -5
  63. package/src/runtime/agent/orchestrator/session/manager/session-tool-surface.mjs +7 -3
  64. package/src/runtime/agent/orchestrator/session/pre-send-compact.mjs +10 -1
  65. package/src/runtime/agent/orchestrator/session/routine-result.mjs +7 -4
  66. package/src/runtime/agent/orchestrator/session/runtime-user-context.mjs +3 -1
  67. package/src/runtime/agent/orchestrator/session/send-with-recovery.mjs +11 -2
  68. package/src/runtime/agent/orchestrator/session/store/sweep/stale-sweep.mjs +5 -4
  69. package/src/runtime/agent/orchestrator/session/store/sweep/sub-agent-retention.mjs +140 -0
  70. package/src/runtime/agent/orchestrator/session/store/sweep/sweep-plan.mjs +5 -0
  71. package/src/runtime/agent/orchestrator/session/store/sweep/sweep-record.mjs +7 -2
  72. package/src/runtime/agent/orchestrator/session/store/sweep/sweep-row.mjs +13 -0
  73. package/src/runtime/agent/orchestrator/session/store-summary-catalog.mjs +76 -0
  74. package/src/runtime/agent/orchestrator/session/store-summary-reader.mjs +33 -1
  75. package/src/runtime/agent/orchestrator/session/store-summary-visibility.d.mts +5 -0
  76. package/src/runtime/agent/orchestrator/session/store-summary-visibility.mjs +37 -0
  77. package/src/runtime/agent/orchestrator/session/store.mjs +1 -0
  78. package/src/runtime/agent/orchestrator/tools/builtin/advisory-lock.mjs +18 -7
  79. package/src/runtime/agent/orchestrator/tools/builtin/bash-tool/backgrounded-result.mjs +2 -0
  80. package/src/runtime/agent/orchestrator/tools/builtin/git-command-tool.mjs +127 -20
  81. package/src/runtime/agent/orchestrator/tools/builtin/git-worktree-tool.mjs +557 -0
  82. package/src/runtime/agent/orchestrator/tools/builtin/lib/shell-job-records.mjs +6 -0
  83. package/src/runtime/agent/orchestrator/tools/builtin/shell-jobs.mjs +8 -2
  84. package/src/runtime/attachments/legacy-office.mjs +110 -0
  85. package/src/runtime/attachments/prompt-restore.mjs +70 -0
  86. package/src/runtime/attachments/store.mjs +60 -3
  87. package/src/runtime/effort-judge/judge-client.mjs +61 -14
  88. package/src/runtime/effort-judge/model-install.mjs +34 -2
  89. package/src/runtime/memory/lib/memory-chunk-quality.mjs +14 -2
  90. package/src/runtime/office/portable/portable-soffice.mjs +132 -30
  91. package/src/runtime/shared/agent-avatar-sprites.mjs +23 -8
  92. package/src/runtime/shared/agent-avatar.mjs +3 -2
  93. package/src/runtime/shared/agent-room-host.d.mts +31 -0
  94. package/src/runtime/shared/agent-room-host.mjs +58 -0
  95. package/src/runtime/shared/bot-hops.mjs +16 -11
  96. package/src/runtime/shared/llm/usage-rollup.mjs +4 -383
  97. package/src/runtime/shared/redact-directories.mjs +18 -0
  98. package/src/runtime/shared/remove-directory.mjs +28 -0
  99. package/src/runtime/shared/session-sidebar-host.d.mts +11 -2
  100. package/src/runtime/shared/session-sidebar-host.mjs +16 -3
  101. package/src/runtime/shared/tool-execution-contract.mjs +4 -0
  102. package/src/runtime/shared/tool-work-units.mjs +12 -9
  103. package/src/runtime/shared/turn-snapshot.mjs +233 -122
  104. package/src/runtime/shared/user-data-guard.mjs +51 -19
  105. package/src/runtime/shared/worktrees/activity-gate.mjs +209 -227
  106. package/src/runtime/shared/worktrees/contract.mjs +11 -3
  107. package/src/runtime/shared/worktrees/maintenance.mjs +11 -2
  108. package/src/runtime/shared/worktrees/manager.mjs +419 -52
  109. package/src/runtime/shared/worktrees/registry.mjs +3 -1
  110. package/src/runtime/shared/worktrees/tool-host.mjs +39 -0
  111. package/src/runtime/tidy/process.mjs +41 -8
  112. package/src/runtime/tidy/resolve.mjs +10 -7
  113. package/src/session-runtime/agent-home-delivery.mjs +73 -91
  114. package/src/session-runtime/agent-profile-changes.mjs +16 -0
  115. package/src/session-runtime/agent-room-delivery.mjs +2 -63
  116. package/src/session-runtime/agent-task-sessions.mjs +194 -64
  117. package/src/session-runtime/agent-tool-routing.mjs +49 -4
  118. package/src/session-runtime/boot/apis.mjs +3 -0
  119. package/src/session-runtime/boot/facade.mjs +5 -6
  120. package/src/session-runtime/boot/tools.mjs +23 -1
  121. package/src/session-runtime/held-requests.mjs +20 -25
  122. package/src/session-runtime/internal-tool-executor/workspace-tools.mjs +5 -22
  123. package/src/session-runtime/model-recency.mjs +1 -0
  124. package/src/session-runtime/provider-models/row-hydration.mjs +8 -1
  125. package/src/session-runtime/quick-model-rows/model-meta.mjs +2 -0
  126. package/src/session-runtime/quick-model-rows/provider-rows.mjs +7 -1
  127. package/src/session-runtime/runtime-review-api.mjs +4 -1
  128. package/src/session-runtime/services/agent-tool/close-flow.mjs +14 -2
  129. package/src/session-runtime/services/agent-tool/execute.mjs +6 -1
  130. package/src/session-runtime/services/agent-tool/job-views/agent-list.mjs +44 -20
  131. package/src/session-runtime/services/agent-tool/render.mjs +3 -1
  132. package/src/session-runtime/services/agent-tool/spawn-flow/job-start.mjs +3 -0
  133. package/src/session-runtime/services/agent-tool/tool-def.mjs +1 -1
  134. package/src/session-runtime/services/provider-admin.mjs +12 -2
  135. package/src/session-runtime/services/worktree-access.mjs +27 -0
  136. package/src/session-runtime/session-hooks.mjs +9 -17
  137. package/src/session-runtime/settings-builtin-tools-api.mjs +2 -0
  138. package/src/session-runtime/setup-tool/executor.mjs +4 -0
  139. package/src/session-runtime/setup-tool/settings-contract.mjs +3 -0
  140. package/src/session-runtime/tool-policy/agent-profile-fold.mjs +98 -14
  141. package/src/session-runtime/tool-policy/policy-stage.mjs +23 -5
  142. package/src/session-runtime/tool-policy-refresh.mjs +1 -0
  143. package/src/session-runtime/tool-surface.mjs +9 -5
  144. package/src/session-runtime/turn/session-ops.mjs +8 -0
  145. package/src/session-runtime/turn/turn-run.mjs +5 -1
  146. package/src/session-runtime/usage-stats-api.mjs +1 -1
  147. package/src/session-runtime/workflow-agents-api/agent-editor.mjs +10 -2
  148. package/src/session-runtime/workflow-agents-api/agent-route.mjs +39 -17
  149. package/src/session-runtime/workspace/transition-steps.mjs +1 -18
  150. package/src/session-runtime/workspace/transitions.mjs +279 -67
  151. package/src/session-runtime/workspace/worktree-tool.mjs +194 -0
  152. package/src/standalone/daemon-lag-profiler.mjs +3 -1
  153. package/src/standalone/daemon-session-control.mjs +140 -23
  154. package/src/standalone/daemon-telemetry.mjs +9 -0
  155. package/src/standalone/daemon.mjs +5 -0
  156. package/src/standalone/local-session-runtime.mjs +11 -2
  157. package/src/standalone/session-protocol.mjs +1 -0
  158. package/src/standalone/session-runtime-inline-host/boot-loaders.mjs +2 -0
  159. package/src/standalone/session-service/agent-route-follow.mjs +69 -0
  160. package/src/standalone/session-service/session-calls/session-turns.mjs +33 -4
  161. package/src/standalone/session-service.mjs +10 -0
  162. package/src/standalone/session-tool-output.mjs +1 -0
  163. package/src/standalone/staged-import.mjs +47 -0
  164. package/src/tui/App.jsx +2 -0
  165. package/src/tui/app/message-selector.mjs +15 -2
  166. package/src/tui/app/model-options.mjs +16 -2
  167. package/src/tui/app/model-picker.mjs +2 -1
  168. package/src/tui/app/route-pickers.mjs +3 -1
  169. package/src/tui/dist/index.mjs +403 -210
  170. package/src/tui/paste-attachments.mjs +0 -1
  171. package/src/tui/paste-text-policy.mjs +4 -5
  172. package/src/tui/session/agent-job-feed/execution-delivery.mjs +4 -1
  173. package/src/tui/session/notice-surface.mjs +3 -0
  174. package/src/tui/session/session-api/intake/abort.mjs +33 -17
  175. package/src/tui/session/session-api/intake/rewind.mjs +39 -4
  176. package/src/tui/session/session-api/routes-agent-definitions.mjs +1 -0
  177. package/src/tui/session/tool-approval.mjs +11 -48
  178. package/src/vendor/statusline/src/gateway/claude-current.mjs +0 -58
  179. package/src/vendor/statusline/src/gateway/route-meta.mjs +1 -361
  180. package/src/vendor/statusline/src/gateway/session-routes.mjs +0 -55
  181. package/src/session-runtime/room-member-gate.mjs +0 -61
  182. package/src/vendor/statusline/scripts/lib/gateway-settings.mjs +0 -285
@@ -27484,8 +27484,8 @@ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
27484
27484
 
27485
27485
  // node_modules/string-width/index.js
27486
27486
  var segmenter = new Intl.Segmenter();
27487
- var zeroWidthClusterRegex = new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Mark}|\\p{Surrogate})+$", "v");
27488
- var leadingNonPrintingRegex = new RegExp("^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Mark}\\p{Surrogate}]+", "v");
27487
+ var visibleCharacterRegex = new RegExp("[^\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Nonspacing_Mark}\\p{Enclosing_Mark}\\p{Surrogate}]", "v");
27488
+ var spacingMarkRegex = new RegExp("\\p{Spacing_Mark}", "v");
27489
27489
  var rgiEmojiRegex = new RegExp("^\\p{RGI_Emoji}$", "v");
27490
27490
  var unqualifiedKeycapRegex = /^[\d#*]\u20E3$/;
27491
27491
  var extendedPictographicRegex = new RegExp("\\p{Extended_Pictographic}", "gu");
@@ -27503,10 +27503,8 @@ function isDoubleWidthNonRgiEmojiSequence(segment) {
27503
27503
  return false;
27504
27504
  }
27505
27505
  function baseVisible(segment) {
27506
- return segment.replace(leadingNonPrintingRegex, "");
27507
- }
27508
- function isZeroWidthCluster(segment) {
27509
- return zeroWidthClusterRegex.test(segment);
27506
+ const index = segment.search(visibleCharacterRegex);
27507
+ return index === -1 ? void 0 : segment.slice(index);
27510
27508
  }
27511
27509
  function isHangulLeadingJamo(codePoint) {
27512
27510
  return codePoint >= 4352 && codePoint <= 4447 || codePoint >= 43360 && codePoint <= 43388;
@@ -27523,7 +27521,7 @@ function isHangulJamo(codePoint) {
27523
27521
  function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) {
27524
27522
  const codePoints = [];
27525
27523
  for (const character of visibleSegment) {
27526
- if (zeroWidthClusterRegex.test(character)) {
27524
+ if (!visibleCharacterRegex.test(character)) {
27527
27525
  continue;
27528
27526
  }
27529
27527
  codePoints.push(character.codePointAt(0));
@@ -27552,7 +27550,7 @@ function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) {
27552
27550
  }
27553
27551
  return width;
27554
27552
  }
27555
- function trailingHalfwidthWidth(visibleSegment, eastAsianWidthOptions) {
27553
+ function trailingWidth(visibleSegment, eastAsianWidthOptions) {
27556
27554
  let extra = 0;
27557
27555
  let first = true;
27558
27556
  for (const character of visibleSegment) {
@@ -27560,7 +27558,7 @@ function trailingHalfwidthWidth(visibleSegment, eastAsianWidthOptions) {
27560
27558
  first = false;
27561
27559
  continue;
27562
27560
  }
27563
- if (character >= "\uFF00" && character <= "\uFFEF") {
27561
+ if (spacingMarkRegex.test(character) || character >= "\uFF00" && character <= "\uFFEF") {
27564
27562
  extra += eastAsianWidth(character.codePointAt(0), eastAsianWidthOptions);
27565
27563
  }
27566
27564
  }
@@ -27587,14 +27585,14 @@ function stringWidth(input, options = {}) {
27587
27585
  let width = 0;
27588
27586
  const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
27589
27587
  for (const { segment } of segmenter.segment(string)) {
27590
- if (isZeroWidthCluster(segment)) {
27588
+ const visibleSegment = baseVisible(segment);
27589
+ if (visibleSegment === void 0) {
27591
27590
  continue;
27592
27591
  }
27593
27592
  if (rgiEmojiRegex.test(segment) || isDoubleWidthNonRgiEmojiSequence(segment)) {
27594
27593
  width += 2;
27595
27594
  continue;
27596
27595
  }
27597
- const visibleSegment = baseVisible(segment);
27598
27596
  const hangulWidth = hangulClusterWidth(visibleSegment, eastAsianWidthOptions);
27599
27597
  if (hangulWidth !== void 0) {
27600
27598
  width += hangulWidth;
@@ -27602,7 +27600,7 @@ function stringWidth(input, options = {}) {
27602
27600
  }
27603
27601
  const codePoint = visibleSegment.codePointAt(0);
27604
27602
  width += eastAsianWidth(codePoint, eastAsianWidthOptions);
27605
- width += trailingHalfwidthWidth(visibleSegment, eastAsianWidthOptions);
27603
+ width += trailingWidth(visibleSegment, eastAsianWidthOptions);
27606
27604
  }
27607
27605
  return width;
27608
27606
  }
@@ -27795,12 +27793,8 @@ var ansi_styles_default = ansiStyles;
27795
27793
 
27796
27794
  // node_modules/wrap-ansi/index.js
27797
27795
  var ANSI_ESCAPE = "\x1B";
27798
- var ANSI_ESCAPE_CSI = "\x9B";
27799
- var ESCAPES = /* @__PURE__ */ new Set([
27800
- ANSI_ESCAPE,
27801
- ANSI_ESCAPE_CSI
27802
- ]);
27803
27796
  var ANSI_ESCAPE_BELL = "\x07";
27797
+ var C1_CSI = "\x9B";
27804
27798
  var ANSI_CSI = "[";
27805
27799
  var ANSI_OSC = "]";
27806
27800
  var ANSI_SGR_TERMINATOR = "m";
@@ -27811,47 +27805,168 @@ var ANSI_SGR_RESET_UNDERLINE_COLOR = 59;
27811
27805
  var ANSI_SGR_FOREGROUND_EXTENDED = 38;
27812
27806
  var ANSI_SGR_BACKGROUND_EXTENDED = 48;
27813
27807
  var ANSI_SGR_UNDERLINE_COLOR_EXTENDED = 58;
27814
- var ANSI_SGR_COLOR_MODE_256 = 5;
27815
27808
  var ANSI_SGR_COLOR_MODE_RGB = 2;
27816
- var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
27817
- var ANSI_ESCAPE_REGEX = new RegExp(`^\\u001B(?:\\${ANSI_CSI}(?<sgr>[0-9;]*)${ANSI_SGR_TERMINATOR}|${ANSI_ESCAPE_LINK}(?<uri>[^\\u0007\\u001B]*)(?:\\u0007|\\u001B\\\\))`);
27818
- var ANSI_ESCAPE_CSI_REGEX = new RegExp(`^\\u009B(?<sgr>[0-9;]*)${ANSI_SGR_TERMINATOR}`);
27809
+ var ANSI_SGR_COLOR_MODE_256 = 5;
27810
+ var ANSI_ESCAPE_LINK = `${ANSI_OSC}8;`;
27811
+ var ESCAPES = /* @__PURE__ */ new Set([
27812
+ ANSI_ESCAPE,
27813
+ C1_CSI
27814
+ ]);
27815
+ var ESCAPE_CHARACTERS = [...ESCAPES].join("");
27816
+ var CSI_INTRODUCER = `(?:${ANSI_ESCAPE}\\${ANSI_CSI}|${C1_CSI})`;
27817
+ var CSI_PARAMETERS = "[0-?]*[ -/]*[@-~]";
27818
+ var SGR_PARAMETERS = `(?<sgr>[0-9;:]*)${ANSI_SGR_TERMINATOR}`;
27819
+ var OSC_STRING_TERMINATOR = `(?:${ANSI_ESCAPE_BELL}|${ANSI_ESCAPE}\\\\)`;
27820
+ var OSC_STRING_PAYLOAD = String.raw`[^\u0000-\u001F\u007F-\u009F]*`;
27821
+ var LINK_PARAMETERS = String.raw`8;(?<parameters>[^;\u0000-\u001F\u007F-\u009F]*);(?<uri>${OSC_STRING_PAYLOAD})${OSC_STRING_TERMINATOR}`;
27822
+ var OSC_STRING = `${OSC_STRING_PAYLOAD}${OSC_STRING_TERMINATOR}`;
27823
+ var ANSI_ESCAPE_REGEX = new RegExp(
27824
+ `${CSI_INTRODUCER}(?:${SGR_PARAMETERS}|${CSI_PARAMETERS})|${ANSI_ESCAPE}\\${ANSI_OSC}(?:${LINK_PARAMETERS}|${OSC_STRING})`,
27825
+ "y"
27826
+ );
27819
27827
  var ANSI_SGR_MODIFIER_CLOSE_CODES = new Set(ansi_styles_default.codes.values());
27820
27828
  ANSI_SGR_MODIFIER_CLOSE_CODES.delete(ANSI_SGR_RESET);
27821
27829
  var segmenter2 = new Intl.Segmenter();
27822
- var getGraphemes = (string) => Array.from(segmenter2.segment(string), ({ segment }) => segment);
27830
+ var getStringWidth = (string) => stringWidth(string, { countAnsiEscapeCodes: true });
27823
27831
  var TAB_SIZE = 8;
27832
+ var ESCAPE_INTRODUCER_REGEX = new RegExp(`[${ESCAPE_CHARACTERS}]`, "g");
27833
+ var ROW_BOUNDARY_REGEX = new RegExp(`[\\n${ESCAPE_CHARACTERS}]`, "g");
27834
+ var ASCII_PRINTABLE_REGEX = /^[ -~]*$/;
27824
27835
  var wrapAnsiCode = (code) => `${ANSI_ESCAPE}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
27825
- var wrapAnsiHyperlink = (url) => `${ANSI_ESCAPE}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
27836
+ var wrapAnsiHyperlink = (url, parameters = "") => `${ANSI_ESCAPE}${ANSI_ESCAPE_LINK}${parameters};${url}${ANSI_ESCAPE_BELL}`;
27837
+ var matchAnsiEscape = (string, index) => {
27838
+ if (!ESCAPES.has(string[index])) {
27839
+ return;
27840
+ }
27841
+ ANSI_ESCAPE_REGEX.lastIndex = index;
27842
+ return ANSI_ESCAPE_REGEX.exec(string) ?? void 0;
27843
+ };
27844
+ var forEachSegment = (string, onPlainText, onEscape = () => {
27845
+ }) => {
27846
+ let plainStart = 0;
27847
+ let index = 0;
27848
+ while (index < string.length) {
27849
+ ESCAPE_INTRODUCER_REGEX.lastIndex = index;
27850
+ const introducer = ESCAPE_INTRODUCER_REGEX.exec(string);
27851
+ if (!introducer) {
27852
+ break;
27853
+ }
27854
+ const escape3 = matchAnsiEscape(string, introducer.index);
27855
+ if (!escape3) {
27856
+ index = introducer.index + 1;
27857
+ continue;
27858
+ }
27859
+ if (introducer.index > plainStart) {
27860
+ onPlainText(string.slice(plainStart, introducer.index));
27861
+ }
27862
+ onEscape(escape3[0]);
27863
+ index = introducer.index + escape3[0].length;
27864
+ plainStart = index;
27865
+ }
27866
+ if (plainStart < string.length) {
27867
+ onPlainText(string.slice(plainStart));
27868
+ }
27869
+ };
27870
+ var getWidth = (string) => {
27871
+ let plainText = "";
27872
+ forEachSegment(string, (part) => {
27873
+ plainText += part;
27874
+ });
27875
+ return getStringWidth(plainText);
27876
+ };
27877
+ var getTokens = (string) => {
27878
+ const tokens = [];
27879
+ forEachSegment(string, (plainText) => {
27880
+ if (ASCII_PRINTABLE_REGEX.test(plainText)) {
27881
+ for (const character of plainText) {
27882
+ tokens.push({ value: character, width: 1 });
27883
+ }
27884
+ return;
27885
+ }
27886
+ for (const { segment } of segmenter2.segment(plainText)) {
27887
+ tokens.push({ value: segment, width: getStringWidth(segment) });
27888
+ }
27889
+ }, (escape3) => {
27890
+ tokens.push({ value: escape3, width: 0 });
27891
+ });
27892
+ return tokens;
27893
+ };
27894
+ var splitWords = (string) => {
27895
+ let currentWord = { value: "", plainText: "" };
27896
+ const words = [currentWord];
27897
+ forEachSegment(string, (plainText) => {
27898
+ const parts = plainText.split(" ");
27899
+ currentWord.value += parts[0];
27900
+ currentWord.plainText += parts[0];
27901
+ for (let index = 1; index < parts.length; index++) {
27902
+ currentWord = { value: parts[index], plainText: parts[index] };
27903
+ words.push(currentWord);
27904
+ }
27905
+ }, (escape3) => {
27906
+ currentWord.value += escape3;
27907
+ });
27908
+ for (const word of words) {
27909
+ word.width = getStringWidth(word.plainText);
27910
+ }
27911
+ return words;
27912
+ };
27913
+ var getColonColorToken = (parameter) => {
27914
+ const parts = parameter.split(":");
27915
+ const code = Number.parseInt(parts[0], 10);
27916
+ const mode = Number.parseInt(parts[1], 10);
27917
+ if (![ANSI_SGR_FOREGROUND_EXTENDED, ANSI_SGR_BACKGROUND_EXTENDED, ANSI_SGR_UNDERLINE_COLOR_EXTENDED].includes(code)) {
27918
+ return;
27919
+ }
27920
+ if (mode === ANSI_SGR_COLOR_MODE_256 && parts.length === 3 && /^\d+$/.test(parts[2])) {
27921
+ return { code, open: parameter, hasArguments: true };
27922
+ }
27923
+ if (mode !== ANSI_SGR_COLOR_MODE_RGB) {
27924
+ return;
27925
+ }
27926
+ const components = parts.length === 6 ? parts.slice(3) : parts.slice(2);
27927
+ const colorSpace = parts.length === 6 ? parts[2] : void 0;
27928
+ if (components.length === 3 && components.every((component) => /^\d+$/.test(component)) && (colorSpace === void 0 || /^\d*$/.test(colorSpace))) {
27929
+ return { code, open: parameter, hasArguments: true };
27930
+ }
27931
+ };
27826
27932
  var getSgrTokens = (sgrParameters) => {
27827
- const codes = sgrParameters.split(";").map((sgrParameter) => sgrParameter === "" ? ANSI_SGR_RESET : Number.parseInt(sgrParameter, 10));
27933
+ const parameters = sgrParameters.split(";");
27828
27934
  const sgrTokens = [];
27829
- for (let index = 0; index < codes.length; index++) {
27830
- const code = codes[index];
27935
+ for (let index = 0; index < parameters.length; index++) {
27936
+ const parameter = parameters[index];
27937
+ if (parameter.includes(":")) {
27938
+ const colonColorToken = getColonColorToken(parameter);
27939
+ if (colonColorToken) {
27940
+ sgrTokens.push(colonColorToken);
27941
+ }
27942
+ continue;
27943
+ }
27944
+ const code = parameter === "" ? ANSI_SGR_RESET : Number.parseInt(parameter, 10);
27831
27945
  if (!Number.isFinite(code)) {
27832
27946
  continue;
27833
27947
  }
27834
27948
  if (code === ANSI_SGR_FOREGROUND_EXTENDED || code === ANSI_SGR_BACKGROUND_EXTENDED || code === ANSI_SGR_UNDERLINE_COLOR_EXTENDED) {
27835
- if (index + 1 >= codes.length) {
27949
+ if (index + 1 >= parameters.length) {
27836
27950
  break;
27837
27951
  }
27838
- const mode = codes[index + 1];
27839
- if (mode === ANSI_SGR_COLOR_MODE_256 && Number.isFinite(codes[index + 2])) {
27840
- sgrTokens.push([code, mode, codes[index + 2]]);
27952
+ const mode = Number.parseInt(parameters[index + 1], 10);
27953
+ const colorIndex = Number.parseInt(parameters[index + 2], 10);
27954
+ if (mode === ANSI_SGR_COLOR_MODE_256 && Number.isFinite(colorIndex)) {
27955
+ sgrTokens.push({ code, open: [code, mode, colorIndex].join(";"), hasArguments: true });
27841
27956
  index += 2;
27842
27957
  continue;
27843
27958
  }
27844
- const red2 = codes[index + 2];
27845
- const green2 = codes[index + 3];
27846
- const blue2 = codes[index + 4];
27959
+ const red2 = Number.parseInt(parameters[index + 2], 10);
27960
+ const green2 = Number.parseInt(parameters[index + 3], 10);
27961
+ const blue2 = Number.parseInt(parameters[index + 4], 10);
27847
27962
  if (mode === ANSI_SGR_COLOR_MODE_RGB && Number.isFinite(red2) && Number.isFinite(green2) && Number.isFinite(blue2)) {
27848
- sgrTokens.push([code, mode, red2, green2, blue2]);
27963
+ sgrTokens.push({ code, open: [code, mode, red2, green2, blue2].join(";"), hasArguments: true });
27849
27964
  index += 4;
27850
27965
  continue;
27851
27966
  }
27852
27967
  break;
27853
27968
  }
27854
- sgrTokens.push([code]);
27969
+ sgrTokens.push({ code, open: String(code), hasArguments: false });
27855
27970
  }
27856
27971
  return sgrTokens;
27857
27972
  };
@@ -27873,25 +27988,26 @@ var removeModifierStylesByClose = (activeStyles, closeCode) => {
27873
27988
  }
27874
27989
  }
27875
27990
  };
27876
- var getColorStyle = (code, sgrToken) => {
27877
- if (code >= 30 && code <= 37 || code >= 90 && code <= 97 || code === ANSI_SGR_FOREGROUND_EXTENDED && sgrToken.length > 1) {
27991
+ var getColorStyle = (sgrToken) => {
27992
+ const { code, open, hasArguments } = sgrToken;
27993
+ if (code >= 30 && code <= 37 || code >= 90 && code <= 97 || code === ANSI_SGR_FOREGROUND_EXTENDED && hasArguments) {
27878
27994
  return {
27879
27995
  family: "foreground",
27880
- open: sgrToken.join(";"),
27996
+ open,
27881
27997
  close: ANSI_SGR_RESET_FOREGROUND
27882
27998
  };
27883
27999
  }
27884
- if (code >= 40 && code <= 47 || code >= 100 && code <= 107 || code === ANSI_SGR_BACKGROUND_EXTENDED && sgrToken.length > 1) {
28000
+ if (code >= 40 && code <= 47 || code >= 100 && code <= 107 || code === ANSI_SGR_BACKGROUND_EXTENDED && hasArguments) {
27885
28001
  return {
27886
28002
  family: "background",
27887
- open: sgrToken.join(";"),
28003
+ open,
27888
28004
  close: ANSI_SGR_RESET_BACKGROUND
27889
28005
  };
27890
28006
  }
27891
- if (code === ANSI_SGR_UNDERLINE_COLOR_EXTENDED && sgrToken.length > 1) {
28007
+ if (code === ANSI_SGR_UNDERLINE_COLOR_EXTENDED && hasArguments) {
27892
28008
  return {
27893
28009
  family: "underlineColor",
27894
- open: sgrToken.join(";"),
28010
+ open,
27895
28011
  close: ANSI_SGR_RESET_UNDERLINE_COLOR
27896
28012
  };
27897
28013
  }
@@ -27920,11 +28036,11 @@ var applySgrResetCode = (code, activeStyles) => {
27920
28036
  return false;
27921
28037
  };
27922
28038
  var applySgrToken = (sgrToken, activeStyles) => {
27923
- const [code] = sgrToken;
28039
+ const { code } = sgrToken;
27924
28040
  if (applySgrResetCode(code, activeStyles)) {
27925
28041
  return;
27926
28042
  }
27927
- const colorStyle = getColorStyle(code, sgrToken);
28043
+ const colorStyle = getColorStyle(sgrToken);
27928
28044
  if (colorStyle) {
27929
28045
  upsertActiveStyle(activeStyles, colorStyle);
27930
28046
  return;
@@ -27933,7 +28049,7 @@ var applySgrToken = (sgrToken, activeStyles) => {
27933
28049
  if (close !== void 0 && close !== ANSI_SGR_RESET) {
27934
28050
  upsertActiveStyle(activeStyles, {
27935
28051
  family: `modifier-${code}`,
27936
- open: sgrToken.join(";"),
28052
+ open: sgrToken.open,
27937
28053
  close
27938
28054
  });
27939
28055
  }
@@ -27944,71 +28060,37 @@ var applySgrParameters = (sgrParameters, activeStyles) => {
27944
28060
  }
27945
28061
  };
27946
28062
  var applySgrResets = (sgrParameters, activeStyles) => {
27947
- for (const sgrToken of getSgrTokens(sgrParameters)) {
27948
- const [code] = sgrToken;
28063
+ for (const { code } of getSgrTokens(sgrParameters)) {
27949
28064
  applySgrResetCode(code, activeStyles);
27950
28065
  }
27951
28066
  };
27952
- var applyLeadingSgrResets = (string, activeStyles) => {
27953
- let remainder = string;
27954
- while (remainder.length > 0) {
27955
- if (remainder.startsWith(ANSI_ESCAPE) && remainder[1] !== "\\") {
27956
- const match = ANSI_ESCAPE_REGEX.exec(remainder);
27957
- if (!match) {
27958
- break;
27959
- }
27960
- if (match.groups.sgr !== void 0) {
27961
- applySgrResets(match.groups.sgr, activeStyles);
27962
- }
27963
- remainder = remainder.slice(match[0].length);
27964
- continue;
28067
+ var applyLeadingSgrResets = (string, startIndex, activeStyles) => {
28068
+ let index = startIndex;
28069
+ while (index < string.length) {
28070
+ const match = matchAnsiEscape(string, index);
28071
+ if (!match) {
28072
+ break;
27965
28073
  }
27966
- if (remainder.startsWith(ANSI_ESCAPE_CSI)) {
27967
- const match = ANSI_ESCAPE_CSI_REGEX.exec(remainder);
27968
- if (!match || match.groups.sgr === void 0) {
27969
- break;
27970
- }
28074
+ if (match.groups.sgr !== void 0) {
27971
28075
  applySgrResets(match.groups.sgr, activeStyles);
27972
- remainder = remainder.slice(match[0].length);
27973
- continue;
27974
28076
  }
27975
- break;
28077
+ index += match[0].length;
27976
28078
  }
27977
28079
  };
27978
28080
  var getClosingSgrSequence = (activeStyles) => [...activeStyles].reverse().map((activeStyle) => wrapAnsiCode(activeStyle.close)).join("");
27979
28081
  var getOpeningSgrSequence = (activeStyles) => activeStyles.map((activeStyle) => wrapAnsiCode(activeStyle.open)).join("");
27980
- var wordLengths = (string) => string.split(" ").map((word) => stringWidth(word));
27981
- var wrapWord = (rows2, word, columns) => {
27982
- const characters = getGraphemes(word);
27983
- let isInsideEscape = false;
27984
- let isInsideLinkEscape = false;
27985
- let visible = stringWidth(stripAnsi(rows2.at(-1)));
27986
- for (const [index, character] of characters.entries()) {
27987
- const characterLength = stringWidth(character);
27988
- if (visible + characterLength <= columns) {
27989
- rows2[rows2.length - 1] += character;
27990
- } else {
27991
- rows2.push(character);
28082
+ var wrapWord = (rows2, word, columns, rowWidth) => {
28083
+ const tokens = getTokens(word);
28084
+ let visible = rowWidth;
28085
+ for (let index = 0; index < tokens.length; index++) {
28086
+ const token = tokens[index];
28087
+ if (token.width > 0 && visible > 0 && visible + token.width > columns) {
28088
+ rows2.push("");
27992
28089
  visible = 0;
27993
28090
  }
27994
- if (ESCAPES.has(character) && !(isInsideLinkEscape && character === ANSI_ESCAPE && characters[index + 1] === "\\")) {
27995
- isInsideEscape = true;
27996
- const ansiEscapeLinkCandidate = characters.slice(index + 1, index + 1 + ANSI_ESCAPE_LINK.length).join("");
27997
- isInsideLinkEscape = ansiEscapeLinkCandidate === ANSI_ESCAPE_LINK;
27998
- }
27999
- if (isInsideEscape) {
28000
- if (isInsideLinkEscape) {
28001
- if (character === ANSI_ESCAPE_BELL || character === "\\" && index > 0 && characters[index - 1] === ANSI_ESCAPE) {
28002
- isInsideEscape = false;
28003
- isInsideLinkEscape = false;
28004
- }
28005
- } else if (character === ANSI_SGR_TERMINATOR) {
28006
- isInsideEscape = false;
28007
- }
28008
- continue;
28009
- }
28010
- visible += characterLength;
28011
- if (visible === columns && index < characters.length - 1) {
28091
+ rows2[rows2.length - 1] += token.value;
28092
+ visible += token.width;
28093
+ if (visible === columns && index < tokens.length - 1) {
28012
28094
  rows2.push("");
28013
28095
  visible = 0;
28014
28096
  }
@@ -28016,54 +28098,134 @@ var wrapWord = (rows2, word, columns) => {
28016
28098
  if (!visible && rows2.at(-1).length > 0 && rows2.length > 1) {
28017
28099
  rows2[rows2.length - 2] += rows2.pop();
28018
28100
  }
28101
+ return getWidth(rows2.at(-1));
28019
28102
  };
28020
28103
  var stringVisibleTrimSpacesRight = (string) => {
28021
- const words = string.split(" ");
28022
- let last = words.length;
28023
- while (last > 0) {
28024
- if (stringWidth(words[last - 1]) > 0) {
28104
+ if (!string.includes(" ")) {
28105
+ return string;
28106
+ }
28107
+ const segments = [];
28108
+ forEachSegment(string, (plainText) => {
28109
+ segments.push({ value: plainText, isEscape: false });
28110
+ }, (escape3) => {
28111
+ segments.push({ value: escape3, isEscape: true });
28112
+ });
28113
+ for (let index = segments.length - 1; index >= 0; index--) {
28114
+ const segment = segments[index];
28115
+ if (segment.isEscape) {
28116
+ continue;
28117
+ }
28118
+ let end = segment.value.length;
28119
+ while (end > 0 && segment.value[end - 1] === " ") {
28120
+ end--;
28121
+ }
28122
+ segment.value = segment.value.slice(0, end);
28123
+ if (getStringWidth(segment.value) > 0) {
28025
28124
  break;
28026
28125
  }
28027
- last--;
28028
28126
  }
28029
- if (last === words.length) {
28030
- return string;
28031
- }
28032
- return words.slice(0, last).join(" ") + words.slice(last).join("");
28127
+ return segments.map((segment) => segment.value).join("");
28033
28128
  };
28034
28129
  var expandTabs = (line) => {
28035
28130
  if (!line.includes(" ")) {
28036
28131
  return line;
28037
28132
  }
28038
- const segments = line.split(" ");
28039
28133
  let visible = 0;
28040
28134
  let expandedLine = "";
28041
- for (const [index, segment] of segments.entries()) {
28042
- expandedLine += segment;
28043
- visible += stringWidth(segment);
28044
- if (index < segments.length - 1) {
28045
- const spaces = TAB_SIZE - visible % TAB_SIZE;
28046
- expandedLine += " ".repeat(spaces);
28047
- visible += spaces;
28135
+ let plainTextSinceTab = "";
28136
+ const expandPlainText = (plainText) => {
28137
+ const segments = plainText.split(" ");
28138
+ for (const [index, segment] of segments.entries()) {
28139
+ expandedLine += segment;
28140
+ plainTextSinceTab += segment;
28141
+ if (index < segments.length - 1) {
28142
+ visible += getStringWidth(plainTextSinceTab);
28143
+ plainTextSinceTab = "";
28144
+ const spaces = TAB_SIZE - visible % TAB_SIZE;
28145
+ expandedLine += " ".repeat(spaces);
28146
+ visible += spaces;
28147
+ }
28048
28148
  }
28049
- }
28149
+ };
28150
+ forEachSegment(line, expandPlainText, (escape3) => {
28151
+ expandedLine += escape3;
28152
+ });
28050
28153
  return expandedLine;
28051
28154
  };
28155
+ var restoreStylesAcrossRows = (preString) => {
28156
+ let returnValue = "";
28157
+ let activeHyperlink;
28158
+ const activeStyles = [];
28159
+ let index = 0;
28160
+ let copiedIndex = 0;
28161
+ while (index < preString.length) {
28162
+ ROW_BOUNDARY_REGEX.lastIndex = index;
28163
+ const boundary = ROW_BOUNDARY_REGEX.exec(preString);
28164
+ if (!boundary) {
28165
+ break;
28166
+ }
28167
+ index = boundary.index;
28168
+ if (boundary[0] !== "\n") {
28169
+ const escape3 = matchAnsiEscape(preString, index);
28170
+ if (!escape3) {
28171
+ index++;
28172
+ continue;
28173
+ }
28174
+ const { groups } = escape3;
28175
+ if (groups.sgr !== void 0) {
28176
+ applySgrParameters(groups.sgr, activeStyles);
28177
+ } else if (groups.uri !== void 0) {
28178
+ activeHyperlink = groups.uri.length === 0 ? void 0 : { parameters: groups.parameters, uri: groups.uri };
28179
+ }
28180
+ index += escape3[0].length;
28181
+ continue;
28182
+ }
28183
+ returnValue += preString.slice(copiedIndex, index);
28184
+ if (index > copiedIndex) {
28185
+ if (activeHyperlink) {
28186
+ returnValue += wrapAnsiHyperlink("");
28187
+ }
28188
+ returnValue += getClosingSgrSequence(activeStyles);
28189
+ }
28190
+ returnValue += "\n";
28191
+ index++;
28192
+ copiedIndex = index;
28193
+ if (index < preString.length && preString[index] !== "\n") {
28194
+ const openingStyles = [...activeStyles];
28195
+ applyLeadingSgrResets(preString, index, openingStyles);
28196
+ returnValue += getOpeningSgrSequence(openingStyles);
28197
+ if (activeHyperlink) {
28198
+ returnValue += wrapAnsiHyperlink(activeHyperlink.uri, activeHyperlink.parameters);
28199
+ }
28200
+ }
28201
+ }
28202
+ return returnValue + preString.slice(copiedIndex);
28203
+ };
28052
28204
  var exec = (string, columns, options = {}) => {
28053
28205
  if (options.trim !== false && string.trim() === "") {
28054
28206
  return "";
28055
28207
  }
28056
- let returnValue = "";
28057
- let escapeUrl;
28058
- const activeStyles = [];
28059
- const lengths = wordLengths(string);
28208
+ const words = splitWords(string);
28060
28209
  let rows2 = [""];
28061
- for (const [index, word] of string.split(" ").entries()) {
28062
- if (options.trim !== false) {
28063
- rows2[rows2.length - 1] = rows2.at(-1).trimStart();
28064
- }
28065
- let rowLength = stringWidth(rows2.at(-1));
28066
- if (index !== 0) {
28210
+ let rowLength = 0;
28211
+ let trimmedRowIndex = -1;
28212
+ let isFirstWord = true;
28213
+ for (const word of words) {
28214
+ const rowIndex = rows2.length - 1;
28215
+ if (options.trim !== false && trimmedRowIndex !== rowIndex) {
28216
+ const row = rows2[rowIndex];
28217
+ const trimmedRow = row.trimStart();
28218
+ if (trimmedRow.length !== row.length) {
28219
+ rows2[rowIndex] = trimmedRow;
28220
+ rowLength = getWidth(trimmedRow);
28221
+ }
28222
+ if (trimmedRow.length > 0) {
28223
+ trimmedRowIndex = rowIndex;
28224
+ }
28225
+ }
28226
+ if (isFirstWord) {
28227
+ isFirstWord = false;
28228
+ } else {
28067
28229
  if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
28068
28230
  rows2.push("");
28069
28231
  rowLength = 0;
@@ -28073,69 +28235,48 @@ var exec = (string, columns, options = {}) => {
28073
28235
  rowLength++;
28074
28236
  }
28075
28237
  }
28076
- if (options.hard && options.wordWrap !== false && lengths[index] > columns) {
28238
+ if (options.hard && options.wordWrap !== false && word.width > columns) {
28077
28239
  const remainingColumns = columns - rowLength;
28078
- const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
28079
- const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
28240
+ const breaksStartingThisLine = 1 + Math.floor((word.width - remainingColumns - 1) / columns);
28241
+ const breaksStartingNextLine = Math.floor((word.width - 1) / columns);
28080
28242
  if (breaksStartingNextLine < breaksStartingThisLine) {
28081
28243
  rows2.push("");
28244
+ rowLength = 0;
28082
28245
  }
28083
- wrapWord(rows2, word, columns);
28246
+ rowLength = wrapWord(rows2, word.value, columns, rowLength);
28084
28247
  continue;
28085
28248
  }
28086
- if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
28249
+ if (rowLength + word.width > columns && rowLength > 0 && word.width > 0) {
28087
28250
  if (options.wordWrap === false && rowLength < columns) {
28088
- wrapWord(rows2, word, columns);
28251
+ rowLength = wrapWord(rows2, word.value, columns, rowLength);
28089
28252
  continue;
28090
28253
  }
28091
28254
  rows2.push("");
28255
+ rowLength = 0;
28092
28256
  }
28093
- if (rowLength + lengths[index] > columns && options.wordWrap === false) {
28094
- wrapWord(rows2, word, columns);
28257
+ if (rowLength + word.width > columns && options.wordWrap === false) {
28258
+ rowLength = wrapWord(rows2, word.value, columns, rowLength);
28095
28259
  continue;
28096
28260
  }
28097
- rows2[rows2.length - 1] += word;
28261
+ rows2[rows2.length - 1] += word.value;
28262
+ rowLength += word.width;
28098
28263
  }
28099
28264
  if (options.trim !== false) {
28100
28265
  rows2 = rows2.map((row) => stringVisibleTrimSpacesRight(row));
28101
28266
  }
28102
- const preString = rows2.join("\n");
28103
- const pre = getGraphemes(preString);
28104
- let preStringIndex = 0;
28105
- for (const [index, character] of pre.entries()) {
28106
- returnValue += character;
28107
- if (character === ANSI_ESCAPE && pre[index + 1] !== "\\") {
28108
- const { groups } = ANSI_ESCAPE_REGEX.exec(preString.slice(preStringIndex)) || { groups: {} };
28109
- if (groups.sgr !== void 0) {
28110
- applySgrParameters(groups.sgr, activeStyles);
28111
- } else if (groups.uri !== void 0) {
28112
- escapeUrl = groups.uri.length === 0 ? void 0 : groups.uri;
28113
- }
28114
- } else if (character === ANSI_ESCAPE_CSI) {
28115
- const { groups } = ANSI_ESCAPE_CSI_REGEX.exec(preString.slice(preStringIndex)) || { groups: {} };
28116
- if (groups.sgr !== void 0) {
28117
- applySgrParameters(groups.sgr, activeStyles);
28118
- }
28119
- }
28120
- if (pre[index + 1] === "\n") {
28121
- if (escapeUrl) {
28122
- returnValue += wrapAnsiHyperlink("");
28123
- }
28124
- returnValue += getClosingSgrSequence(activeStyles);
28125
- } else if (character === "\n") {
28126
- const openingStyles = [...activeStyles];
28127
- applyLeadingSgrResets(preString.slice(preStringIndex + 1), openingStyles);
28128
- returnValue += getOpeningSgrSequence(openingStyles);
28129
- if (escapeUrl) {
28130
- returnValue += wrapAnsiHyperlink(escapeUrl);
28131
- }
28132
- }
28133
- preStringIndex += character.length;
28134
- }
28135
- return returnValue;
28267
+ return restoreStylesAcrossRows(rows2.join("\n"));
28268
+ };
28269
+ var normalizeText = (string) => {
28270
+ let normalizedString = "";
28271
+ forEachSegment(string, (plainText) => {
28272
+ normalizedString += plainText.normalize();
28273
+ }, (escape3) => {
28274
+ normalizedString += escape3;
28275
+ });
28276
+ return normalizedString;
28136
28277
  };
28137
28278
  function wrapAnsi(string, columns, options) {
28138
- return String(string).normalize().replaceAll("\r\n", "\n").split("\n").map((line) => exec(expandTabs(line), columns, options)).join("\n");
28279
+ return normalizeText(String(string)).replaceAll("\r\n", "\n").split("\n").map((line) => exec(expandTabs(line), columns, options)).join("\n");
28139
28280
  }
28140
28281
 
28141
28282
  // node_modules/terminal-size/index.js
@@ -41529,6 +41670,14 @@ function gitStageUnit(a) {
41529
41670
  effect: true
41530
41671
  });
41531
41672
  }
41673
+ function gitWorktreeUnit(a) {
41674
+ return unitDescriptor("Git", {
41675
+ active: "Managing",
41676
+ done: "Managed",
41677
+ noun: "worktree",
41678
+ effect: String(a.worktree_action || "").toLowerCase() !== "list"
41679
+ });
41680
+ }
41532
41681
  function cwdUnit(a) {
41533
41682
  const action = String(a.action || a.type || "").toLowerCase();
41534
41683
  if (action === "set" || action === "set-project" || !action && a.path) {
@@ -41559,14 +41708,6 @@ function cwdUnit(a) {
41559
41708
  const [active, done] = words;
41560
41709
  return unitDescriptor("Setup", { active, done, noun: "session", effect: true });
41561
41710
  }
41562
- if (action.endsWith("-worktree") || action.endsWith("-worktrees")) {
41563
- return unitDescriptor("Setup", {
41564
- active: "Managing",
41565
- done: "Managed",
41566
- noun: "worktree",
41567
- effect: !action.startsWith("list")
41568
- });
41569
- }
41570
41711
  if (action === "status") {
41571
41712
  return unitDescriptor("Setup", { active: "Checking", done: "Checked", noun: "session" });
41572
41713
  }
@@ -41661,7 +41802,7 @@ var TOOL_UNITS = /* @__PURE__ */ new Map([
41661
41802
  ["job_wait", shellUnit],
41662
41803
  [
41663
41804
  "git",
41664
- (a) => a.action === "stage" ? gitStageUnit(a) : unitDescriptor("Git", { count: queryCount(a, "command", "commands") || 1, noun: "Git command" })
41805
+ (a) => a.action === "stage" ? gitStageUnit(a) : a.action === "worktree" ? gitWorktreeUnit(a) : unitDescriptor("Git", { count: queryCount(a, "command", "commands") || 1, noun: "Git command" })
41665
41806
  ],
41666
41807
  ["github", githubUnit],
41667
41808
  // Preserve the staging work unit when rendering historical transcripts.
@@ -47542,17 +47683,14 @@ async function resizeImageBuffer(buffer, ext, { maxTokens = DEFAULT_IMAGE_MAX_TO
47542
47683
  var TOOL_IMAGE_TARGET_BASE64_SIZE = 256 * 1024;
47543
47684
 
47544
47685
  // src/tui/paste-text-policy.mjs
47545
- var PASTE_TOKEN_MIN_LINES = 10;
47546
- var PASTE_TOKEN_MIN_CHARS = 200;
47686
+ var PASTE_TOKEN_MIN_CHARS = 1e3;
47547
47687
  function pastedTextLineCount(text) {
47548
47688
  const value = String(text ?? "").replace(/\r\n?/g, "\n").replace(/\n+$/, "");
47549
47689
  if (!value) return 0;
47550
47690
  return value.split("\n").length;
47551
47691
  }
47552
47692
  function shouldFoldPastedText(text) {
47553
- const value = String(text ?? "");
47554
- if (!value) return false;
47555
- return pastedTextLineCount(value) >= PASTE_TOKEN_MIN_LINES || value.length > PASTE_TOKEN_MIN_CHARS;
47693
+ return String(text ?? "").length > PASTE_TOKEN_MIN_CHARS;
47556
47694
  }
47557
47695
  function formatPastedTextRef(id, text) {
47558
47696
  return `[Pasted text #${id} +${pastedTextLineCount(text)} lines]`;
@@ -59570,6 +59708,15 @@ var loadProviderDisplayNames = async (store) => {
59570
59708
  }
59571
59709
  return names;
59572
59710
  };
59711
+ var catalogProviderDisplayNames = (models, setupNames = null) => {
59712
+ const names = {};
59713
+ for (const model of Array.isArray(models) ? models : []) {
59714
+ const provider = String(model?.provider || "").trim();
59715
+ const name = String(model?.providerName || "").trim();
59716
+ if (provider.startsWith("custom-") && name) names[provider] = name;
59717
+ }
59718
+ return { ...names, ...setupNames };
59719
+ };
59573
59720
  var loadProviderCatalogFailures = async (store) => {
59574
59721
  let setup = null;
59575
59722
  try {
@@ -59683,9 +59830,9 @@ var routeSpeedLabel = (route) => {
59683
59830
  return route.modelParameters?.serviceTier === "ultrafast" ? "Ultrafast" : "Fast";
59684
59831
  };
59685
59832
  var routeModelDetails = (route) => [routeModelDisplayName(route), route.effort ? effortDisplayLabel(route.effort) : "", routeSpeedLabel(route)].filter(Boolean).join(" \xB7 ");
59686
- var routeLabel = (route) => {
59833
+ var routeLabel = (route, providerNames = null) => {
59687
59834
  if (!route?.provider || !route?.model) return "(unset)";
59688
- return [providerDisplayName(route.provider), routeModelDetails(route)].filter(Boolean).join(" \xB7 ");
59835
+ return [resolveProviderDisplayName(route.provider, providerNames), routeModelDetails(route)].filter(Boolean).join(" \xB7 ");
59689
59836
  };
59690
59837
  var routeModelLabel = (route) => route?.model ? routeModelDetails(route) : "(unset)";
59691
59838
  var agentModelProfile = (route) => route?.model ? routeModelDetails(route) : "";
@@ -61162,7 +61309,7 @@ function createModelPicker({
61162
61309
  return;
61163
61310
  }
61164
61311
  const models = normalizeModelOptions(providerModels);
61165
- const providerNames = await loadProviderDisplayNames(store);
61312
+ const providerNames = catalogProviderDisplayNames(models, await loadProviderDisplayNames(store));
61166
61313
  const catalogFailures = await loadProviderCatalogFailures(store);
61167
61314
  const activeRoute = options.currentRoute || {
61168
61315
  provider: state.provider,
@@ -61590,7 +61737,8 @@ function createRoutePickers({
61590
61737
  store.pushNotice("Web-search model save is already running.", "warn");
61591
61738
  return;
61592
61739
  }
61593
- store.pushNotice(`Web-search model set to ${routeLabel2(result)}`, "info");
61740
+ const providerNames = await loadProviderDisplayNames(store);
61741
+ store.pushNotice(`Web-search model set to ${routeLabel2(result, providerNames)}`, "info");
61594
61742
  return result;
61595
61743
  },
61596
61744
  onAfterSelect: null
@@ -61950,8 +62098,16 @@ function copyTree(src, dst, copied) {
61950
62098
  writeFileAtomicSync(dst, readFileSync10(src), { mode: st.mode & 511 });
61951
62099
  copied.push(dst);
61952
62100
  }
62101
+ var manifestPath = (scopeDir, name) => join11(scopeDir, name, BACKUP_MANIFEST);
61953
62102
  function pruneBackups(scopeDir, names, own) {
61954
- for (const name of backupsToPrune(names, own)) {
62103
+ const completed = names.filter((name) => {
62104
+ try {
62105
+ return statSync4(manifestPath(scopeDir, name)).isFile();
62106
+ } catch {
62107
+ return false;
62108
+ }
62109
+ });
62110
+ for (const name of backupsToPrune(completed, own)) {
61955
62111
  try {
61956
62112
  rmSync(join11(scopeDir, name), { recursive: true, force: true });
61957
62113
  } catch {
@@ -62001,16 +62157,24 @@ function backupUserData(dataDir2, reason = "snapshot", { dirs = [] } = {}) {
62001
62157
  const scopeDir = scopeDirFor(dataDir2);
62002
62158
  const { backupDir, names } = reserveBackupDir(scopeDir, reason);
62003
62159
  const copied = [];
62004
- for (const rel of USER_DATA_FILES) {
62005
- const src = join11(dataDir2, rel);
62006
- if (existsSync9(src)) copyTree(src, join11(backupDir, rel), copied);
62007
- }
62008
- for (const rel of [...USER_DATA_DIRS, ...dirs]) {
62009
- const src = join11(dataDir2, rel);
62010
- if (existsSync9(src)) copyTree(src, join11(backupDir, rel), copied);
62160
+ try {
62161
+ for (const rel of USER_DATA_FILES) {
62162
+ const src = join11(dataDir2, rel);
62163
+ if (existsSync9(src)) copyTree(src, join11(backupDir, rel), copied);
62164
+ }
62165
+ for (const rel of [...USER_DATA_DIRS, ...dirs]) {
62166
+ const src = join11(dataDir2, rel);
62167
+ if (existsSync9(src)) copyTree(src, join11(backupDir, rel), copied);
62168
+ }
62169
+ if (copied.length > 0) finishBackup(dataDir2, backupDir, reason);
62170
+ } catch (error) {
62171
+ try {
62172
+ rmSync(backupDir, { recursive: true, force: true });
62173
+ } catch {
62174
+ }
62175
+ throw error;
62011
62176
  }
62012
62177
  if (copied.length > 0) {
62013
- finishBackup(dataDir2, backupDir, reason);
62014
62178
  pruneBackups(scopeDir, names, basename5(backupDir));
62015
62179
  if (process.env.MIXDOG_SETUP_QUIET !== "1") {
62016
62180
  process.stderr.write(`[user-data-backup] ${reason}: copied ${copied.length} file(s) to ${backupDir}
@@ -62034,7 +62198,14 @@ async function copyTreeAsync(src, dst, copied) {
62034
62198
  copied.push(dst);
62035
62199
  }
62036
62200
  async function pruneBackupsAsync(scopeDir, names, own) {
62037
- for (const name of backupsToPrune(names, own)) {
62201
+ const completed = [];
62202
+ for (const name of names) {
62203
+ try {
62204
+ if ((await statP(manifestPath(scopeDir, name))).isFile()) completed.push(name);
62205
+ } catch {
62206
+ }
62207
+ }
62208
+ for (const name of backupsToPrune(completed, own)) {
62038
62209
  try {
62039
62210
  await rmP(join11(scopeDir, name), { recursive: true, force: true });
62040
62211
  } catch {
@@ -62047,16 +62218,24 @@ async function backupUserDataAsync(dataDir2, reason = "snapshot") {
62047
62218
  const scopeDir = scopeDirFor(dataDir2);
62048
62219
  const { backupDir, names } = await reserveBackupDirAsync(scopeDir, reason);
62049
62220
  const copied = [];
62050
- for (const rel of USER_DATA_FILES) {
62051
- const src = join11(dataDir2, rel);
62052
- if (existsSync9(src)) await copyTreeAsync(src, join11(backupDir, rel), copied);
62053
- }
62054
- for (const rel of USER_DATA_DIRS) {
62055
- const src = join11(dataDir2, rel);
62056
- if (existsSync9(src)) await copyTreeAsync(src, join11(backupDir, rel), copied);
62221
+ try {
62222
+ for (const rel of USER_DATA_FILES) {
62223
+ const src = join11(dataDir2, rel);
62224
+ if (existsSync9(src)) await copyTreeAsync(src, join11(backupDir, rel), copied);
62225
+ }
62226
+ for (const rel of USER_DATA_DIRS) {
62227
+ const src = join11(dataDir2, rel);
62228
+ if (existsSync9(src)) await copyTreeAsync(src, join11(backupDir, rel), copied);
62229
+ }
62230
+ if (copied.length > 0) finishBackup(dataDir2, backupDir, reason);
62231
+ } catch (error) {
62232
+ try {
62233
+ await rmP(backupDir, { recursive: true, force: true });
62234
+ } catch {
62235
+ }
62236
+ throw error;
62057
62237
  }
62058
62238
  if (copied.length > 0) {
62059
- finishBackup(dataDir2, backupDir, reason);
62060
62239
  await pruneBackupsAsync(scopeDir, names, basename5(backupDir));
62061
62240
  if (process.env.MIXDOG_SETUP_QUIET !== "1") {
62062
62241
  process.stderr.write(`[user-data-backup] ${reason}: copied ${copied.length} file(s) to ${backupDir}
@@ -63969,7 +64148,9 @@ function useMessageSelector({
63969
64148
  setPromptDraftOverride,
63970
64149
  syncPromptLayoutRows,
63971
64150
  showPromptHint,
63972
- clearPromptHint
64151
+ clearPromptHint,
64152
+ installPastedImages,
64153
+ installPastedTexts
63973
64154
  }) {
63974
64155
  const hasUserMessages = useMemo7(
63975
64156
  () => (Array.isArray(state.items) ? state.items : []).some(
@@ -63985,11 +64166,21 @@ function useMessageSelector({
63985
64166
  return false;
63986
64167
  }
63987
64168
  clearPromptHint();
64169
+ if (restored.pastedImages) installPastedImages?.(restored.pastedImages, { merge: true });
64170
+ if (restored.pastedTexts) installPastedTexts?.(restored.pastedTexts, { merge: true });
63988
64171
  syncPromptLayoutRows(text);
63989
64172
  setPromptDraftOverride({ id: Date.now(), value: text });
64173
+ if (restored.notice) showPromptHint(restored.notice, "error");
63990
64174
  return true;
63991
64175
  },
63992
- [clearPromptHint, syncPromptLayoutRows, setPromptDraftOverride, showPromptHint]
64176
+ [
64177
+ clearPromptHint,
64178
+ syncPromptLayoutRows,
64179
+ setPromptDraftOverride,
64180
+ showPromptHint,
64181
+ installPastedImages,
64182
+ installPastedTexts
64183
+ ]
63993
64184
  );
63994
64185
  const openMessageSelector = useCallback20(() => {
63995
64186
  const items = store.getState?.().items ?? state.items;
@@ -64009,7 +64200,7 @@ function useMessageSelector({
64009
64200
  own.close();
64010
64201
  let restored;
64011
64202
  try {
64012
- restored = store.rewindToItem?.(value);
64203
+ restored = store.rewindToItem?.(value, { restoreFiles: false });
64013
64204
  } catch (error) {
64014
64205
  showPromptHint(`rewind failed: ${error?.message || error}`, "error");
64015
64206
  return;
@@ -65920,7 +66111,9 @@ function App2({ store, initialStatusLine = "", forceOnboarding = false, onboardi
65920
66111
  setPromptDraftOverride,
65921
66112
  syncPromptLayoutRows,
65922
66113
  showPromptHint,
65923
- clearPromptHint
66114
+ clearPromptHint,
66115
+ installPastedImages,
66116
+ installPastedTexts
65924
66117
  });
65925
66118
  const { handlePromptPaste, handlePromptHistoryNavigate, handlePromptEscape, handlePromptInterrupt } = usePromptHandlers({
65926
66119
  store,