omnius 1.0.103 → 1.0.105

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -21863,27 +21863,27 @@ function readInteger(buf, context2) {
21863
21863
  function readObjectIdentifier(buf, context2) {
21864
21864
  const count = readLength(buf, context2);
21865
21865
  const finalOffset = context2.offset + count;
21866
- const byte = buf[context2.offset];
21866
+ const byte2 = buf[context2.offset];
21867
21867
  context2.offset++;
21868
21868
  let val1 = 0;
21869
21869
  let val2 = 0;
21870
- if (byte < 40) {
21870
+ if (byte2 < 40) {
21871
21871
  val1 = 0;
21872
- val2 = byte;
21873
- } else if (byte < 80) {
21872
+ val2 = byte2;
21873
+ } else if (byte2 < 80) {
21874
21874
  val1 = 1;
21875
- val2 = byte - 40;
21875
+ val2 = byte2 - 40;
21876
21876
  } else {
21877
21877
  val1 = 2;
21878
- val2 = byte - 80;
21878
+ val2 = byte2 - 80;
21879
21879
  }
21880
21880
  let oid = `${val1}.${val2}`;
21881
21881
  let num = [];
21882
21882
  while (context2.offset < finalOffset) {
21883
- const byte2 = buf[context2.offset];
21883
+ const byte3 = buf[context2.offset];
21884
21884
  context2.offset++;
21885
- num.push(byte2 & 127);
21886
- if (byte2 < 128) {
21885
+ num.push(byte3 & 127);
21886
+ if (byte3 < 128) {
21887
21887
  num.reverse();
21888
21888
  let val = 0;
21889
21889
  for (let i2 = 0; i2 < num.length; i2++) {
@@ -28115,16 +28115,16 @@ function ipToString(ip) {
28115
28115
  }
28116
28116
  function simpleMaskLength(mask) {
28117
28117
  let ones = 0;
28118
- for (let [index, byte] of mask.entries()) {
28119
- if (byte === 255) {
28118
+ for (let [index, byte2] of mask.entries()) {
28119
+ if (byte2 === 255) {
28120
28120
  ones += 8;
28121
28121
  continue;
28122
28122
  }
28123
- while ((byte & 128) != 0) {
28123
+ while ((byte2 & 128) != 0) {
28124
28124
  ones++;
28125
- byte = byte << 1;
28125
+ byte2 = byte2 << 1;
28126
28126
  }
28127
- if ((byte & 128) != 0) {
28127
+ if ((byte2 & 128) != 0) {
28128
28128
  return -1;
28129
28129
  }
28130
28130
  for (let i2 = index + 1; i2 < mask.length; i2++) {
@@ -28138,8 +28138,8 @@ function simpleMaskLength(mask) {
28138
28138
  }
28139
28139
  function maskToHex(mask) {
28140
28140
  let hex = "0x";
28141
- for (const byte of mask) {
28142
- hex += (byte >> 4).toString(16) + (byte & 15).toString(16);
28141
+ for (const byte2 of mask) {
28142
+ hex += (byte2 >> 4).toString(16) + (byte2 & 15).toString(16);
28143
28143
  }
28144
28144
  return hex;
28145
28145
  }
@@ -30727,8 +30727,8 @@ var init_utils8 = __esm({
30727
30727
  ip4ToBytes = function(ip) {
30728
30728
  ip = ip.toString().trim();
30729
30729
  const bytes = new Uint8Array(4);
30730
- ip.split(/\./g).forEach((byte, index) => {
30731
- const value2 = parseInt(byte, 10);
30730
+ ip.split(/\./g).forEach((byte2, index) => {
30731
+ const value2 = parseInt(byte2, 10);
30732
30732
  if (isNaN(value2) || value2 < 0 || value2 > 255) {
30733
30733
  throw new InvalidMultiaddrError2("Invalid byte value in IP address");
30734
30734
  }
@@ -53788,11 +53788,11 @@ var require_build = __commonJS({
53788
53788
  let result = "";
53789
53789
  const len = buf.length;
53790
53790
  for (let i2 = 0; i2 < len; i2++) {
53791
- const byte = buf[i2];
53792
- if (byte < 16) {
53791
+ const byte2 = buf[i2];
53792
+ if (byte2 < 16) {
53793
53793
  result += "0";
53794
53794
  }
53795
- result += byte.toString(16);
53795
+ result += byte2.toString(16);
53796
53796
  }
53797
53797
  return result;
53798
53798
  }
@@ -55520,8 +55520,8 @@ ${values.join("\n")}` : `${blockName} :`;
55520
55520
  } else {
55521
55521
  const bits = [];
55522
55522
  const valueHex = this.valueBlock.valueHexView;
55523
- for (const byte of valueHex) {
55524
- bits.push(byte.toString(2).padStart(8, "0"));
55523
+ for (const byte2 of valueHex) {
55524
+ bits.push(byte2.toString(2).padStart(8, "0"));
55525
55525
  }
55526
55526
  const bitsStr = bits.join("");
55527
55527
  const name10 = this.constructor.NAME;
@@ -64507,12 +64507,12 @@ var require_Reflect = __commonJS({
64507
64507
  data[8] = data[8] & 191 | 128;
64508
64508
  var result = "";
64509
64509
  for (var offset = 0; offset < UUID_SIZE; ++offset) {
64510
- var byte = data[offset];
64510
+ var byte2 = data[offset];
64511
64511
  if (offset === 4 || offset === 6 || offset === 8)
64512
64512
  result += "-";
64513
- if (byte < 16)
64513
+ if (byte2 < 16)
64514
64514
  result += "0";
64515
- result += byte.toString(16).toLowerCase();
64515
+ result += byte2.toString(16).toLowerCase();
64516
64516
  }
64517
64517
  return result;
64518
64518
  }
@@ -66303,7 +66303,7 @@ var require_ip_converter = __commonJS({
66303
66303
  const half = uint8.length / 2;
66304
66304
  const addrBytes = uint8.slice(0, half);
66305
66305
  const maskBytes = uint8.slice(half);
66306
- const isAllZeros = uint8.every((byte) => byte === 0);
66306
+ const isAllZeros = uint8.every((byte2) => byte2 === 0);
66307
66307
  if (isAllZeros) {
66308
66308
  return uint8.length === 8 ? "0.0.0.0/0" : "::/0";
66309
66309
  }
@@ -119032,13 +119032,13 @@ var require_data_url = __commonJS({
119032
119032
  const bytes = encoder2.encode(input);
119033
119033
  return percentDecode(bytes);
119034
119034
  }
119035
- function isHexCharByte(byte) {
119036
- return byte >= 48 && byte <= 57 || byte >= 65 && byte <= 70 || byte >= 97 && byte <= 102;
119035
+ function isHexCharByte(byte2) {
119036
+ return byte2 >= 48 && byte2 <= 57 || byte2 >= 65 && byte2 <= 70 || byte2 >= 97 && byte2 <= 102;
119037
119037
  }
119038
- function hexByteToNumber(byte) {
119038
+ function hexByteToNumber(byte2) {
119039
119039
  return (
119040
119040
  // 0-9
119041
- byte >= 48 && byte <= 57 ? byte - 48 : (byte & 223) - 55
119041
+ byte2 >= 48 && byte2 <= 57 ? byte2 - 48 : (byte2 & 223) - 55
119042
119042
  );
119043
119043
  }
119044
119044
  function percentDecode(input) {
@@ -119047,10 +119047,10 @@ var require_data_url = __commonJS({
119047
119047
  let j = 0;
119048
119048
  let i2 = 0;
119049
119049
  while (i2 < length4) {
119050
- const byte = input[i2];
119051
- if (byte !== 37) {
119052
- output[j++] = byte;
119053
- } else if (byte === 37 && !(isHexCharByte(input[i2 + 1]) && isHexCharByte(input[i2 + 2]))) {
119050
+ const byte2 = input[i2];
119051
+ if (byte2 !== 37) {
119052
+ output[j++] = byte2;
119053
+ } else if (byte2 === 37 && !(isHexCharByte(input[i2 + 1]) && isHexCharByte(input[i2 + 2]))) {
119054
119054
  output[j++] = 37;
119055
119055
  } else {
119056
119056
  output[j++] = hexByteToNumber(input[i2 + 1]) << 4 | hexByteToNumber(input[i2 + 2]);
@@ -137344,8 +137344,8 @@ var require_util7 = __commonJS({
137344
137344
  return false;
137345
137345
  }
137346
137346
  for (let i2 = 0; i2 < value2.length; i2++) {
137347
- const byte = value2.charCodeAt(i2);
137348
- if (byte < 48 || byte > 57) {
137347
+ const byte2 = value2.charCodeAt(i2);
137348
+ if (byte2 < 48 || byte2 > 57) {
137349
137349
  return false;
137350
137350
  }
137351
137351
  }
@@ -211022,8 +211022,8 @@ var init_refresh = __esm({
211022
211022
  for (const { kadId } of this.routingTable.kb.toIterable()) {
211023
211023
  const distance = xor(this.routingTable.kb.localPeer.kadId, kadId);
211024
211024
  let leadingZeros = 0;
211025
- for (const byte of distance) {
211026
- if (byte === 0) {
211025
+ for (const byte2 of distance) {
211026
+ if (byte2 === 0) {
211027
211027
  leadingZeros++;
211028
211028
  } else {
211029
211029
  break;
@@ -232126,7 +232126,7 @@ function decodeCerthash(certhash2) {
232126
232126
  function ma2Fingerprint(ma) {
232127
232127
  const multihashDecoded = decodeCerthash(certhash(ma));
232128
232128
  const prefix = toSupportedHashFunction(multihashDecoded.code);
232129
- const fingerprint = multihashDecoded.digest.reduce((str, byte) => str + byte.toString(16).padStart(2, "0"), "");
232129
+ const fingerprint = multihashDecoded.digest.reduce((str, byte2) => str + byte2.toString(16).padStart(2, "0"), "");
232130
232130
  const sdp = fingerprint.match(/.{1,2}/g);
232131
232131
  if (sdp == null) {
232132
232132
  throw new InvalidFingerprintError(fingerprint, ma.toString());
@@ -236931,13 +236931,13 @@ var init_listener5 = __esm({
236931
236931
  await pEvent(socket, "readable");
236932
236932
  buffer2 = socket.read(1);
236933
236933
  }
236934
- const byte = buffer2[0];
236934
+ const byte2 = buffer2[0];
236935
236935
  let server2 = this.http;
236936
- if (byte < 32 || byte >= 127) {
236936
+ if (byte2 < 32 || byte2 >= 127) {
236937
236937
  server2 = this.https;
236938
236938
  }
236939
236939
  if (server2 == null) {
236940
- this.log.error("no appropriate listener configured for byte %d", byte);
236940
+ this.log.error("no appropriate listener configured for byte %d", byte2);
236941
236941
  socket.destroy();
236942
236942
  return;
236943
236943
  }
@@ -239340,15 +239340,15 @@ var require_sparse_array = __commonJS({
239340
239340
  if (bytePos >= this._bitArrays.length) {
239341
239341
  return -1;
239342
239342
  }
239343
- const byte = this._bitArrays[bytePos];
239343
+ const byte2 = this._bitArrays[bytePos];
239344
239344
  const bitPos = index - bytePos * BITS_PER_BYTE;
239345
- const exists2 = (byte & 1 << bitPos) > 0;
239345
+ const exists2 = (byte2 & 1 << bitPos) > 0;
239346
239346
  if (!exists2) {
239347
239347
  return -1;
239348
239348
  }
239349
239349
  const previousPopCount = this._bitArrays.slice(0, bytePos).reduce(popCountReduce, 0);
239350
239350
  const mask = ~(4294967295 << bitPos + 1);
239351
- const bytePopCount = popCount(byte & mask);
239351
+ const bytePopCount = popCount(byte2 & mask);
239352
239352
  const arrayPos = previousPopCount + bytePopCount - 1;
239353
239353
  return arrayPos;
239354
239354
  }
@@ -239440,8 +239440,8 @@ var require_sparse_array = __commonJS({
239440
239440
  return this._data.map(valueOnly);
239441
239441
  }
239442
239442
  };
239443
- function popCountReduce(count, byte) {
239444
- return count + popCount(byte);
239443
+ function popCountReduce(count, byte2) {
239444
+ return count + popCount(byte2);
239445
239445
  }
239446
239446
  function popCount(_v) {
239447
239447
  let v = _v;
@@ -239655,9 +239655,9 @@ var init_bucket2 = __esm({
239655
239655
  });
239656
239656
 
239657
239657
  // ../node_modules/hamt-sharding/dist/src/consumable-buffer.js
239658
- function byteBitsToInt(byte, start2, length4) {
239658
+ function byteBitsToInt(byte2, start2, length4) {
239659
239659
  const mask = maskFor(start2, length4);
239660
- return (byte & mask) >>> start2;
239660
+ return (byte2 & mask) >>> start2;
239661
239661
  }
239662
239662
  function maskFor(start2, length4) {
239663
239663
  return START_MASKS[start2] & STOP_MASKS[Math.min(length4 + start2 - 1, 7)];
@@ -239704,10 +239704,10 @@ var init_consumable_buffer = __esm({
239704
239704
  let pendingBits = bits;
239705
239705
  let result = 0;
239706
239706
  while (pendingBits > 0 && this._haveBits()) {
239707
- const byte = this._value[this._currentBytePos];
239707
+ const byte2 = this._value[this._currentBytePos];
239708
239708
  const availableBits = this._currentBitPos + 1;
239709
239709
  const taking = Math.min(availableBits, pendingBits);
239710
- const value2 = byteBitsToInt(byte, availableBits - taking, taking);
239710
+ const value2 = byteBitsToInt(byte2, availableBits - taking, taking);
239711
239711
  result = (result << taking) + value2;
239712
239712
  pendingBits -= taking;
239713
239713
  this._currentBitPos -= taking;
@@ -241535,9 +241535,9 @@ function wrapHash2(hashFn2) {
241535
241535
  }
241536
241536
  return hashing;
241537
241537
  }
241538
- function byteBitsToInt2(byte, start2, length4) {
241538
+ function byteBitsToInt2(byte2, start2, length4) {
241539
241539
  const mask = maskFor2(start2, length4);
241540
- return (byte & mask) >>> start2;
241540
+ return (byte2 & mask) >>> start2;
241541
241541
  }
241542
241542
  function maskFor2(start2, length4) {
241543
241543
  return START_MASKS2[start2] & STOP_MASKS2[Math.min(length4 + start2 - 1, 7)];
@@ -241645,10 +241645,10 @@ var init_consumable_hash2 = __esm({
241645
241645
  let pendingBits = bits;
241646
241646
  let result = 0;
241647
241647
  while (pendingBits > 0 && this._haveBits()) {
241648
- const byte = this._value[this._currentBytePos];
241648
+ const byte2 = this._value[this._currentBytePos];
241649
241649
  const availableBits = this._currentBitPos + 1;
241650
241650
  const taking = Math.min(availableBits, pendingBits);
241651
- const value2 = byteBitsToInt2(byte, availableBits - taking, taking);
241651
+ const value2 = byteBitsToInt2(byte2, availableBits - taking, taking);
241652
241652
  result = (result << taking) + value2;
241653
241653
  pendingBits -= taking;
241654
241654
  this._currentBitPos -= taking;
@@ -564075,7 +564075,8 @@ function renderImageAsciiPreview(title, imagePath, ascii2, renderer) {
564075
564075
  ${prefix}${c3.cyan(c3.bold(header.length > maxW ? header.slice(0, maxW - 3) + "..." : header))}
564076
564076
  `);
564077
564077
  for (const line of ascii2.split("\n")) {
564078
- process.stdout.write(`${prefix}${c3.dim(line)}
564078
+ const renderedLine = /\x1B\[[0-?]*[ -/]*[@-~]/.test(line) ? line : c3.dim(line);
564079
+ process.stdout.write(`${prefix}${renderedLine}
564079
564080
  `);
564080
564081
  }
564081
564082
  }
@@ -576297,8 +576298,8 @@ function stripAnsi3(s2) {
576297
576298
  return s2.replace(/\x1B\[[0-9;]*m/g, "");
576298
576299
  }
576299
576300
  function defaultRenderRow(item, focused, isActive) {
576300
- const marker = isActive ? selectColors.green("●") : focused ? selectColors.orange("●") : selectColors.dim("○");
576301
- const label = focused ? selectColors.orange(selectColors.bold(item.label)) : isActive ? selectColors.green(item.label) : item.label;
576301
+ const marker = isActive ? selectColors.green("●") : focused ? selectColors.blue("●") : selectColors.dim("○");
576302
+ const label = focused ? selectColors.blue(selectColors.bold(item.label)) : isActive ? selectColors.green(item.label) : item.label;
576302
576303
  const detail = item.detail ? ` ${selectColors.dim(item.detail)}` : "";
576303
576304
  return ` ${marker} ${label}${detail}`;
576304
576305
  }
@@ -576481,7 +576482,7 @@ function tuiSelect(opts) {
576481
576482
  const isActive = item.key === activeKey;
576482
576483
  if (deleteConfirmIdx === idx) {
576483
576484
  const yesLabel = deleteConfirmSel ? selectColors.bold(selectColors.green("[Yes]")) : selectColors.dim("[Yes]");
576484
- const noLabel = !deleteConfirmSel ? selectColors.bold(selectColors.orange("[No]")) : selectColors.dim("[No]");
576485
+ const noLabel = !deleteConfirmSel ? selectColors.bold(selectColors.blue("[No]")) : selectColors.dim("[No]");
576485
576486
  lines.push(` ${ansi3("31", "✕")} ${ansi3("31", stripAnsi3(item.label))} Delete? ${yesLabel} ${noLabel}`);
576486
576487
  } else if (filter2) {
576487
576488
  lines.push(matchRow(item, focused, isActive));
@@ -576921,7 +576922,7 @@ ${tuiBgSeq()}`);
576921
576922
  }
576922
576923
  });
576923
576924
  }
576924
- var isTTY3, selectColors;
576925
+ var isTTY3, MENU_ACTIVE_GREEN_256, selectColors;
576925
576926
  var init_tui_select = __esm({
576926
576927
  "packages/cli/src/tui/tui-select.ts"() {
576927
576928
  "use strict";
@@ -576929,9 +576930,10 @@ var init_tui_select = __esm({
576929
576930
  init_theme();
576930
576931
  init_layout2();
576931
576932
  isTTY3 = process.stdout.isTTY ?? false;
576933
+ MENU_ACTIVE_GREEN_256 = 154;
576932
576934
  selectColors = {
576933
- orange: (t2) => fg2563(208, t2),
576934
- green: (t2) => ansi3("32", t2),
576935
+ blue: (t2) => fg2563(39, t2),
576936
+ green: (t2) => fg2563(MENU_ACTIVE_GREEN_256, t2),
576935
576937
  dim: (t2) => fg2563(tuiTextDim(), t2),
576936
576938
  bold: (t2) => ansi3("1", t2),
576937
576939
  cyan: (t2) => ansi3("36", t2),
@@ -578126,7 +578128,8 @@ function recommendModel(specs) {
578126
578128
  return QWEN_VARIANTS.find((v) => v.tag === "qwen3.5:cloud");
578127
578129
  }
578128
578130
  function calculateContextWindow(specs, modelSizeGB2, kvBytesPerToken, archMax) {
578129
- const totalAvail = Math.max(specs.gpuVramGB, specs.totalRamGB);
578131
+ const ramBudget = specs.availableRamGB > 0 ? specs.availableRamGB : specs.totalRamGB;
578132
+ const totalAvail = Math.max(specs.gpuVramGB, ramBudget);
578130
578133
  const remaining = Math.max(0, totalAvail - modelSizeGB2);
578131
578134
  const usableGB = remaining * 0.85;
578132
578135
  let numCtx;
@@ -578153,11 +578156,18 @@ function formatContextLabel(numCtx) {
578153
578156
  return numCtx >= 1024 ? `${Math.floor(numCtx / 1024)}K` : String(numCtx);
578154
578157
  }
578155
578158
  function calculateExpandedVariantContextWindow(specs, modelSizeGB2, kvBytesPerToken, archMax) {
578159
+ const memoryBudget = calculateContextWindow(
578160
+ specs,
578161
+ modelSizeGB2,
578162
+ kvBytesPerToken,
578163
+ archMax
578164
+ );
578156
578165
  if (archMax && archMax > 0) {
578157
- const numCtx = Math.max(2048, Math.floor(archMax / 1024) * 1024);
578166
+ const archCtx = Math.max(2048, Math.floor(archMax / 1024) * 1024);
578167
+ const numCtx = Math.min(archCtx, memoryBudget.numCtx);
578158
578168
  return { numCtx, label: formatContextLabel(numCtx) };
578159
578169
  }
578160
- return calculateContextWindow(specs, modelSizeGB2, kvBytesPerToken, archMax);
578170
+ return memoryBudget;
578161
578171
  }
578162
578172
  function ask(rl, question) {
578163
578173
  return new Promise((resolve52) => {
@@ -579435,7 +579445,10 @@ function getVenvDir2() {
579435
579445
  }
579436
579446
  function hasVenvModule() {
579437
579447
  try {
579438
- execSync50("python3 -m venv --help", { stdio: "pipe", timeout: 5e3 });
579448
+ execSync50('python3 -c "import ensurepip, venv"', {
579449
+ stdio: "pipe",
579450
+ timeout: 5e3
579451
+ });
579439
579452
  return true;
579440
579453
  } catch {
579441
579454
  return false;
@@ -579468,15 +579481,15 @@ function ensureVenv(log22) {
579468
579481
  }
579469
579482
  }
579470
579483
  }
579471
- log22("Creating Python venv for vision deps...");
579472
579484
  if (!hasCmd(pythonCmd) && !hasCmd("python3")) {
579473
579485
  log22(`${pythonCmd} not found — cannot create venv.`);
579474
579486
  return null;
579475
579487
  }
579476
579488
  if (!isWin2 && !hasVenvModule()) {
579477
- log22("python3 venv module not available — venv creation skipped.");
579489
+ log22("python3-venv is not installed — venv creation skipped. Install with: sudo apt-get install python3-venv");
579478
579490
  return null;
579479
579491
  }
579492
+ log22("Creating Python venv for vision deps...");
579480
579493
  try {
579481
579494
  mkdirSync52(join107(homedir34(), ".omnius"), { recursive: true });
579482
579495
  const pyCmd = hasCmd(pythonCmd) ? pythonCmd : "python3";
@@ -580032,7 +580045,10 @@ async function repairExpandedVariantIfStale(variantModel, fallbackBaseModel, bac
580032
580045
  return { repaired: false, currentNumCtx: state.currentNumCtx, baseModel: null, resolvedModel: variantName };
580033
580046
  }
580034
580047
  const canonicalModel = expandedModelName(baseModel);
580035
- const needsCtxRepair = !(state.currentNumCtx > 0 && state.currentNumCtx >= targetNumCtx);
580048
+ const hasCtx = state.currentNumCtx > 0;
580049
+ const tooSmall = hasCtx && state.currentNumCtx < targetNumCtx;
580050
+ const tooLarge = hasCtx && state.currentNumCtx > Math.floor(targetNumCtx * 1.1);
580051
+ const needsCtxRepair = !hasCtx || tooSmall || tooLarge;
580036
580052
  const needsCanonicalVariant = variantName !== canonicalModel;
580037
580053
  let repaired = false;
580038
580054
  if (needsCtxRepair) {
@@ -585130,7 +585146,7 @@ async function stepModelSelection(ep, rl, availableRows) {
585130
585146
  return false;
585131
585147
  },
585132
585148
  renderRow: (item, focused, _isActive) => {
585133
- const prefix = focused ? selectColors.orange("❯ ") : " ";
585149
+ const prefix = focused ? selectColors.blue("❯ ") : " ";
585134
585150
  if (item.key === "hdr") return selectColors.bold(item.label);
585135
585151
  return `${prefix}${item.label}`;
585136
585152
  }
@@ -585222,7 +585238,7 @@ async function stepEndpoints(config, ollamaUrl, rl, availableRows, repoRoot) {
585222
585238
  return false;
585223
585239
  },
585224
585240
  renderRow: (item, focused, _isActive) => {
585225
- const prefix = focused ? selectColors.orange("❯ ") : " ";
585241
+ const prefix = focused ? selectColors.blue("❯ ") : " ";
585226
585242
  if (item.key === "hdr") {
585227
585243
  return selectColors.bold(item.label);
585228
585244
  }
@@ -585685,7 +585701,7 @@ async function stepCohere(config, rl, availableRows) {
585685
585701
  return false;
585686
585702
  },
585687
585703
  renderRow: (item, focused, _isActive) => {
585688
- const prefix = focused ? selectColors.orange("❯ ") : " ";
585704
+ const prefix = focused ? selectColors.blue("❯ ") : " ";
585689
585705
  if (item.key === "hdr") return selectColors.bold(item.label);
585690
585706
  if (item.key.startsWith("desc")) return selectColors.dim(item.label);
585691
585707
  return `${prefix}${item.label}`;
@@ -585846,6 +585862,7 @@ var init_sponsor_wizard = __esm({
585846
585862
  // packages/cli/src/tui/image-ascii-preview.ts
585847
585863
  var image_ascii_preview_exports = {};
585848
585864
  __export(image_ascii_preview_exports, {
585865
+ IMAGE_ASCII_RENDER_OPTIONS: () => IMAGE_ASCII_RENDER_OPTIONS,
585849
585866
  buildImageAsciiPreview: () => buildImageAsciiPreview,
585850
585867
  defaultAsciiPreviewSize: () => defaultAsciiPreviewSize,
585851
585868
  extractSavedImagePath: () => extractSavedImagePath,
@@ -585919,9 +585936,101 @@ function readImageDimensions(imagePath) {
585919
585936
  }
585920
585937
  return null;
585921
585938
  }
585922
- function normalizeAscii(ascii2, width, height) {
585923
- const lines = ascii2.replace(ANSI_PATTERN, "").replace(/\r/g, "").split("\n").map((line) => line.replace(/\s+$/g, "")).filter((line, idx, all2) => line.length > 0 || idx > 0 && idx < all2.length - 1);
585924
- return lines.slice(0, height).map((line) => line.length > width ? line.slice(0, width) : line).join("\n").trimEnd();
585939
+ function stripAsciiAnsi(text) {
585940
+ return text.replace(ANSI_PATTERN, "");
585941
+ }
585942
+ function visibleWidth(text) {
585943
+ return stripAsciiAnsi(text).length;
585944
+ }
585945
+ function truncateVisible(text, width) {
585946
+ if (width <= 0) return "";
585947
+ let out = "";
585948
+ let visible = 0;
585949
+ let i2 = 0;
585950
+ let sawAnsi = false;
585951
+ while (i2 < text.length && visible < width) {
585952
+ ANSI_STICKY_PATTERN.lastIndex = i2;
585953
+ const ansi5 = ANSI_STICKY_PATTERN.exec(text);
585954
+ if (ansi5) {
585955
+ sawAnsi = true;
585956
+ out += ansi5[0];
585957
+ i2 = ANSI_STICKY_PATTERN.lastIndex;
585958
+ continue;
585959
+ }
585960
+ const codePoint = text.codePointAt(i2);
585961
+ if (codePoint == null) break;
585962
+ const ch = String.fromCodePoint(codePoint);
585963
+ out += ch;
585964
+ i2 += ch.length;
585965
+ visible++;
585966
+ }
585967
+ return sawAnsi ? `${out}\x1B[0m` : out;
585968
+ }
585969
+ function normalizeAscii(ascii2, width, height, options2 = {}) {
585970
+ const preserveAnsi = options2.preserveAnsi === true;
585971
+ const lines = ascii2.replace(/\r/g, "").split("\n").map((line) => preserveAnsi ? line : stripAsciiAnsi(line).replace(/\s+$/g, "")).filter((line, idx, all2) => stripAsciiAnsi(line).trim().length > 0 || idx > 0 && idx < all2.length - 1);
585972
+ const normalized = lines.slice(0, height).map((line) => visibleWidth(line) > width ? truncateVisible(line, width) : line);
585973
+ while (normalized.length > 0 && stripAsciiAnsi(normalized[normalized.length - 1] ?? "").trim().length === 0) {
585974
+ normalized.pop();
585975
+ }
585976
+ return normalized.join("\n");
585977
+ }
585978
+ function byte(value2, fallback) {
585979
+ const n2 = Number(value2);
585980
+ return Number.isFinite(n2) ? clamp5(n2, 0, 255) : fallback;
585981
+ }
585982
+ function luminance(r2, g, b) {
585983
+ return clamp5(Math.round(0.2126 * r2 + 0.7152 * g + 0.0722 * b), 0, 255);
585984
+ }
585985
+ function matrixPixel(cell) {
585986
+ if (cell && typeof cell === "object") {
585987
+ const pixel = cell;
585988
+ const valueFallback = byte(pixel.value, 0);
585989
+ const r2 = byte(pixel.r, valueFallback);
585990
+ const g = byte(pixel.g, valueFallback);
585991
+ const b = byte(pixel.b, valueFallback);
585992
+ const value2 = byte(pixel.value, luminance(r2, g, b));
585993
+ return { r: r2, g, b, value: value2 };
585994
+ }
585995
+ return { r: 0, g: 0, b: 0, value: 0 };
585996
+ }
585997
+ function stringifyImageAsciiMatrix(matrix) {
585998
+ const rows = Array.isArray(matrix) ? matrix : [];
585999
+ const displayLines = [];
586000
+ const plainLines = [];
586001
+ for (const rowUnknown of rows) {
586002
+ const row = Array.isArray(rowUnknown) ? rowUnknown : [];
586003
+ let displayLine = "";
586004
+ let plainLine = "";
586005
+ for (const cell of row) {
586006
+ const pixel = matrixPixel(cell);
586007
+ displayLine += `\x1B[38;2;${pixel.r};${pixel.g};${pixel.b}m${IMAGE_ASCII_BLOCK}\x1B[0m`;
586008
+ const idx = Math.round(pixel.value / 255 * (DEFAULT_PIXELS.length - 1));
586009
+ plainLine += DEFAULT_PIXELS[idx] ?? " ";
586010
+ }
586011
+ displayLines.push(displayLine);
586012
+ plainLines.push(plainLine.replace(/\s+$/g, ""));
586013
+ }
586014
+ return {
586015
+ ascii: displayLines.join("\n"),
586016
+ plainAscii: plainLines.join("\n")
586017
+ };
586018
+ }
586019
+ function normalizeImageToAsciiResult(converted, width, height) {
586020
+ let asciiSource = null;
586021
+ let plainSource = null;
586022
+ if (typeof converted === "string") {
586023
+ asciiSource = converted;
586024
+ } else if (converted && typeof converted === "object") {
586025
+ const result = converted;
586026
+ if (typeof result.ascii === "string") asciiSource = result.ascii;
586027
+ if (typeof result.plainAscii === "string") plainSource = result.plainAscii;
586028
+ }
586029
+ if (!asciiSource) return { ascii: null, error: "empty renderer output" };
586030
+ const ascii2 = normalizeAscii(asciiSource, width, height, { preserveAnsi: true });
586031
+ const plainAscii = normalizeAscii(plainSource ?? stripAsciiAnsi(asciiSource), width, height);
586032
+ if (!ascii2) return { ascii: null, error: "empty normalized renderer output" };
586033
+ return { ascii: ascii2, plainAscii: plainAscii || void 0 };
585925
586034
  }
585926
586035
  function previewFailure(message2, width) {
585927
586036
  const clean5 = message2.replace(/\s+/g, " ").trim();
@@ -585952,25 +586061,23 @@ async function convertWithImageToAscii(imagePath, width, height, timeoutMs) {
585952
586061
  imageToAscii(
585953
586062
  imagePath,
585954
586063
  {
585955
- colored: false,
586064
+ ...IMAGE_ASCII_RENDER_OPTIONS,
585956
586065
  size: { width, height },
585957
586066
  size_options: {
585958
586067
  preserve_aspect_ratio: false,
585959
586068
  fit_screen: false
585960
- }
586069
+ },
586070
+ stringify_fn: stringifyImageAsciiMatrix
585961
586071
  },
585962
586072
  (err, converted) => {
585963
586073
  if (settled) return;
585964
586074
  settled = true;
585965
586075
  clearTimeout(timer);
585966
- if (err || !converted) {
586076
+ if (err) {
585967
586077
  resolvePreview({ ascii: null, error: err?.message || "empty renderer output" });
585968
586078
  return;
585969
586079
  }
585970
- const normalized = normalizeAscii(converted, width, height);
585971
- resolvePreview(
585972
- normalized ? { ascii: normalized } : { ascii: null, error: "empty normalized renderer output" }
585973
- );
586080
+ resolvePreview(normalizeImageToAsciiResult(converted, width, height));
585974
586081
  }
585975
586082
  );
585976
586083
  } catch (err) {
@@ -586042,7 +586149,16 @@ async function buildImageAsciiPreview(inputPath, options2 = {}) {
586042
586149
  const timeoutMs = clamp5(options2.timeoutMs ?? 5e3, 500, 3e4);
586043
586150
  if (options2.preferPackage !== false) {
586044
586151
  const result = await convertWithImageToAscii(imagePath, width, height, timeoutMs);
586045
- if (result.ascii) return { path: imagePath, ascii: result.ascii, renderer: "image-to-ascii", width, height };
586152
+ if (result.ascii) {
586153
+ return {
586154
+ path: imagePath,
586155
+ ascii: result.ascii,
586156
+ plainAscii: result.plainAscii,
586157
+ renderer: "image-to-ascii",
586158
+ width,
586159
+ height
586160
+ };
586161
+ }
586046
586162
  return {
586047
586163
  path: imagePath,
586048
586164
  ascii: previewFailure(result.error || "renderer unavailable", width),
@@ -586052,12 +586168,13 @@ async function buildImageAsciiPreview(inputPath, options2 = {}) {
586052
586168
  };
586053
586169
  }
586054
586170
  const fallback = convertWithFfmpeg(imagePath, width, height, timeoutMs);
586055
- if (fallback) return { path: imagePath, ascii: fallback, renderer: "ffmpeg", width, height };
586171
+ if (fallback) return { path: imagePath, ascii: fallback, plainAscii: fallback, renderer: "ffmpeg", width, height };
586056
586172
  return null;
586057
586173
  }
586058
586174
  function formatImageAsciiContext(preview, label) {
586175
+ const ascii2 = preview.plainAscii ?? normalizeAscii(stripAsciiAnsi(preview.ascii), preview.width, preview.height);
586059
586176
  return `[ASCII preview of image: ${label}]
586060
- ${preview.ascii}`;
586177
+ ${ascii2}`;
586061
586178
  }
586062
586179
  function hasImageExtension(filePath) {
586063
586180
  const lower = filePath.toLowerCase();
@@ -586087,12 +586204,20 @@ function extractSavedImagePath(text, repoRoot) {
586087
586204
  }
586088
586205
  return null;
586089
586206
  }
586090
- var DEFAULT_PIXELS, ANSI_PATTERN, TERMINAL_CELL_ASPECT, IMAGE_PREVIEW_EXTENSIONS;
586207
+ var DEFAULT_PIXELS, IMAGE_ASCII_BLOCK, IMAGE_ASCII_RENDER_OPTIONS, ANSI_PATTERN, ANSI_STICKY_PATTERN, TERMINAL_CELL_ASPECT, IMAGE_PREVIEW_EXTENSIONS;
586091
586208
  var init_image_ascii_preview = __esm({
586092
586209
  "packages/cli/src/tui/image-ascii-preview.ts"() {
586093
586210
  "use strict";
586094
586211
  DEFAULT_PIXELS = " .,:;i1tfLCG08@";
586212
+ IMAGE_ASCII_BLOCK = "█";
586213
+ IMAGE_ASCII_RENDER_OPTIONS = Object.freeze({
586214
+ colored: true,
586215
+ pixels: IMAGE_ASCII_BLOCK.repeat(2),
586216
+ white_bg: true,
586217
+ px_background: Object.freeze({ r: 255, g: 255, b: 255 })
586218
+ });
586095
586219
  ANSI_PATTERN = /\x1B\[[0-?]*[ -/]*[@-~]/g;
586220
+ ANSI_STICKY_PATTERN = /\x1B\[[0-?]*[ -/]*[@-~]/y;
586096
586221
  TERMINAL_CELL_ASPECT = 0.52;
586097
586222
  IMAGE_PREVIEW_EXTENSIONS = /* @__PURE__ */ new Set([
586098
586223
  ".png",
@@ -596275,8 +596400,8 @@ async function showConfigEditor(ctx3) {
596275
596400
  if (item.kind === "header") {
596276
596401
  return ` ${item.label}`;
596277
596402
  }
596278
- const marker = focused ? selectColors.orange("●") : selectColors.dim("○");
596279
- const nameStr = focused ? selectColors.orange(selectColors.bold(item.label)) : item.label;
596403
+ const marker = focused ? selectColors.blue("●") : selectColors.dim("○");
596404
+ const nameStr = focused ? selectColors.blue(selectColors.bold(item.label)) : item.label;
596280
596405
  if (item.kind === "action") {
596281
596406
  return ` ${marker} ${nameStr} ${selectColors.dim(item.detail ?? "")}`;
596282
596407
  }
@@ -599891,7 +600016,7 @@ async function handleSponsoredEndpoint(ctx3, local) {
599891
600016
  availableRows: ctx3.availableContentRows?.(),
599892
600017
  renderRow: (item, focused, _isActive) => {
599893
600018
  if (item.key === "hdr") return selectColors.bold(item.label);
599894
- const prefix = focused ? selectColors.orange("❯ ") : " ";
600019
+ const prefix = focused ? selectColors.blue("❯ ") : " ";
599895
600020
  if (item.detail) {
599896
600021
  const detailLines = item.detail.split("\n");
599897
600022
  return `${prefix}${item.label}
@@ -601075,7 +601200,8 @@ async function handleUpdate(subcommand, ctx3) {
601075
601200
  buf += `\x1B[${boxTop + 2};${barCol}H\x1B[38;5;${accentColor}m${bar}\x1B[0m`;
601076
601201
  }
601077
601202
  const phaseText = _installPhase ? `${_installPhase}` : "";
601078
- const statusText = isDone ? `v${version4}` : statusLine || phaseText || `v${version4}`;
601203
+ const combinedStatus = phaseText && statusLine && !statusLine.startsWith(`${phaseText}:`) ? `${phaseText}: ${statusLine}` : statusLine || phaseText;
601204
+ const statusText = isDone ? `v${version4}` : combinedStatus || `v${version4}`;
601079
601205
  const statusTrunc = statusText.slice(0, innerW - 2);
601080
601206
  const sCol = centerCol - Math.floor(statusTrunc.length / 2);
601081
601207
  buf += `\x1B[${boxTop + 3};${sCol}H\x1B[38;5;${getDimColor()}m${statusTrunc}\x1B[0m`;
@@ -601134,7 +601260,7 @@ async function handleUpdate(subcommand, ctx3) {
601134
601260
  }
601135
601261
  };
601136
601262
  }
601137
- const { exec: exec5, execSync: es2 } = await import("node:child_process");
601263
+ const { exec: exec5, spawn: spawn32, execSync: es2 } = await import("node:child_process");
601138
601264
  const execA = (cmd, opts) => new Promise(
601139
601265
  (res, rej) => exec5(
601140
601266
  cmd,
@@ -601444,36 +601570,139 @@ async function handleUpdate(subcommand, ctx3) {
601444
601570
  const doOllama = menuResult.key === "full" && ollamaUpdate?.needsUpdate;
601445
601571
  const targetVersion = info?.latestVersion ?? currentVersion;
601446
601572
  const installOverlay = startInstallOverlay(targetVersion);
601573
+ const stripInstallAnsi = (value2) => value2.replace(/\x1B\][^\x07]*(?:\x07|\x1B\\)/g, "").replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, "").replace(/\r/g, "\n");
601574
+ const truncateInstallStatus = (value2, max = 88) => {
601575
+ const compact3 = value2.replace(/\s+/g, " ").trim();
601576
+ if (compact3.length <= max) return compact3;
601577
+ return compact3.slice(0, Math.max(1, max - 1)).trimEnd() + "…";
601578
+ };
601579
+ const summarizeInstallCommand = (cmd) => {
601580
+ const cleaned = cmd.replace(/^\s*sudo\s+/, "").replace(/\s+2>\/dev\/null/g, "").replace(/\s+\|\|\s+true\s*$/g, "").replace(/\s+/g, " ").trim();
601581
+ if (/^npm install -g omnius@/i.test(cleaned)) {
601582
+ const match = cleaned.match(/omnius@([^\s]+)/i);
601583
+ return `installing omnius@${match?.[1] ?? "latest"}`;
601584
+ }
601585
+ if (/^npm install\b/i.test(cleaned)) return "installing npm packages";
601586
+ if (/^npm update\b/i.test(cleaned)) return "updating npm packages";
601587
+ if (/^npm rebuild\b/i.test(cleaned)) return "rebuilding native modules";
601588
+ if (/pip"? install\b/i.test(cleaned)) return "upgrading Python packages";
601589
+ return truncateInstallStatus(cleaned, 64);
601590
+ };
601591
+ const summarizeInstallOutputLine = (line) => {
601592
+ const clean5 = truncateInstallStatus(stripInstallAnsi(line), 100);
601593
+ if (!clean5) return "";
601594
+ if (/^npm notice/i.test(clean5)) return "";
601595
+ if (/^\d+\s+packages?\s+are looking for funding/i.test(clean5)) return "";
601596
+ const deprecated = clean5.match(/^npm warn deprecated\s+(\S+)\s+(.+)/i);
601597
+ if (deprecated) {
601598
+ return truncateInstallStatus(`deprecated ${deprecated[1]}: ${deprecated[2]}`);
601599
+ }
601600
+ const warn = clean5.match(/^npm warn\s+(.+)/i);
601601
+ if (warn) return truncateInstallStatus(`warn: ${warn[1]}`);
601602
+ const fetch4 = clean5.match(/^npm http fetch\s+\S+\s+\d+\s+(.+?)\s+(\d+ms.*)?$/i);
601603
+ if (fetch4) return truncateInstallStatus(`fetching ${fetch4[1]}`);
601604
+ const run = clean5.match(/^npm info run\s+(\S+)\s+(\S+)\s+(.+)$/i);
601605
+ if (run) {
601606
+ const pkg = run[1];
601607
+ const script = run[2];
601608
+ const detail = run[3];
601609
+ if (/\{\s*code:\s*0/i.test(detail)) return `finished ${script}: ${pkg}`;
601610
+ return truncateInstallStatus(`running ${script}: ${pkg}`);
601611
+ }
601612
+ if (/node-gyp|prebuild-install|cmake|make\b|g\+\+|clang/i.test(clean5)) {
601613
+ return truncateInstallStatus(clean5);
601614
+ }
601615
+ if (/^(added|removed|changed|updated|up to date|audited)\b/i.test(clean5)) {
601616
+ return clean5;
601617
+ }
601618
+ if (/npm ERR!|error|failed/i.test(clean5)) return truncateInstallStatus(clean5);
601619
+ return clean5;
601620
+ };
601447
601621
  let installError = "";
601448
601622
  _installProgress = 0;
601449
601623
  _installTotal = 20;
601450
601624
  _installPhase = "Preparing...";
601451
- const runInstall2 = (cmd) => new Promise((resolve52) => {
601452
- const child = exec5(cmd, { timeout: 18e4 }, (err, _stdout, stderr) => {
601453
- if (err) installError = (stderr || err.message || "").trim();
601454
- resolve52(!err);
601625
+ const runInstall2 = (cmd, label = summarizeInstallCommand(cmd)) => new Promise((resolve52) => {
601626
+ const startedAt2 = Date.now();
601627
+ let lastOutputAt = startedAt2;
601628
+ let settled = false;
601629
+ const errorLines = [];
601630
+ const finish = (ok2, error) => {
601631
+ if (settled) return;
601632
+ settled = true;
601633
+ clearInterval(heartbeat);
601634
+ clearTimeout(timeout2);
601635
+ if (!ok2 && error) installError = error.trim();
601636
+ resolve52(ok2);
601637
+ };
601638
+ const noteLine = (line, isError2) => {
601639
+ const cleaned = stripInstallAnsi(line).trim();
601640
+ if (!cleaned) return;
601641
+ if (isError2) {
601642
+ errorLines.push(cleaned);
601643
+ if (errorLines.length > 12) errorLines.shift();
601644
+ }
601645
+ const status = summarizeInstallOutputLine(cleaned);
601646
+ if (!status) return;
601647
+ _installProgress++;
601648
+ lastOutputAt = Date.now();
601649
+ installOverlay.setStatus(status);
601650
+ };
601651
+ installOverlay.setStatus(`starting ${label}`);
601652
+ const heartbeat = setInterval(() => {
601653
+ if (settled) return;
601654
+ const elapsed = Math.max(1, Math.floor((Date.now() - startedAt2) / 1e3));
601655
+ if (Date.now() - lastOutputAt > 1500) {
601656
+ installOverlay.setStatus(`${label} · ${elapsed}s`);
601657
+ }
601658
+ }, 1e3);
601659
+ heartbeat.unref?.();
601660
+ const child = spawn32(cmd, {
601661
+ shell: true,
601662
+ stdio: ["ignore", "pipe", "pipe"],
601663
+ env: {
601664
+ ...process.env,
601665
+ FORCE_COLOR: "0",
601666
+ NO_COLOR: "1",
601667
+ npm_config_progress: "true",
601668
+ npm_config_loglevel: "notice"
601669
+ }
601455
601670
  });
601671
+ const timeout2 = setTimeout(() => {
601672
+ installError = `${label} timed out`;
601673
+ installOverlay.setStatus(`${label} timed out`);
601674
+ try {
601675
+ child.kill("SIGTERM");
601676
+ } catch {
601677
+ }
601678
+ setTimeout(() => {
601679
+ try {
601680
+ child.kill("SIGKILL");
601681
+ } catch {
601682
+ }
601683
+ }, 2500).unref?.();
601684
+ }, 18e4);
601685
+ timeout2.unref?.();
601456
601686
  child.stdout?.on("data", (chunk) => {
601457
601687
  const text = String(chunk);
601458
601688
  for (const line of text.split("\n")) {
601459
- const trimmed = line.trim();
601460
- if (trimmed) {
601461
- _installProgress++;
601462
- if (!trimmed.startsWith("npm") && trimmed.length < 50) {
601463
- installOverlay.setStatus(trimmed);
601464
- }
601465
- }
601689
+ noteLine(line, false);
601466
601690
  }
601467
601691
  });
601468
601692
  child.stderr?.on("data", (chunk) => {
601469
601693
  const text = String(chunk);
601470
601694
  for (const line of text.split("\n")) {
601471
- const trimmed = line.trim();
601472
- if (trimmed && !trimmed.includes("npm warn") && !trimmed.includes("npm notice")) {
601473
- _installProgress++;
601474
- installOverlay.setStatus(trimmed.slice(0, 40));
601475
- }
601695
+ noteLine(line, true);
601696
+ }
601697
+ });
601698
+ child.on("error", (err) => finish(false, err.message));
601699
+ child.on("close", (code8, signal) => {
601700
+ if (code8 === 0) {
601701
+ finish(true);
601702
+ return;
601476
601703
  }
601704
+ const errorText = errorLines.join("\n") || installError || `${label} exited with ${signal ? `signal ${signal}` : `code ${code8 ?? "unknown"}`}`;
601705
+ finish(false, errorText);
601477
601706
  });
601478
601707
  });
601479
601708
  if (needsSudo) {
@@ -601507,10 +601736,9 @@ async function handleUpdate(subcommand, ctx3) {
601507
601736
  installOverlay.setProgress(0, totalPhases || 1);
601508
601737
  if (doPackage && info) {
601509
601738
  installOverlay.setPhase("Package");
601510
- installOverlay.setStatus("Installing package...");
601511
601739
  const versionSpec = info.latestVersion ? `@${info.latestVersion}` : "@latest";
601512
601740
  const installCmd = `${sudoPrefix}npm install -g omnius${versionSpec} --prefer-online --cache-min=0`;
601513
- let installOk = await runInstall2(installCmd);
601741
+ let installOk = await runInstall2(installCmd, `installing omnius${versionSpec}`);
601514
601742
  if (!installOk && process.platform === "win32" && /EPERM|EACCES|access|denied|permission/i.test(installError)) {
601515
601743
  installOverlay.setStatus("Elevating permissions...");
601516
601744
  installError = "";
@@ -624452,6 +624680,7 @@ var init_mouse_filter = __esm({
624452
624680
  onPointer = null;
624453
624681
  onKeyboard = null;
624454
624682
  flushTimer = null;
624683
+ expectPrefixlessMouseUntil = 0;
624455
624684
  constructor(scrollHandler, activityHandler, pointerHandler, keyboardHandler) {
624456
624685
  super();
624457
624686
  this.onScroll = scrollHandler;
@@ -624467,32 +624696,26 @@ var init_mouse_filter = __esm({
624467
624696
  let output = "";
624468
624697
  let i2 = 0;
624469
624698
  while (i2 < this.buffer.length) {
624699
+ const remaining = this.buffer.slice(i2);
624700
+ const prefixlessMouse = this.matchPrefixlessSgrMouse(remaining);
624701
+ if (prefixlessMouse) {
624702
+ this.handleSgrMouse(prefixlessMouse);
624703
+ i2 += prefixlessMouse.raw.length;
624704
+ continue;
624705
+ }
624706
+ if (this.looksLikePartialPrefixlessSgrMouse(remaining)) {
624707
+ break;
624708
+ }
624470
624709
  if (this.buffer[i2] === "\x1B") {
624471
- const remaining = this.buffer.slice(i2);
624472
624710
  const mouseMatch = remaining.match(/^\x1B\[<(\d+);(\d+);(\d+)([Mm])/);
624473
624711
  if (mouseMatch) {
624474
- const btn = parseInt(mouseMatch[1]);
624475
- const col = parseInt(mouseMatch[2]);
624476
- const row = parseInt(mouseMatch[3]);
624477
- const suffix = mouseMatch[4];
624478
- if ((btn === 64 || btn === 96) && this.onScroll)
624479
- this.onScroll("up", 3, row);
624480
- else if ((btn === 65 || btn === 97) && this.onScroll)
624481
- this.onScroll("down", 3, row);
624482
- else if (this.onPointer) {
624483
- const hasShift = (btn & 4) !== 0 && btn < 32;
624484
- if (btn === 2) {
624485
- } else if (hasShift) {
624486
- process.stdout.write("\x1B[?1002l\x1B[?1006l");
624487
- } else if ((btn === 0 || btn === 1) && suffix === "M") {
624488
- this.onPointer("press", col, row);
624489
- } else if (btn >= 32 && btn <= 35 && suffix === "M") {
624490
- this.onPointer("drag", col, row);
624491
- } else if (suffix === "m") {
624492
- this.onPointer("release", col, row);
624493
- }
624494
- }
624495
- if (this.onActivity) this.onActivity();
624712
+ this.handleSgrMouse({
624713
+ raw: mouseMatch[0],
624714
+ btn: parseInt(mouseMatch[1]),
624715
+ col: parseInt(mouseMatch[2]),
624716
+ row: parseInt(mouseMatch[3]),
624717
+ suffix: mouseMatch[4]
624718
+ });
624496
624719
  i2 += mouseMatch[0].length;
624497
624720
  continue;
624498
624721
  }
@@ -624527,8 +624750,14 @@ var init_mouse_filter = __esm({
624527
624750
  this.flushTimer = setTimeout(() => {
624528
624751
  if (this.buffer.length > 0) {
624529
624752
  if (this.buffer.startsWith("\x1B[<") || this.buffer.startsWith("\x1B[M")) {
624753
+ this.expectPrefixlessMouseUntil = Date.now() + 1e3;
624754
+ this.buffer = "";
624755
+ } else if (this.buffer === "\x1B[") {
624756
+ this.expectPrefixlessMouseUntil = Date.now() + 1e3;
624530
624757
  this.buffer = "";
624531
- } else if (this.buffer === "\x1B" || this.buffer === "\x1B[") {
624758
+ } else if (this.looksLikePartialPrefixlessSgrMouse(this.buffer)) {
624759
+ this.buffer = "";
624760
+ } else if (this.buffer === "\x1B") {
624532
624761
  this.push(this.buffer);
624533
624762
  this.buffer = "";
624534
624763
  } else {
@@ -624546,11 +624775,68 @@ var init_mouse_filter = __esm({
624546
624775
  this.flushTimer = null;
624547
624776
  }
624548
624777
  if (this.buffer.length > 0) {
624778
+ if (this.buffer.startsWith("\x1B[<") || this.buffer.startsWith("\x1B[M") || this.buffer === "\x1B[" || this.looksLikePartialPrefixlessSgrMouse(this.buffer)) {
624779
+ this.buffer = "";
624780
+ callback();
624781
+ return;
624782
+ }
624549
624783
  this.push(this.buffer);
624550
624784
  this.buffer = "";
624551
624785
  }
624552
624786
  callback();
624553
624787
  }
624788
+ matchPrefixlessSgrMouse(input) {
624789
+ const match = input.match(/^(<)?(\d{1,3});(\d{1,5});(\d{1,5})([Mm])/);
624790
+ if (!match) return null;
624791
+ const hasMarker = Boolean(match[1]);
624792
+ const btn = parseInt(match[2], 10);
624793
+ const col = parseInt(match[3], 10);
624794
+ const row = parseInt(match[4], 10);
624795
+ const suffix = match[5];
624796
+ if (!Number.isFinite(btn) || !Number.isFinite(col) || !Number.isFinite(row))
624797
+ return null;
624798
+ if (col <= 0 || row <= 0) return null;
624799
+ if (!hasMarker && Date.now() > this.expectPrefixlessMouseUntil && !this.isKnownMouseButton(btn))
624800
+ return null;
624801
+ if (btn < 0 || btn > 255) return null;
624802
+ return { raw: match[0], btn, col, row, suffix };
624803
+ }
624804
+ looksLikePartialPrefixlessSgrMouse(input) {
624805
+ if (input.length < 2) return false;
624806
+ if (/^<\d{1,3};\d{0,5}(?:;\d{0,5})?$/.test(input)) return true;
624807
+ if (Date.now() <= this.expectPrefixlessMouseUntil && /^\d{1,3};\d{0,5}(?:;\d{0,5})?$/.test(input)) {
624808
+ return true;
624809
+ }
624810
+ return false;
624811
+ }
624812
+ isKnownMouseButton(btn) {
624813
+ if (btn >= 0 && btn <= 6) return true;
624814
+ if (btn >= 32 && btn <= 39) return true;
624815
+ if (btn >= 64 && btn <= 71) return true;
624816
+ if (btn >= 96 && btn <= 103) return true;
624817
+ return false;
624818
+ }
624819
+ handleSgrMouse(mouse) {
624820
+ const { btn, col, row, suffix } = mouse;
624821
+ if ((btn === 64 || btn === 96) && this.onScroll)
624822
+ this.onScroll("up", 3, row);
624823
+ else if ((btn === 65 || btn === 97) && this.onScroll)
624824
+ this.onScroll("down", 3, row);
624825
+ else if (this.onPointer) {
624826
+ const hasShift = (btn & 4) !== 0 && btn < 32;
624827
+ if (btn === 2) {
624828
+ } else if (hasShift) {
624829
+ process.stdout.write("\x1B[?1002l\x1B[?1006l");
624830
+ } else if ((btn === 0 || btn === 1) && suffix === "M") {
624831
+ this.onPointer("press", col, row);
624832
+ } else if (btn >= 32 && btn <= 35 && suffix === "M") {
624833
+ this.onPointer("drag", col, row);
624834
+ } else if (suffix === "m") {
624835
+ this.onPointer("release", col, row);
624836
+ }
624837
+ }
624838
+ if (this.onActivity) this.onActivity();
624839
+ }
624554
624840
  };
624555
624841
  }
624556
624842
  });
@@ -624582,6 +624868,7 @@ var init_direct_input = __esm({
624582
624868
  _buffer = "";
624583
624869
  // partial escape sequence buffer
624584
624870
  _flushTimer = null;
624871
+ _expectPrefixlessMouseUntil = 0;
624585
624872
  constructor(input, options2) {
624586
624873
  super();
624587
624874
  this._input = input;
@@ -624749,10 +625036,18 @@ var init_direct_input = __esm({
624749
625036
  _processBuffer() {
624750
625037
  let i2 = 0;
624751
625038
  while (i2 < this._buffer.length) {
625039
+ const remaining = this._buffer.slice(i2);
625040
+ const prefixlessMouse = this._matchPrefixlessSgrMouse(remaining);
625041
+ if (prefixlessMouse) {
625042
+ i2 += prefixlessMouse.length;
625043
+ continue;
625044
+ }
625045
+ if (this._looksLikePartialPrefixlessSgrMouse(remaining)) {
625046
+ break;
625047
+ }
624752
625048
  const ch = this._buffer[i2];
624753
625049
  const code8 = ch.charCodeAt(0);
624754
625050
  if (code8 === 27) {
624755
- const remaining = this._buffer.slice(i2);
624756
625051
  if (remaining.length >= 2 && remaining[1] === "[") {
624757
625052
  const mouseMatch = remaining.match(/^\x1B\[<(\d+);(\d+);(\d+)([Mm])/);
624758
625053
  if (mouseMatch) {
@@ -624770,6 +625065,7 @@ var init_direct_input = __esm({
624770
625065
  break;
624771
625066
  }
624772
625067
  if (remaining.startsWith("\x1B[<")) {
625068
+ this._expectPrefixlessMouseUntil = Date.now() + 1e3;
624773
625069
  let end = 3;
624774
625070
  while (end < remaining.length && remaining[end] !== "M" && remaining[end] !== "m") end++;
624775
625071
  if (end < remaining.length) end++;
@@ -624818,6 +625114,20 @@ var init_direct_input = __esm({
624818
625114
  this._flushTimer = setTimeout(() => {
624819
625115
  this._flushTimer = null;
624820
625116
  if (this._buffer.length > 0) {
625117
+ if (this._buffer.startsWith("\x1B[<") || this._buffer.startsWith("\x1B[M")) {
625118
+ this._expectPrefixlessMouseUntil = Date.now() + 1e3;
625119
+ this._buffer = "";
625120
+ return;
625121
+ }
625122
+ if (this._buffer === "\x1B[") {
625123
+ this._expectPrefixlessMouseUntil = Date.now() + 1e3;
625124
+ this._buffer = "";
625125
+ return;
625126
+ }
625127
+ if (this._looksLikePartialPrefixlessSgrMouse(this._buffer)) {
625128
+ this._buffer = "";
625129
+ return;
625130
+ }
624821
625131
  if (this._buffer === "\x1B") {
624822
625132
  this.emit("escape");
624823
625133
  }
@@ -624831,6 +625141,35 @@ var init_direct_input = __esm({
624831
625141
  }
624832
625142
  }
624833
625143
  }
625144
+ _matchPrefixlessSgrMouse(input) {
625145
+ const match = input.match(/^(<)?(\d{1,3});(\d{1,5});(\d{1,5})([Mm])/);
625146
+ if (!match) return null;
625147
+ const hasMarker = Boolean(match[1]);
625148
+ const btn = parseInt(match[2], 10);
625149
+ const col = parseInt(match[3], 10);
625150
+ const row = parseInt(match[4], 10);
625151
+ if (!Number.isFinite(btn) || !Number.isFinite(col) || !Number.isFinite(row))
625152
+ return null;
625153
+ if (btn < 0 || btn > 255 || col <= 0 || row <= 0) return null;
625154
+ if (!hasMarker && Date.now() > this._expectPrefixlessMouseUntil && !this._isKnownMouseButton(btn))
625155
+ return null;
625156
+ return { length: match[0].length };
625157
+ }
625158
+ _looksLikePartialPrefixlessSgrMouse(input) {
625159
+ if (input.length < 2) return false;
625160
+ if (/^<\d{1,3};\d{0,5}(?:;\d{0,5})?$/.test(input)) return true;
625161
+ if (Date.now() <= this._expectPrefixlessMouseUntil && /^\d{1,3};\d{0,5}(?:;\d{0,5})?$/.test(input)) {
625162
+ return true;
625163
+ }
625164
+ return false;
625165
+ }
625166
+ _isKnownMouseButton(btn) {
625167
+ if (btn >= 0 && btn <= 6) return true;
625168
+ if (btn >= 32 && btn <= 39) return true;
625169
+ if (btn >= 64 && btn <= 71) return true;
625170
+ if (btn >= 96 && btn <= 103) return true;
625171
+ return false;
625172
+ }
624834
625173
  _emitChangeIfNeeded(beforeLine, beforeCursor) {
624835
625174
  if (this.line === beforeLine && this.cursor === beforeCursor) return;
624836
625175
  this.emit("change", { line: this.line, cursor: this.cursor });
@@ -652475,15 +652814,41 @@ ${result.summary}`
652475
652814
  },
652476
652815
  () => new Promise((resolve52) => {
652477
652816
  depSudoPromptPending = true;
652817
+ if (process.stdout.isTTY) {
652818
+ process.stdout.write("\x1B[?1000l\x1B[?1002l\x1B[?1006l");
652819
+ }
652820
+ const origProvider = statusBar.inputStateProvider;
652821
+ if (statusBar?.isActive) {
652822
+ statusBar.inputStateProvider = () => {
652823
+ const state = origProvider?.() ?? { line: "", cursor: 0 };
652824
+ return { line: "●".repeat(state.line.length), cursor: state.cursor };
652825
+ };
652826
+ }
652827
+ const footerPwPrompt = `\x1B[38;5;198m● password:\x1B[0m `;
652828
+ const prevPromptText = statusBar.promptText;
652829
+ const prevPromptWidth = statusBar.promptWidth;
652830
+ if (statusBar?.isActive) {
652831
+ statusBar.setPromptText(footerPwPrompt, 12);
652832
+ }
652478
652833
  depSudoResolver = (pw2) => {
652479
652834
  depSudoPromptPending = false;
652480
652835
  depSudoResolver = null;
652836
+ if (statusBar?.isActive) {
652837
+ statusBar.inputStateProvider = origProvider ?? (() => ({ line: rl.line ?? "", cursor: rl.cursor ?? 0 }));
652838
+ if (prevPromptText !== void 0 && prevPromptWidth !== void 0) {
652839
+ statusBar.setPromptText(prevPromptText, prevPromptWidth);
652840
+ }
652841
+ }
652842
+ if (process.stdout.isTTY) {
652843
+ process.stdout.write("\x1B[?1002h\x1B[?1006h");
652844
+ }
652481
652845
  if (pw2) sessionSudoPassword = pw2;
652482
652846
  resolve52(pw2);
652483
652847
  };
652484
652848
  const pwPrompt = `
652485
- ${c3.bold(c3.yellow("🔑 Password needed for dependency install:"))}
652486
- ${c3.dim("Type your sudo password below and press Enter.")}
652849
+ \x1B[5;38;5;198m⚠ Password needed for dependency install\x1B[0m
652850
+ ${c3.dim("Type your sudo password below and press Enter. Input is hidden.")}
652851
+
652487
652852
  `;
652488
652853
  if (isNeovimActive()) {
652489
652854
  writeToNeovimOutput(pwPrompt);