@herbertgao/pi-extensions 2026.11.3 → 2026.11.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 (203) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +7 -7
  3. package/THIRD_PARTY_NOTICES.md +2 -2
  4. package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
  5. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +2 -2
  6. package/node_modules/@herbertgao/pi-cc-extensions/README.md +2 -2
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/mouse/interaction.ts +33 -5
  8. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/ccstyle-tool.ts +72 -17
  9. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/grouping.ts +10 -2
  10. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/tool-io.ts +16 -7
  11. package/node_modules/@herbertgao/pi-cc-extensions/package.json +7 -5
  12. package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-dark-hc.json +92 -0
  13. package/node_modules/@herbertgao/pi-cc-extensions/themes/cc-light-hc.json +92 -0
  14. package/node_modules/pi-commandcode-provider/CHANGELOG.md +27 -0
  15. package/node_modules/pi-commandcode-provider/CONTRIBUTING.md +64 -5
  16. package/node_modules/pi-commandcode-provider/README.md +40 -26
  17. package/node_modules/pi-commandcode-provider/RELEASE.md +25 -0
  18. package/node_modules/pi-commandcode-provider/index.ts +212 -38
  19. package/node_modules/pi-commandcode-provider/package.json +9 -8
  20. package/node_modules/pi-commandcode-provider/scripts/live-e2e-profile.mjs +6 -13
  21. package/node_modules/pi-commandcode-provider/scripts/typecheck-entrypoint.mjs +88 -0
  22. package/node_modules/pi-commandcode-provider/src/api-key.ts +43 -2
  23. package/node_modules/pi-commandcode-provider/src/commandcode-catalog-overrides.ts +1 -1
  24. package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +9 -2
  25. package/node_modules/pi-commandcode-provider/src/cost.ts +3 -37
  26. package/node_modules/pi-commandcode-provider/src/diagnostics.ts +215 -0
  27. package/node_modules/pi-commandcode-provider/src/oauth.ts +1 -1
  28. package/node_modules/pi-commandcode-provider/src/quota-command.ts +1 -1
  29. package/node_modules/pi-commandcode-provider/src/routing.ts +166 -0
  30. package/node_modules/pi-commandcode-provider/src/runtime.ts +15 -9
  31. package/node_modules/pi-commandcode-provider/src/transport.ts +79 -85
  32. package/node_modules/pi-commandcode-provider/src/types.ts +20 -39
  33. package/node_modules/pi-commandcode-provider/src/usage.ts +1 -1
  34. package/node_modules/pi-lens/CHANGELOG-USER.md +31 -0
  35. package/node_modules/pi-lens/CHANGELOG.md +178 -0
  36. package/node_modules/pi-lens/README.md +2 -1
  37. package/node_modules/pi-lens/config/dependency-cruiser-eager-allowlist.json +1 -1
  38. package/node_modules/pi-lens/dist/{chunk-3O5EII3W.js → chunk-2VZ3VN3N.js} +2 -2
  39. package/node_modules/pi-lens/dist/{chunk-SDFKOLSF.js → chunk-3HTZDY3C.js} +8 -6
  40. package/node_modules/pi-lens/dist/{chunk-A5GRLYPZ.js → chunk-3NPWO5UO.js} +7 -13
  41. package/node_modules/pi-lens/dist/{chunk-AGGUWKRK.js → chunk-47UCC4MM.js} +1 -1
  42. package/node_modules/pi-lens/dist/chunk-4ENEJHF4.js +198 -0
  43. package/node_modules/pi-lens/dist/{chunk-WXUDRAG6.js → chunk-5GEYJJHG.js} +10 -12
  44. package/node_modules/pi-lens/dist/{chunk-HHR7WGCI.js → chunk-5YSEQHJN.js} +3 -3
  45. package/node_modules/pi-lens/dist/{chunk-L3CLUGDY.js → chunk-6GPB3JLL.js} +3 -3
  46. package/node_modules/pi-lens/dist/{chunk-5F3XF3SX.js → chunk-7R5GZIA6.js} +6 -6
  47. package/node_modules/pi-lens/dist/{chunk-CUDD35TW.js → chunk-7UTSNTWM.js} +4 -4
  48. package/node_modules/pi-lens/dist/{chunk-DYRZGUMA.js → chunk-7YTRG6YW.js} +2 -2
  49. package/node_modules/pi-lens/dist/{chunk-JZRP4DGP.js → chunk-AACN5GNE.js} +2 -2
  50. package/node_modules/pi-lens/dist/{chunk-7ANZ7XDD.js → chunk-ACRJ2GZ5.js} +2 -2
  51. package/node_modules/pi-lens/dist/{chunk-6FIRFP6A.js → chunk-C3YRO3EU.js} +10 -12
  52. package/node_modules/pi-lens/dist/{chunk-GMROJJRN.js → chunk-CB7PEVOJ.js} +9 -1
  53. package/node_modules/pi-lens/dist/{chunk-BBET6HD6.js → chunk-CDFJF5YD.js} +1 -1
  54. package/node_modules/pi-lens/dist/{chunk-NSPVR3FN.js → chunk-CJS6WE66.js} +17 -19
  55. package/node_modules/pi-lens/dist/{chunk-6YUNI7B5.js → chunk-CM6BDY4E.js} +14 -60
  56. package/node_modules/pi-lens/dist/{chunk-G5GV2Q7K.js → chunk-CZCAZVTD.js} +16 -2
  57. package/node_modules/pi-lens/dist/chunk-DGKFWQK4.js +23 -0
  58. package/node_modules/pi-lens/dist/{chunk-VOP4PJKA.js → chunk-E65WJVI5.js} +7 -9
  59. package/node_modules/pi-lens/dist/{chunk-TV6RXRYH.js → chunk-EKNYSXFB.js} +8 -10
  60. package/node_modules/pi-lens/dist/{chunk-4LL2VRNY.js → chunk-EY6LY2HO.js} +16 -18
  61. package/node_modules/pi-lens/dist/{chunk-MC6VB2E5.js → chunk-F6BEQWAK.js} +17 -5
  62. package/node_modules/pi-lens/dist/{chunk-R2QQC33W.js → chunk-FGNSESAC.js} +12 -14
  63. package/node_modules/pi-lens/dist/{chunk-OC7VWJBZ.js → chunk-FRUBVFXV.js} +35 -37
  64. package/node_modules/pi-lens/dist/{chunk-7CGIDRIK.js → chunk-G22UNQID.js} +14 -16
  65. package/node_modules/pi-lens/dist/{chunk-L4NEVZ4T.js → chunk-GQTQUNCG.js} +25 -27
  66. package/node_modules/pi-lens/dist/{chunk-ZKLTNLAW.js → chunk-H3BVMK47.js} +6 -6
  67. package/node_modules/pi-lens/dist/chunk-H6FLQ5NW.js +28 -0
  68. package/node_modules/pi-lens/dist/{chunk-2ZE3AUJQ.js → chunk-HEA3EM23.js} +13 -15
  69. package/node_modules/pi-lens/dist/{chunk-CZL44WFN.js → chunk-HSOBIN22.js} +2 -2
  70. package/node_modules/pi-lens/dist/{chunk-PKSUMEPT.js → chunk-HYSKJMZK.js} +3 -3
  71. package/node_modules/pi-lens/dist/{chunk-VN3L2JWZ.js → chunk-IICERRFF.js} +5 -5
  72. package/node_modules/pi-lens/dist/{chunk-O4N5BQ3T.js → chunk-IILEH3ZC.js} +8 -10
  73. package/node_modules/pi-lens/dist/{chunk-WC6WRNQT.js → chunk-J3Q2NYJR.js} +2 -2
  74. package/node_modules/pi-lens/dist/{chunk-SFLHSL5R.js → chunk-JUZ67QZQ.js} +18 -7
  75. package/node_modules/pi-lens/dist/chunk-KR5VGMVT.js +25 -0
  76. package/node_modules/pi-lens/dist/{chunk-UHHLR2VY.js → chunk-KV6GQOGN.js} +38 -41
  77. package/node_modules/pi-lens/dist/{chunk-HUAM7QG3.js → chunk-KXMJLOZF.js} +25 -23
  78. package/node_modules/pi-lens/dist/{chunk-BUZIQDFS.js → chunk-L4Y3ROKQ.js} +3 -3
  79. package/node_modules/pi-lens/dist/{chunk-JBP7KESM.js → chunk-L6WBJGQS.js} +1 -1
  80. package/node_modules/pi-lens/dist/{chunk-35WKJWO5.js → chunk-L7O774U7.js} +14 -14
  81. package/node_modules/pi-lens/dist/{chunk-BOPDQ7AZ.js → chunk-LAHHGNAY.js} +19 -21
  82. package/node_modules/pi-lens/dist/{chunk-RGGH6M34.js → chunk-LT62P654.js} +1 -1
  83. package/node_modules/pi-lens/dist/{chunk-5T5A6YAJ.js → chunk-LWOM6LVS.js} +33 -34
  84. package/node_modules/pi-lens/dist/{chunk-JYLOYTZD.js → chunk-MKPDIAZH.js} +5 -1
  85. package/node_modules/pi-lens/dist/{chunk-CM73PPGD.js → chunk-MN635QYA.js} +3 -4
  86. package/node_modules/pi-lens/dist/{chunk-BQG2QFVO.js → chunk-MQ4PPCJB.js} +21 -29
  87. package/node_modules/pi-lens/dist/{chunk-HXFUTMX2.js → chunk-MRLH4MYU.js} +2 -2
  88. package/node_modules/pi-lens/dist/{chunk-XOMGO63G.js → chunk-N56BNAA6.js} +19 -21
  89. package/node_modules/pi-lens/dist/{chunk-7MAD5ZAY.js → chunk-N5CEGQPG.js} +14 -16
  90. package/node_modules/pi-lens/dist/{chunk-ZFORSIED.js → chunk-NCLO6E6N.js} +13 -33
  91. package/node_modules/pi-lens/dist/{chunk-SQC7K3SP.js → chunk-NL5LSKVD.js} +2 -2
  92. package/node_modules/pi-lens/dist/{chunk-I22THIHI.js → chunk-NMUSOZ2D.js} +10 -12
  93. package/node_modules/pi-lens/dist/{chunk-4NBWFYWW.js → chunk-NOWH2VA2.js} +8 -33
  94. package/node_modules/pi-lens/dist/{chunk-NM2NWH55.js → chunk-NUSXS6YB.js} +6 -5
  95. package/node_modules/pi-lens/dist/{chunk-OZWXLJMX.js → chunk-OSEKJEUU.js} +2 -2
  96. package/node_modules/pi-lens/dist/{chunk-2BKUFQKR.js → chunk-OUYAUXAT.js} +405 -181
  97. package/node_modules/pi-lens/dist/{chunk-JPRDTY5S.js → chunk-PBZNYHMM.js} +8 -10
  98. package/node_modules/pi-lens/dist/{chunk-JE6HKLC7.js → chunk-PIIUNJIT.js} +2 -4
  99. package/node_modules/pi-lens/dist/{chunk-ZZDIOAAJ.js → chunk-PRHYIA6X.js} +6 -6
  100. package/node_modules/pi-lens/dist/{chunk-4W52ZKZX.js → chunk-PXQ45SGD.js} +2 -2
  101. package/node_modules/pi-lens/dist/chunk-Q6JQKWPK.js +25 -0
  102. package/node_modules/pi-lens/dist/{chunk-PIQQM32Y.js → chunk-QB7T2PHK.js} +2 -2
  103. package/node_modules/pi-lens/dist/{chunk-HKIL6DCL.js → chunk-QGITU23N.js} +1 -1
  104. package/node_modules/pi-lens/dist/chunk-QJJKOHLH.js +57 -0
  105. package/node_modules/pi-lens/dist/{chunk-6LJOJ6EO.js → chunk-QP33NKYC.js} +14 -16
  106. package/node_modules/pi-lens/dist/{chunk-DIWK3LBC.js → chunk-QVBOXT3L.js} +8 -10
  107. package/node_modules/pi-lens/dist/{chunk-IYVYZQRL.js → chunk-RNJFRXEN.js} +5 -7
  108. package/node_modules/pi-lens/dist/{chunk-G6JKM4O7.js → chunk-RNXOWDM6.js} +10 -10
  109. package/node_modules/pi-lens/dist/{chunk-5RNB4HVK.js → chunk-RTFMDIKV.js} +1 -1
  110. package/node_modules/pi-lens/dist/{chunk-XWIME22V.js → chunk-SIQHOB6P.js} +11 -13
  111. package/node_modules/pi-lens/dist/{chunk-T2S3FNNJ.js → chunk-SLSMJPEF.js} +41 -42
  112. package/node_modules/pi-lens/dist/chunk-T5QSLSMM.js +50 -0
  113. package/node_modules/pi-lens/dist/chunk-TGQDAG4B.js +88 -0
  114. package/node_modules/pi-lens/dist/{chunk-6GMGEKQN.js → chunk-THYHUIDR.js} +39 -12
  115. package/node_modules/pi-lens/dist/{chunk-WMDUT4KH.js → chunk-TMNUTMT5.js} +72 -89
  116. package/node_modules/pi-lens/dist/{chunk-7TNILKGY.js → chunk-TOE2RRCS.js} +1 -1
  117. package/node_modules/pi-lens/dist/chunk-TYHPVE5H.js +25 -0
  118. package/node_modules/pi-lens/dist/chunk-UAKO2M6B.js +73 -0
  119. package/node_modules/pi-lens/dist/chunk-UC5AXW5Z.js +20 -0
  120. package/node_modules/pi-lens/dist/chunk-UTJP6WOS.js +28 -0
  121. package/node_modules/pi-lens/dist/{chunk-FRLAUP2B.js → chunk-UXTQ3QPD.js} +4 -4
  122. package/node_modules/pi-lens/dist/{chunk-4QG55RRC.js → chunk-V2WDBOLZ.js} +10 -12
  123. package/node_modules/pi-lens/dist/{chunk-FHEV6T4L.js → chunk-V67D6TMU.js} +8 -10
  124. package/node_modules/pi-lens/dist/{chunk-VLQ7UKZH.js → chunk-VCRVNLE7.js} +135 -2
  125. package/node_modules/pi-lens/dist/{chunk-KZ4ALBCH.js → chunk-VO4JFPTV.js} +2 -2
  126. package/node_modules/pi-lens/dist/{chunk-GIRBSBGL.js → chunk-VWLSU3XV.js} +3 -3
  127. package/node_modules/pi-lens/dist/{chunk-2453RRJ2.js → chunk-W5E72HJA.js} +59 -22
  128. package/node_modules/pi-lens/dist/{chunk-VPLBLWFO.js → chunk-W7TY6HYX.js} +1 -1
  129. package/node_modules/pi-lens/dist/{chunk-SP4TFY5F.js → chunk-WSSLVMDA.js} +11 -13
  130. package/node_modules/pi-lens/dist/{chunk-PPKECBPP.js → chunk-WTB4GKMH.js} +10 -1
  131. package/node_modules/pi-lens/dist/{chunk-X35S7HSB.js → chunk-X5BJ3G2P.js} +41 -30
  132. package/node_modules/pi-lens/dist/{chunk-X66YJ2SS.js → chunk-XKFO2SZV.js} +33 -34
  133. package/node_modules/pi-lens/dist/{chunk-OWTG6UMO.js → chunk-XLAI7UYY.js} +75 -22
  134. package/node_modules/pi-lens/dist/{chunk-4B2YFN4U.js → chunk-XO756WE5.js} +45 -33
  135. package/node_modules/pi-lens/dist/{chunk-VOXTCULR.js → chunk-XVB3Q2PG.js} +2 -4
  136. package/node_modules/pi-lens/dist/{chunk-XYLC35E4.js → chunk-YOXCCJDF.js} +517 -308
  137. package/node_modules/pi-lens/dist/{chunk-O2ARHQKF.js → chunk-ZCQBNPRH.js} +2 -2
  138. package/node_modules/pi-lens/dist/chunk-ZD4KVFXI.js +234 -0
  139. package/node_modules/pi-lens/dist/{chunk-LSFXZLPW.js → chunk-ZDMFGACN.js} +184 -235
  140. package/node_modules/pi-lens/dist/{chunk-4BKU7PV3.js → chunk-ZMMHHXSW.js} +1 -1
  141. package/node_modules/pi-lens/dist/{chunk-OY7WZI7Q.js → chunk-ZPM7ZIFL.js} +6 -6
  142. package/node_modules/pi-lens/dist/{chunk-R4QWJQ2H.js → chunk-ZVCDHYWZ.js} +9 -11
  143. package/node_modules/pi-lens/dist/{chunk-RZG472YW.js → chunk-ZZN74OGD.js} +83 -46
  144. package/node_modules/pi-lens/dist/{chunk-BHWW6FAX.js → chunk-ZZSJAR76.js} +37 -19
  145. package/node_modules/pi-lens/dist/index.js +4910 -4218
  146. package/node_modules/pi-lens/dist/mcp/analyze-cli.js +12 -17
  147. package/node_modules/pi-lens/dist/mcp/cli.js +41 -42
  148. package/node_modules/pi-lens/dist/mcp/server.js +1451 -648
  149. package/node_modules/pi-lens/dist/mcp/worker.js +59 -60
  150. package/node_modules/pi-lens/dist/probes/installer.js +17 -19
  151. package/node_modules/pi-lens/docs/agent-tools.md +40 -8
  152. package/node_modules/pi-lens/docs/analysisall.md +1 -1
  153. package/node_modules/pi-lens/docs/ci-bot-pr-checks.md +7 -5
  154. package/node_modules/pi-lens/docs/configuration.md +51 -9
  155. package/node_modules/pi-lens/docs/defect-shapes.md +52 -3
  156. package/node_modules/pi-lens/docs/environment-variables.md +18 -1
  157. package/node_modules/pi-lens/docs/features.md +12 -5
  158. package/node_modules/pi-lens/docs/globalconfig.md +11 -3
  159. package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +9 -2
  160. package/node_modules/pi-lens/docs/invariants/session-telemetry.md +2 -2
  161. package/node_modules/pi-lens/docs/language-coverage.md +1 -0
  162. package/node_modules/pi-lens/docs/lsp-capability-matrix.md +57 -35
  163. package/node_modules/pi-lens/docs/lsp-idle-eviction.md +4 -1
  164. package/node_modules/pi-lens/docs/merge-queue-rollout.md +10 -8
  165. package/node_modules/pi-lens/docs/module-report-read-symbol.md +34 -23
  166. package/node_modules/pi-lens/docs/pi-lens-fixer.md +11 -1
  167. package/node_modules/pi-lens/docs/pi-lens-investigator.md +3 -0
  168. package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +15 -7
  169. package/node_modules/pi-lens/docs/pi-lens-reviewer.md +1 -1
  170. package/node_modules/pi-lens/docs/pi-lens-subagent.md +13 -0
  171. package/node_modules/pi-lens/docs/public-api-stability.md +39 -5
  172. package/node_modules/pi-lens/docs/release-qa-baseline.md +7 -4
  173. package/node_modules/pi-lens/docs/schema/pi-lens-config-v1.json +11 -2
  174. package/node_modules/pi-lens/docs/servercapabilities.md +3 -1
  175. package/node_modules/pi-lens/docs/settings.md +2 -2
  176. package/node_modules/pi-lens/docs/word-index.md +3 -2
  177. package/node_modules/pi-lens/package.json +8 -3
  178. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-sql-in-code-execute-js.yml +1 -2
  179. package/node_modules/pi-lens/rules/ast-grep-rules/rules/no-sql-in-code-execute.yml +1 -2
  180. package/node_modules/pi-lens/scripts/download-grammars.js +3 -2
  181. package/node_modules/pi-lens/skills/pi-lens-lsp-navigation/SKILL.md +5 -1
  182. package/node_modules/pi-provider-qoder/dist/index.js +473 -62
  183. package/node_modules/pi-provider-qoder/package.json +1 -1
  184. package/package.json +10 -8
  185. package/node_modules/pi-commandcode-provider/src/converters.ts +0 -419
  186. package/node_modules/pi-commandcode-provider/src/core.ts +0 -861
  187. package/node_modules/pi-commandcode-provider/src/json-schema.ts +0 -417
  188. package/node_modules/pi-commandcode-provider/src/transcript.ts +0 -56
  189. package/node_modules/pi-lens/dist/chunk-2TS4GLOJ.js +0 -31
  190. package/node_modules/pi-lens/dist/chunk-3JAHQBSY.js +0 -27
  191. package/node_modules/pi-lens/dist/chunk-447YZL4S.js +0 -25
  192. package/node_modules/pi-lens/dist/chunk-565VRUP4.js +0 -136
  193. package/node_modules/pi-lens/dist/chunk-57X2CDRX.js +0 -49
  194. package/node_modules/pi-lens/dist/chunk-GGYOZWHW.js +0 -27
  195. package/node_modules/pi-lens/dist/chunk-IE5D3RA5.js +0 -58
  196. package/node_modules/pi-lens/dist/chunk-LPYTPNOJ.js +0 -22
  197. package/node_modules/pi-lens/dist/chunk-OFNMHPBT.js +0 -89
  198. package/node_modules/pi-lens/dist/chunk-U3AS2FR6.js +0 -106
  199. package/node_modules/pi-lens/dist/chunk-W3BGKBBK.js +0 -27
  200. package/node_modules/pi-lens/dist/chunk-WQV6BI4Q.js +0 -48
  201. package/node_modules/pi-lens/dist/chunk-YHGYAEFH.js +0 -443
  202. package/node_modules/pi-lens/dist/chunk-ZONZ6YY3.js +0 -74
  203. package/node_modules/pi-lens/dist/chunk-ZSM35JF4.js +0 -30
