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

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 (157) hide show
  1. package/{_executeModel-RWPVI3YV.js → _executeModel-BTZJ6QKO.js} +56 -58
  2. package/{action-SMLG6OTB.js → action-LKQAGKHH.js} +11 -11
  3. package/{addContentAction-SFO244QN.js → addContentAction-IP2B6UUB.js} +9 -9
  4. package/{addDialogAgentAction-W44ZCEHB.js → addDialogAgentAction-JNIAUFE6.js} +8 -8
  5. package/{agentDeleteCommand-KU2RXQPP.js → agentDeleteCommand-WG6T4OTP.js} +48 -44
  6. package/{agentEmailCommands-MPCMDENS.js → agentEmailCommands-4CEZD4JW.js} +83 -80
  7. package/{agentListCommands-EPD4N6FX.js → agentListCommands-2YHWZHLD.js} +56 -43
  8. package/{agentMachineCommands-AF7C3YRT.js → agentMachineCommands-LKCUIDHA.js} +46 -42
  9. package/agentProviderCommands-65ZC2WB4.js +122 -0
  10. package/{agentPullCommand-YH5GEBK4.js → agentPullCommand-NYHSK6EW.js} +3 -3
  11. package/{agentRecordCommands-EYE6MZZG.js → agentRecordCommands-VSBYJUBN.js} +74 -71
  12. package/{agentRunCommand-LL22SGTN.js → agentRunCommand-LAD7TRWT.js} +80 -76
  13. package/{agentRuntimeLocal-JX34G47Z.js → agentRuntimeLocal-TEJECMTH.js} +34 -31
  14. package/{agentSlice-TNMFQQOV.js → agentSlice-3U3H657P.js} +11 -11
  15. package/{appDeleteCommands-43K5VXQB.js → appDeleteCommands-5QCUYGTX.js} +41 -37
  16. package/{appDeployCommands-FEEJSVDZ.js → appDeployCommands-GMIAIMDB.js} +41 -37
  17. package/{appDeployStatusCommands-H76CG45R.js → appDeployStatusCommands-ZTJ6APB6.js} +41 -37
  18. package/{appGetCommands-MDZYFTYZ.js → appGetCommands-PI4NTPKT.js} +41 -37
  19. package/{appListCommands-TUJJXPWG.js → appListCommands-QMRCLRJ6.js} +41 -37
  20. package/{authCommand-T7UK4CWS.js → authCommand-4ICNA46V.js} +21 -20
  21. package/{authCommands-EAPFGNHN.js → authCommands-W74NRPA6.js} +6 -6
  22. package/{chatQueueReduxAdapter-LVQXC4ZY.js → chatQueueReduxAdapter-5GNVXJ5T.js} +25 -24
  23. package/{chunk-JZ5AMMXU.js → chunk-244YJUYS.js} +4 -4
  24. package/{chunk-2UECQ7RE.js → chunk-3AOLVADY.js} +1 -1
  25. package/{chunk-AFV4FOT2.js → chunk-3GDKZAPT.js} +4 -91
  26. package/{chunk-M4NC7NF6.js → chunk-3H3FPUCI.js} +2 -2
  27. package/chunk-3Z32AD6X.js +22 -0
  28. package/{chunk-B2BSG6QQ.js → chunk-4EXK5Q2M.js} +18 -18
  29. package/{chunk-UK5JGQVU.js → chunk-52DHSNJC.js} +14 -20
  30. package/{chunk-LOD75GOS.js → chunk-6PI2635O.js} +3884 -1562
  31. package/{chunk-HDKRSRYU.js → chunk-7CH6ONWB.js} +636 -210
  32. package/{chunk-FMEVI5TG.js → chunk-7CH6U3FL.js} +1 -1
  33. package/{chunk-FSSX3XRY.js → chunk-7URTEFXJ.js} +1 -1
  34. package/{chunk-JTSGWTYZ.js → chunk-ASA3CJSG.js} +2 -2
  35. package/{chunk-6SXC35F4.js → chunk-AXCXE35O.js} +13 -13
  36. package/{chunk-2QTEYCR7.js → chunk-C2UKEL7P.js} +17 -7
  37. package/{chunk-I6N2UVVY.js → chunk-CBYBNR2K.js} +1 -1
  38. package/{chunk-WHD6BG7M.js → chunk-DMOWI2S7.js} +48 -44
  39. package/{chunk-3GZXL6FM.js → chunk-DZPK4YQY.js} +1 -1
  40. package/{chunk-6HYVJV7B.js → chunk-ESHYE7WU.js} +2 -1
  41. package/{chunk-TFPUAELY.js → chunk-ET4UZQN3.js} +3 -3
  42. package/{chunk-3WXRAHCG.js → chunk-EU7POTD4.js} +3 -3
  43. package/{chunk-DPMBNHOJ.js → chunk-FAMAQ3A7.js} +1 -1
  44. package/{chunk-JZPBVBIY.js → chunk-FD36SCCD.js} +19 -8
  45. package/{chunk-57QJXIB6.js → chunk-FEDK54U6.js} +10 -10
  46. package/{chunk-MPZJVZDC.js → chunk-FL3KRU3X.js} +41 -2674
  47. package/{chunk-ZURFOV5J.js → chunk-FS5VNMPF.js} +3 -3
  48. package/{chunk-2H3XIBY4.js → chunk-FSOCQPX7.js} +4 -82
  49. package/{chunk-M2YMQOLC.js → chunk-G34SHBSK.js} +11 -11
  50. package/{chunk-U4TRT5V4.js → chunk-GEPHJJW4.js} +1 -1
  51. package/{chunk-OIQPORYI.js → chunk-GN6ENM54.js} +178 -2
  52. package/{chunk-X664KVEV.js → chunk-HHBXCRJS.js} +204 -123
  53. package/chunk-HJ23CUHW.js +109 -0
  54. package/{chunk-RAZOLMJR.js → chunk-HXV5GJFC.js} +15 -8
  55. package/{chunk-OR2HNLVO.js → chunk-HYQSSY7V.js} +71 -79
  56. package/{chunk-WLH5BAKX.js → chunk-IIOHYLIG.js} +9 -4
  57. package/{chunk-2IVEXF7P.js → chunk-ISQZFROX.js} +2 -9
  58. package/{chunk-IHEC7VBF.js → chunk-J36P3SH5.js} +1 -1
  59. package/{chunk-PREQU5QV.js → chunk-J5STUEYU.js} +1 -1
  60. package/{chunk-O6GEBMIY.js → chunk-JE4J3T7A.js} +5296 -4981
  61. package/{chunk-VH2F7ZB6.js → chunk-JG43PNFR.js} +1 -1
  62. package/{chunk-GTYM4HKV.js → chunk-JZ6JDSWD.js} +5 -5
  63. package/{chunk-X2DAEZ3X.js → chunk-KWPXU3W5.js} +1 -1
  64. package/{chunk-WJSW43QZ.js → chunk-L3JWI7WX.js} +0 -1
  65. package/{chunk-NNWHHCVP.js → chunk-LI6SNQF6.js} +2 -3
  66. package/{chunk-GM6PU7B6.js → chunk-MEYIRKDN.js} +0 -1
  67. package/{chunk-Q5ITEGIN.js → chunk-N4XRDM26.js} +1 -1
  68. package/{chunk-7E72JMBB.js → chunk-N543Q3VR.js} +57 -16
  69. package/{chunk-YDTYDA5W.js → chunk-NBIS3WYT.js} +8 -6
  70. package/{chunk-JMPYDFHY.js → chunk-NI72ISCU.js} +21 -8
  71. package/{chunk-5CS33IBL.js → chunk-NQ4N4IGO.js} +11 -12
  72. package/chunk-OH4Q4VVA.js +38 -0
  73. package/{chunk-CLP2K7U4.js → chunk-OS63QEVB.js} +7 -7
  74. package/{chunk-DFUPZE6V.js → chunk-P35OZHD4.js} +3 -16
  75. package/{chunk-GMXWYXAF.js → chunk-PJT3CCBL.js} +4 -4
  76. package/{chunk-3VAQHAXT.js → chunk-PYLC3472.js} +27 -27
  77. package/{chunk-ADLYMQB6.js → chunk-QUK7UZW7.js} +137 -0
  78. package/{chunk-37V5LNEQ.js → chunk-RRYRKT7X.js} +1 -1
  79. package/{chunk-AAGCMVFT.js → chunk-S6QP3AK4.js} +895 -175
  80. package/{chunk-73GINUCW.js → chunk-SQPMYIR5.js} +135 -56
  81. package/{chunk-XCCGU6QB.js → chunk-SSK4QDFL.js} +1 -1
  82. package/{chunk-IL545V3E.js → chunk-TACRGJZO.js} +7 -7
  83. package/chunk-TVXJEOU2.js +78 -0
  84. package/{chunk-NUO3QFWD.js → chunk-UNHKVD2N.js} +1 -1
  85. package/{chunk-GE6IWA5N.js → chunk-UNZDCI3O.js} +126 -1
  86. package/chunk-UOLENXLQ.js +1132 -0
  87. package/{chunk-5SBK2MTI.js → chunk-UOVE5ZHK.js} +24 -71
  88. package/{chunk-ZJMME4DS.js → chunk-VBJVODPE.js} +6 -6
  89. package/{chunk-FXFGNOT2.js → chunk-VFVCYIRQ.js} +1 -1
  90. package/{chunk-AOXVOC6D.js → chunk-W2DNU6FK.js} +3 -3
  91. package/chunk-X6WFECZY.js +97 -0
  92. package/{chunk-RY57GLGW.js → chunk-YPREESF4.js} +42 -5
  93. package/{chunk-HUCT7HID.js → chunk-YXB5JR6N.js} +1 -1
  94. package/{chunk-BQXOGBFN.js → chunk-YZ2WE6CW.js} +2 -2
  95. package/{cliExecutor-DW3PHGEL.js → cliExecutor-BBUVQU4L.js} +2 -2
  96. package/{codingSkills-DY5MINPG.js → codingSkills-FXKII4C6.js} +3 -3
  97. package/{createAgentAutomationAction-INQT23LX.js → createAgentAutomationAction-CMOMDO6G.js} +25 -26
  98. package/{createDialogAction-LDCPDI73.js → createDialogAction-QG7DKUA7.js} +28 -29
  99. package/{createPageAction-5YXOG2M4.js → createPageAction-JCMCNMTK.js} +30 -31
  100. package/{dbSlice-3SD5L5H2.js → dbSlice-ZNHRC4BK.js} +8 -8
  101. package/{deleteFile-XQXPBFFB.js → deleteFile-NPZ64DFN.js} +5 -5
  102. package/{dialogCommands-CHJO47AX.js → dialogCommands-T43TTFWR.js} +40 -36
  103. package/{dialogSlice-DOWKOILN.js → dialogSlice-5VZFBHCA.js} +24 -23
  104. package/{docCreateCommands-OVZARUFX.js → docCreateCommands-DQBKKPOC.js} +42 -38
  105. package/{docDeleteCommands-E2XJ62LD.js → docDeleteCommands-ULM4MTP3.js} +43 -39
  106. package/{docReadCommands-I7OSREPJ.js → docReadCommands-3FXTVWVJ.js} +42 -38
  107. package/{docStore-UAWSKZ2Y.js → docStore-LTAGA6XZ.js} +26 -27
  108. package/{docUpdateCommands-X4Z26VJM.js → docUpdateCommands-ZE6B3SLE.js} +44 -40
  109. package/emscripten-module-EDQBMDVK.js +576 -0
  110. package/emscripten-module-LCBQ7VWY.js +1506 -0
  111. package/emscripten-module-OFHQ7EL3.js +482 -0
  112. package/emscripten-module-XM7NDJQA.js +4536 -0
  113. package/fetchMessages-7QRCCRYK.js +1 -1
  114. package/ffi-6ZSX3QJ4.js +80 -0
  115. package/ffi-742Y76PE.js +92 -0
  116. package/ffi-AEYWSYLM.js +80 -0
  117. package/ffi-KQC27OUM.js +92 -0
  118. package/{getPricing-L2ENXWHV.js → getPricing-5R7P4JLI.js} +4 -4
  119. package/{handleSendMessageAction-C3TSDWKH.js → handleSendMessageAction-7GF5IU4J.js} +26 -25
  120. package/index.js +78 -76
  121. package/{localRuntimeAuthority-E3R24J4T.js → localRuntimeAuthority-S77B5QVB.js} +6 -2
  122. package/{localRuntimeDb-DDZCJFQZ.js → localRuntimeDb-N3H3HQ7G.js} +1 -1
  123. package/{machineCommands-BUOIYJAD.js → machineCommands-57UG5TRO.js} +84 -81
  124. package/{machineInfo-M6KB6HZN.js → machineInfo-66ZFUMLE.js} +1 -1
  125. package/{machineWsRunDispatch-7CRWAA6O.js → machineWsRunDispatch-L3GQ7ASL.js} +72 -69
  126. package/{models-OX2S5C6Q.js → models-CQOLEOPZ.js} +2 -2
  127. package/module-ES6BEMUI-AFCVSBMS.js +14 -0
  128. package/module-asyncify-2EFITU5U-DEP2F2QP.js +9 -0
  129. package/package.json +1 -1
  130. package/{read-6G73BMEY.js → read-QOLSHOT5.js} +6 -6
  131. package/{readDocTool-DK4EI2GA.js → readDocTool-X7HLXXBW.js} +1 -1
  132. package/{readlineWorkspace-ZDWEASJV.js → readlineWorkspace-SFUQOD4C.js} +3746 -3155
  133. package/{removeDialogAgentAction-E7H557UO.js → removeDialogAgentAction-UBYX7RVR.js} +12 -12
  134. package/{runAgentClientLoop-U7HYA3O5.js → runAgentClientLoop-VCTFHJVP.js} +53 -54
  135. package/{runtimeDoctorCommands-KIKM6BIO.js → runtimeDoctorCommands-HT4O2PXL.js} +6 -6
  136. package/{setDialogExtraReferencesAction-RMMGBR5F.js → setDialogExtraReferencesAction-GMXZTTQA.js} +9 -9
  137. package/{setPrimaryDialogAgentAction-FWBKKLVA.js → setPrimaryDialogAgentAction-JKVEILI3.js} +12 -12
  138. package/{settingSlice-73PV4KG4.js → settingSlice-EQKEXSTU.js} +10 -10
  139. package/{skillDiscovery-KLLKXPUO.js → skillDiscovery-6YSTRCQ7.js} +3 -3
  140. package/{slateUtils-VO2FU36K.js → slateUtils-RIZES3PV.js} +1 -1
  141. package/{spaceCommands-GEWZXGHM.js → spaceCommands-3PVSEEGH.js} +235 -46
  142. package/{spaceSlice-B6MOVY4N.js → spaceSlice-OEBVDZGG.js} +25 -26
  143. package/{streamAgentChatTurn-T527EQTT.js → streamAgentChatTurn-YLUPK5CI.js} +107 -120
  144. package/{switchDialogAgentAction-US6QNL3N.js → switchDialogAgentAction-DSC2T3JW.js} +8 -8
  145. package/{chunk-IDAU4UFS.js → syncMapping-N6RGXGBW.js} +11 -11
  146. package/{tableCommands-QE47K72R.js → tableCommands-SQSOF2XK.js} +9 -9
  147. package/{tools-XMWCVMPM.js → tools-IZUS4UM5.js} +41 -42
  148. package/{tuiSummaryLlmCaller-NCAJSVSD.js → tuiSummaryLlmCaller-ZFPTFGXJ.js} +17 -16
  149. package/{updateCommands-AK2RDOFR.js → updateCommands-MNDUIKN7.js} +2 -2
  150. package/{updateDialogTitleAction-XPJZRJEL.js → updateDialogTitleAction-BB53DOCT.js} +31 -32
  151. package/chunk-6PO2SYCS.js +0 -1800
  152. package/chunk-M3JEW6N6.js +0 -193
  153. package/syncMapping-RK2MANUX.js +0 -43
  154. package/{agentGrantCommands-2LEZDADN.js → agentGrantCommands-OPIGFRDO.js} +2 -2
  155. package/{chunk-ZHYK3N56.js → chunk-G7HTVVFL.js} +3 -3
  156. package/{chunk-SAQQLJZ5.js → chunk-JDSUTNYY.js} +3 -3
  157. 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-JE4J3T7A.js";
