nolo-cli 0.33.0-alpha.3 → 0.33.0-alpha.30

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 (148) hide show
  1. package/{_executeModel-RWPVI3YV.js → _executeModel-G2YBBSYF.js} +53 -53
  2. package/{action-SMLG6OTB.js → action-4KWNL4XI.js} +10 -10
  3. package/{addContentAction-SFO244QN.js → addContentAction-SUL5AFLY.js} +8 -8
  4. package/{addDialogAgentAction-W44ZCEHB.js → addDialogAgentAction-T645TULN.js} +7 -7
  5. package/{agentDeleteCommand-KU2RXQPP.js → agentDeleteCommand-DZPB57QC.js} +47 -43
  6. package/{agentEmailCommands-MPCMDENS.js → agentEmailCommands-5UPJMRRT.js} +79 -75
  7. package/{agentListCommands-EPD4N6FX.js → agentListCommands-FHWEJ56M.js} +47 -42
  8. package/{agentMachineCommands-AF7C3YRT.js → agentMachineCommands-FNVJTZ3J.js} +44 -40
  9. package/agentProviderCommands-65ZC2WB4.js +122 -0
  10. package/{agentPullCommand-YH5GEBK4.js → agentPullCommand-NYHSK6EW.js} +3 -3
  11. package/{agentRecordCommands-EYE6MZZG.js → agentRecordCommands-JN2L5AMM.js} +70 -66
  12. package/{agentRunCommand-LL22SGTN.js → agentRunCommand-R57HN7XZ.js} +76 -71
  13. package/{agentRuntimeLocal-JX34G47Z.js → agentRuntimeLocal-MXIGYCZW.js} +32 -29
  14. package/{agentSlice-TNMFQQOV.js → agentSlice-L3S542FP.js} +10 -10
  15. package/{appDeleteCommands-43K5VXQB.js → appDeleteCommands-LF6HKT65.js} +39 -35
  16. package/{appDeployCommands-FEEJSVDZ.js → appDeployCommands-S5M2FFQS.js} +39 -35
  17. package/{appDeployStatusCommands-H76CG45R.js → appDeployStatusCommands-AVT2B5LY.js} +39 -35
  18. package/{appGetCommands-MDZYFTYZ.js → appGetCommands-ACH4E3F4.js} +39 -35
  19. package/{appListCommands-TUJJXPWG.js → appListCommands-LKI2VES7.js} +39 -35
  20. package/{authCommand-T7UK4CWS.js → authCommand-AECKBG65.js} +21 -20
  21. package/{authCommands-EAPFGNHN.js → authCommands-W74NRPA6.js} +6 -6
  22. package/{chatQueueReduxAdapter-LVQXC4ZY.js → chatQueueReduxAdapter-WJXO2JCG.js} +23 -22
  23. package/{chunk-HDKRSRYU.js → chunk-326E2B5C.js} +289 -93
  24. package/{chunk-2UECQ7RE.js → chunk-3AOLVADY.js} +1 -1
  25. package/{chunk-M2YMQOLC.js → chunk-3CPL3LU2.js} +11 -11
  26. package/chunk-3Z32AD6X.js +22 -0
  27. package/{chunk-HUCT7HID.js → chunk-42IF53CR.js} +1 -1
  28. package/{chunk-5SBK2MTI.js → chunk-64M2WCLT.js} +23 -70
  29. package/{chunk-LOD75GOS.js → chunk-674FTH5U.js} +3751 -1557
  30. package/{chunk-AOXVOC6D.js → chunk-6O5DMZOS.js} +3 -3
  31. package/{chunk-GMXWYXAF.js → chunk-7AXGPKX5.js} +3 -3
  32. package/{chunk-FMEVI5TG.js → chunk-7CH6U3FL.js} +1 -1
  33. package/{chunk-OR2HNLVO.js → chunk-7EPNNOL4.js} +6 -6
  34. package/{chunk-DFUPZE6V.js → chunk-7SLMYTSF.js} +1 -1
  35. package/{chunk-BQXOGBFN.js → chunk-A2YCVTV6.js} +1 -1
  36. package/{chunk-UK5JGQVU.js → chunk-A3UZKNUI.js} +13 -18
  37. package/{chunk-3GZXL6FM.js → chunk-AOWETAXX.js} +1 -1
  38. package/{chunk-B2BSG6QQ.js → chunk-ASWSPCJH.js} +18 -18
  39. package/{chunk-CLP2K7U4.js → chunk-BP3FSWKY.js} +6 -6
  40. package/{chunk-IHEC7VBF.js → chunk-BW7JSRVT.js} +1 -1
  41. package/{chunk-AAGCMVFT.js → chunk-BYXLXABD.js} +495 -148
  42. package/{chunk-MPZJVZDC.js → chunk-CDSTQJIJ.js} +27 -27
  43. package/{chunk-2H3XIBY4.js → chunk-D2CTCWWG.js} +4 -82
  44. package/{chunk-OIQPORYI.js → chunk-ECHNSF4H.js} +178 -2
  45. package/{chunk-TFPUAELY.js → chunk-EIWIUEOH.js} +2 -2
  46. package/{chunk-JTSGWTYZ.js → chunk-EMKX4VZW.js} +2 -2
  47. package/{chunk-6HYVJV7B.js → chunk-ESHYE7WU.js} +2 -1
  48. package/{chunk-ZURFOV5J.js → chunk-FS5VNMPF.js} +3 -3
  49. package/{chunk-U4TRT5V4.js → chunk-GEPHJJW4.js} +1 -1
  50. package/{chunk-5CS33IBL.js → chunk-GKAQBXBO.js} +11 -12
  51. package/{chunk-M4NC7NF6.js → chunk-GMSUMWFO.js} +2 -2
  52. package/{chunk-JMPYDFHY.js → chunk-HLXJXFXN.js} +21 -8
  53. package/{chunk-I6N2UVVY.js → chunk-JZUS5GOM.js} +1 -1
  54. package/{chunk-RAZOLMJR.js → chunk-KVRWX6K7.js} +2 -2
  55. package/{chunk-VH2F7ZB6.js → chunk-L4O5JAIW.js} +1 -1
  56. package/{chunk-57QJXIB6.js → chunk-L7EJWFAP.js} +9 -9
  57. package/{chunk-DPMBNHOJ.js → chunk-LAZTMWIU.js} +1 -1
  58. package/{chunk-ADLYMQB6.js → chunk-MBUNBGBE.js} +127 -0
  59. package/{chunk-Q5ITEGIN.js → chunk-N4XRDM26.js} +1 -1
  60. package/{chunk-7E72JMBB.js → chunk-N543Q3VR.js} +57 -16
  61. package/{chunk-WHD6BG7M.js → chunk-NEG2ROC2.js} +45 -41
  62. package/{chunk-2IVEXF7P.js → chunk-NMB23CNE.js} +2 -9
  63. package/{chunk-XCCGU6QB.js → chunk-NQWDSCDT.js} +1 -1
  64. package/{chunk-FSSX3XRY.js → chunk-NTOLFNU3.js} +1 -1
  65. package/chunk-OH4Q4VVA.js +38 -0
  66. package/{chunk-37V5LNEQ.js → chunk-OOG3PQCH.js} +1 -1
  67. package/{chunk-3WXRAHCG.js → chunk-OPSKBBSX.js} +3 -3
  68. package/{chunk-AFV4FOT2.js → chunk-OQVRTSZ5.js} +4 -91
  69. package/{chunk-GTYM4HKV.js → chunk-OXLUSM42.js} +5 -5
  70. package/{chunk-YDTYDA5W.js → chunk-PAW3XFD3.js} +8 -6
  71. package/{chunk-PREQU5QV.js → chunk-PECRHVNK.js} +1 -1
  72. package/{chunk-O6GEBMIY.js → chunk-PVJS353C.js} +8861 -8608
  73. package/{chunk-JZPBVBIY.js → chunk-QTZD6HBK.js} +18 -8
  74. package/chunk-TVXJEOU2.js +78 -0
  75. package/{chunk-3VAQHAXT.js → chunk-UFMFWBSG.js} +26 -26
  76. package/{chunk-73GINUCW.js → chunk-UGWIRZO6.js} +129 -50
  77. package/{chunk-NUO3QFWD.js → chunk-UNHKVD2N.js} +1 -1
  78. package/{chunk-GE6IWA5N.js → chunk-UNZDCI3O.js} +126 -1
  79. package/chunk-UOLENXLQ.js +1132 -0
  80. package/{chunk-FXFGNOT2.js → chunk-VFVCYIRQ.js} +1 -1
  81. package/chunk-VIRTYWWE.js +97 -0
  82. package/{chunk-6SXC35F4.js → chunk-VMAK5YKS.js} +12 -12
  83. package/{chunk-ZJMME4DS.js → chunk-W6NT2FW3.js} +6 -6
  84. package/{chunk-2QTEYCR7.js → chunk-X65PIFJI.js} +17 -7
  85. package/{chunk-JZ5AMMXU.js → chunk-XBNLE3MR.js} +3 -3
  86. package/{chunk-WLH5BAKX.js → chunk-YYTTDOWA.js} +2 -2
  87. package/{chunk-X2DAEZ3X.js → chunk-ZFGAPMSF.js} +1 -1
  88. package/{chunk-IL545V3E.js → chunk-ZJVSRWOP.js} +7 -7
  89. package/{cliExecutor-DW3PHGEL.js → cliExecutor-BBUVQU4L.js} +2 -2
  90. package/{codingSkills-DY5MINPG.js → codingSkills-5VOV3JVB.js} +3 -3
  91. package/{createAgentAutomationAction-INQT23LX.js → createAgentAutomationAction-RMKFWLA3.js} +24 -23
  92. package/{createDialogAction-LDCPDI73.js → createDialogAction-BLNYPWJ6.js} +27 -26
  93. package/{createPageAction-5YXOG2M4.js → createPageAction-MSJTHWS7.js} +28 -27
  94. package/{dbSlice-3SD5L5H2.js → dbSlice-YBUD2NZB.js} +7 -7
  95. package/{deleteFile-XQXPBFFB.js → deleteFile-74VF4EAJ.js} +4 -4
  96. package/{dialogCommands-CHJO47AX.js → dialogCommands-JI6X34PB.js} +38 -34
  97. package/{dialogSlice-DOWKOILN.js → dialogSlice-MJAX2T2X.js} +23 -22
  98. package/{docCreateCommands-OVZARUFX.js → docCreateCommands-KNLITDCK.js} +40 -36
  99. package/{docDeleteCommands-E2XJ62LD.js → docDeleteCommands-6SBOU75S.js} +41 -37
  100. package/{docReadCommands-I7OSREPJ.js → docReadCommands-NX77P5X4.js} +40 -36
  101. package/{docStore-UAWSKZ2Y.js → docStore-472FHNNN.js} +25 -24
  102. package/{docUpdateCommands-X4Z26VJM.js → docUpdateCommands-IHWNHH4O.js} +43 -39
  103. package/emscripten-module-EDQBMDVK.js +576 -0
  104. package/emscripten-module-LCBQ7VWY.js +1506 -0
  105. package/emscripten-module-OFHQ7EL3.js +482 -0
  106. package/emscripten-module-XM7NDJQA.js +4536 -0
  107. package/fetchMessages-7QRCCRYK.js +1 -1
  108. package/ffi-6ZSX3QJ4.js +80 -0
  109. package/ffi-742Y76PE.js +92 -0
  110. package/ffi-AEYWSYLM.js +80 -0
  111. package/ffi-KQC27OUM.js +92 -0
  112. package/{getPricing-L2ENXWHV.js → getPricing-J4VXWR5B.js} +4 -4
  113. package/{handleSendMessageAction-C3TSDWKH.js → handleSendMessageAction-V3SKWOOV.js} +26 -25
  114. package/index.js +78 -74
  115. package/{localRuntimeAuthority-E3R24J4T.js → localRuntimeAuthority-S77B5QVB.js} +6 -2
  116. package/{localRuntimeDb-DDZCJFQZ.js → localRuntimeDb-N3H3HQ7G.js} +1 -1
  117. package/{machineCommands-BUOIYJAD.js → machineCommands-ZDULQKUU.js} +80 -76
  118. package/{machineInfo-M6KB6HZN.js → machineInfo-66ZFUMLE.js} +1 -1
  119. package/{machineWsRunDispatch-7CRWAA6O.js → machineWsRunDispatch-XX2LNRJT.js} +68 -64
  120. package/{models-OX2S5C6Q.js → models-FM7YJ47W.js} +2 -2
  121. package/module-ES6BEMUI-AFCVSBMS.js +14 -0
  122. package/module-asyncify-2EFITU5U-DEP2F2QP.js +9 -0
  123. package/package.json +1 -1
  124. package/{read-6G73BMEY.js → read-7SIURKBF.js} +5 -5
  125. package/{readDocTool-DK4EI2GA.js → readDocTool-NWQFQ4IG.js} +1 -1
  126. package/{readlineWorkspace-ZDWEASJV.js → readlineWorkspace-NXB4IBLM.js} +3886 -3344
  127. package/{removeDialogAgentAction-E7H557UO.js → removeDialogAgentAction-S3LYHK4M.js} +11 -11
  128. package/{runAgentClientLoop-U7HYA3O5.js → runAgentClientLoop-TNETRJFJ.js} +50 -49
  129. package/{runtimeDoctorCommands-KIKM6BIO.js → runtimeDoctorCommands-HT4O2PXL.js} +6 -6
  130. package/{setDialogExtraReferencesAction-RMMGBR5F.js → setDialogExtraReferencesAction-L5ET3HEX.js} +8 -8
  131. package/{setPrimaryDialogAgentAction-FWBKKLVA.js → setPrimaryDialogAgentAction-ZZJOZQEM.js} +11 -11
  132. package/{settingSlice-73PV4KG4.js → settingSlice-ZFOZPBI2.js} +9 -9
  133. package/{skillDiscovery-KLLKXPUO.js → skillDiscovery-6YSTRCQ7.js} +3 -3
  134. package/{spaceCommands-GEWZXGHM.js → spaceCommands-CAWUGXJS.js} +44 -40
  135. package/{spaceSlice-B6MOVY4N.js → spaceSlice-J5D3LTMO.js} +24 -23
  136. package/{streamAgentChatTurn-T527EQTT.js → streamAgentChatTurn-YI5O3T4X.js} +104 -114
  137. package/{switchDialogAgentAction-US6QNL3N.js → switchDialogAgentAction-ZWCYLWVK.js} +7 -7
  138. package/{tableCommands-QE47K72R.js → tableCommands-5OKD2DKN.js} +8 -8
  139. package/{tools-XMWCVMPM.js → tools-HI4U6J6S.js} +39 -38
  140. package/{tuiSummaryLlmCaller-NCAJSVSD.js → tuiSummaryLlmCaller-3RC6WWRV.js} +15 -14
  141. package/{updateCommands-AK2RDOFR.js → updateCommands-MNDUIKN7.js} +2 -2
  142. package/{updateDialogTitleAction-XPJZRJEL.js → updateDialogTitleAction-V5H4LWFR.js} +30 -29
  143. package/chunk-6PO2SYCS.js +0 -1800
  144. package/{agentGrantCommands-2LEZDADN.js → agentGrantCommands-OPIGFRDO.js} +2 -2
  145. package/{chunk-ZHYK3N56.js → chunk-G7HTVVFL.js} +3 -3
  146. package/{chunk-SAQQLJZ5.js → chunk-JDSUTNYY.js} +3 -3
  147. package/{chunk-X664KVEV.js → chunk-QM6EN2ES.js} +3 -3
  148. package/{offlineMarxistsAgentCommand-GEH6SNNA.js → offlineMarxistsAgentCommand-HDIQVGKN.js} +3 -3