@@ -3026,6 +3026,41 @@ function stripTerminalSequences(str) {
3026
3026
  }
3027
3027
  return result;
3028
3028
  }
3029
+ function extractAnsiCodes(str) {
3030
+ let result = "";
3031
+ let i = str.indexOf("\x1B");
3032
+ while (i !== -1) {
3033
+ const length = ansiCodeLength(str, i);
3034
+ if (length > 0) {
3035
+ result += str.substring(i, i + length);
3036
+ i += length;
3037
+ } else {
3038
+ i++;
3039
+ }
3040
+ i = str.indexOf("\x1B", i);
3041
+ }
3042
+ return result;
3043
+ }
3044
+ var WHITESPACE_REGEX = /\s/;
3045
+ function isWhitespaceToken(token) {
3046
+ let i = 0;
3047
+ while (i < token.length) {
3048
+ const code = token.charCodeAt(i);
3049
+ if (code === 27) {
3050
+ const length = ansiCodeLength(token, i);
3051
+ if (length === 0)
3052
+ return false;
3053
+ i += length;
3054
+ } else if (code === 32 || code >= 9 && code <= 13) {
3055
+ i++;
3056
+ } else if (code < 128 || !WHITESPACE_REGEX.test(token[i])) {
3057
+ return false;
3058
+ } else {
3059
+ i++;
3060
+ }
3061
+ }
3062
+ return true;
3063
+ }
3029
3064
  function getGraphemeCellRange(line, column) {
3030
3065
  let currentCol = 0;
3031
3066
  let i = 0;
@@ -3374,7 +3409,7 @@ var AnsiCodeTracker = class {
3374
3409
  }
3375
3410
  /**
3376
3411
  * Get reset codes for attributes that need to be turned off at line end.
3377
- * Underline must be closed to prevent bleeding into padding.
3412
+ * Underline and strikethrough must be closed to prevent bleeding into padding.
3378
3413
  * Active OSC 8 hyperlinks must be closed and re-opened on the next line.
3379
3414
  * Returns empty string if no attributes need closing.
3380
3415
  */
@@ -3383,6 +3418,9 @@ var AnsiCodeTracker = class {
3383
3418
  if (this.underline) {
3384
3419
  result += "\x1B[24m";
3385
3420
  }
3421
+ if (this.strikethrough) {
3422
+ result += "\x1B[29m";
3423
+ }
3386
3424
  if (this.activeHyperlink) {
3387
3425
  result += formatOsc8Close(this.activeHyperlink.terminator);
3388
3426
  }
@@ -3508,9 +3546,10 @@ function wrapSingleLine(line, width) {
3508
3546
  let currentVisibleLength = 0;
3509
3547
  for (const token of tokens) {
3510
3548
  const tokenVisibleLength = visibleWidth(token);
3511
- const isWhitespace = token.trim() === "";
3549
+ const isWhitespace = isWhitespaceToken(token);
3512
3550
  if (tokenVisibleLength > width && !isWhitespace) {
3513
3551
  if (currentLine) {
3552
+ currentLine = currentLine.trimEnd();
3514
3553
  const lineEndReset = tracker.getLineEndReset();
3515
3554
  if (lineEndReset) {
3516
3555
  currentLine += lineEndReset;
@@ -3530,6 +3569,10 @@ function wrapSingleLine(line, width) {
3530
3569
  const totalNeeded = currentVisibleLength + tokenVisibleLength;
3531
3570
  if (totalNeeded > width && currentVisibleLength > 0) {
3532
3571
  let lineToWrap = currentLine.trimEnd();
3572
+ if (isWhitespace) {
3573
+ lineToWrap += extractAnsiCodes(token);
3574
+ updateTrackerFromText(token, tracker);
3575
+ }
3533
3576
  const lineEndReset = tracker.getLineEndReset();
3534
3577
  if (lineEndReset) {
3535
3578
  lineToWrap += lineEndReset;
@@ -3538,10 +3581,12 @@ function wrapSingleLine(line, width) {
3538
3581
  if (isWhitespace) {
3539
3582
  currentLine = tracker.getActiveCodes();
3540
3583
  currentVisibleLength = 0;
3541
- } else {
3542
- currentLine = tracker.getActiveCodes() + token;
3543
- currentVisibleLength = tokenVisibleLength;
3584
+ continue;
3544
3585
  }
3586
+ currentLine = tracker.getActiveCodes() + token;
3587
+ currentVisibleLength = tokenVisibleLength;
3588
+ } else if (isWhitespace && totalNeeded > width && token.includes("\x1B")) {
3589
+ currentLine += extractAnsiCodes(token);
3545
3590
  } else {
3546
3591
  currentLine += token;
3547
3592
  currentVisibleLength += tokenVisibleLength;
@@ -3788,7 +3833,7 @@ function extractSegments(line, beforeEnd, afterStart, afterLen, strictAfter = fa
3788
3833
  pooledStyleTracker.process(ansi.code);
3789
3834
  if (currentCol < beforeEnd) {
3790
3835
  pendingAnsiBefore += ansi.code;
3791
- } else if (currentCol >= afterStart && currentCol < afterEnd && afterStarted) {
3836
+ } else if (currentCol >= afterStart && currentCol < afterEnd && (afterStarted || ansi.code.startsWith("\x1B_"))) {
3792
3837
  after += ansi.code;
3793
3838
  }
3794
3839
  i += ansi.length;
@@ -3880,6 +3925,8 @@ var SYMBOL_KEYS = /* @__PURE__ */ new Set([
3880
3925
  ">",
3881
3926
  "?"
3882
3927
  ]);
3928
+ var SHIFTED_SYMBOL_KEYS = new Set("~!@#$%^&*()_+|{}:<>?");
3929
+ var MODIFIER_NAMES = ["shift", "alt", "ctrl", "super"];
3883
3930
  var MODIFIERS = {
3884
3931
  shift: 1,
3885
3932
  alt: 2,
@@ -3908,8 +3955,22 @@ var FUNCTIONAL_CODEPOINTS = {
3908
3955
  pageUp: -12,
3909
3956
  pageDown: -13,
3910
3957
  home: -14,
3911
- end: -15
3958
+ end: -15,
3959
+ f1: -21,
3960
+ f2: -22,
3961
+ f3: -23,
3962
+ f4: -24,
3963
+ f5: -25,
3964
+ f6: -26,
3965
+ f7: -27,
3966
+ f8: -28,
3967
+ f9: -29,
3968
+ f10: -30,
3969
+ f11: -31,
3970
+ f12: -32
3912
3971
  };
3972
+ var KITTY_FUNCTIONAL_PUA_START = 57344;
3973
+ var KITTY_FUNCTIONAL_PUA_END = 63743;
3913
3974
  var KITTY_FUNCTIONAL_KEY_EQUIVALENTS = /* @__PURE__ */ new Map([
3914
3975
  [57399, 48],
3915
3976
  // KP_0 -> 0
@@ -3966,6 +4027,14 @@ function normalizeShiftedLetterIdentityCodepoint(codepoint, modifier) {
3966
4027
  }
3967
4028
  return codepoint;
3968
4029
  }
4030
+ function getLogicalShiftedSymbolCandidate(codepoint, modifier, allowedSymbols) {
4031
+ if (codepoint === void 0 || (modifier & MODIFIERS.shift) === 0)
4032
+ return void 0;
4033
+ const normalizedCodepoint = normalizeKittyFunctionalCodepoint(codepoint);
4034
+ if (!allowedSymbols.has(String.fromCharCode(normalizedCodepoint)))
4035
+ return void 0;
4036
+ return { codepoint: normalizedCodepoint, modifier: modifier & ~MODIFIERS.shift };
4037
+ }
3969
4038
  var LEGACY_KEY_SEQUENCES = {
3970
4039
  up: ["\x1B[A", "\x1BOA"],
3971
4040
  down: ["\x1B[B", "\x1BOB"],
@@ -4032,7 +4101,7 @@ function isKeyRelease(data) {
4032
4101
  if (data.includes("\x1B[200~")) {
4033
4102
  return false;
4034
4103
  }
4035
- if (data.includes(":3u") || data.includes(":3~") || data.includes(":3A") || data.includes(":3B") || data.includes(":3C") || data.includes(":3D") || data.includes(":3H") || data.includes(":3F")) {
4104
+ if (data.includes(":3u") || data.includes(":3~") || data.includes(":3A") || data.includes(":3B") || data.includes(":3C") || data.includes(":3D") || data.includes(":3H") || data.includes(":3F") || data.includes(":3P") || data.includes(":3Q") || data.includes(":3S")) {
4036
4105
  return true;
4037
4106
  }
4038
4107
  return false;
@@ -4077,7 +4146,19 @@ function parseKittySequence(data) {
4077
4146
  5: FUNCTIONAL_CODEPOINTS.pageUp,
4078
4147
  6: FUNCTIONAL_CODEPOINTS.pageDown,
4079
4148
  7: FUNCTIONAL_CODEPOINTS.home,
4080
- 8: FUNCTIONAL_CODEPOINTS.end
4149
+ 8: FUNCTIONAL_CODEPOINTS.end,
4150
+ 11: FUNCTIONAL_CODEPOINTS.f1,
4151
+ 12: FUNCTIONAL_CODEPOINTS.f2,
4152
+ 13: FUNCTIONAL_CODEPOINTS.f3,
4153
+ 14: FUNCTIONAL_CODEPOINTS.f4,
4154
+ 15: FUNCTIONAL_CODEPOINTS.f5,
4155
+ 17: FUNCTIONAL_CODEPOINTS.f6,
4156
+ 18: FUNCTIONAL_CODEPOINTS.f7,
4157
+ 19: FUNCTIONAL_CODEPOINTS.f8,
4158
+ 20: FUNCTIONAL_CODEPOINTS.f9,
4159
+ 21: FUNCTIONAL_CODEPOINTS.f10,
4160
+ 23: FUNCTIONAL_CODEPOINTS.f11,
4161
+ 24: FUNCTIONAL_CODEPOINTS.f12
4081
4162
  };
4082
4163
  const codepoint = funcCodes[keyNum];
4083
4164
  if (codepoint !== void 0) {
@@ -4093,6 +4174,18 @@ function parseKittySequence(data) {
4093
4174
  _lastEventType = eventType;
4094
4175
  return { codepoint, modifier: modValue - 1, eventType };
4095
4176
  }
4177
+ const fKeyMatch = data.match(/^\x1b\[(?:1;(\d+)(?::(\d+))?)?([PQS])$/);
4178
+ if (fKeyMatch) {
4179
+ const modValue = fKeyMatch[1] ? parseInt(fKeyMatch[1], 10) : 1;
4180
+ const eventType = parseEventType(fKeyMatch[2]);
4181
+ const fKeyCodes = {
4182
+ P: FUNCTIONAL_CODEPOINTS.f1,
4183
+ Q: FUNCTIONAL_CODEPOINTS.f2,
4184
+ S: FUNCTIONAL_CODEPOINTS.f4
4185
+ };
4186
+ _lastEventType = eventType;
4187
+ return { codepoint: fKeyCodes[fKeyMatch[3]], modifier: modValue - 1, eventType };
4188
+ }
4096
4189
  return null;
4097
4190
  }
4098
4191
  function matchesKittySequence(data, expectedCodepoint, expectedModifier) {
@@ -4101,12 +4194,16 @@ function matchesKittySequence(data, expectedCodepoint, expectedModifier) {
4101
4194
  return false;
4102
4195
  const actualMod = parsed.modifier & ~LOCK_MASK;
4103
4196
  const expectedMod = expectedModifier & ~LOCK_MASK;
4104
- if (actualMod !== expectedMod)
4105
- return false;
4106
4197
  const normalizedCodepoint = normalizeShiftedLetterIdentityCodepoint(normalizeKittyFunctionalCodepoint(parsed.codepoint), parsed.modifier);
4107
4198
  const normalizedExpectedCodepoint = normalizeShiftedLetterIdentityCodepoint(normalizeKittyFunctionalCodepoint(expectedCodepoint), expectedModifier);
4108
- if (normalizedCodepoint === normalizedExpectedCodepoint)
4199
+ if (actualMod === expectedMod && normalizedCodepoint === normalizedExpectedCodepoint)
4109
4200
  return true;
4201
+ const logicalShiftedSymbol = getLogicalShiftedSymbolCandidate(parsed.shiftedKey, actualMod, SYMBOL_KEYS);
4202
+ if (logicalShiftedSymbol && (logicalShiftedSymbol.modifier & ~LOCK_MASK) === expectedMod && logicalShiftedSymbol.codepoint === normalizeKittyFunctionalCodepoint(expectedCodepoint)) {
4203
+ return true;
4204
+ }
4205
+ if (actualMod !== expectedMod)
4206
+ return false;
4110
4207
  if (parsed.baseLayoutKey !== void 0 && parsed.baseLayoutKey === expectedCodepoint) {
4111
4208
  const cp = normalizedCodepoint;
4112
4209
  const isLatinLetter = cp >= 97 && cp <= 122;
@@ -4155,24 +4252,35 @@ function isDigitKey(key) {
4155
4252
  return key >= "0" && key <= "9";
4156
4253
  }
4157
4254
  function matchesPrintableModifyOtherKeys(data, expectedKeycode, expectedModifier) {
4158
- if (expectedModifier === 0)
4159
- return false;
4160
4255
  const parsed = parseModifyOtherKeysSequence(data);
4161
- if (!parsed || parsed.modifier !== expectedModifier)
4256
+ if (!parsed)
4162
4257
  return false;
4163
- return normalizeShiftedLetterIdentityCodepoint(parsed.codepoint, parsed.modifier) === normalizeShiftedLetterIdentityCodepoint(expectedKeycode, expectedModifier);
4258
+ const physicalMatch = parsed.modifier === expectedModifier && normalizeShiftedLetterIdentityCodepoint(parsed.codepoint, parsed.modifier) === normalizeShiftedLetterIdentityCodepoint(expectedKeycode, expectedModifier);
4259
+ if (physicalMatch)
4260
+ return true;
4261
+ const logicalShiftedSymbol = getLogicalShiftedSymbolCandidate(parsed.codepoint, parsed.modifier, SHIFTED_SYMBOL_KEYS);
4262
+ return logicalShiftedSymbol?.modifier === expectedModifier && logicalShiftedSymbol.codepoint === expectedKeycode;
4164
4263
  }
4165
4264
  function parseKeyId(keyId) {
4166
- const parts = keyId.toLowerCase().split("+");
4167
- const key = parts[parts.length - 1];
4168
- if (!key)
4265
+ let key = keyId.toLowerCase();
4266
+ const modifiers = /* @__PURE__ */ new Set();
4267
+ while (true) {
4268
+ const modifier = MODIFIER_NAMES.find((name) => key.startsWith(`${name}+`));
4269
+ if (!modifier)
4270
+ break;
4271
+ if (modifiers.has(modifier))
4272
+ return null;
4273
+ modifiers.add(modifier);
4274
+ key = key.slice(modifier.length + 1);
4275
+ }
4276
+ if (!key || key.includes("+") && key !== "+")
4169
4277
  return null;
4170
4278
  return {
4171
4279
  key,
4172
- ctrl: parts.includes("ctrl"),
4173
- shift: parts.includes("shift"),
4174
- alt: parts.includes("alt"),
4175
- super: parts.includes("super")
4280
+ ctrl: modifiers.has("ctrl"),
4281
+ shift: modifiers.has("shift"),
4282
+ alt: modifiers.has("alt"),
4283
+ super: modifiers.has("super")
4176
4284
  };
4177
4285
  }
4178
4286
  function matchesKey(data, keyId) {
@@ -4378,11 +4486,11 @@ function matchesKey(data, keyId) {
4378
4486
  case "f10":
4379
4487
  case "f11":
4380
4488
  case "f12": {
4381
- if (modifier !== 0) {
4382
- return false;
4383
- }
4384
4489
  const functionKey = key;
4385
- return matchesLegacySequence(data, LEGACY_KEY_SEQUENCES[functionKey]);
4490
+ if (modifier === 0 && matchesLegacySequence(data, LEGACY_KEY_SEQUENCES[functionKey])) {
4491
+ return true;
4492
+ }
4493
+ return matchesKittySequence(data, FUNCTIONAL_CODEPOINTS[functionKey], modifier);
4386
4494
  }
4387
4495
  }
4388
4496
  if (key.length === 1 && (key >= "a" && key <= "z" || isDigitKey(key) || SYMBOL_KEYS.has(key))) {
@@ -4414,7 +4522,7 @@ function matchesKey(data, keyId) {
4414
4522
  if (modifier !== 0) {
4415
4523
  return matchesKittySequence(data, codepoint, modifier) || matchesPrintableModifyOtherKeys(data, codepoint, modifier);
4416
4524
  }
4417
- return data === key || matchesKittySequence(data, codepoint, 0);
4525
+ return data === key || matchesKittySequence(data, codepoint, 0) || matchesPrintableModifyOtherKeys(data, codepoint, 0);
4418
4526
  }
4419
4527
  return false;
4420
4528
  }
@@ -4441,6 +4549,9 @@ function decodeKittyPrintable(data) {
4441
4549
  effectiveCodepoint = normalizeKittyFunctionalCodepoint(effectiveCodepoint);
4442
4550
  if (!Number.isFinite(effectiveCodepoint) || effectiveCodepoint < 32)
4443
4551
  return void 0;
4552
+ if (effectiveCodepoint >= KITTY_FUNCTIONAL_PUA_START && effectiveCodepoint <= KITTY_FUNCTIONAL_PUA_END) {
4553
+ return void 0;
4554
+ }
4444
4555
  try {
4445
4556
  return String.fromCodePoint(effectiveCodepoint);
4446
4557
  } catch {
@@ -4542,6 +4653,15 @@ function detectCapabilitiesFromEnvironment(tmuxForwardsHyperlink) {
4542
4653
  if (term.startsWith("screen")) {
4543
4654
  return { images: null, trueColor: hasTrueColorHint, hyperlinks: false };
4544
4655
  }
4656
+ if (termProgram === "herdr") {
4657
+ return { images: "kitty", trueColor: hasTrueColorHint, hyperlinks: true };
4658
+ }
4659
+ if (termProgram === "rex") {
4660
+ return { images: "kitty", trueColor: true, hyperlinks: true };
4661
+ }
4662
+ if (termProgram === "orca" && process.env.ORCA_IMAGE_PROTOCOL === "kitty") {
4663
+ return { images: "kitty", trueColor: true, hyperlinks: true };
4664
+ }
4545
4665
  if (process.env.KITTY_WINDOW_ID || termProgram === "kitty") {
4546
4666
  return { images: "kitty", trueColor: true, hyperlinks: true };
4547
4667
  }
@@ -4618,6 +4738,10 @@ function deleteAllKittyPlacements() {
4618
4738
  return "\x1B_Ga=d,d=a,q=2\x1B\\";
4619
4739
  }
4620
4740
  var kittyImageMetadata = /* @__PURE__ */ new Map();
4741
+ var maxKittyImageRows = 0;
4742
+ function getMaxKittyImageRows() {
4743
+ return maxKittyImageRows;
4744
+ }
4621
4745
  function getRegisteredKittyImageMetadataFromControls(controls) {
4622
4746
  const imageId = /(?:^|,)i=(\d+)(?:,|$)/.exec(controls)?.[1];
4623
4747
  return imageId === void 0 ? void 0 : kittyImageMetadata.get(Number.parseInt(imageId, 10));
@@ -4770,6 +4894,12 @@ function isFocusable(component) {
4770
4894
  return component !== null && "focused" in component;
4771
4895
  }
4772
4896
  var CURSOR_MARKER = "\x1B_pi:c\x07";
4897
+ var FAKE_CURSOR_START = "\x1B_pi:fc\x07";
4898
+ var FAKE_CURSOR_END = "\x1B_pi:/fc\x07";
4899
+ var FOCUSED_FAKE_CURSOR = /(\x1b_pi:c\x07)\x1b_pi:fc\x07(.*?)(?:\x1b_pi:\/fc\x07|$)/s;
4900
+ function renderFakeCursor(text) {
4901
+ return `${FAKE_CURSOR_START}${text}${FAKE_CURSOR_END}`;
4902
+ }
4773
4903
  function parseSizeValue(value, referenceSize) {
4774
4904
  if (value === void 0)
4775
4905
  return void 0;
@@ -4902,6 +5032,26 @@ var TuiBase = class _TuiBase extends Container {
4902
5032
  }
4903
5033
  afterTerminalStop(_options) {
4904
5034
  }
5035
+ /** Mode resets written before the terminal's own resets when the process exits without stop(). */
5036
+ getExitRestorePrefix() {
5037
+ return `${this.terminalColorSchemeNotificationsEnabled ? "\x1B[?2031l" : ""}\x1B[?25h`;
5038
+ }
5039
+ /** Mode resets written after the terminal's own resets when the process exits without stop(). */
5040
+ getExitRestoreSuffix() {
5041
+ return "";
5042
+ }
5043
+ /**
5044
+ * Last-resort restore for exit paths that skip stop(), e.g. a direct process.exit() (#11170).
5045
+ * Hard kills and native aborts run no JavaScript and cannot be covered.
5046
+ */
5047
+ exitRestoreHandler = () => {
5048
+ if (this.stopped)
5049
+ return;
5050
+ try {
5051
+ this.terminal.restoreOnExit?.(this.getExitRestorePrefix(), this.getExitRestoreSuffix());
5052
+ } catch {
5053
+ }
5054
+ };
4905
5055
  get fullRedraws() {
4906
5056
  return this.fullRedrawCount;
4907
5057
  }
@@ -5218,6 +5368,8 @@ var TuiBase = class _TuiBase extends Container {
5218
5368
  }
5219
5369
  start() {
5220
5370
  this.stopped = false;
5371
+ process.off("exit", this.exitRestoreHandler);
5372
+ process.on("exit", this.exitRestoreHandler);
5221
5373
  this.beforeTerminalStart();
5222
5374
  this.terminal.start((data) => this.handleTerminalInput(data), () => this.requestRender());
5223
5375
  this.afterTerminalStart();
@@ -5260,6 +5412,7 @@ var TuiBase = class _TuiBase extends Container {
5260
5412
  }
5261
5413
  stop(options = {}) {
5262
5414
  this.stopped = true;
5415
+ process.off("exit", this.exitRestoreHandler);
5263
5416
  this.cancelRenderTimer();
5264
5417
  if (this.terminalColorSchemeNotificationsEnabled) {
5265
5418
  this.terminal.write("\x1B[?2031l");
@@ -5572,7 +5725,7 @@ var TuiBase = class _TuiBase extends Container {
5572
5725
  for (const entry of visibleEntries) {
5573
5726
  const { component, options } = entry;
5574
5727
  const { width, maxHeight } = this.resolveOverlayLayout(options, 0, termWidth, termHeight);
5575
- let overlayLines = component.render(width);
5728
+ let overlayLines = this.resolveFakeCursors(component.render(width));
5576
5729
  if (maxHeight !== void 0 && overlayLines.length > maxHeight) {
5577
5730
  overlayLines = overlayLines.slice(0, maxHeight);
5578
5731
  }
@@ -5639,6 +5792,19 @@ var TuiBase = class _TuiBase extends Container {
5639
5792
  }
5640
5793
  return null;
5641
5794
  }
5795
+ /**
5796
+ * Resolve fake cursor markers to reverse video. When the hardware cursor is shown, a fake cursor
5797
+ * directly after CURSOR_MARKER is dropped because the terminal cursor is drawn there. Fake cursors
5798
+ * of components without focus have no CURSOR_MARKER and stay visible.
5799
+ */
5800
+ resolveFakeCursors(lines) {
5801
+ return lines.map((line) => {
5802
+ if (!line.includes(FAKE_CURSOR_START))
5803
+ return line;
5804
+ const resolved = this.showHardwareCursor ? line.replace(FOCUSED_FAKE_CURSOR, "$1$2") : line;
5805
+ return resolved.replaceAll(FAKE_CURSOR_START, "\x1B[7m").replaceAll(FAKE_CURSOR_END, "\x1B[27m");
5806
+ });
5807
+ }
5642
5808
  /**
5643
5809
  * Query the terminal's theme colors: the default foreground (OSC 10), the default background
5644
5810
  * (OSC 11), and ANSI colors 0-15 (OSC 4), followed by a DA1 request that marks the end of the
@@ -6449,7 +6615,7 @@ var Input = class {
6449
6615
  const atCursor2 = graphemes2[0]?.segment ?? " ";
6450
6616
  const afterCursor2 = placeholder.slice(atCursor2.length);
6451
6617
  const marker2 = this.focused ? CURSOR_MARKER : "";
6452
- const cursorChar2 = `\x1B[7m${this.placeholderStyle(atCursor2)}\x1B[27m`;
6618
+ const cursorChar2 = renderFakeCursor(this.placeholderStyle(atCursor2));
6453
6619
  const textWithCursor2 = marker2 + cursorChar2 + this.placeholderStyle(afterCursor2);
6454
6620
  const padding2 = " ".repeat(Math.max(0, availableWidth - visibleWidth(textWithCursor2)));
6455
6621
  return [this.prompt + textWithCursor2 + padding2];
@@ -6488,7 +6654,7 @@ var Input = class {
6488
6654
  const atCursor = cursorGrapheme?.segment ?? " ";
6489
6655
  const afterCursor = visibleText.slice(cursorDisplay + atCursor.length);
6490
6656
  const marker = this.focused ? CURSOR_MARKER : "";
6491
- const cursorChar = `\x1B[7m${atCursor}\x1B[27m`;
6657
+ const cursorChar = renderFakeCursor(atCursor);
6492
6658
  const textWithCursor = beforeCursor + marker + cursorChar + afterCursor;
6493
6659
  const visualLength = visibleWidth(textWithCursor);
6494
6660
  const padding = " ".repeat(Math.max(0, availableWidth - visualLength));
@@ -6497,9 +6663,193 @@ var Input = class {
6497
6663
  }
6498
6664
  };
6499
6665
 
6666
+ // node_modules/marked-cjk-friendly/dist/index.js
6667
+ var CJK = "\\u1100-\\u11ff\\u20a9\\u2329-\\u232a\\u2630-\\u2637\\u268a-\\u268f\\u2e80-\\u2e99\\u2e9b-\\u2ef3\\u2f00-\\u2fd5\\u2ff0-\\u303e\\u3041-\\u3096\\u3099-\\u30ff\\u3105-\\u312f\\u3131-\\u318e\\u3190-\\u31e5\\u31ef-\\u321e\\u3220-\\u3247\\u3250-\\ua48c\\ua490-\\ua4c6\\ua960-\\ua97c\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufaff\\ufe10-\\ufe19\\ufe30-\\ufe52\\ufe54-\\ufe66\\ufe68-\\ufe6b\\uff01-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc\\uffe0-\\uffe6\\uffe8-\\uffee\\u{16fe0}-\\u{16fe4}\\u{16ff0}-\\u{16ff6}\\u{17000}-\\u{18cda}\\u{18cff}-\\u{18d20}\\u{18d80}-\\u{18df2}\\u{18e00}-\\u{19191}\\u{191a0}-\\u{191d2}\\u{1aff0}-\\u{1aff3}\\u{1aff5}-\\u{1affb}\\u{1affd}-\\u{1affe}\\u{1b000}-\\u{1b128}\\u{1b132}\\u{1b150}-\\u{1b152}\\u{1b155}\\u{1b164}-\\u{1b168}\\u{1b170}-\\u{1b2fb}\\u{1d300}-\\u{1d356}\\u{1d360}-\\u{1d376}\\u{1f1ae}\\u{1f200}\\u{1f202}\\u{1f210}-\\u{1f219}\\u{1f21b}-\\u{1f22e}\\u{1f230}-\\u{1f231}\\u{1f237}\\u{1f23b}\\u{1f240}-\\u{1f248}\\u{1f260}-\\u{1f265}\\u{1f7da}\\u{20000}-\\u{3fffd}";
6668
+ var cjkTest = new RegExp(`[${CJK}]`, "u");
6669
+ var punctuationCjk = new RegExp(`^((?![*_])[\\s\\p{P}\\p{S}${CJK}])`, "u");
6670
+ function buildRDelimAst(punct, punctSpace, notPunctSpace) {
6671
+ return new RegExp(`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)${punct}(\\*+)(?=[\\s]|$)|${notPunctSpace}(\\*+)(?!\\*)(?=${punctSpace}|$)|(?!\\*)${punctSpace}(\\*+)(?=${notPunctSpace})|[\\s](\\*+)(?!\\*)(?=${punct})|(?!\\*)${punct}(\\*+)(?!\\*)(?=${punct})|${notPunctSpace}(\\*+)(?=${notPunctSpace})`, "gu");
6672
+ }
6673
+ function buildRDelimUnd(punct, punctSpace, notPunctSpace) {
6674
+ return new RegExp(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)${punct}(_+)(?=[\\s]|$)|${notPunctSpace}(_+)(?!_)(?=${punctSpace}|$)|(?!_)${punctSpace}(_+)(?=${notPunctSpace})|[\\s](_+)(?!_)(?=${punct})|(?!_)${punct}(_+)(?!_)(?=${punct})`, "gu");
6675
+ }
6676
+ function buildRDelimDel(punct, punctSpace, notPunctSpace) {
6677
+ return new RegExp(`^[^~]+(?=[^~])|(?!~)${punct}(~~?)(?=[\\s]|$)|${notPunctSpace}(~~?)(?!~)(?=${punctSpace}|$)|(?!~)${punctSpace}(~~?)(?=${notPunctSpace})|[\\s](~~?)(?!~)(?=${punct})|(?!~)${punct}(~~?)(?!~)(?=${punct})|${notPunctSpace}(~~?)(?=${notPunctSpace})`, "gu");
6678
+ }
6679
+ var cjkPunct = `[\\p{P}\\p{S}${CJK}]`;
6680
+ var cjkPunctSpace = `[\\s\\p{P}\\p{S}${CJK}]`;
6681
+ var cjkNotPunctSpace = `[^\\s\\p{P}\\p{S}${CJK}]`;
6682
+ var cjkDelPunct = `(?![*_])[\\p{P}\\p{S}${CJK}]`;
6683
+ var cjkDelPunctSpace = `(?![*_])[\\s\\p{P}\\p{S}${CJK}]`;
6684
+ var cjkDelNotPunctSpace = `(?:[^\\s\\p{P}\\p{S}${CJK}]|[*_])`;
6685
+ var cjkPunctGfm = `(?!~)[\\p{P}\\p{S}${CJK}]`;
6686
+ var cjkPunctSpaceGfm = `(?!~)[\\s\\p{P}\\p{S}${CJK}]`;
6687
+ var cjkNotPunctSpaceGfm = `(?:[^\\s\\p{P}\\p{S}${CJK}]|~)`;
6688
+ var emStrongRDelimAstCjk = buildRDelimAst(cjkPunct, cjkPunctSpace, cjkNotPunctSpace);
6689
+ var emStrongRDelimAstCjkGfm = buildRDelimAst(cjkPunctGfm, cjkPunctSpaceGfm, cjkNotPunctSpaceGfm);
6690
+ var emStrongRDelimUndCjk = buildRDelimUnd(cjkPunct, cjkPunctSpace, cjkNotPunctSpace);
6691
+ var delRDelimCjk = buildRDelimDel(cjkDelPunct, cjkDelPunctSpace, cjkDelNotPunctSpace);
6692
+ function isPrevCharCjk(prevChar, maskedSrc, src) {
6693
+ let prevIsCjk = punctuationCjk.test(prevChar);
6694
+ if (!prevIsCjk && prevChar) {
6695
+ const prevIdx = maskedSrc.length - src.length;
6696
+ if (prevIdx >= 1) {
6697
+ let idx = prevIdx - 1;
6698
+ let code = maskedSrc.charCodeAt(idx);
6699
+ if (code >= 65024 && code <= 65038 && idx >= 1) {
6700
+ idx--;
6701
+ code = maskedSrc.charCodeAt(idx);
6702
+ }
6703
+ if ((code & 64512) === 56320 && idx >= 1) {
6704
+ const cp = maskedSrc.codePointAt(idx - 1);
6705
+ if (cp !== void 0 && cp > 65535) {
6706
+ if (cp >= 917760 && cp <= 917999) prevIsCjk = true;
6707
+ else prevIsCjk = cjkTest.test(String.fromCodePoint(cp));
6708
+ }
6709
+ } else prevIsCjk = cjkTest.test(String.fromCharCode(code));
6710
+ }
6711
+ }
6712
+ return prevIsCjk;
6713
+ }
6714
+ function isCjkAdjacentToDelimiter(rightMatch, clippedMaskedSrc) {
6715
+ if (!(rightMatch[1] || rightMatch[2] || rightMatch[3] || rightMatch[4])) return false;
6716
+ const charBefore = String.fromCodePoint(rightMatch[0].codePointAt(0));
6717
+ const afterPos = rightMatch.index + rightMatch[0].length;
6718
+ const charAfter = afterPos < clippedMaskedSrc.length ? String.fromCodePoint(clippedMaskedSrc.codePointAt(afterPos)) : "";
6719
+ return cjkTest.test(charBefore) || cjkTest.test(charAfter);
6720
+ }
6721
+ function usesModernEmStrongLayout(match) {
6722
+ return match.length >= 5;
6723
+ }
6724
+ function hasEmStrongLeadContent(match) {
6725
+ return Boolean(match[1] || match[2] || match[3] || match[4]);
6726
+ }
6727
+ function isEmStrongUnderscoreWordChar(match) {
6728
+ return usesModernEmStrongLayout(match) ? Boolean(match[4]) : Boolean(match[3]);
6729
+ }
6730
+ function getEmStrongOpeningPunctuation(match) {
6731
+ if (usesModernEmStrongLayout(match)) return match[1] || match[3] || "";
6732
+ return match[1] || match[2] || "";
6733
+ }
6734
+ function markedCjkFriendly() {
6735
+ return { tokenizer: {
6736
+ emStrong(src, maskedSrc, prevChar = "") {
6737
+ const { rules } = this;
6738
+ const match = rules.inline.emStrongLDelim.exec(src);
6739
+ if (!match) return false;
6740
+ const modernEmStrongLayout = usesModernEmStrongLayout(match);
6741
+ if (modernEmStrongLayout && !hasEmStrongLeadContent(match)) return;
6742
+ if (isEmStrongUnderscoreWordChar(match) && prevChar.match(rules.other.unicodeAlphaNumeric)) return false;
6743
+ const nextChar = getEmStrongOpeningPunctuation(match);
6744
+ const prevIsCjk = isPrevCharCjk(prevChar, maskedSrc, src);
6745
+ if (!nextChar || !prevChar || rules.inline.punctuation.exec(prevChar) || prevIsCjk || cjkTest.test(nextChar)) {
6746
+ const lLength = [...match[0]].length - 1;
6747
+ let rDelim;
6748
+ let rLength;
6749
+ let delimTotal = lLength;
6750
+ let midDelimTotal = 0;
6751
+ const prevCharIsSameDelimiter = modernEmStrongLayout && prevChar === match[0][0];
6752
+ const isGfm = rules.inline.emStrongRDelimAst.source.includes("(?!~)");
6753
+ let endReg;
6754
+ if (match[0][0] === "*") endReg = isGfm ? emStrongRDelimAstCjkGfm : emStrongRDelimAstCjk;
6755
+ else endReg = emStrongRDelimUndCjk;
6756
+ endReg.lastIndex = 0;
6757
+ const clippedMaskedSrc = maskedSrc.slice(-1 * src.length + lLength);
6758
+ let rMatch;
6759
+ while ((rMatch = endReg.exec(clippedMaskedSrc)) != null) {
6760
+ rDelim = rMatch[1] || rMatch[2] || rMatch[3] || rMatch[4] || rMatch[5] || rMatch[6];
6761
+ if (!rDelim) continue;
6762
+ rLength = [...rDelim].length;
6763
+ const isCjkAdjacent = isCjkAdjacentToDelimiter(rMatch, clippedMaskedSrc);
6764
+ const isLeftOnly = Boolean(rMatch[3] || rMatch[4]);
6765
+ const isBoth = Boolean(rMatch[5] || rMatch[6]);
6766
+ if (isLeftOnly && !isCjkAdjacent) {
6767
+ delimTotal += rLength;
6768
+ continue;
6769
+ }
6770
+ if (isBoth || isCjkAdjacent) {
6771
+ if (lLength % 3 && !((lLength + rLength) % 3)) {
6772
+ midDelimTotal += rLength;
6773
+ continue;
6774
+ }
6775
+ if (prevCharIsSameDelimiter && isBoth) break;
6776
+ }
6777
+ delimTotal -= rLength;
6778
+ if (delimTotal > 0) continue;
6779
+ rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
6780
+ const lastCharLength = rMatch[0].codePointAt(0) > 65535 ? 2 : 1;
6781
+ const raw = src.slice(0, lLength + rMatch.index + lastCharLength + rLength);
6782
+ if (Math.min(lLength, rLength) % 2) {
6783
+ const text2 = raw.slice(1, -1);
6784
+ return {
6785
+ type: "em",
6786
+ raw,
6787
+ text: text2,
6788
+ tokens: this.lexer.inlineTokens(text2)
6789
+ };
6790
+ }
6791
+ const text = raw.slice(2, -2);
6792
+ return {
6793
+ type: "strong",
6794
+ raw,
6795
+ text,
6796
+ tokens: this.lexer.inlineTokens(text)
6797
+ };
6798
+ }
6799
+ }
6800
+ },
6801
+ del(src, maskedSrc, prevChar = "") {
6802
+ const { rules } = this;
6803
+ const match = rules.inline.delLDelim.exec(src);
6804
+ if (!match) return false;
6805
+ const nextChar = match[1] || "";
6806
+ const prevIsCjk = isPrevCharCjk(prevChar, maskedSrc, src);
6807
+ if (!nextChar || !prevChar || rules.inline.punctuation.exec(prevChar) || prevIsCjk || cjkTest.test(nextChar)) {
6808
+ const lLength = [...match[0]].length - 1;
6809
+ let rDelim;
6810
+ let rLength;
6811
+ let delimTotal = lLength;
6812
+ delRDelimCjk.lastIndex = 0;
6813
+ const clippedMaskedSrc = maskedSrc.slice(-1 * src.length + lLength);
6814
+ let rMatch;
6815
+ while ((rMatch = delRDelimCjk.exec(clippedMaskedSrc)) != null) {
6816
+ rDelim = rMatch[1] || rMatch[2] || rMatch[3] || rMatch[4] || rMatch[5] || rMatch[6];
6817
+ if (!rDelim) continue;
6818
+ rLength = [...rDelim].length;
6819
+ if (rLength !== lLength) continue;
6820
+ const isCjkAdjacent = isCjkAdjacentToDelimiter(rMatch, clippedMaskedSrc);
6821
+ if ((rMatch[3] || rMatch[4]) && !isCjkAdjacent) {
6822
+ delimTotal += rLength;
6823
+ continue;
6824
+ }
6825
+ delimTotal -= rLength;
6826
+ if (delimTotal > 0) continue;
6827
+ rLength = Math.min(rLength, rLength + delimTotal);
6828
+ const lastCharLength = rMatch[0].codePointAt(0) > 65535 ? 2 : 1;
6829
+ const raw = src.slice(0, lLength + rMatch.index + lastCharLength + rLength);
6830
+ const text = raw.slice(lLength, -lLength);
6831
+ return {
6832
+ type: "del",
6833
+ raw,
6834
+ text,
6835
+ tokens: this.lexer.inlineTokens(text)
6836
+ };
6837
+ }
6838
+ }
6839
+ }
6840
+ } };
6841
+ }
6842
+
6500
6843
  // node_modules/@earendil-works/pi-tui/dist/components/markdown.js
6501
6844
  var STRICT_STRIKETHROUGH_REGEX = /^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/;
6502
- var StrictStrikethroughTokenizer = class extends y {
6845
+ var MarkdownTokenizer = class extends y {
6846
+ url(src) {
6847
+ const token = super.url(src);
6848
+ if (!token)
6849
+ return void 0;
6850
+ const punctuationIndex = token.raw.search(cjkPunctuationRegex);
6851
+ return punctuationIndex < 0 ? token : super.url(token.raw.slice(0, punctuationIndex));
6852
+ }
6503
6853
  del(src) {
6504
6854
  const match = STRICT_STRIKETHROUGH_REGEX.exec(src);
6505
6855
  if (!match) {
@@ -6567,21 +6917,32 @@ function tokenizeInlineLatex(source) {
6567
6917
  const raw = source.slice(0, closingIndex + closing.length);
6568
6918
  return { type: "latex", raw, text };
6569
6919
  }
6920
+ var TABLE_DELIMITER_ROW_REGEX = /^ {0,3}\|?[ \t]*:?-+:?[ \t]*(?:\|[ \t]*:?-+:?[ \t]*)*\|?[ \t]*$/;
6921
+ function containsTableStart(source) {
6922
+ const lines = source.split("\n");
6923
+ for (let index = 0; index < lines.length - 1; index++) {
6924
+ const delimiterRow = lines[index + 1];
6925
+ if ((delimiterRow.includes("|") || lines[index].includes("|")) && TABLE_DELIMITER_ROW_REGEX.test(delimiterRow)) {
6926
+ return true;
6927
+ }
6928
+ }
6929
+ return false;
6930
+ }
6570
6931
  function tokenizeBlockLatex(source) {
6571
6932
  const dollarMatch = /^ {0,3}\$\$[ \t]*(?:\n)?([\s\S]*?)\$\$[ \t]*(?:\n|$)/.exec(source);
6572
- if (dollarMatch?.[1]) {
6933
+ if (dollarMatch?.[1] && !containsTableStart(dollarMatch[1])) {
6573
6934
  return { type: "latexBlock", raw: dollarMatch[0], text: dollarMatch[1].trim() };
6574
6935
  }
6575
6936
  const bracketMatch = /^ {0,3}\\\[[ \t]*(?:\n)?([\s\S]*?)\\\][ \t]*(?:\n|$)/.exec(source);
6576
- if (bracketMatch?.[1]) {
6937
+ if (bracketMatch?.[1] && !containsTableStart(bracketMatch[1])) {
6577
6938
  return { type: "latexBlock", raw: bracketMatch[0], text: bracketMatch[1].trim() };
6578
6939
  }
6579
6940
  const pendingBracket = /^ {0,3}\\\[[ \t]*(?:\n)?([\s\S]*)$/.exec(source);
6580
- if (pendingBracket) {
6941
+ if (pendingBracket?.[1] && !containsTableStart(pendingBracket[1])) {
6581
6942
  return { type: "latexBlock", raw: pendingBracket[0], text: pendingBracket[1], pending: true };
6582
6943
  }
6583
6944
  const pendingDollar = /^ {0,3}\$\$[ \t]*(?:\n)?([\s\S]*)$/.exec(source);
6584
- if (pendingDollar?.[1] && looksLikePendingDollarMath(pendingDollar[1])) {
6945
+ if (pendingDollar?.[1] && looksLikePendingDollarMath(pendingDollar[1]) && !containsTableStart(pendingDollar[1])) {
6585
6946
  return { type: "latexBlock", raw: pendingDollar[0], text: pendingDollar[1], pending: true };
6586
6947
  }
6587
6948
  return void 0;
@@ -6608,9 +6969,12 @@ var LATEX_MARKDOWN_EXTENSIONS = [
6608
6969
  ];
6609
6970
  var markdownParser = new Z();
6610
6971
  markdownParser.setOptions({
6611
- tokenizer: new StrictStrikethroughTokenizer()
6972
+ tokenizer: new MarkdownTokenizer()
6973
+ });
6974
+ markdownParser.use({
6975
+ tokenizer: { emStrong: markedCjkFriendly().tokenizer?.emStrong },
6976
+ extensions: [...LATEX_MARKDOWN_EXTENSIONS]
6612
6977
  });
6613
- markdownParser.use({ extensions: [...LATEX_MARKDOWN_EXTENSIONS] });
6614
6978
 
6615
6979
  // node_modules/@earendil-works/pi-tui/dist/components/scroll-view.js
6616
6980
  var ScrollView = class extends Container {
@@ -6815,7 +7179,7 @@ var cjsRequire = createRequire2(import.meta.url);
6815
7179
 
6816
7180
  // node_modules/@earendil-works/pi-tui/dist/terminal.js
6817
7181
  var DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS = 7;
6818
- var KITTY_KEYBOARD_PROTOCOL_QUERY = `\x1B[>${DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS}u\x1B[?u\x1B[c`;
7182
+ var KITTY_KEYBOARD_PROTOCOL_QUERY = `\x1B[>${DESIRED_KITTY_KEYBOARD_PROTOCOL_FLAGS}u\x1B[?u`;
6819
7183
 
6820
7184
  // node_modules/@earendil-works/pi-tui/dist/alt-screen-search.js
6821
7185
  var segmenter2 = getGraphemeSegmenter();
@@ -7350,21 +7714,23 @@ function paintBox(box, screen, totalWidth) {
7350
7714
  for (const child of box.children)
7351
7715
  paintBox(child, screen, totalWidth);
7352
7716
  if (box.scrollView && box.scrollContentLines && box.scrollView.scrollTop > 0 && box.rect.height > 0) {
7353
- for (let imageRow = box.scrollView.scrollTop - 1; imageRow >= 0; imageRow--) {
7717
+ const scrollTop = box.scrollView.scrollTop;
7718
+ const minRow = Math.max(0, scrollTop - getMaxKittyImageRows());
7719
+ for (let imageRow = scrollTop - 1; imageRow >= minRow; imageRow--) {
7354
7720
  const imageLine = box.scrollContentLines[imageRow] ?? "";
7721
+ if (!isImageLine(imageLine))
7722
+ continue;
7355
7723
  const metadata = getKittyImageMetadata(imageLine);
7356
- if (metadata) {
7357
- const hiddenRows = box.scrollView.scrollTop - imageRow;
7358
- if (hiddenRows < metadata.rows) {
7359
- const visibleRows = Math.min(box.rect.height, metadata.rows - hiddenRows);
7360
- const cropped = cropKittyImageLine(imageLine, hiddenRows, visibleRows);
7361
- if (box.rect.x === 0 && box.rect.width >= totalWidth)
7362
- screen[box.rect.y] = cropped;
7363
- }
7364
- break;
7724
+ if (!metadata)
7725
+ continue;
7726
+ const hiddenRows = scrollTop - imageRow;
7727
+ if (hiddenRows < metadata.rows) {
7728
+ const visibleRows = Math.min(box.rect.height, metadata.rows - hiddenRows);
7729
+ const cropped = cropKittyImageLine(imageLine, hiddenRows, visibleRows);
7730
+ if (box.rect.x === 0 && box.rect.width >= totalWidth)
7731
+ screen[box.rect.y] = cropped;
7365
7732
  }
7366
- if (imageLine !== "")
7367
- break;
7733
+ break;
7368
7734
  }
7369
7735
  }
7370
7736
  paintScrollbar(box, screen, totalWidth);
@@ -7514,7 +7880,7 @@ var MAX_CACHED_OFFSCREEN_KITTY_TRANSMISSION_BYTES = 32 * 1024 * 1024;
7514
7880
  var MAX_CACHED_OFFSCREEN_KITTY_DECODED_BYTES = 64 * 1024 * 1024;
7515
7881
  var DOUBLE_CLICK_INTERVAL_MS = 500;
7516
7882
  var COPY_ERROR_FLASH_DURATION_MS = 5e3;
7517
- var TERMINAL_WORD_SELECTION_JOINERS = /* @__PURE__ */ new Set(["/", "-"]);
7883
+ var TERMINAL_WORD_SELECTION_JOINERS = /* @__PURE__ */ new Set(["/", "-", "+", "\\", "~", "_", "."]);
7518
7884
  var wordSegmenter4 = getWordSegmenter();
7519
7885
  var TuiAltScreen = class extends TuiBase {
7520
7886
  mode = "fullscreen";
@@ -7612,6 +7978,11 @@ var TuiAltScreen = class extends TuiBase {
7612
7978
  return false;
7613
7979
  return this.copyTextToClipboard(text);
7614
7980
  }
7981
+ /** Drop the text selection and multi-click history, e.g. before the host replaces the transcript. */
7982
+ resetTextSelection() {
7983
+ this.clearTextSelection();
7984
+ this.lastClick = void 0;
7985
+ }
7615
7986
  /** The lines of the last rendered frame, one per terminal row, as written to the terminal. */
7616
7987
  getScreenLines() {
7617
7988
  return [...this.previousScreen];
@@ -7683,7 +8054,7 @@ var TuiAltScreen = class extends TuiBase {
7683
8054
  this.terminal.write(`${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}\x1B[?25h${END_SYNCHRONIZED_OUTPUT}`);
7684
8055
  } else {
7685
8056
  const width = Math.max(1, this.terminal.columns);
7686
- const documentLines = this.render(width).map((line) => line.replace(OSC133_ZONE_PREFIX2, ""));
8057
+ const documentLines = this.resolveFakeCursors(this.render(width)).map((line) => line.replace(OSC133_ZONE_PREFIX2, ""));
7687
8058
  this.lastDocument = this.applyLineResets(documentLines.map((line) => line.replaceAll(CURSOR_MARKER, ""))).map((line) => isImageLine(line) || visibleWidth(line) <= width ? line : sliceByColumn(line, 0, width, true));
7688
8059
  let buffer = `${BEGIN_SYNCHRONIZED_OUTPUT}${EXIT_ALT_SCREEN}${DISABLE_AUTOWRAP}`;
7689
8060
  for (let row = 0; row < this.lastDocument.length; row++) {
@@ -7700,6 +8071,15 @@ var TuiAltScreen = class extends TuiBase {
7700
8071
  this.savedCapabilities = void 0;
7701
8072
  }
7702
8073
  }
8074
+ getExitRestorePrefix() {
8075
+ const prefix = super.getExitRestorePrefix();
8076
+ if (!this.altScreenActive)
8077
+ return prefix;
8078
+ return `${END_SYNCHRONIZED_OUTPUT}${this.mouseEnabled ? DISABLE_MOUSE : ""}${ENABLE_AUTOWRAP}${prefix}`;
8079
+ }
8080
+ getExitRestoreSuffix() {
8081
+ return `${super.getExitRestoreSuffix()}${this.altScreenActive ? `${EXIT_ALT_SCREEN}\x1B[?25h` : ""}`;
8082
+ }
7703
8083
  deleteKittyImages() {
7704
8084
  return this.imageProtocol === "kitty" ? deleteAllKittyImages() : "";
7705
8085
  }
@@ -7920,7 +8300,10 @@ var TuiAltScreen = class extends TuiBase {
7920
8300
  flash(message, durationMs) {
7921
8301
  this.flashes.flash(message, durationMs);
7922
8302
  }
7923
- shouldDeferViewportInputToOverlay() {
8303
+ /** Focused overlays and components that capture viewport input receive viewport keys instead of the transcript. */
8304
+ shouldDeferViewportInput() {
8305
+ if (this.getFocusedComponent()?.capturesViewportInput)
8306
+ return true;
7924
8307
  return this.isOverlayFocused() && this.activeSearch?.overlay?.isFocused() !== true;
7925
8308
  }
7926
8309
  clearComponentMouseGesture() {
@@ -7968,8 +8351,6 @@ var TuiAltScreen = class extends TuiBase {
7968
8351
  this.requestRender();
7969
8352
  return { consume: true };
7970
8353
  }
7971
- if (this.shouldDeferViewportInputToOverlay())
7972
- return void 0;
7973
8354
  this.routeWheel(wheelEvent, wheelDelta);
7974
8355
  return { consume: true };
7975
8356
  }
@@ -8004,7 +8385,7 @@ var TuiAltScreen = class extends TuiBase {
8004
8385
  return { consume: true };
8005
8386
  }
8006
8387
  }
8007
- if (this.shouldDeferViewportInputToOverlay())
8388
+ if (this.shouldDeferViewportInput())
8008
8389
  return void 0;
8009
8390
  if (keybindings.matches(data, "tui.altScreen.pageUp")) {
8010
8391
  if (!isRelease) {
@@ -8840,7 +9221,7 @@ var TuiAltScreen = class extends TuiBase {
8840
9221
  if (this.refreshSearch(nextLayout)) {
8841
9222
  nextLayout = renderLayoutFrame(root, width, height, () => this.requestRender());
8842
9223
  }
8843
- let screen = nextLayout.lines.map((line) => line.replace(OSC133_ZONE_PREFIX2, ""));
9224
+ let screen = this.resolveFakeCursors(nextLayout.lines.map((line) => line.replace(OSC133_ZONE_PREFIX2, "")));
8844
9225
  screen = this.applySearchHighlights(screen, nextLayout);
8845
9226
  screen = this.compositeScrollToEndIndicator(screen, nextLayout, width);
8846
9227
  screen = this.compositeOverlays(screen, width, height);
@@ -10174,8 +10555,13 @@ function retireCompleteCandidates(toolCalls, candidates) {
10174
10555
  }
10175
10556
  var TOOL_ARGUMENT_STRUCTURE = /["\\{}[\]]/g;
10176
10557
  var NON_JSON_WHITESPACE = /[^ \t\r\n]/;
10558
+ var UnusableToolCallError = class extends Error {
10559
+ };
10177
10560
  function invalidToolArguments(state) {
10178
- return new Error(`Invalid or incomplete tool-call JSON (characters=${state.argumentLength})`);
10561
+ return new UnusableToolCallError(`Invalid or incomplete tool-call JSON (characters=${state.argumentLength})`);
10562
+ }
10563
+ function lostToolArgumentStream() {
10564
+ return new Error("Qoder server error: tool-call argument stream was cut off (unparseable upstream payload)");
10179
10565
  }
10180
10566
  function appendToolArguments(state, fragment) {
10181
10567
  state.argumentChunks.push(fragment);
@@ -10234,7 +10620,7 @@ function parseToolArguments(state) {
10234
10620
  }
10235
10621
  }
10236
10622
  if (args === null || typeof args !== "object" || Array.isArray(args)) {
10237
- throw new Error(`Non-object tool-call arguments (characters=${state.argumentLength})`);
10623
+ throw new UnusableToolCallError(`Non-object tool-call arguments (characters=${state.argumentLength})`);
10238
10624
  }
10239
10625
  state.parsedArguments = args;
10240
10626
  return state.parsedArguments;
@@ -10333,6 +10719,7 @@ function streamQoder(model, context, options) {
10333
10719
  stopReason: "stop",
10334
10720
  timestamp: Date.now()
10335
10721
  };
10722
+ let droppedPayloads = 0;
10336
10723
  (async () => {
10337
10724
  try {
10338
10725
  const providerMode = model.provider === "qoder-cn" ? "cn" : "global";
@@ -10515,6 +10902,7 @@ function streamQoder(model, context, options) {
10515
10902
  let toolCalls;
10516
10903
  const thinkingParser = thinkingEnabled ? new ThinkingTagParser(output, stream) : null;
10517
10904
  let sawModelOutput = false;
10905
+ droppedPayloads = 0;
10518
10906
  let sawDone = false;
10519
10907
  try {
10520
10908
  while (!sawDone) {
@@ -10536,6 +10924,7 @@ function streamQoder(model, context, options) {
10536
10924
  sawDone = true;
10537
10925
  break;
10538
10926
  }
10927
+ let parsePhase = "envelope";
10539
10928
  try {
10540
10929
  const envelope = JSON.parse(dataStr);
10541
10930
  if (envelope.statusCodeValue && envelope.statusCodeValue !== 200) {
@@ -10567,6 +10956,7 @@ function streamQoder(model, context, options) {
10567
10956
  break;
10568
10957
  }
10569
10958
  if (!innerStr) continue;
10959
+ parsePhase = "payload";
10570
10960
  const inner = JSON.parse(innerStr);
10571
10961
  if (inner.id) output.responseId = inner.id;
10572
10962
  if (inner.model) output.responseModel = inner.model;
@@ -10756,6 +11146,7 @@ function streamQoder(model, context, options) {
10756
11146
  }
10757
11147
  } catch (e) {
10758
11148
  if (e instanceof SyntaxError) {
11149
+ if (parsePhase === "payload") droppedPayloads += 1;
10759
11150
  if (process.env.QODER_DEBUG) {
10760
11151
  console.error("[pi-provider-qoder] skipping malformed SSE line:", dataStr.slice(0, 200));
10761
11152
  }
@@ -10789,7 +11180,7 @@ function streamQoder(model, context, options) {
10789
11180
  if (toolCalls) {
10790
11181
  for (const state of toolCalls.states) {
10791
11182
  if (!state.id || !state.name) {
10792
- throw new Error(`Unresolved tool-call identity (characters=${state.argumentLength})`);
11183
+ throw new UnusableToolCallError(`Unresolved tool-call identity (characters=${state.argumentLength})`);
10793
11184
  }
10794
11185
  parseToolArguments(state);
10795
11186
  }
@@ -10884,7 +11275,27 @@ function streamQoder(model, context, options) {
10884
11275
  }
10885
11276
  }
10886
11277
  } catch (e) {
10887
- output.stopReason = options?.signal?.aborted ? "aborted" : "error";
11278
+ const aborted = options?.signal?.aborted === true;
11279
+ if (!aborted && droppedPayloads > 0 && e instanceof UnusableToolCallError) {
11280
+ if (process.env.QODER_DEBUG) {
11281
+ console.error(
11282
+ `[pi-provider-qoder] lost tool-call argument stream: ${e.message}, droppedPayloads=${droppedPayloads}`
11283
+ );
11284
+ }
11285
+ const terminal = {
11286
+ ...output,
11287
+ content: output.content.filter((block) => block.type !== "toolCall"),
11288
+ stopReason: "error",
11289
+ errorMessage: lostToolArgumentStream().message
11290
+ };
11291
+ stream.push({ type: "error", reason: "error", error: terminal });
11292
+ try {
11293
+ stream.end();
11294
+ } catch {
11295
+ }
11296
+ return;
11297
+ }
11298
+ output.stopReason = aborted ? "aborted" : "error";
10888
11299
  output.errorMessage = e instanceof Error ? e.message : String(e);
10889
11300
  stream.push({ type: "error", reason: output.stopReason, error: output });
10890
11301
  try {