24
+ import {
25
+ getReadableCliDb
26
+ } from "./chunk-UNHKVD2N.js";
27
+ import {
28
+ normalizeAgentHandle,
29
+ readDbRecord,
30
+ resolveAgentRecordFromHybridStore
31
+ } from "./chunk-NBIS3WYT.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-7CH6ONWB.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-AXCXE35O.js";
54
70
  import {
55
71
  API_REPORTED_COST_MULTIPLIER,
56
72
  normalizeUsage,
57
73
  parseUiAskChoiceContent
58
- } from "./chunk-73GINUCW.js";
74
+ } from "./chunk-SQPMYIR5.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-6PI2635O.js";
91
+ import {
92
+ resolveAgentRuntimeConfigFromRecord
93
+ } from "./chunk-GN6ENM54.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-3GDKZAPT.js";
102
+ import {
103
+ isQuotaExhaustedError
104
+ } from "./chunk-QUK7UZW7.js";
76
105
  import {
77
106
  DEFAULT_CONTEXT_WINDOW,
78
107
  getModelContextWindow
79
- } from "./chunk-2H3XIBY4.js";
108
+ } from "./chunk-FSOCQPX7.js";
80
109
  import {
81
110
  clipCompactText
82
- } from "./chunk-AOXVOC6D.js";
111
+ } from "./chunk-W2DNU6FK.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-P35OZHD4.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-52DHSNJC.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;
@@ -963,8 +1345,295 @@ function classifyDiffLine(line) {
963
1345
  return "context";
964
1346
  }