@@ -1,3 +1,6 @@
1
+ import {
2
+ resolveMachineId
3
+ } from "./chunk-ESHYE7WU.js";
1
4
  import {
2
5
  buildLocalRunEnv,
3
6
  isFullstackCodingAgentRef,
@@ -6,25 +9,26 @@ import {
6
9
  resolveRawAgentInput,
7
10
  resolveServerUrl,
8
11
  writeUsage
9
- } from "./chunk-ZHYK3N56.js";
10
- import {
11
- getReadableCliDb
12
- } from "./chunk-NUO3QFWD.js";
13
- import {
14
- normalizeAgentHandle,
15
- readDbRecord,
16
- resolveAgentRecordFromHybridStore
17
- } from "./chunk-YDTYDA5W.js";
12
+ } from "./chunk-G7HTVVFL.js";
18
13
  import {
19
14
  agentRunCardLabels,
20
15
  createCliLocalRuntimeAdapter,
21
16
  getCliLocale,
22
17
  isBuiltinNoloAgentRef,
23
18
  isSubtaskRun,
19
+ isTransientFetchError,
24
20
  parseAgentRunEvent,
25
21
  t,
26
22
  toolLabel
27
- } from "./chunk-O6GEBMIY.js";
23
+ } from "./chunk-PVJS353C.js";
24
+ import {
25
+ getReadableCliDb
26
+ } from "./chunk-UNHKVD2N.js";
27
+ import {
28
+ normalizeAgentHandle,
29
+ readDbRecord,
30
+ resolveAgentRecordFromHybridStore
31
+ } from "./chunk-PAW3XFD3.js";
28
32
  import {
29
33
  NOLO_PROJECT_MANAGER_AGENT_KEY,
30
34
  isLocalCliAgentKey
@@ -34,37 +38,59 @@ import {
34
38
  buildModelLayerOverride
35
39
  } from "./chunk-LTRXGFMS.js";
36
40
  import {
37
- resolveMachineId
38
- } from "./chunk-6HYVJV7B.js";
41
+ CliProviderQuotaError
42
+ } from "./chunk-JDSUTNYY.js";
43
+ import {
44
+ createRunActivityTracker,
45
+ finalizeRunRecord,
46
+ spawnLocalBackgroundRun
47
+ } from "./chunk-7KNERA53.js";
39
48
  import {
40
49
  formatAgentListCard
41
- } from "./chunk-HDKRSRYU.js";
50
+ } from "./chunk-326E2B5C.js";
42
51
  import {
43
52
  isGatewayHttpStatus
44
53
  } from "./chunk-RQSOAMPJ.js";
45
54
  import {
46
- getDefaultCliLocalRuntimeDb
47
- } from "./chunk-Q5ITEGIN.js";
55
+ formatFinishedRunCard,
56
+ formatListRunsCard,
57
+ formatNotFoundRunCard,
58
+ formatStartRunCard,
59
+ formatStatusRunCard,
60
+ formatStopRunCard,
61
+ isAgentRunTerminalStatus,
62
+ runShowsLogTail
63
+ } from "./chunk-KXKQO4Q6.js";
48
64
  import {
49
65
  buildMemorySubjectsForAgent,
50
66
  chooseMemoryOwners,
51
67
  loadMemoryCandidatesFromDb,
52
68
  resolveAgentMemoryPolicy
53
- } from "./chunk-6SXC35F4.js";
69
+ } from "./chunk-VMAK5YKS.js";
54
70
  import {
55
71
  API_REPORTED_COST_MULTIPLIER,
56
72
  normalizeUsage,
57
73
  parseUiAskChoiceContent
58
- } from "./chunk-73GINUCW.js";
74
+ } from "./chunk-UGWIRZO6.js";
59
75
  import {
60
- resolveAgentRuntimeConfigFromRecord
61
- } from "./chunk-OIQPORYI.js";
76
+ getDefaultCliLocalRuntimeDb
77
+ } from "./chunk-N4XRDM26.js";
78
+ import {
79
+ buildSkillDiscoveryContextLayer
80
+ } from "./chunk-FS5VNMPF.js";
81
+ import {
82
+ parseExternalSkillMarkdown,
83
+ parseSkillDocProtocol
84
+ } from "./chunk-AETZ7AD6.js";
62
85
  import {
63
86
  LOCAL_AGENT_CONFIG_MISSING_CODE,
64
87
  LOCAL_TURN_ABORTED_CODE,
65
88
  readActionGate,
66
89
  readCommandActionGatePayload
67
- } from "./chunk-6PO2SYCS.js";
90
+ } from "./chunk-674FTH5U.js";
91
+ import {
92
+ resolveAgentRuntimeConfigFromRecord
93
+ } from "./chunk-ECHNSF4H.js";
68
94
  import {
69
95
  createThinkParserState,
70
96
  flushThinkParser,
@@ -72,62 +98,33 @@ import {
72
98
  } from "./chunk-N7J63Q6C.js";
73
99
  import {
74
100
  resolvePlatformAuthToken
75
- } from "./chunk-AFV4FOT2.js";
101
+ } from "./chunk-OQVRTSZ5.js";
102
+ import {
103
+ isQuotaExhaustedError
104
+ } from "./chunk-MBUNBGBE.js";
76
105
  import {
77
106
  DEFAULT_CONTEXT_WINDOW,
78
107
  getModelContextWindow
79
- } from "./chunk-2H3XIBY4.js";
108
+ } from "./chunk-D2CTCWWG.js";
80
109
  import {
81
110
  clipCompactText
82
- } from "./chunk-AOXVOC6D.js";
111
+ } from "./chunk-6O5DMZOS.js";
83
112
  import {
84
113
  findModelConfig
85
- } from "./chunk-DFUPZE6V.js";
86
- import {
87
- buildSkillDiscoveryContextLayer
88
- } from "./chunk-ZURFOV5J.js";
89
- import {
90
- buildAgentsMdLayer,
91
- buildMemoryOverlayLayer,
92
- buildMemoryUseGuidanceLayer,
93
- partitionScopedBlocks,
94
- renderTurnContextBlocksWithScope
95
- } from "./chunk-2UECQ7RE.js";
96
- import {
97
- parseExternalSkillMarkdown,
98
- parseSkillDocProtocol
99
- } from "./chunk-AETZ7AD6.js";
114
+ } from "./chunk-7SLMYTSF.js";
100
115
  import {
101
116
  compactWhitespace
102
117
  } from "./chunk-DWLEOOGR.js";
103
- import {
104
- createRunActivityTracker,
105
- finalizeRunRecord,
106
- spawnLocalBackgroundRun
107
- } from "./chunk-7KNERA53.js";
108
- import {
109
- formatFinishedRunCard,
110
- formatListRunsCard,
111
- formatNotFoundRunCard,
112
- formatStartRunCard,
113
- formatStatusRunCard,
114
- formatStopRunCard,
115
- isAgentRunTerminalStatus,
116
- runShowsLogTail
117
- } from "./chunk-KXKQO4Q6.js";
118
- import {
119
- CliProviderQuotaError
120
- } from "./chunk-SAQQLJZ5.js";
121
118
  import {
122
119
  toErrorMessage
123
120
  } from "./chunk-HNMXYYJR.js";
124
121
  import {
125
- readPipeText,
126
- spawnProcess
127
- } from "./chunk-IDZTNRP2.js";
128
- import {
129
- resolveAuthToken
130
- } from "./chunk-A7GB5UGH.js";
122
+ buildAgentsMdLayer,
123
+ buildMemoryOverlayLayer,
124
+ buildMemoryUseGuidanceLayer,
125
+ partitionScopedBlocks,
126
+ renderTurnContextBlocksWithScope
127
+ } from "./chunk-3AOLVADY.js";
131
128
  import {
132
129
  parsePositiveFiniteNumberOrFallback
133
130
  } from "./chunk-Y5GCAMGP.js";
@@ -141,13 +138,20 @@ import {
141
138
  BUILTIN_NOLO_AGENT_KEY,
142
139
  BUILTIN_NOLO_AGENT_NAME,
143
140
  builtinAgentCatalogEntryById
144
- } from "./chunk-UK5JGQVU.js";
141
+ } from "./chunk-A3UZKNUI.js";
142
+ import {
143
+ parsePublicAgentId
144
+ } from "./chunk-BJIRLHJR.js";
145
145
  import {
146
146
  asTrimmedString
147
147
  } from "./chunk-3EUW3WEO.js";