965
1347
 
966
- // packages/cli/client/assistantOutput.ts
1348
+ // packages/cli/client/mermaid.ts
967
1349
  var STYLE = {
1350
+ reset: "\x1B[0m"
1351
+ };
1352
+ function maskLabelSpans(line, restores = []) {
1353
+ const text = line.replace(
1354
+ /("[^"\n]*"|\[[^\]\n]*\]|\{[^}\n]*\}|\([^()\n]*\)|\|[^|\n]*\|)/g,
1355
+ (m) => {
1356
+ const idx = restores.push(m) - 1;
1357
+ return `\0M${idx}\0`;
1358
+ }
1359
+ );
1360
+ return { text, restores };
1361
+ }
1362
+ function unmask(masked, restores) {
1363
+ return masked.replace(/\x00M(\d+)\x00/g, (_, i) => restores[+i] ?? "");
1364
+ }
1365
+ function decodeShape(rest) {
1366
+ let lm;
1367
+ if (lm = rest.match(/^\[\s*"([^"]*)"\s*\]/)) return { shape: "rect", label: lm[1] };
1368
+ if (lm = rest.match(/^\(\s*\(\s*"?([^"()]*)"?\s*\)\s*\)/)) return { shape: "stadium", label: lm[1] };
1369
+ if (lm = rest.match(/^\(\s*\[\s*"?([^"()]*)"?\s*\]\s*\)/)) return { shape: "stadium", label: lm[1] };
1370
+ if (lm = rest.match(/^\[\s*([^\[\]]+)\s*\]/)) return { shape: "rect", label: lm[1] };
1371
+ if (lm = rest.match(/^\{\s*([^}]*)\s*\}/)) return { shape: "diamond", label: lm[1] };
1372
+ if (lm = rest.match(/^\(\s*"?([^[\]()]*)"?\s*\)/)) return { shape: "rounded", label: lm[1] };
1373
+ return null;
1374
+ }
1375
+ function parseNodeSeg(seg) {
1376
+ const t2 = seg.trim();
1377
+ if (!t2) return null;
1378
+ const m = t2.match(/^([A-Za-z_][A-Za-z0-9_-]*)(.*)$/s);
1379
+ if (!m) return null;
1380
+ const id = m[1];
1381
+ const rest = m[2].trim();
1382
+ if (rest && decodeShape(rest) === null) return null;
1383
+ const dec = decodeShape(rest);
1384
+ return { id, shape: dec ? dec.shape : "rect", label: (dec ? dec.label : id).trim() || id };
1385
+ }
1386
+ function stripComment(line) {
1387
+ const idx = line.indexOf("%%");
1388
+ return (idx >= 0 ? line.slice(0, idx) : line).trim().replace(/[,;]\s*$/, "");
1389
+ }
1390
+ var DIAGRAM_HEADERS = /^\s*(graph|flowchart|subgraph|end)\b|^\s*(sequenceDiagram|sequence|gantt|classDiagram|stateDiagram|erDiagram|requirementDiagram|pie|journey|mindmap|sankey|timeline)\b/;
1391
+ function parseMermaid(source) {
1392
+ const nodes = /* @__PURE__ */ new Map();
1393
+ const edges = [];
1394
+ const skipped = [];
1395
+ const parseStatement = (maskedStmt, restores) => {
1396
+ const parts = maskedStmt.split(/-->/);
1397
+ if (parts.length < 2) {
1398
+ const parsed = parseNodeSeg(unmask(parts[0], restores).trim());
1399
+ if (parsed) {
1400
+ nodes.set(parsed.id, { id: parsed.id, label: parsed.label, shape: parsed.shape });
1401
+ return true;
1402
+ }
1403
+ return false;
1404
+ }
1405
+ const lineNodes = /* @__PURE__ */ new Map();
1406
+ const lineEdges = [];
1407
+ let ok = true;
1408
+ let fromPrev = null;
1409
+ for (let i = 0; i < parts.length; i++) {
1410
+ let seg = parts[i];
1411
+ let label;
1412
+ if (i > 0) {
1413
+ const restored = unmask(seg, restores);
1414
+ const pm = restored.match(/^\|\s*([^|]*)\s*\|([\s\S]*)$/);
1415
+ if (pm) {
1416
+ label = pm[1].trim() || void 0;
1417
+ seg = pm[2];
1418
+ }
1419
+ }
1420
+ const nodeText = unmask(seg, restores).trim();
1421
+ const parsed = parseNodeSeg(nodeText);
1422
+ if (!parsed) {
1423
+ ok = false;
1424
+ break;
1425
+ }
1426
+ const prev = lineNodes.get(parsed.id);
1427
+ lineNodes.set(parsed.id, {
1428
+ id: parsed.id,
1429
+ label: parsed.label !== parsed.id && parsed.label ? parsed.label : prev?.label ?? parsed.label,
1430
+ shape: parsed.shape !== "rect" ? parsed.shape : prev?.shape ?? parsed.shape
1431
+ });
1432
+ if (i > 0 && fromPrev !== null) lineEdges.push({ from: fromPrev, to: parsed.id, label });
1433
+ fromPrev = parsed.id;
1434
+ }
1435
+ if (!ok) return false;
1436
+ for (const [id, n] of lineNodes) {
1437
+ const cur = nodes.get(id);
1438
+ if (cur) {
1439
+ if (n.label !== id) cur.label = n.label;
1440
+ if (n.shape !== "rect") cur.shape = n.shape;
1441
+ } else nodes.set(id, n);
1442
+ }
1443
+ for (const e of lineEdges) edges.push(e);
1444
+ return true;
1445
+ };
1446
+ for (const raw of source.split("\n")) {
1447
+ const line = stripComment(raw);
1448
+ if (!line) continue;
1449
+ if (DIAGRAM_HEADERS.test(line)) continue;
1450
+ const restores = [];
1451
+ const { text: masked1 } = maskLabelSpans(line, restores);
1452
+ let norm = masked1.replace(/-{2,}>/g, "-->");
1453
+ norm = norm.replace(/\.?-[.]?->/g, "-->");
1454
+ norm = norm.replace(/={2,}>/g, "-->");
1455
+ norm = norm.replace(/--\s*([^>]+?)\s*-->/g, "-->|$1|");
1456
+ const { text: masked } = maskLabelSpans(norm, restores);
1457
+ const stmts = masked.split(";").map((s) => s.trim()).filter(Boolean);
1458
+ const results = stmts.map((s) => parseStatement(s, restores));
1459
+ if (results.some((r) => !r)) {
1460
+ skipped.push(raw.trim());
1461
+ }
1462
+ }
1463
+ return { nodes, edges, skipped };
1464
+ }
1465
+ function assignLayers(flow) {
1466
+ const layer = /* @__PURE__ */ new Map();
1467
+ const adj = /* @__PURE__ */ new Map();
1468
+ const indeg = /* @__PURE__ */ new Map();
1469
+ for (const id of flow.nodes.keys()) {
1470
+ adj.set(id, []);
1471
+ indeg.set(id, 0);
1472
+ }
1473
+ for (const e of flow.edges) {
1474
+ adj.get(e.from)?.push(e.to);
1475
+ indeg.set(e.to, (indeg.get(e.to) ?? 0) + 1);
1476
+ }
1477
+ const queue = [];
1478
+ for (const [id, d] of indeg) {
1479
+ if (d === 0) {
1480
+ layer.set(id, 0);
1481
+ queue.push(id);
1482
+ }
1483
+ }
1484
+ let head = 0;
1485
+ while (head < queue.length) {
1486
+ const cur = queue[head++];
1487
+ const l = layer.get(cur) ?? 0;
1488
+ for (const next of adj.get(cur) ?? []) {
1489
+ if ((layer.get(next) ?? 0) < l + 1) {
1490
+ layer.set(next, l + 1);
1491
+ queue.push(next);
1492
+ }
1493
+ }
1494
+ }
1495
+ if (queue.length === 0) {
1496
+ for (const id of flow.nodes.keys()) if (!layer.has(id)) layer.set(id, 0);
1497
+ }
1498
+ return layer;
1499
+ }
1500
+ function wrapLabel(label, width) {
1501
+ const clean = label.replace(/\s+/g, " ").trim();
1502
+ if (!clean) return [""];
1503
+ if (clean.length <= width) return [clean];
1504
+ const words = clean.split(" ");
1505
+ const lines = [];
1506
+ let cur = "";
1507
+ for (const w of words) {
1508
+ if ((cur + " " + w).trim().length > width && cur) {
1509
+ lines.push(cur);
1510
+ cur = w;
1511
+ } else {
1512
+ cur = cur ? cur + " " + w : w;
1513
+ }
1514
+ }
1515
+ if (cur) lines.push(cur);
1516
+ return lines;
1517
+ }
1518
+ function boxCorners(shape) {
1519
+ switch (shape) {
1520
+ case "diamond":
1521
+ return { l: "<", r: ">" };
1522
+ case "rounded":
1523
+ case "stadium":
1524
+ return { l: "(", r: ")" };
1525
+ case "parallelogram":
1526
+ return { l: "/", r: "\\" };
1527
+ default:
1528
+ return { l: "[", r: "]" };
1529
+ }
1530
+ }
1531
+ function drawBox(node, width, accent) {
1532
+ const inner = wrapLabel(node.label, Math.max(1, width - 2));
1533
+ const { l, r } = boxCorners(node.shape);
1534
+ const rows = [];
1535
+ rows.push(accent(l + "\u2500".repeat(width) + r));
1536
+ for (const text of inner) {
1537
+ const pad = " ".repeat(Math.max(0, width - 2 - text.length));
1538
+ rows.push(accent(l + " " + text + pad + " " + r));
1539
+ }
1540
+ rows.push(accent(l + "\u2500".repeat(width) + r));
1541
+ return rows;
1542
+ }
1543
+ function renderMermaid(flow, brightness, colorEnabled = true) {
1544
+ const accentTok = themeColorSequence("accent", process.env, brightness);
1545
+ const warningTok = themeColorSequence("warning", process.env, brightness);
1546
+ const mutedTok = themeColorSequence("muted", process.env, brightness);
1547
+ const wrap = (s, tok) => colorEnabled ? `${tok}${s}${STYLE.reset}` : s;
1548
+ const cAccent = (s) => wrap(s, accentTok);
1549
+ const cWarn = (s) => wrap(s, warningTok);
1550
+ const cMuted = (s) => wrap(s, mutedTok);
1551
+ if (flow.nodes.size === 0) {
1552
+ const sk = flow.skipped.join("\n");
1553
+ return cMuted("(empty mermaid diagram)") + (sk ? "\n" + cMuted(sk) : "");
1554
+ }
1555
+ const layers = assignLayers(flow);
1556
+ const maxLayer = Math.max(...Array.from(layers.values(), (v) => v));
1557
+ const byLayer = [];
1558
+ for (let l = 0; l <= maxLayer; l++) byLayer.push([]);
1559
+ for (const [id] of flow.nodes) byLayer[layers.get(id) ?? 0].push(id);
1560
+ const width = Math.max(
1561
+ 8,
1562
+ ...Array.from(flow.nodes.values(), (n) => n.label.length + 2)
1563
+ );
1564
+ const GAP = 3;
1565
+ const edgeLabel = /* @__PURE__ */ new Map();
1566
+ for (const e of flow.edges) {
1567
+ if (e.label && !edgeLabel.has(`${e.from}:${e.to}`)) {
1568
+ edgeLabel.set(`${e.from}:${e.to}`, e.label);
1569
+ }
1570
+ }
1571
+ const out = [];
1572
+ for (let l = 0; l <= maxLayer; l++) {
1573
+ const layerIds = byLayer[l] ?? [];
1574
+ if (layerIds.length === 0) continue;
1575
+ const boxes = layerIds.map((id) => drawBox(flow.nodes.get(id), width, cAccent));
1576
+ const boxHeight = Math.max(...boxes.map((b) => b.length));
1577
+ const colStart = (bi) => bi * (width + GAP);
1578
+ for (let r = 0; r < boxHeight; r++) {
1579
+ let line = "";
1580
+ boxes.forEach((b, bi) => {
1581
+ const cell = b[r] ?? b[b.length - 1];
1582
+ const col = colStart(bi);
1583
+ if (line.length < col) line += " ".repeat(col - line.length);
1584
+ line += cell;
1585
+ });
1586
+ out.push(line);
1587
+ }
1588
+ if (l < maxLayer) {
1589
+ const down = layerIds.map(
1590
+ (id) => flow.edges.some(
1591
+ (e) => e.from === id && (layers.get(e.to) ?? -1) === l + 1
1592
+ )
1593
+ );
1594
+ if (down.some(Boolean)) {
1595
+ let stemRow = "";
1596
+ layerIds.forEach((_, bi) => {
1597
+ if (!down[bi]) return;
1598
+ const mid = colStart(bi) + Math.floor(width / 2);
1599
+ if (stemRow.length < mid) stemRow += " ".repeat(mid - stemRow.length);
1600
+ stemRow += "\u2502";
1601
+ });
1602
+ out.push(stemRow);
1603
+ let arrowRow = "";
1604
+ layerIds.forEach((_, bi) => {
1605
+ if (!down[bi]) return;
1606
+ const mid = colStart(bi) + Math.floor(width / 2);
1607
+ if (arrowRow.length < mid) arrowRow += " ".repeat(mid - arrowRow.length);
1608
+ arrowRow += cWarn("\u25BC");
1609
+ });
1610
+ out.push(arrowRow);
1611
+ const labels = layerIds.flatMap((id, bi) => {
1612
+ if (!down[bi]) return [];
1613
+ return flow.edges.filter((e) => e.from === id && (layers.get(e.to) ?? -1) === l + 1).map((e) => edgeLabel.get(`${e.from}:${e.to}`)).filter((t2) => !!t2);
1614
+ });
1615
+ if (labels.length > 0) {
1616
+ out.push(cMuted(" \u2937 " + labels.join(" / ")));
1617
+ }
1618
+ }
1619
+ }
1620
+ }
1621
+ if (flow.skipped.length > 0) {
1622
+ out.push(cMuted("(skipped)"));
1623
+ for (const s of flow.skipped) out.push(cMuted(s));
1624
+ }
1625
+ return out.join("\n");
1626
+ }
1627
+ function renderMermaidBlock(source, brightness, colorEnabled = true) {
1628
+ const flow = parseMermaid(source);
1629
+ if (flow.nodes.size === 0) {
1630
+ return source;
1631
+ }
1632
+ return renderMermaid(flow, brightness, colorEnabled);
1633
+ }
1634
+
1635
+ // packages/cli/client/assistantOutput.ts
1636
+ var STYLE2 = {
968
1637
  reset: "\x1B[0m",
969
1638
  bold: "\x1B[1m",
970
1639
  dim: "\x1B[2m"
@@ -1143,7 +1812,7 @@ function detectCodeLangFromPath(filePath) {
1143
1812
  function highlightCodeLine(line, lang, brightness) {
1144
1813
  const info = colorSeq("info", brightness);
1145
1814
  if (lang === "unknown") {
1146
- return `${info}${line}${STYLE.reset}`;
1815
+ return `${info}${line}${STYLE2.reset}`;
1147
1816
  }
1148
1817
  if (lang === "diff") {
1149
1818
  return renderDiffLine({ kind: classifyDiffLine(line), text: line, colorEnabled: true });
@@ -1154,8 +1823,8 @@ function highlightCodeLine(line, lang, brightness) {
1154
1823
  const success = colorSeq("success", brightness);
1155
1824
  const warning = colorSeq("warning", brightness);
1156
1825
  const chrome = colorSeq("chrome", brightness);
1157
- const dim = STYLE.dim;
1158
- const reset = STYLE.reset;
1826
+ const dim = STYLE2.dim;
1827
+ const reset = STYLE2.reset;
1159
1828
  const out = [];
1160
1829
  let cursor = 0;
1161
1830
  for (const region of regions) {
@@ -1305,9 +1974,9 @@ function renderMarkdownLink(match, text, url) {
1305
1974
  var MARKDOWN_LINK_RE = /\[([^\]]+)\]\(([^)\s]+)\)/g;
1306
1975
  function styleInlineMarkdown(line, brightness) {
1307
1976
  const inlineCode = colorSeq("muted", brightness);
1308
- const reset = STYLE.reset;
1309
- const bold = STYLE.bold;
1310
- const dim = STYLE.dim;
1977
+ const reset = STYLE2.reset;
1978
+ const bold = STYLE2.bold;
1979
+ const dim = STYLE2.dim;
1311
1980
  return line.replace(MARKDOWN_LINK_RE, (m, t2, u) => renderMarkdownLink(m, t2, u)).replace(/`([^`]+)`/g, `${inlineCode}$1${reset}`).replace(/\*\*(.+?)\*\*/g, `${bold}$1${reset}`).replace(/(?<!\*)\*([^*]+?)\*(?!\*)/g, `${dim}$1${reset}`).replace(/~~([^~]+?)~~/g, `${dim}\x1B[9m$1\x1B[29m${reset}`);
1312
1981
  }
1313
1982
  function styleRichMarkdownLine(line, brightness) {
@@ -1316,62 +1985,110 @@ function styleRichMarkdownLine(line, brightness) {
1316
1985
  const level = heading[1].length;
1317
1986
  const title = heading[2];
1318
1987
  if (level === 1) {
1319
- return `${STYLE.bold}\x1B[4m${colorSeq("accent", brightness)}${title}${STYLE.reset}`;
1988
+ return `${STYLE2.bold}\x1B[4m${colorSeq("accent", brightness)}${title}${STYLE2.reset}`;
1320
1989
  }
1321
1990
  if (level === 2) {
1322
- return `${STYLE.bold}${colorSeq("warning", brightness)}${title}${STYLE.reset}`;
1991
+ return `${STYLE2.bold}${colorSeq("warning", brightness)}${title}${STYLE2.reset}`;
1323
1992
  }
1324
- return `${STYLE.bold}${colorSeq("info", brightness)}${title}${STYLE.reset}`;
1993
+ return `${STYLE2.bold}${colorSeq("info", brightness)}${title}${STYLE2.reset}`;
1325
1994
  }
1326
1995
  if (line.startsWith("\u8FDB\u5165 nolo-plan")) {
1327
- return `${colorSeq("chrome", brightness)}${STYLE.dim}${line}${STYLE.reset}`;
1996
+ return `${colorSeq("chrome", brightness)}${STYLE2.dim}${line}${STYLE2.reset}`;
1328
1997
  }
1329
1998
  const blockquote = line.match(/^>\s?(.*)$/);
1330
1999
  if (blockquote) {
1331
2000
  const border = colorSeq("chrome", brightness);
1332
2001
  const content = blockquote[1];
1333
- return `${border}\u2502${STYLE.reset} ${STYLE.dim}${content}${STYLE.reset}`;
2002
+ return `${border}\u2502${STYLE2.reset} ${STYLE2.dim}${content}${STYLE2.reset}`;
1334
2003
  }
1335
2004
  if (/^---+$/.test(line.trim())) {
1336
- return `${colorSeq("chrome", brightness)}${"\u2500".repeat(Math.min(line.trim().length, 40))}${STYLE.reset}`;
2005
+ return `${colorSeq("chrome", brightness)}${"\u2500".repeat(Math.min(line.trim().length, 40))}${STYLE2.reset}`;
1337
2006
  }
1338
2007
  const bullet = line.match(/^(\s*)(•)\s(.+)$/);
1339
2008
  if (bullet) {
1340
2009
  const styled = styleInlineMarkdown(bullet[3], brightness);
1341
- return `${bullet[1]}${colorSeq("accent", brightness)}\u2022${STYLE.reset} ${styled}`;
2010
+ return `${bullet[1]}${colorSeq("accent", brightness)}\u2022${STYLE2.reset} ${styled}`;
1342
2011
  }
1343
2012
  const ordered = line.match(/^(\s*)(\d+\.)\s(.+)$/);
1344
2013
  if (ordered) {
1345
2014
  const styled = styleInlineMarkdown(ordered[3], brightness);
1346
- return `${ordered[1]}${colorSeq("chrome", brightness)}${ordered[2]}${STYLE.reset} ${styled}`;
2015
+ return `${ordered[1]}${colorSeq("chrome", brightness)}${ordered[2]}${STYLE2.reset} ${styled}`;
1347
2016
  }
1348
2017
  const task = line.match(/^(\s*)(☐|☑)\s(.+)$/);
1349
2018
  if (task) {
1350
2019
  const styled = styleInlineMarkdown(task[3], brightness);
1351
- return `${task[1]}${colorSeq("accent", brightness)}${task[2]}${STYLE.reset} ${styled}`;
2020
+ return `${task[1]}${colorSeq("accent", brightness)}${task[2]}${STYLE2.reset} ${styled}`;
1352
2021
  }
1353
2022
  return styleInlineMarkdown(line, brightness);
1354
2023
  }
2024
+ function renderMermaidBody(bodyLines, brightness) {
2025
+ const body = bodyLines.join("\n");
2026
+ const rendered = renderMermaidBlock(body, brightness, true);
2027
+ if (rendered === body) {
2028
+ return bodyLines.map((l) => highlightCodeLine(l, "unknown", brightness)).join("\n");
2029
+ }
2030
+ return rendered;
2031
+ }
1355
2032
  function formatAssistantDisplay(text, options = {}) {
1356
2033
  const brightness = resolveTuiBrightness();
1357
2034
  const polished = polishAssistantStructure(text, options);
2035
+ const lines = polished.split("\n");
2036
+ const out = [];
2037
+ let i = 0;
1358
2038
  let inFence = false;
1359
2039
  let fenceLang = "unknown";
1360
- return polished.split("\n").map((line) => {
2040
+ let inMermaid = false;
2041
+ let mermaidBody = null;
2042
+ const flushMermaid = () => {
2043
+ if (mermaidBody !== null) {
2044
+ out.push(renderMermaidBody(mermaidBody, brightness));
2045
+ mermaidBody = null;
2046
+ }
2047
+ };
2048
+ while (i < lines.length) {
2049
+ const line = lines[i];
1361
2050
  if (isCodeFenceLine(line)) {
2051
+ const lang = readFenceLanguage(line);
2052
+ if (inMermaid) {
2053
+ flushMermaid();
2054
+ inMermaid = false;
2055
+ inFence = false;
2056
+ out.push(`${STYLE2.dim}${line}${STYLE2.reset}`);
2057
+ i++;
2058
+ continue;
2059
+ }
1362
2060
  if (inFence) {
1363
2061
  fenceLang = "unknown";
1364
- } else {
1365
- fenceLang = normalizeCodeLang(readFenceLanguage(line));
2062
+ inFence = false;
2063
+ out.push(`${STYLE2.dim}${line}${STYLE2.reset}`);
2064
+ i++;
2065
+ continue;
1366
2066
  }
1367
- inFence = !inFence;
1368
- return `${STYLE.dim}${line}${STYLE.reset}`;
2067
+ inFence = true;
2068
+ fenceLang = normalizeCodeLang(lang);
2069
+ if (/^mermaid$/i.test(lang)) {
2070
+ inMermaid = true;
2071
+ mermaidBody = [];
2072
+ }
2073
+ out.push(`${STYLE2.dim}${line}${STYLE2.reset}`);
2074
+ i++;
2075
+ continue;
2076
+ }
2077
+ if (inMermaid && mermaidBody !== null) {
2078
+ mermaidBody.push(line);
2079
+ i++;
2080
+ continue;
1369
2081
  }
1370
2082
  if (inFence) {
1371
- return highlightCodeLine(line, fenceLang, brightness);
2083
+ out.push(highlightCodeLine(line, fenceLang, brightness));
2084
+ i++;
2085
+ continue;
1372
2086
  }
1373
- return styleRichMarkdownLine(line, brightness);
1374
- }).join("\n");
2087
+ out.push(styleRichMarkdownLine(line, brightness));
2088
+ i++;
2089
+ }
2090
+ flushMermaid();
2091
+ return out.join("\n");
1375
2092
  }
1376
2093
  function emitFormattedAssistantBlock(write, text, trailingNewline = false) {
1377
2094
  if (!text) return;
@@ -1396,6 +2113,8 @@ function createRenderAwareStreamWriter(args) {
1396
2113
  let buffer = "";
1397
2114
  let inFence = false;
1398
2115
  let fenceLang = "unknown";
2116
+ let inMermaid = false;
2117
+ let mermaidBody = [];
1399
2118
  let lastKind = null;
1400
2119
  const PARTIAL_FLUSH_THRESHOLD = 48;
1401
2120
  const emitBreathIfNeeded = (nextKind) => {
@@ -1425,19 +2144,44 @@ function createRenderAwareStreamWriter(args) {
1425
2144
  if (lines.length < 2) break;
1426
2145
  const firstLine = lines[0] ?? "";
1427
2146
  if (isCodeFenceLine(firstLine)) {
2147
+ if (inMermaid) {
2148
+ const diagram = renderMermaidBody(mermaidBody, brightness);
2149
+ args.write(diagram + "\n");
2150
+ mermaidBody = [];
2151
+ inMermaid = false;
2152
+ inFence = false;
2153
+ fenceLang = "unknown";
2154
+ emitBreathIfNeeded("other");
2155
+ args.write(`${STYLE2.dim}${firstLine}${STYLE2.reset}
2156
+ `);
2157
+ lastKind = "other";
2158
+ buffer = lines.slice(1).join("\n");
2159
+ continue;
2160
+ }
1428
2161
  if (inFence) {
1429
2162
  fenceLang = "unknown";
2163
+ inFence = false;
1430
2164
  } else {
1431
- fenceLang = normalizeCodeLang(readFenceLanguage(firstLine));
2165
+ const lang = readFenceLanguage(firstLine);
2166
+ fenceLang = normalizeCodeLang(lang);
2167
+ if (/^mermaid$/i.test(lang)) {
2168
+ inMermaid = true;
2169
+ mermaidBody = [];
2170
+ }
2171
+ inFence = true;
1432
2172
  }
1433
- inFence = !inFence;
1434
2173
  emitBreathIfNeeded("other");
1435
- args.write(`${STYLE.dim}${firstLine}${STYLE.reset}
2174
+ args.write(`${STYLE2.dim}${firstLine}${STYLE2.reset}
1436
2175
  `);
1437
2176
  lastKind = "other";
1438
2177
  buffer = lines.slice(1).join("\n");
1439
2178
  continue;
1440
2179
  }
2180
+ if (inMermaid) {
2181
+ mermaidBody.push(firstLine);
2182
+ buffer = lines.slice(1).join("\n");
2183
+ continue;
2184
+ }
1441
2185
  if (inFence) {
1442
2186
  args.write(`${highlightCodeLine(firstLine, fenceLang, brightness)}
1443
2187
  `);
@@ -1481,6 +2225,14 @@ function createRenderAwareStreamWriter(args) {
1481
2225
  flushPartialProse();
1482
2226
  },
1483
2227
  flush() {
2228
+ if (inMermaid) {
2229
+ if (buffer) mermaidBody.push(...buffer.split("\n"));
2230
+ args.write(renderMermaidBody(mermaidBody, brightness) + "\n");
2231
+ mermaidBody = [];
2232
+ inMermaid = false;
2233
+ buffer = "";
2234
+ return;
2235
+ }
1484
2236
  if (!buffer) return;
1485
2237
  if (inFence) {
1486
2238
  args.write(buffer);
@@ -3304,7 +4056,7 @@ async function detectCurrentMachineId(env) {
3304
4056
  const fromEnv = (env.NOLO_CURRENT_MACHINE_ID || env.NOLO_MACHINE_ID || "").trim();
3305
4057
  if (fromEnv) return fromEnv;
3306
4058
  try {
3307
- const { detectMachineInfo } = await import("./machineInfo-M6KB6HZN.js");
4059
+ const { detectMachineInfo } = await import("./machineInfo-66ZFUMLE.js");
3308
4060
  const machine = await detectMachineInfo({ probeLaunchable: true });
3309
4061
  return asOptionalTrimmedString(machine?.machineId);
3310
4062
  } catch {
@@ -3521,7 +4273,7 @@ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
3521
4273
  // packages/cli/client/agentRun.ts
3522
4274
  import { ulid } from "ulid";
3523
4275
  async function loadRunLocalAgentTurn() {
3524
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-JX34G47Z.js");
4276
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-TEJECMTH.js");
3525
4277
  return runLocalAgentTurn;
3526
4278
  }
3527
4279
  async function resolveCurrentMachineId(options) {
@@ -3753,6 +4505,10 @@ function describeLocalRunFailure(message) {
3753
4505
  }
3754
4506
  const cls = classifyLocalRunError(message);
3755
4507
  if (cls.kind === "generic") {
4508
+ if (isTransientFetchError(message)) {
4509
+ 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.
4510
+ `;
4511
+ }
3756
4512
  return `${RUN_UNAVAILABLE_PREFIX} (${message}). ${NO_FALLBACK} Fix the local credential/config and retry, ${SERVER_FALLBACK_HINT}.
3757
4513
  `;
3758
4514
  }
@@ -4054,12 +4810,6 @@ async function runLocalAgentTurnForCli(options, settings) {
4054
4810
  "[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
4811
  );
4056
4812
  }
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
4813
  options.onLoopEvent?.(event);
4064
4814
  },
4065
4815
  ...options.abortSignal ? { abortSignal: options.abortSignal } : {},
@@ -4071,6 +4821,9 @@ async function runLocalAgentTurnForCli(options, settings) {
4071
4821
  ...!options.noStream ? {
4072
4822
  onTextDelta: (chunk) => {
4073
4823
  turnOutput.pushText(chunk);
4824
+ },
4825
+ onReasoningDelta: (chunk) => {
4826
+ turnOutput.pushThinking(chunk);
4074
4827
  }
4075
4828
  } : {}
4076
4829
  });
@@ -4868,40 +5621,6 @@ var resolveCliMemory = async (input) => {
4868
5621
  }
4869
5622
  };
4870
5623
 
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
5624
  // packages/cli/agentRunCommand.ts
4906
5625
  function resolvePositiveMs(value, fallback) {
4907
5626
  return parsePositiveFiniteNumberOrFallback(value, fallback);
@@ -5363,7 +6082,7 @@ export {
5363
6082
  resolveCliColorEnabled,
5364
6083
  dimCliText,
5365
6084
  ANSI_ESCAPE_REGEX,
5366
- stripAnsi,
6085
+ stripAnsi2 as stripAnsi,
5367
6086
  applyTerminalOutputToText,
5368
6087
  displayWidth,
5369
6088
  visibleWidth,
@@ -5372,6 +6091,9 @@ export {
5372
6091
  countPhysicalLines,
5373
6092
  takeDisplayWidth,
5374
6093
  padOrTruncateToWidth,
6094
+ tokenizeAnsiLine,
6095
+ buildSourceMapping,
6096
+ wrapTranscriptLineWithLayout,
5375
6097
  wrapTranscriptLine,
5376
6098
  buildWindowTitle,
5377
6099
  wrapTextToLines,
@@ -5411,8 +6133,6 @@ export {
5411
6133
  normalizeCliImageInput,
5412
6134
  inspectLocalRunWorkspace,
5413
6135
  resolveCliMemory,
5414
- QUOTA_ERROR_PATTERNS,
5415
- isQuotaExhaustedError,
5416
6136
  runAgentRunCommand,
5417
6137
  isBalanceExhaustedError
5418
6138
  };