148
148
  import {
149
- parsePublicAgentId
150
- } from "./chunk-BJIRLHJR.js";
149
+ readPipeText,
150
+ spawnProcess
151
+ } from "./chunk-IDZTNRP2.js";
152
+ import {
153
+ resolveAuthToken
154
+ } from "./chunk-A7GB5UGH.js";
151
155
  import {
152
156
  isLoopbackUrl
153
157
  } from "./chunk-4SN6J65J.js";
@@ -317,11 +321,243 @@ function dimCliText(text, enabled = resolveCliColorEnabled()) {
317
321
  return styleCliText(text, "dim", enabled);
318
322
  }
319
323
 
324
+ // node_modules/ansi-regex/index.js
325
+ function ansiRegex({ onlyFirst = false } = {}) {
326
+ const ST = "(?:\\u0007|\\u001B\\u005C|\\u009C)";
327
+ const osc = `(?:\\u001B\\][^\\u0007\\u001B\\u009C]*${ST})`;
328
+ const csi = "[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]";
329
+ const pattern = `${osc}|${csi}`;
330
+ return new RegExp(pattern, onlyFirst ? void 0 : "g");
331
+ }
332
+
333
+ // node_modules/strip-ansi/index.js
334
+ var regex = ansiRegex();
335
+ function stripAnsi(string) {
336
+ if (typeof string !== "string") {
337
+ throw new TypeError(`Expected a \`string\`, got \`${typeof string}\``);
338
+ }
339
+ if (!string.includes("\x1B") && !string.includes("\x9B")) {
340
+ return string;
341
+ }
342
+ return string.replace(regex, "");
343
+ }
344
+
345
+ // node_modules/get-east-asian-width/lookup-data.js
346
+ var ambiguousMinimalCodePoint = 161;
347
+ var ambiguousMaximumCodePoint = 1114109;
348
+ var ambiguousRanges = [161, 161, 164, 164, 167, 168, 170, 170, 173, 174, 176, 180, 182, 186, 188, 191, 198, 198, 208, 208, 215, 216, 222, 225, 230, 230, 232, 234, 236, 237, 240, 240, 242, 243, 247, 250, 252, 252, 254, 254, 257, 257, 273, 273, 275, 275, 283, 283, 294, 295, 299, 299, 305, 307, 312, 312, 319, 322, 324, 324, 328, 331, 333, 333, 338, 339, 358, 359, 363, 363, 462, 462, 464, 464, 466, 466, 468, 468, 470, 470, 472, 472, 474, 474, 476, 476, 593, 593, 609, 609, 708, 708, 711, 711, 713, 715, 717, 717, 720, 720, 728, 731, 733, 733, 735, 735, 768, 879, 913, 929, 931, 937, 945, 961, 963, 969, 1025, 1025, 1040, 1103, 1105, 1105, 8208, 8208, 8211, 8214, 8216, 8217, 8220, 8221, 8224, 8226, 8228, 8231, 8240, 8240, 8242, 8243, 8245, 8245, 8251, 8251, 8254, 8254, 8308, 8308, 8319, 8319, 8321, 8324, 8364, 8364, 8451, 8451, 8453, 8453, 8457, 8457, 8467, 8467, 8470, 8470, 8481, 8482, 8486, 8486, 8491, 8491, 8531, 8532, 8539, 8542, 8544, 8555, 8560, 8569, 8585, 8585, 8592, 8601, 8632, 8633, 8658, 8658, 8660, 8660, 8679, 8679, 8704, 8704, 8706, 8707, 8711, 8712, 8715, 8715, 8719, 8719, 8721, 8721, 8725, 8725, 8730, 8730, 8733, 8736, 8739, 8739, 8741, 8741, 8743, 8748, 8750, 8750, 8756, 8759, 8764, 8765, 8776, 8776, 8780, 8780, 8786, 8786, 8800, 8801, 8804, 8807, 8810, 8811, 8814, 8815, 8834, 8835, 8838, 8839, 8853, 8853, 8857, 8857, 8869, 8869, 8895, 8895, 8978, 8978, 9312, 9449, 9451, 9547, 9552, 9587, 9600, 9615, 9618, 9621, 9632, 9633, 9635, 9641, 9650, 9651, 9654, 9655, 9660, 9661, 9664, 9665, 9670, 9672, 9675, 9675, 9678, 9681, 9698, 9701, 9711, 9711, 9733, 9734, 9737, 9737, 9742, 9743, 9756, 9756, 9758, 9758, 9792, 9792, 9794, 9794, 9824, 9825, 9827, 9829, 9831, 9834, 9836, 9837, 9839, 9839, 9886, 9887, 9919, 9919, 9926, 9933, 9935, 9939, 9941, 9953, 9955, 9955, 9960, 9961, 9963, 9969, 9972, 9972, 9974, 9977, 9979, 9980, 9982, 9983, 10045, 10045, 10102, 10111, 11094, 11097, 12872, 12879, 57344, 63743, 65024, 65039, 65533, 65533, 127232, 127242, 127248, 127277, 127280, 127337, 127344, 127373, 127375, 127376, 127387, 127404, 917760, 917999, 983040, 1048573, 1048576, 1114109];
349
+ var fullwidthMinimalCodePoint = 12288;
350
+ var fullwidthMaximumCodePoint = 65510;
351
+ var fullwidthRanges = [12288, 12288, 65281, 65376, 65504, 65510];
352
+ var wideMinimalCodePoint = 4352;
353
+ var wideMaximumCodePoint = 262141;
354
+ var wideRanges = [4352, 4447, 8986, 8987, 9001, 9002, 9193, 9196, 9200, 9200, 9203, 9203, 9725, 9726, 9748, 9749, 9776, 9783, 9800, 9811, 9855, 9855, 9866, 9871, 9875, 9875, 9889, 9889, 9898, 9899, 9917, 9918, 9924, 9925, 9934, 9934, 9940, 9940, 9962, 9962, 9970, 9971, 9973, 9973, 9978, 9978, 9981, 9981, 9989, 9989, 9994, 9995, 10024, 10024, 10060, 10060, 10062, 10062, 10067, 10069, 10071, 10071, 10133, 10135, 10160, 10160, 10175, 10175, 11035, 11036, 11088, 11088, 11093, 11093, 11904, 11929, 11931, 12019, 12032, 12245, 12272, 12287, 12289, 12350, 12353, 12438, 12441, 12543, 12549, 12591, 12593, 12686, 12688, 12773, 12783, 12830, 12832, 12871, 12880, 42124, 42128, 42182, 43360, 43388, 44032, 55203, 63744, 64255, 65040, 65049, 65072, 65106, 65108, 65126, 65128, 65131, 94176, 94180, 94192, 94198, 94208, 101589, 101631, 101662, 101760, 101874, 110576, 110579, 110581, 110587, 110589, 110590, 110592, 110882, 110898, 110898, 110928, 110930, 110933, 110933, 110948, 110951, 110960, 111355, 119552, 119638, 119648, 119670, 126980, 126980, 127183, 127183, 127374, 127374, 127377, 127386, 127488, 127490, 127504, 127547, 127552, 127560, 127568, 127569, 127584, 127589, 127744, 127776, 127789, 127797, 127799, 127868, 127870, 127891, 127904, 127946, 127951, 127955, 127968, 127984, 127988, 127988, 127992, 128062, 128064, 128064, 128066, 128252, 128255, 128317, 128331, 128334, 128336, 128359, 128378, 128378, 128405, 128406, 128420, 128420, 128507, 128591, 128640, 128709, 128716, 128716, 128720, 128722, 128725, 128728, 128732, 128735, 128747, 128748, 128756, 128764, 128992, 129003, 129008, 129008, 129292, 129338, 129340, 129349, 129351, 129535, 129648, 129660, 129664, 129674, 129678, 129734, 129736, 129736, 129741, 129756, 129759, 129770, 129775, 129784, 131072, 196605, 196608, 262141];
355
+
356
+ // node_modules/get-east-asian-width/utilities.js
357
+ var isInRange = (ranges, codePoint) => {
358
+ let low = 0;
359
+ let high = Math.floor(ranges.length / 2) - 1;
360
+ while (low <= high) {
361
+ const mid = Math.floor((low + high) / 2);
362
+ const i = mid * 2;
363
+ if (codePoint < ranges[i]) {
364
+ high = mid - 1;
365
+ } else if (codePoint > ranges[i + 1]) {
366
+ low = mid + 1;
367
+ } else {
368
+ return true;
369
+ }
370
+ }
371
+ return false;
372
+ };
373
+
374
+ // node_modules/get-east-asian-width/lookup.js
375
+ var commonCjkCodePoint = 19968;
376
+ var [wideFastPathStart, wideFastPathEnd] = /* @__PURE__ */ findWideFastPathRange(wideRanges);
377
+ function findWideFastPathRange(ranges) {
378
+ let fastPathStart = ranges[0];
379
+ let fastPathEnd = ranges[1];
380
+ for (let index = 0; index < ranges.length; index += 2) {
381
+ const start = ranges[index];
382
+ const end = ranges[index + 1];
383
+ if (commonCjkCodePoint >= start && commonCjkCodePoint <= end) {
384
+ return [start, end];
385
+ }
386
+ if (end - start > fastPathEnd - fastPathStart) {
387
+ fastPathStart = start;
388
+ fastPathEnd = end;
389
+ }
390
+ }
391
+ return [fastPathStart, fastPathEnd];
392
+ }
393
+ var isAmbiguous = (codePoint) => {
394
+ if (codePoint < ambiguousMinimalCodePoint || codePoint > ambiguousMaximumCodePoint) {
395
+ return false;
396
+ }
397
+ return isInRange(ambiguousRanges, codePoint);
398
+ };
399
+ var isFullWidth = (codePoint) => {
400
+ if (codePoint < fullwidthMinimalCodePoint || codePoint > fullwidthMaximumCodePoint) {
401
+ return false;
402
+ }
403
+ return isInRange(fullwidthRanges, codePoint);
404
+ };
405
+ var isWide = (codePoint) => {
406
+ if (codePoint >= wideFastPathStart && codePoint <= wideFastPathEnd) {
407
+ return true;
408
+ }
409
+ if (codePoint < wideMinimalCodePoint || codePoint > wideMaximumCodePoint) {
410
+ return false;
411
+ }
412
+ return isInRange(wideRanges, codePoint);
413
+ };
414
+
415
+ // node_modules/get-east-asian-width/index.js
416
+ function validate(codePoint) {
417
+ if (!Number.isSafeInteger(codePoint)) {
418
+ throw new TypeError(`Expected a code point, got \`${typeof codePoint}\`.`);
419
+ }
420
+ }
421
+ function eastAsianWidth(codePoint, { ambiguousAsWide = false } = {}) {
422
+ validate(codePoint);
423
+ if (isFullWidth(codePoint) || isWide(codePoint) || ambiguousAsWide && isAmbiguous(codePoint)) {
424
+ return 2;
425
+ }
426
+ return 1;
427
+ }
428
+
429
+ // node_modules/string-width/index.js
430
+ var segmenter = new Intl.Segmenter();
431
+ var zeroWidthClusterRegex = new RegExp("^(?:\\p{Default_Ignorable_Code_Point}|\\p{Control}|\\p{Format}|\\p{Nonspacing_Mark}|\\p{Enclosing_Mark}|\\p{Surrogate})+$", "v");
432
+ var leadingNonPrintingRegex = new RegExp("^[\\p{Default_Ignorable_Code_Point}\\p{Control}\\p{Format}\\p{Nonspacing_Mark}\\p{Enclosing_Mark}\\p{Surrogate}]+", "v");
433
+ var spacingMarkRegex = new RegExp("\\p{Spacing_Mark}", "v");
434
+ var rgiEmojiRegex = new RegExp("^\\p{RGI_Emoji}$", "v");
435
+ var unqualifiedKeycapRegex = /^[\d#*]\u20E3$/;
436
+ var extendedPictographicRegex = new RegExp("\\p{Extended_Pictographic}", "gu");
437
+ function isDoubleWidthNonRgiEmojiSequence(segment) {
438
+ if (segment.length > 50) {
439
+ return false;
440
+ }
441
+ if (unqualifiedKeycapRegex.test(segment)) {
442
+ return true;
443
+ }
444
+ if (segment.includes("\u200D")) {
445
+ const pictographics = segment.match(extendedPictographicRegex);
446
+ return pictographics !== null && pictographics.length >= 2;
447
+ }
448
+ return false;
449
+ }
450
+ function baseVisible(segment) {
451
+ return segment.replace(leadingNonPrintingRegex, "");
452
+ }
453
+ function isZeroWidthCluster(segment) {
454
+ return zeroWidthClusterRegex.test(segment);
455
+ }
456
+ function isHangulLeadingJamo(codePoint) {
457
+ return codePoint >= 4352 && codePoint <= 4447 || codePoint >= 43360 && codePoint <= 43388;
458
+ }
459
+ function isHangulVowelJamo(codePoint) {
460
+ return codePoint >= 4448 && codePoint <= 4519 || codePoint >= 55216 && codePoint <= 55238;
461
+ }
462
+ function isHangulTrailingJamo(codePoint) {
463
+ return codePoint >= 4520 && codePoint <= 4607 || codePoint >= 55243 && codePoint <= 55291;
464
+ }
465
+ function isHangulJamo(codePoint) {
466
+ return isHangulLeadingJamo(codePoint) || isHangulVowelJamo(codePoint) || isHangulTrailingJamo(codePoint);
467
+ }
468
+ function hangulClusterWidth(visibleSegment, eastAsianWidthOptions) {
469
+ const codePoints = [];
470
+ for (const character of visibleSegment) {
471
+ if (zeroWidthClusterRegex.test(character)) {
472
+ continue;
473
+ }
474
+ codePoints.push(character.codePointAt(0));
475
+ }
476
+ if (codePoints.length === 0) {
477
+ return void 0;
478
+ }
479
+ let width = 0;
480
+ for (let index = 0; index < codePoints.length; index++) {
481
+ const codePoint = codePoints[index];
482
+ if (!isHangulJamo(codePoint)) {
483
+ if (width === 0) {
484
+ return void 0;
485
+ }
486
+ for (let remaining = index; remaining < codePoints.length; remaining++) {
487
+ width += eastAsianWidth(codePoints[remaining], eastAsianWidthOptions);
488
+ }
489
+ return width;
490
+ }
491
+ if (isHangulLeadingJamo(codePoint) && isHangulVowelJamo(codePoints[index + 1])) {
492
+ width += 2;
493
+ index += isHangulTrailingJamo(codePoints[index + 2]) ? 2 : 1;
494
+ continue;
495
+ }
496
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
497
+ }
498
+ return width;
499
+ }
500
+ function trailingWidth(visibleSegment, eastAsianWidthOptions) {
501
+ let extra = 0;
502
+ let first = true;
503
+ for (const character of visibleSegment) {
504
+ if (first) {
505
+ first = false;
506
+ continue;
507
+ }
508
+ if (spacingMarkRegex.test(character) || character >= "\uFF00" && character <= "\uFFEF") {
509
+ extra += eastAsianWidth(character.codePointAt(0), eastAsianWidthOptions);
510
+ }
511
+ }
512
+ return extra;
513
+ }
514
+ function stringWidth(input, options = {}) {
515
+ if (typeof input !== "string" || input.length === 0) {
516
+ return 0;
517
+ }
518
+ const {
519
+ ambiguousIsNarrow = true,
520
+ countAnsiEscapeCodes = false
521
+ } = options;
522
+ let string = input;
523
+ if (!countAnsiEscapeCodes && (string.includes("\x1B") || string.includes("\x9B"))) {
524
+ string = stripAnsi(string);
525
+ }
526
+ if (string.length === 0) {
527
+ return 0;
528
+ }
529
+ if (/^[\u0020-\u007E]*$/.test(string)) {
530
+ return string.length;
531
+ }
532
+ let width = 0;
533
+ const eastAsianWidthOptions = { ambiguousAsWide: !ambiguousIsNarrow };
534
+ for (const { segment } of segmenter.segment(string)) {
535
+ if (isZeroWidthCluster(segment)) {
536
+ continue;
537
+ }
538
+ if (rgiEmojiRegex.test(segment) || isDoubleWidthNonRgiEmojiSequence(segment)) {
539
+ width += 2;
540
+ continue;
541
+ }
542
+ const visibleSegment = baseVisible(segment);
543
+ const hangulWidth = hangulClusterWidth(visibleSegment, eastAsianWidthOptions);
544
+ if (hangulWidth !== void 0) {
545
+ width += hangulWidth;
546
+ continue;
547
+ }
548
+ const codePoint = visibleSegment.codePointAt(0);
549
+ width += eastAsianWidth(codePoint, eastAsianWidthOptions);
550
+ width += trailingWidth(visibleSegment, eastAsianWidthOptions);
551
+ }
552
+ return width;
553
+ }
554
+
320
555
  // packages/cli/tui/tuiAnsi.ts
321
556
  var ANSI_ESCAPE_REGEX = /\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]/g;
322
- var OSC_HYPERLINK_REGEX = /\x1b\]8;;[^\x07\x1b]*(?:\x07|\x1b\\)\x1b\]8;;(?:\x07|\x1b\\)|\x1b\]8;;[^\x07\x1b]*(?:\x07|\x1b\\)/g;
323
- function stripAnsi(text) {
324
- return text.replace(OSC_HYPERLINK_REGEX, "").replace(ANSI_ESCAPE_REGEX, "");
557
+ var ALL_ANSI_ESCAPE_REGEX = ansiRegex();
558
+ var FIRST_ANSI_ESCAPE_REGEX = ansiRegex({ onlyFirst: true });
559
+ function stripAnsi2(text) {
560
+ return text.replace(ANSI_ESCAPE_REGEX, "").replace(ALL_ANSI_ESCAPE_REGEX, "");
325
561
  }
326
562
  var SGR_SEQUENCE_REGEX = /^\x1b\[[0-9;]*m/;
327
563
  var TRAILING_SGR_REGEX = /(?:\x1b\[[0-9;]*m)+$/;
@@ -383,29 +619,19 @@ function applyTerminalOutputToText(existing, chunk) {
383
619
  return text;
384
620
  }
385
621
  function displayWidth(str) {
386
- let width = 0;
387
- for (const char of str) {
388
- const code = char.codePointAt(0) ?? 0;
389
- if (code < 32 || code === 127) continue;
390
- if (code >= 4352 && code <= 4447 || // 0x2768-0x2775 (ornamental brackets, incl. the ❯ prompt at U+276F)
391
- // render narrow in terminals; counting them wide drifts the cursor.
392
- code >= 9728 && code <= 10175 && !(code >= 10088 && code <= 10101) || // 0x2B00-0x2BFF (Misc Symbols and Arrows, incl. ⬢ U+2B22 used as the
393
- // status-line agent icon) render double-wide in common monospace fonts;
394
- // counting ⬢ as width 1 drifts the whole status line right of the icon.
395
- code >= 11008 && code <= 11263 || code >= 11904 && code <= 12350 || code >= 12352 && code <= 13247 || code >= 13312 && code <= 19903 || code >= 19968 && code <= 42191 || code >= 44032 && code <= 55203 || code >= 63744 && code <= 64255 || code >= 65072 && code <= 65135 || code >= 65281 && code <= 65376 || code >= 65504 && code <= 65510 || code >= 127744 && code <= 129791 || code >= 131072 && code <= 196605 || code >= 196608 && code <= 262141 || // East Asian Ambiguous CJK quotation marks (U+201C/D “ ”, U+2018/9 ‘ ’).
396
- // In CJK locale + CJK fonts these render double-wide like 全角 punctuation;
397
- // in English fonts they stay width 1. Follow the active locale so Chinese
398
- // replies align correctly without breaking English terminal output.
399
- getCliLocale() === "zh" && (code === 8220 || code === 8221 || code === 8216 || code === 8217)) {
400
- width += 2;
401
- } else {
402
- width += 1;
403
- }
622
+ const plain = stripAnsi2(str);
623
+ let width = stringWidth(plain);
624
+ for (const { segment } of graphemeSegmenter.segment(plain)) {
625
+ if (stringWidth(segment) !== 1) continue;
626
+ const code = segment.codePointAt(0) ?? 0;
627
+ const forceWideSymbol = code >= 9728 && code <= 10175 && !(code >= 10088 && code <= 10101) || code >= 11008 && code <= 11263 || code >= 127744 && code <= 129791;
628
+ const cjkQuote = getCliLocale() === "zh" && (code === 8220 || code === 8221 || code === 8216 || code === 8217);
629
+ if (forceWideSymbol || cjkQuote) width += 1;
404
630
  }
405
631
  return width;
406
632
  }
407
633
  function visibleWidth(str) {
408
- return displayWidth(stripAnsi(str));
634
+ return displayWidth(stripAnsi2(str));
409
635
  }
410
636
  function truncateAnsi(text, maxWidth) {
411
637
  if (maxWidth <= 0) return "";
@@ -473,6 +699,7 @@ function padOrTruncateToWidth(text, width) {
473
699
  return `${text}${" ".repeat(width - textWidth)}`;
474
700
  }
475
701
  var SGR_RESET_REGEX = /^\x1b\[0?m$/;
702
+ var graphemeSegmenter = new Intl.Segmenter(void 0, { granularity: "grapheme" });
476
703
  function tokenizeAnsiLine(line) {
477
704
  const tokens = [];
478
705
  let index = 0;
@@ -480,28 +707,125 @@ function tokenizeAnsiLine(line) {
480
707
  if (line[index] === "\x1B") {
481
708
  const osc = line.slice(index).match(/^\x1b\]8;;[^\x07\x1b]*(?:\x07|\x1b\\)/);
482
709
  if (osc) {
483
- tokens.push({ kind: "sgr", value: osc[0], width: 0 });
710
+ tokens.push({ kind: "sgr", value: osc[0], width: 0, charIndex: index });
484
711
  index += osc[0].length;
485
712
  continue;
486
713
  }
487
714
  const sgr = SGR_SEQUENCE_REGEX.exec(line.slice(index));
488
715
  if (sgr) {
489
- tokens.push({ kind: "sgr", value: sgr[0], width: 0 });
716
+ tokens.push({ kind: "sgr", value: sgr[0], width: 0, charIndex: index });
490
717
  index += sgr[0].length;
491
718
  continue;
492
719
  }
720
+ const csi = line.slice(index).match(/^\x1b\[[\x30-\x3f]*[\x20-\x2f]*[\x40-\x7e]/);
721
+ if (csi) {
722
+ index += csi[0].length;
723
+ continue;
724
+ }
725
+ const escape = FIRST_ANSI_ESCAPE_REGEX.exec(line.slice(index));
726
+ if (escape?.index === 0) {
727
+ index += escape[0].length;
728
+ continue;
729
+ }
730
+ index += 1;
731
+ continue;
493
732
  }
494
- const codePoint = line.codePointAt(index) ?? 0;
495
- const value = String.fromCodePoint(codePoint);
496
- tokens.push({ kind: "char", value, width: displayWidth(value) });
497
- index += value.length;
733
+ let nextEsc = line.indexOf("\x1B", index);
734
+ if (nextEsc === -1) nextEsc = line.length;
735
+ const chunk = line.slice(index, nextEsc);
736
+ for (const item of graphemeSegmenter.segment(chunk)) {
737
+ tokens.push({
738
+ kind: "char",
739
+ value: item.segment,
740
+ width: displayWidth(item.segment),
741
+ charIndex: index + item.index
742
+ });
743
+ }
744
+ index = nextEsc;
498
745
  }
499
746
  return tokens;
500
747
  }
501
- function wrapTranscriptLine(line, columns, hangingIndent = "") {
502
- if (line === "") return [""];
748
+ function buildSourceMapping(rawLine, styledLine, prefixCharCount) {
749
+ let contentStart = 0;
750
+ const headingMatch = rawLine.match(/^(#{1,3})\s+(.+)$/);
751
+ let lineToParse = rawLine;
752
+ if (headingMatch) {
753
+ contentStart = headingMatch[1].length + 1;
754
+ while (contentStart < rawLine.length && rawLine[contentStart] === " ") contentStart++;
755
+ lineToParse = rawLine.slice(contentStart);
756
+ }
757
+ const INLINE_RE = /(\[([^\]]+)\]\(([^)\s]+)\)|`([^`]+)`|\*\*(.+?)\*\*|(?<!\*)\*([^*]+?)\*(?!\*)|~~([^~]+?)~~)/g;
758
+ const mapping = [];
759
+ let lastIdx = 0;
760
+ let match;
761
+ while ((match = INLINE_RE.exec(lineToParse)) !== null) {
762
+ const plainBefore = lineToParse.slice(lastIdx, match.index);
763
+ for (let c = 0; c < plainBefore.length; c++) {
764
+ mapping.push(contentStart + lastIdx + c);
765
+ }
766
+ const fullMatch = match[0];
767
+ if (match[2] !== void 0 && match[3] !== void 0) {
768
+ const linkText = match[2];
769
+ const linkUrl = match[3];
770
+ const textOffset = contentStart + match.index + 1;
771
+ for (let c = 0; c < linkText.length; c++) {
772
+ mapping.push(textOffset + c);
773
+ }
774
+ const parenOffset = textOffset + linkText.length;
775
+ mapping.push(parenOffset);
776
+ mapping.push(parenOffset + 1);
777
+ const urlOffset = parenOffset + 2;
778
+ for (let c = 0; c < linkUrl.length; c++) {
779
+ mapping.push(urlOffset + c);
780
+ }
781
+ mapping.push(urlOffset + linkUrl.length);
782
+ } else if (match[4] !== void 0) {
783
+ const codeText = match[4];
784
+ const codeOffset = contentStart + match.index + 1;
785
+ for (let c = 0; c < codeText.length; c++) {
786
+ mapping.push(codeOffset + c);
787
+ }
788
+ } else if (match[5] !== void 0) {
789
+ const boldText = match[5];
790
+ const boldOffset = contentStart + match.index + 2;
791
+ for (let c = 0; c < boldText.length; c++) {
792
+ mapping.push(boldOffset + c);
793
+ }
794
+ } else if (match[6] !== void 0) {
795
+ const italicText = match[6];
796
+ const italicOffset = contentStart + match.index + 1;
797
+ for (let c = 0; c < italicText.length; c++) {
798
+ mapping.push(italicOffset + c);
799
+ }
800
+ } else if (match[7] !== void 0) {
801
+ const strikeText = match[7];
802
+ const strikeOffset = contentStart + match.index + 2;
803
+ for (let c = 0; c < strikeText.length; c++) {
804
+ mapping.push(strikeOffset + c);
805
+ }
806
+ }
807
+ lastIdx = match.index + fullMatch.length;
808
+ }
809
+ const plainRest = lineToParse.slice(lastIdx);
810
+ for (let c = 0; c < plainRest.length; c++) {
811
+ mapping.push(contentStart + lastIdx + c);
812
+ }
813
+ return mapping;
814
+ }
815
+ function wrapTranscriptLineWithLayout(line, columns, hangingIndent = "", lineSourceStart = 0, prefixWidth = 0, prefixCharCount = 0, sourceMapping, rawLineLength) {
816
+ if (line === "") {
817
+ const rawLen = rawLineLength ?? 0;
818
+ return [
819
+ {
820
+ rendered: "",
821
+ sourceStart: lineSourceStart,
822
+ sourceEnd: lineSourceStart + rawLen,
823
+ prefixWidth
824
+ }
825
+ ];
826
+ }
503
827
  const tokens = tokenizeAnsiLine(line);
504
- const result = [];
828
+ const rows = [];
505
829
  let activeStyles = [];
506
830
  const applyStyleToken = (value) => {
507
831
  if (SGR_RESET_REGEX.test(value)) {
@@ -513,10 +837,11 @@ function wrapTranscriptLine(line, columns, hangingIndent = "") {
513
837
  let start = 0;
514
838
  while (start < tokens.length) {
515
839
  if (tokens.slice(start).every((token) => token.kind === "sgr")) {
516
- if (result.length > 0) break;
840
+ if (rows.length > 0) break;
517
841
  }
518
842
  const openingStyles = [...activeStyles];
519
- const isContinuation = result.length > 0 && hangingIndent.length > 0;
843
+ const isContinuation = rows.length > 0;
844
+ const currentPrefixWidth = isContinuation ? visibleWidth(hangingIndent) : prefixWidth;
520
845
  const indentWidth = isContinuation ? visibleWidth(hangingIndent) : 0;
521
846
  const maxSegmentWidth = Math.max(1, columns - indentWidth);
522
847
  let width = 0;
@@ -531,7 +856,7 @@ function wrapTranscriptLine(line, columns, hangingIndent = "") {
531
856
  if (width + token.width > maxSegmentWidth && width > 0) break;
532
857
  width += token.width;
533
858
  end += 1;
534
- if (token.value === " " || token.value === " ") {
859
+ if ((token.value === " " || token.value === " ") && token.charIndex >= prefixCharCount) {
535
860
  lastBreak = end;
536
861
  }
537
862
  }
@@ -556,21 +881,78 @@ function wrapTranscriptLine(line, columns, hangingIndent = "") {
556
881
  const prefix = openingStyles.join("");
557
882
  const needsReset = (sawStyle || activeStyles.length > 0) && !segment.endsWith("\x1B[0m");
558
883
  const lineContent = `${prefix}${segment}${needsReset ? "\x1B[0m" : ""}`;
559
- result.push(isContinuation ? `${hangingIndent}${lineContent}` : lineContent);
884
+ const rowRendered = isContinuation && hangingIndent.length > 0 ? `${hangingIndent}${lineContent}` : lineContent;
885
+ let segSourceStart = lineSourceStart;
886
+ let segSourceEnd = lineSourceStart;
887
+ let foundFirst = false;
888
+ const rowMapping = [];
889
+ let plainCharIndex = 0;
890
+ for (let i = 0; i < start; i++) {
891
+ const tok = tokens[i];
892
+ if (tok.kind === "char" && tok.charIndex >= prefixCharCount) {
893
+ plainCharIndex += tok.value.length;
894
+ }
895
+ }
896
+ for (let i = start; i < segmentEnd; i++) {
897
+ const tok = tokens[i];
898
+ if (tok.kind === "char" && tok.charIndex >= prefixCharCount) {
899
+ const mappedOffset = sourceMapping && sourceMapping[plainCharIndex] !== void 0 ? sourceMapping[plainCharIndex] : plainCharIndex;
900
+ if (!foundFirst) {
901
+ segSourceStart = lineSourceStart + mappedOffset;
902
+ foundFirst = true;
903
+ }
904
+ for (let c = 0; c < tok.value.length; c++) {
905
+ const idx = plainCharIndex + c;
906
+ const mapped = sourceMapping && sourceMapping[idx] !== void 0 ? sourceMapping[idx] : idx;
907
+ rowMapping.push(lineSourceStart + mapped);
908
+ }
909
+ const lastCharIdx = plainCharIndex + tok.value.length - 1;
910
+ const mappedEndOffset = sourceMapping && sourceMapping[lastCharIdx] !== void 0 ? sourceMapping[lastCharIdx] + 1 : plainCharIndex + tok.value.length;
911
+ segSourceEnd = lineSourceStart + mappedEndOffset;
912
+ plainCharIndex += tok.value.length;
913
+ }
914
+ }
560
915
  start = segmentEnd;
916
+ let softWrapJoiner = "";
561
917
  while (start < tokens.length) {
562
918
  const token = tokens[start];
563
- if (token.kind === "char" && token.value === " ") {
919
+ if (token.kind === "char" && token.value === " " && token.charIndex >= prefixCharCount) {
920
+ softWrapJoiner += token.value;
921
+ const mappedOffset = sourceMapping && sourceMapping[plainCharIndex] !== void 0 ? sourceMapping[plainCharIndex] + 1 : plainCharIndex + 1;
922
+ segSourceEnd = lineSourceStart + mappedOffset;
923
+ plainCharIndex += token.value.length;
564
924
  start += 1;
565
925
  continue;
566
926
  }
567
927
  break;
568
928
  }
929
+ if (start >= tokens.length && rawLineLength !== void 0) {
930
+ segSourceEnd = lineSourceStart + rawLineLength;
931
+ }
932
+ rows.push({
933
+ rendered: rowRendered,
934
+ sourceStart: segSourceStart,
935
+ sourceEnd: segSourceEnd,
936
+ prefixWidth: currentPrefixWidth,
937
+ sourceMapping: rowMapping.length > 0 ? rowMapping : void 0,
938
+ softWrapped: start < tokens.length,
939
+ softWrapJoiner
940
+ });
569
941
  }
570
- return result.length > 0 ? result : [""];
942
+ return rows.length > 0 ? rows : [
943
+ {
944
+ rendered: "",
945
+ sourceStart: lineSourceStart,
946
+ sourceEnd: lineSourceStart + (rawLineLength ?? 0),
947
+ prefixWidth
948
+ }
949
+ ];
950
+ }
951
+ function wrapTranscriptLine(line, columns, hangingIndent = "") {
952
+ return wrapTranscriptLineWithLayout(line, columns, hangingIndent).map((r) => r.rendered);
571
953
  }
572
954
  function buildWindowTitle(title) {
573
- const plain = stripAnsi(title).replace(/[\x00-\x1f\x7f]+/g, " ");
955
+ const plain = stripAnsi2(title).replace(/[\x00-\x1f\x7f]+/g, " ");
574
956
  let truncated = "";
575
957
  let width = 0;
576
958
  const maxCols = 80;
@@ -3304,7 +3686,7 @@ async function detectCurrentMachineId(env) {
3304
3686
  const fromEnv = (env.NOLO_CURRENT_MACHINE_ID || env.NOLO_MACHINE_ID || "").trim();
3305
3687
  if (fromEnv) return fromEnv;
3306
3688
  try {
3307
- const { detectMachineInfo } = await import("./machineInfo-M6KB6HZN.js");
3689
+ const { detectMachineInfo } = await import("./machineInfo-66ZFUMLE.js");
3308
3690
  const machine = await detectMachineInfo({ probeLaunchable: true });
3309
3691
  return asOptionalTrimmedString(machine?.machineId);
3310
3692
  } catch {
@@ -3521,7 +3903,7 @@ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
3521
3903
  // packages/cli/client/agentRun.ts
3522
3904
  import { ulid } from "ulid";
3523
3905
  async function loadRunLocalAgentTurn() {
3524
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-JX34G47Z.js");
3906
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-MXIGYCZW.js");
3525
3907
  return runLocalAgentTurn;
3526
3908
  }
3527
3909
  async function resolveCurrentMachineId(options) {
@@ -3753,6 +4135,10 @@ function describeLocalRunFailure(message) {
3753
4135
  }
3754
4136
  const cls = classifyLocalRunError(message);
3755
4137
  if (cls.kind === "generic") {
4138
+ if (isTransientFetchError(message)) {
4139
+ return `${RUN_UNAVAILABLE_PREFIX} (${message}). ${NO_FALLBACK} The upstream connection dropped mid-request (transient network/gateway issue \u2014 not a local credential or config problem). Send again (or say "continue") to retry in the same conversation.
4140
+ `;
4141
+ }
3756
4142
  return `${RUN_UNAVAILABLE_PREFIX} (${message}). ${NO_FALLBACK} Fix the local credential/config and retry, ${SERVER_FALLBACK_HINT}.
3757
4143
  `;
3758
4144
  }
@@ -4054,12 +4440,6 @@ async function runLocalAgentTurnForCli(options, settings) {
4054
4440
  "[nolo] \u5F53\u524D agent \u4E0D\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C\u5DF2\u7528\u5360\u4F4D\u6587\u672C\u66FF\u4EE3\u3002\u8981\u5B8C\u6574\u56FE\u7247\u7406\u89E3\u53EF /switch \u5230 Kimi K2.6\u3002\n"
4055
4441
  );
4056
4442
  }
4057
- if (event.kind === "image-preprocessed") {
4058
- options.output.write(
4059
- `[nolo] \u5DF2\u7528\u89C6\u89C9\u6A21\u578B\u89E3\u6790 ${event.imageCount} \u5F20\u56FE\u7247\u4E3A\u6587\u5B57\u63CF\u8FF0\uFF0C\u4F9B\u5F53\u524D agent \u4F7F\u7528\u3002
4060
- `
4061
- );
4062
- }
4063
4443
  options.onLoopEvent?.(event);
4064
4444
  },
4065
4445
  ...options.abortSignal ? { abortSignal: options.abortSignal } : {},
@@ -4868,40 +5248,6 @@ var resolveCliMemory = async (input) => {
4868
5248
  }
4869
5249
  };
4870
5250
 
4871
- // packages/ai/tools/agent/quotaCircuitBreaker.ts
4872
- var QUOTA_ERROR_PATTERNS = [
4873
- /429/,
4874
- /quota/i,
4875
- /rate\s*limit/i,
4876
- /too\s*many\s*requests/i,
4877
- /额度/,
4878
- /上限/,
4879
- /用尽/,
4880
- /CliProviderQuotaError/i
4881
- ];
4882
- function isCliProviderQuotaErrorShape(error) {
4883
- if (!error || typeof error !== "object") return false;
4884
- const e = error;
4885
- return e.name === "CliProviderQuotaError" || typeof e.message === "string" && e.message.startsWith("[QUOTA_LIMITED:");
4886
- }
4887
- function isQuotaExhaustedError(error) {
4888
- if (!error) return false;
4889
- if (isCliProviderQuotaErrorShape(error)) return true;
4890
- if (error instanceof Error) {
4891
- return QUOTA_ERROR_PATTERNS.some((pattern) => pattern.test(error.message));
4892
- }
4893
- if (typeof error === "string") {
4894
- return QUOTA_ERROR_PATTERNS.some((pattern) => pattern.test(error));
4895
- }
4896
- const maybeStatus = error.status;
4897
- if (typeof maybeStatus === "number" && maybeStatus === 429) return true;
4898
- const maybeStatusCode = error.statusCode;
4899
- if (typeof maybeStatusCode === "number" && maybeStatusCode === 429) return true;
4900
- return false;
4901
- }
4902
- var DEFAULT_QUOTA_BREAKER_MS = 6 * 3600 * 1e3;
4903
- var DEFAULT_AGENT_NOT_FOUND_BREAKER_MS = 15 * 60 * 1e3;
4904
-
4905
5251
  // packages/cli/agentRunCommand.ts
4906
5252
  function resolvePositiveMs(value, fallback) {
4907
5253
  return parsePositiveFiniteNumberOrFallback(value, fallback);
@@ -5363,7 +5709,7 @@ export {
5363
5709
  resolveCliColorEnabled,
5364
5710
  dimCliText,
5365
5711
  ANSI_ESCAPE_REGEX,
5366
- stripAnsi,
5712
+ stripAnsi2 as stripAnsi,
5367
5713
  applyTerminalOutputToText,
5368
5714
  displayWidth,
5369
5715
  visibleWidth,
@@ -5372,6 +5718,9 @@ export {
5372
5718
  countPhysicalLines,
5373
5719
  takeDisplayWidth,
5374
5720
  padOrTruncateToWidth,
5721
+ tokenizeAnsiLine,
5722
+ buildSourceMapping,
5723
+ wrapTranscriptLineWithLayout,
5375
5724
  wrapTranscriptLine,
5376
5725
  buildWindowTitle,
5377
5726
  wrapTextToLines,
@@ -5411,8 +5760,6 @@ export {
5411
5760
  normalizeCliImageInput,
5412
5761
  inspectLocalRunWorkspace,
5413
5762
  resolveCliMemory,
5414
- QUOTA_ERROR_PATTERNS,
5415
- isQuotaExhaustedError,
5416
5763
  runAgentRunCommand,
5417
5764
  isBalanceExhaustedError
5418
5765
  };