nolo-cli 0.104.0-alpha.2 → 0.104.0

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 (208) hide show
  1. package/README.md +1 -1
  2. package/{_executeModel-4W7C3ACS.js → _executeModel-JXG5TLPE.js} +75 -68
  3. package/action-GVA5ARSJ.js +20 -0
  4. package/{addContentAction-O7R66HEX.js → addContentAction-J3DLDV64.js} +12 -11
  5. package/{addDialogAgentAction-74OA7KYP.js → addDialogAgentAction-PHIXJCF2.js} +18 -19
  6. package/{agentDeleteCommand-YB3S2LPY.js → agentDeleteCommand-2AWJGHXG.js} +117 -42
  7. package/{agentEmailCommands-AQZVMNLR.js → agentEmailCommands-VV5OSILE.js} +98 -88
  8. package/agentListCommands-OQMRBDWP.js +742 -0
  9. package/{agentMachineCommands-R5AVYYN3.js → agentMachineCommands-3VLLR6RL.js} +48 -43
  10. package/{agentProviderCommands-GNPTL5XR.js → agentProviderCommands-XPJYZSCE.js} +97 -2
  11. package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-B4T2DJ5H.js} +1 -1
  12. package/agentRecordCommands-GPIARVOW.js +138 -0
  13. package/agentRunCommand-LRJTZ7IM.js +167 -0
  14. package/{agentRunControl-AVJR4JW4.js → agentRunControl-3HWA2LLQ.js} +2 -2
  15. package/{agentRuntimeLocal-FRUE5P2V.js → agentRuntimeLocal-PV6AZOEU.js} +44 -39
  16. package/{agentSlice-6LBOYNKN.js → agentSlice-6R3JKS6I.js} +14 -13
  17. package/{appDeleteCommands-JPWTSFID.js → appDeleteCommands-WEX73P5R.js} +46 -41
  18. package/{appDeployCommands-YCVY2UYO.js → appDeployCommands-7BAXWA4M.js} +46 -41
  19. package/{appDeployStatusCommands-JMCEIKTI.js → appDeployStatusCommands-EJ6A2U4X.js} +46 -41
  20. package/{appGetCommands-EXWT3QAE.js → appGetCommands-SB355OEX.js} +46 -41
  21. package/{appListCommands-PKRLSWRE.js → appListCommands-TSZDPIKJ.js} +46 -41
  22. package/{authCommand-F4EFRRX6.js → authCommand-5PB3YRVV.js} +118 -24
  23. package/{authCommands-RGOGCPP6.js → authCommands-5RTUDYZW.js} +7 -5
  24. package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-SBBWTANC.js} +10 -8
  25. package/{chromeCommands-FZYAU75D.js → chromeCommands-AU5ZJXBG.js} +289 -37
  26. package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-ZYTCMNHG.js} +156 -22
  27. package/{chunk-6OZ36FXI.js → chunk-27ONFIEY.js} +22 -4
  28. package/{chunk-JEDZAO7L.js → chunk-2SYTUTLI.js} +257 -37
  29. package/{chunk-HVURBGF3.js → chunk-2U3NHADM.js} +6 -6
  30. package/{chunk-53HEEOTT.js → chunk-2WJ57RJA.js} +83 -16
  31. package/{chunk-OIVSQH2O.js → chunk-3BXNTXYI.js} +299 -5
  32. package/{chunk-V4MJDUSR.js → chunk-3F424ASC.js} +2 -2
  33. package/{chunk-HJUYAD4A.js → chunk-3Q7NEHAR.js} +5 -5
  34. package/chunk-44CU7CKA.js +13545 -0
  35. package/{chunk-EYAQT56M.js → chunk-4DPP773Q.js} +2 -2
  36. package/chunk-4LCOCOR5.js +50 -0
  37. package/{chunk-JPGCXHNM.js → chunk-4LKMZ3RR.js} +1 -1
  38. package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
  39. package/{chunk-6D6VBVEW.js → chunk-4W24JM32.js} +80 -14
  40. package/{chunk-H62HCIUP.js → chunk-4WMMIL66.js} +35 -22
  41. package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
  42. package/{chunk-ZCYXJSTU.js → chunk-54VPQTOA.js} +66 -94
  43. package/{chunk-E4MARS3Q.js → chunk-5GVBDNTO.js} +1 -1
  44. package/chunk-5MMAK75Q.js +15 -0
  45. package/{chunk-7S4YWN7P.js → chunk-5UUIGN6I.js} +4 -4
  46. package/{chunk-42V6BK2E.js → chunk-62IL3KQV.js} +4 -34
  47. package/{chunk-GQBOR3G6.js → chunk-7KVZ5LDQ.js} +2 -2
  48. package/chunk-A4SQRTZ6.js +15 -0
  49. package/{chunk-L5UXH3B2.js → chunk-AFH5QC6R.js} +58 -9
  50. package/{chunk-AEOE4Z6Q.js → chunk-AFSY3ZMB.js} +39 -15
  51. package/chunk-AGIM7IMJ.js +147 -0
  52. package/{chunk-5UTFL4QJ.js → chunk-AOTBKDRK.js} +7 -0
  53. package/{chunk-NA35QHCF.js → chunk-AWVP7PPG.js} +1 -1
  54. package/{chunk-EEGDMATE.js → chunk-B7APRSPS.js} +86 -81
  55. package/{chunk-W324THOB.js → chunk-BB7LVBTS.js} +20 -11
  56. package/{chunk-6YTOJY35.js → chunk-BZ7NPA6G.js} +35 -2
  57. package/{chunk-5H7KJX7J.js → chunk-CFHWVEUJ.js} +5 -5
  58. package/chunk-CHOZJMJS.js +78 -0
  59. package/{chunk-ETI2NYVF.js → chunk-CNA27EMD.js} +4 -4
  60. package/{chunk-ACTMNVHM.js → chunk-CYSYR67N.js} +1 -1
  61. package/{chunk-WV42OMV7.js → chunk-D2GQE6AF.js} +8 -8
  62. package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
  63. package/{chunk-Q554LLSI.js → chunk-DMXLXZKL.js} +1 -1
  64. package/chunk-DZ7R5V3Y.js +164 -0
  65. package/{chunk-3VNWWVKB.js → chunk-E3YWHWCR.js} +50 -18
  66. package/{chunk-KQ4ONNQD.js → chunk-EKPKW6RM.js} +155 -8
  67. package/{chunk-2J5Y72GY.js → chunk-EP7BWZ4B.js} +1 -1
  68. package/{chunk-ABQYVJBJ.js → chunk-EV235ILT.js} +5 -5
  69. package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
  70. package/{chunk-3ZW5ZJMM.js → chunk-FGSJ3YMD.js} +23 -28
  71. package/{chunk-2F7RJC6L.js → chunk-FOXQ7BAB.js} +1 -1
  72. package/{chunk-SH43IESU.js → chunk-GGC55Q32.js} +199 -29
  73. package/chunk-GMZLP5DV.js +82 -0
  74. package/{chunk-DHDMC6FO.js → chunk-GSKPJIHY.js} +14 -9
  75. package/{chunk-FDTR4QJ6.js → chunk-H6A6X4EK.js} +32 -1
  76. package/{chunk-DVINR3PL.js → chunk-HDLLCBRF.js} +1 -1
  77. package/{chunk-QOKAKDPE.js → chunk-HIM3FCLF.js} +0 -1
  78. package/{chunk-ONXOABJR.js → chunk-HNGRBWYF.js} +3 -0
  79. package/{chunk-VLTIYV3X.js → chunk-HP57OUJO.js} +4 -4
  80. package/{chunk-NXUYQBDZ.js → chunk-HYXABXCZ.js} +29 -78
  81. package/{chunk-DNCEALKX.js → chunk-IEJ5YDA4.js} +22 -29
  82. package/{chunk-O6OSWFZQ.js → chunk-IHPDK6UD.js} +6 -0
  83. package/{chunk-BP4XNZRM.js → chunk-JIXGJTBU.js} +4 -4
  84. package/{chunk-GPCZ7UXG.js → chunk-K6U4NKFJ.js} +1 -1
  85. package/{chunk-Z77CRGTW.js → chunk-KA5O5KQL.js} +1 -1
  86. package/{chunk-4OEFYTWL.js → chunk-L5WOICCV.js} +67 -48
  87. package/{chunk-LS2ZANRJ.js → chunk-LOCNXNOU.js} +1 -1
  88. package/chunk-LWLNLZC5.js +265 -0
  89. package/{chunk-H66KLASO.js → chunk-LWXE6IFU.js} +567 -519
  90. package/{chunk-PUOC4YRO.js → chunk-M7VLQGQP.js} +11 -0
  91. package/chunk-NKWIS6G2.js +442 -0
  92. package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
  93. package/{chunk-DJWMIXDZ.js → chunk-NSAFG343.js} +10 -10
  94. package/{chunk-UKZDAFYT.js → chunk-NSBID7PR.js} +6 -10
  95. package/{chunk-O7EBSHZR.js → chunk-NTR4SD3P.js} +845 -240
  96. package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
  97. package/chunk-NWENLDMM.js +42 -0
  98. package/chunk-O7SVKKLY.js +875 -0
  99. package/chunk-OCZKATRC.js +129 -0
  100. package/{chunk-VMFTFOWF.js → chunk-OKGVNZTL.js} +35 -8
  101. package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
  102. package/{chunk-JRQFUXY7.js → chunk-P5GCTVGV.js} +99 -22
  103. package/{chunk-PQFHGD77.js → chunk-QKTESDWK.js} +161 -14
  104. package/{chunk-U3JZVWIB.js → chunk-QMXJ5KDJ.js} +68 -46
  105. package/{chunk-GEPUP7OO.js → chunk-QYUBY3OZ.js} +3 -3
  106. package/{chunk-3BMYXEUW.js → chunk-R5AJODNI.js} +1 -1
  107. package/{chunk-J4MOO56S.js → chunk-RILRSUGC.js} +10 -2
  108. package/{chunk-OEVAY4J6.js → chunk-RWX7AY7J.js} +18 -20
  109. package/{chunk-YY7I6GQ3.js → chunk-S2NSK7AZ.js} +11 -9
  110. package/{chunk-IIVGDG4I.js → chunk-SJKULPGX.js} +13 -7
  111. package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
  112. package/chunk-TY3TIUJK.js +89 -0
  113. package/{chunk-I3TQJXQ7.js → chunk-U3C3IA32.js} +9 -2
  114. package/{chunk-UZGQNTVW.js → chunk-UA324D4O.js} +8 -6
  115. package/{chunk-YYLHWIW6.js → chunk-UKZX3NHN.js} +1 -1
  116. package/chunk-UWXDA7L5.js +8005 -0
  117. package/{chunk-3DII57IT.js → chunk-VCAQFMVN.js} +1 -1
  118. package/chunk-VIWDGTDA.js +8 -0
  119. package/chunk-VJVNU77E.js +83 -0
  120. package/{chunk-A6FMKU7M.js → chunk-VVJ2ENLY.js} +47 -67
  121. package/{chunk-UKWGR5SS.js → chunk-VY6VFGKR.js} +194 -1144
  122. package/{chunk-QDSINZM3.js → chunk-WJ3B6FX6.js} +1 -14
  123. package/{chunk-Q67DOFOO.js → chunk-Y3PMXGLH.js} +2 -0
  124. package/chunk-YK5MHOWM.js +915 -0
  125. package/chunk-YV25TM3R.js +780 -0
  126. package/{chunk-TOP2VXOR.js → chunk-YVU4XVJD.js} +5 -5
  127. package/{chunk-S6JLBH6Z.js → chunk-Z5NGE5DH.js} +29 -9
  128. package/{chunk-LC43IGO4.js → chunk-ZBHR642M.js} +704 -950
  129. package/chunk-ZRAU6T47.js +56 -0
  130. package/{chunk-VLI5LVL5.js → chunk-ZSUDOTPL.js} +19 -17
  131. package/commandRegistry-QU62WJQX.js +833 -0
  132. package/{contentThunks-LXOZUD2Y.js → contentThunks-VGV3JJVB.js} +37 -35
  133. package/{cooldownCommands-REAWYVTY.js → cooldownCommands-ZLEPIB4A.js} +2 -2
  134. package/{createAgentAutomationAction-M5NDEIC6.js → createAgentAutomationAction-ZNVLI4WV.js} +39 -37
  135. package/createDialogAction-TTUA46DT.js +69 -0
  136. package/{createPageAction-WY5ZKP2M.js → createPageAction-KUFSC5XW.js} +46 -43
  137. package/{chunk-RJ4QOQDA.js → cursorProvider-YGGNMVWX.js} +2496 -9905
  138. package/{dbSlice-XVWBAGYN.js → dbSlice-MYEETO73.js} +11 -10
  139. package/{deleteFile-YG6QMJLU.js → deleteFile-KESP65GC.js} +7 -6
  140. package/{dialogCommands-YVMHDEOX.js → dialogCommands-DRDPEOTL.js} +49 -45
  141. package/{dialogSlice-HSGREZGA.js → dialogSlice-V2SVSTIV.js} +41 -34
  142. package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
  143. package/{docCreateCommands-7UTWDYJU.js → docCreateCommands-M26CFDDQ.js} +48 -43
  144. package/{docDeleteCommands-GG6BJ4PS.js → docDeleteCommands-LRZHCKVX.js} +49 -44
  145. package/{docReadCommands-QHMQVSLP.js → docReadCommands-6QJSISHK.js} +47 -42
  146. package/{docStore-IIS36NGG.js → docStore-4RWAFNDM.js} +16 -12
  147. package/{docUpdateCommands-QPL6IVUK.js → docUpdateCommands-W4KU4U5T.js} +48 -43
  148. package/{fetchMessages-EIU7UFFK.js → fetchMessages-3PXAHKCR.js} +5 -5
  149. package/{getPricing-LUSEABA6.js → getPricing-NMMFT3YI.js} +4 -4
  150. package/{handleSendMessageAction-FEHCWMN2.js → handleSendMessageAction-VEWLGB5Z.js} +107 -41
  151. package/index.js +87 -884
  152. package/{lib-FRRS27KN.js → lib-PU2G2MSO.js} +523 -191
  153. package/{localDialogRead-BTFJ4V2I.js → localDialogRead-UYCKO7YZ.js} +2 -2
  154. package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-TU6OBC76.js} +9 -6
  155. package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-VKWVOPPI.js} +1 -1
  156. package/{machineCommands-7DEUPY32.js → machineCommands-AEHHCJEW.js} +92 -82
  157. package/machineWsRunDispatch-MY2KHS36.js +154 -0
  158. package/{memberThunks-QGFLFVCI.js → memberThunks-EE6TI3TV.js} +20 -18
  159. package/{models-T3SG6MJ5.js → models-ZPU5EDF4.js} +2 -2
  160. package/oauthTokenStore-ITEB663N.js +23 -0
  161. package/package.json +1 -1
  162. package/pdf-U6KSUEZZ.js +26435 -0
  163. package/processSpawn-SOAV3FEV.js +11 -0
  164. package/profileConfig-ZGOFORWV.js +43 -0
  165. package/{providerPresetApply-FG6NZ57W.js → providerPresetApply-TEBH7FDX.js} +7 -7
  166. package/{providerRegistry-757OWH3O.js → providerRegistry-CBJLNCET.js} +11 -7
  167. package/{read-COE3ZYR6.js → read-PJIT2YEJ.js} +7 -6
  168. package/{readDocTool-5USN4A6V.js → readDocTool-DRSXHGNL.js} +5 -3
  169. package/{readlineWorkspace-JP2AOALW.js → readlineWorkspace-7Q6MITLV.js} +2685 -2050
  170. package/{removeDialogAgentAction-IX3MN2ZO.js → removeDialogAgentAction-IN4WUKJJ.js} +21 -25
  171. package/{runAgentClientLoop-UY76PPZM.js → runAgentClientLoop-H2JALUVD.js} +76 -70
  172. package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-PIVSBZRZ.js} +4 -4
  173. package/runtimeModeArgs-2Y7BALTO.js +31 -0
  174. package/{setDialogExtraReferencesAction-X4HCPNZL.js → setDialogExtraReferencesAction-VDRF7LPK.js} +15 -13
  175. package/{setPrimaryDialogAgentAction-4GMIQLOD.js → setPrimaryDialogAgentAction-RO6LIWJ4.js} +22 -26
  176. package/{chunk-AFUORTY4.js → settingThunks-3OPOLOIA.js} +226 -940
  177. package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-ZBU76COE.js} +3 -3
  178. package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
  179. package/{spaceCommands-BMXKR7H6.js → spaceCommands-UBLL5EF2.js} +51 -46
  180. package/{streamAgentChatTurn-3YVIO4KE.js → streamAgentChatTurn-FFJWW3FD.js} +214 -108
  181. package/{switchDialogAgentAction-N52LRPA3.js → switchDialogAgentAction-MVF2JNE7.js} +18 -19
  182. package/{tableCommands-O6NWHFKV.js → tableCommands-6U4BMLRR.js} +10 -10
  183. package/{toolApiClient-QVJ6HDNN.js → toolApiClient-EJT6TMFG.js} +3 -3
  184. package/tools-AZRYLYNK.js +116 -0
  185. package/{tuiSummaryLlmCaller-WFRWERGK.js → tuiSummaryLlmCaller-7S5HJ3MT.js} +25 -22
  186. package/{updateCommands-2M74UL7P.js → updateCommands-4EHDLF5J.js} +3 -3
  187. package/{updateDialogTitleAction-GF5T3VMK.js → updateDialogTitleAction-5WXTRUJM.js} +82 -44
  188. package/action-YVYQEAAV.js +0 -31
  189. package/agentListCommands-3GWH4E4G.js +0 -410
  190. package/agentRecordCommands-JY4IWSSQ.js +0 -128
  191. package/agentRunCommand-7VTYZY3Q.js +0 -156
  192. package/browser-image-compression-MFDTD7K6.js +0 -1763
  193. package/chatQueueReduxAdapter-WFROMKD3.js +0 -186
  194. package/chunk-CQ3WA2NE.js +0 -299
  195. package/chunk-FQUHIG5X.js +0 -20782
  196. package/chunk-M76ECQRD.js +0 -13658
  197. package/chunk-MEYIRKDN.js +0 -8967
  198. package/chunk-Q5FJJ6XI.js +0 -103
  199. package/chunk-S7Z2HMCN.js +0 -25
  200. package/chunk-Y5GCAMGP.js +0 -9
  201. package/chunk-YPREESF4.js +0 -225
  202. package/createDialogAction-TDFOINOY.js +0 -65
  203. package/machineWsRunDispatch-D2NHL3P7.js +0 -144
  204. package/settingSlice-ZQZVUPKK.js +0 -204
  205. package/syncMapping-N6RGXGBW.js +0 -437
  206. package/tools-Q6IBBG33.js +0 -110
  207. package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
  208. package/{db-WK5MDZVN.js → db-VQSAOWAO.js} +1 -1
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  findPotentialSecrets
3
- } from "./chunk-S7Z2HMCN.js";
3
+ } from "./chunk-VJVNU77E.js";
4
4
  import {
5
5
  buildLocalRunEnv,
6
6
  isFullstackCodingAgentRef,
@@ -26,29 +26,35 @@ import {
26
26
  resolveFileWriteGateEnabled,
27
27
  resolveLocalUserId,
28
28
  t,
29
- toolLabel
30
- } from "./chunk-RJ4QOQDA.js";
31
- import {
32
- createRunActivityTracker,
33
- popSingleQueueMessage,
34
- readRunRecord,
35
- resolveRunQueuePath,
36
- settleRunTerminalAuthoritatively,
37
- spawnLocalBackgroundRun
38
- } from "./chunk-I3TQJXQ7.js";
29
+ toolLabel,
30
+ toolLabelVariants
31
+ } from "./chunk-UWXDA7L5.js";
39
32
  import {
40
33
  clearCredentialAvailability,
41
34
  readCredentialEntry,
42
- recordCredentialProbe,
43
- resolveCredentialKeyWithFallback
44
- } from "./chunk-42V6BK2E.js";
35
+ recordCredentialProbe
36
+ } from "./chunk-62IL3KQV.js";
45
37
  import {
46
38
  getReadableCliDb
47
- } from "./chunk-LS2ZANRJ.js";
39
+ } from "./chunk-LOCNXNOU.js";
40
+ import {
41
+ _appendEntityBatch,
42
+ _appendEvidenceBatch,
43
+ _appendRelationBatch,
44
+ _appendRetiredStateBatch,
45
+ _appendStateBatch,
46
+ getMemoryEntityVNext,
47
+ getMemoryEvidenceVNext,
48
+ getMemoryEvidenceVNextStrict,
49
+ getMemoryStateVNext,
50
+ listMemoryStatesForEntityVNext,
51
+ loadMemoryVNextCatalog,
52
+ putMemoryEvidenceVNext
53
+ } from "./chunk-TY3TIUJK.js";
48
54
  import {
49
55
  readDbRecord,
50
56
  resolveAgentRecordFromHybridStore
51
- } from "./chunk-AEOE4Z6Q.js";
57
+ } from "./chunk-AFSY3ZMB.js";
52
58
  import {
53
59
  isLocalCliAgentKey
54
60
  } from "./chunk-SV5IJK6K.js";
@@ -62,24 +68,13 @@ import {
62
68
  applyModelLayerOverride,
63
69
  buildModelLayerOverride
64
70
  } from "./chunk-LTRXGFMS.js";
65
- import {
66
- formatAgentListCard
67
- } from "./chunk-H66KLASO.js";
68
- import {
69
- isTransientFetchError
70
- } from "./chunk-5UTFL4QJ.js";
71
71
  import {
72
72
  isGatewayHttpStatus
73
73
  } from "./chunk-NF64D32W.js";
74
74
  import {
75
- formatFinishedRunCard,
76
- formatListRunsCard,
77
- formatNotFoundRunCard,
78
- formatStartRunCard,
79
- formatStatusRunCard,
80
- formatStopRunCard,
81
- isAgentRunTerminalStatus
82
- } from "./chunk-3VNWWVKB.js";
75
+ isTransientFetchError,
76
+ parsePositiveFiniteNumberOrFallback
77
+ } from "./chunk-AOTBKDRK.js";
83
78
  import {
84
79
  extractGoogleValidationLink
85
80
  } from "./chunk-BMQ2MJUK.js";
@@ -88,37 +83,55 @@ import {
88
83
  chooseMemoryOwners,
89
84
  loadMemoryCandidatesFromDb,
90
85
  resolveAgentMemoryPolicy
91
- } from "./chunk-3ZW5ZJMM.js";
86
+ } from "./chunk-FGSJ3YMD.js";
92
87
  import {
93
- API_REPORTED_COST_MULTIPLIER,
94
- parseUiAskChoiceContent
95
- } from "./chunk-FQUHIG5X.js";
88
+ createRunActivityTracker,
89
+ popSingleQueueMessage,
90
+ readRunRecord,
91
+ resolveRunQueuePath,
92
+ settleRunTerminalAuthoritatively,
93
+ spawnLocalBackgroundRun
94
+ } from "./chunk-U3C3IA32.js";
96
95
  import {
97
- isOAuthApiKeyRef
98
- } from "./chunk-YYLHWIW6.js";
96
+ formatAgentListCard,
97
+ formatFinishedRunCard,
98
+ formatListRunsCard,
99
+ formatNotFoundRunCard,
100
+ formatStartRunCard,
101
+ formatStatusRunCard,
102
+ formatStopRunCard,
103
+ isAgentRunTerminalStatus
104
+ } from "./chunk-E3YWHWCR.js";
99
105
  import {
100
106
  isCliAuthorityBrokerProtocolError,
101
107
  isCliAuthorityBrokerTimeoutError,
102
108
  isCliAuthorityBrokerUnavailableError
103
- } from "./chunk-TRV2MIDW.js";
109
+ } from "./chunk-EXAJ6DCR.js";
104
110
  import {
105
111
  getDefaultCliLocalRuntimeDb
106
- } from "./chunk-2F7RJC6L.js";
112
+ } from "./chunk-FOXQ7BAB.js";
113
+ import {
114
+ API_REPORTED_COST_MULTIPLIER,
115
+ parseUiAskChoiceContent
116
+ } from "./chunk-44CU7CKA.js";
117
+ import {
118
+ isOAuthApiKeyRef
119
+ } from "./chunk-UKZX3NHN.js";
107
120
  import {
108
121
  buildSkillDiscoveryContextLayer
109
- } from "./chunk-E4MARS3Q.js";
122
+ } from "./chunk-5GVBDNTO.js";
110
123
  import {
111
124
  parseExternalSkillMarkdown,
112
125
  parseSkillDocProtocol
113
- } from "./chunk-Q554LLSI.js";
126
+ } from "./chunk-DMXLXZKL.js";
114
127
  import {
115
128
  LOCAL_AGENT_CONFIG_MISSING_CODE,
116
129
  LOCAL_TURN_ABORTED_CODE,
117
130
  readActionGate
118
- } from "./chunk-LC43IGO4.js";
131
+ } from "./chunk-ZBHR642M.js";
119
132
  import {
120
133
  resolveAgentRuntimeConfigFromRecord
121
- } from "./chunk-5H7KJX7J.js";
134
+ } from "./chunk-CFHWVEUJ.js";
122
135
  import {
123
136
  createThinkParserState,
124
137
  flushThinkParser,
@@ -129,57 +142,55 @@ import {
129
142
  isQuotaExhaustedError,
130
143
  isQuotaLimited403Body,
131
144
  mergeAvailabilityDeadline,
132
- resolveCooldownGate
133
- } from "./chunk-FDTR4QJ6.js";
134
- import {
135
- isAntigravityOAuthAgent
136
- } from "./chunk-UZGQNTVW.js";
137
- import {
138
- resolveClientVersion
139
- } from "./chunk-6OZ36FXI.js";
145
+ resolveCooldownGate,
146
+ resolveCredentialKeyWithFallback
147
+ } from "./chunk-H6A6X4EK.js";
140
148
  import {
141
149
  DEFAULT_CONTEXT_WINDOW,
142
150
  getModelContextWindow,
143
151
  normalizeUsage
144
- } from "./chunk-4OEFYTWL.js";
152
+ } from "./chunk-L5WOICCV.js";
145
153
  import {
146
154
  clipCompactText
147
- } from "./chunk-DNCEALKX.js";
148
- import {
149
- findModelConfig
150
- } from "./chunk-OIVSQH2O.js";
155
+ } from "./chunk-5MMAK75Q.js";
151
156
  import {
152
157
  compactWhitespace
153
158
  } from "./chunk-DWLEOOGR.js";
154
- import {
155
- toErrorMessage
156
- } from "./chunk-HNMXYYJR.js";
157
159
  import {
158
160
  buildAgentsMdLayer,
159
161
  buildMemoryOverlayLayer,
160
162
  buildMemoryUseGuidanceLayer,
161
163
  partitionScopedBlocks,
162
164
  renderTurnContextBlocksWithScope
163
- } from "./chunk-DVINR3PL.js";
165
+ } from "./chunk-HDLLCBRF.js";
164
166
  import {
165
- readPipeText,
166
- spawnProcess
167
- } from "./chunk-X7HHHIOZ.js";
167
+ isAntigravityOAuthAgent
168
+ } from "./chunk-UA324D4O.js";
169
+ import {
170
+ resolveClientVersion
171
+ } from "./chunk-27ONFIEY.js";
172
+ import {
173
+ findModelConfig
174
+ } from "./chunk-3BXNTXYI.js";
175
+ import {
176
+ toErrorMessage
177
+ } from "./chunk-HNMXYYJR.js";
178
+ import {
179
+ getLogger,
180
+ normalizeError
181
+ } from "./chunk-YV25TM3R.js";
168
182
  import {
169
183
  resolveAuthToken
170
184
  } from "./chunk-A7GB5UGH.js";
185
+ import {
186
+ readPipeText,
187
+ spawnProcess
188
+ } from "./chunk-Y6ROFCZO.js";
171
189
  import {
172
190
  CLIENT_VERSION_TOO_OLD_CODE,
173
191
  NOLO_CLIENT_VERSION_HEADER,
174
192
  buildClientVersionUpgradeMessage
175
- } from "./chunk-Q67DOFOO.js";
176
- import {
177
- parsePositiveFiniteNumberOrFallback
178
- } from "./chunk-Y5GCAMGP.js";
179
- import {
180
- createMemoryKey,
181
- ulid
182
- } from "./chunk-VMFTFOWF.js";
193
+ } from "./chunk-Y3PMXGLH.js";
183
194
  import {
184
195
  asTrimmedLowercaseString
185
196
  } from "./chunk-QSJ3HFEF.js";
@@ -192,8 +203,9 @@ import {
192
203
  parsePublicAgentId
193
204
  } from "./chunk-M2EJHDJP.js";
194
205
  import {
195
- isLevelNotFoundError
196
- } from "./chunk-OW765XBU.js";
206
+ createMemoryKey,
207
+ ulid
208
+ } from "./chunk-OKGVNZTL.js";
197
209
  import {
198
210
  asTrimmedString
199
211
  } from "./chunk-3EUW3WEO.js";
@@ -8206,7 +8218,12 @@ function emitPlainGap(text, keywords, info, accent, warning, reset) {
8206
8218
  var UNORDERED_LIST_RE = /^(\s*)([-*+])\s+(.+)$/;
8207
8219
  var ORDERED_LIST_RE = /^(\s*)(\d+)\.\s+(.+)$/;
8208
8220
  var TASK_LIST_RE = /^(\s*)([-*+])\s+\[([ xX])\]\s+(.+)$/;
8221
+ var THEMATIC_BREAK_PATTERN = "(?:(-[ \\t]*){3,}|(\\*[ \\t]*){3,}|(_[ \\t]*){3,})";
8222
+ var THEMATIC_BREAK_RE = new RegExp(`^[ ]{0,3}${THEMATIC_BREAK_PATTERN}$`);
8209
8223
  function normalizeListLine(line) {
8224
+ if (THEMATIC_BREAK_RE.test(line)) {
8225
+ return line;
8226
+ }
8210
8227
  const task = line.match(TASK_LIST_RE);
8211
8228
  if (task) {
8212
8229
  const checked = task[3] === "x" || task[3] === "X";
@@ -8222,12 +8239,99 @@ function normalizeListLine(line) {
8222
8239
  }
8223
8240
  return line;
8224
8241
  }
8242
+ var TOOL_TREE_HEADER_RE = /^•\s+(.+?)\s+\((\d+)\)$/;
8243
+ var TOOL_TREE_LEAF_RE = /^([├└]──\s+)(.*?)\s{2}(✓|✗|!)(?:\s+(.*))?$/;
8244
+ var TOOL_SINGLE_RE = /^▸\s+(.+?)(?:\s+·\s+(.*?))?(?:\s{2}(✓|✗|!)(?:\s+(.*))?)$/;
8245
+ function plainToolLine(line) {
8246
+ return stripAnsi2(line);
8247
+ }
8248
+ var TOOL_TREE_GROUP_LABELS = new Set(
8249
+ ["execShell", "readFile", "fetchWebpage", "exa_search"].flatMap(toolLabelVariants)
8250
+ );
8251
+ function isKnownToolGroupLabel(label) {
8252
+ return TOOL_TREE_GROUP_LABELS.has(label);
8253
+ }
8254
+ function toolTreeHeaderMatch(line) {
8255
+ const match = plainToolLine(line).match(TOOL_TREE_HEADER_RE);
8256
+ return match && isKnownToolGroupLabel(match[1]) ? match : null;
8257
+ }
8258
+ function isToolTreeHeaderLine(line) {
8259
+ return toolTreeHeaderMatch(line) !== null;
8260
+ }
8261
+ function isToolTreeLeafLine(line) {
8262
+ return TOOL_TREE_LEAF_RE.test(plainToolLine(line));
8263
+ }
8264
+ function isToolSingleLine(line) {
8265
+ return TOOL_SINGLE_RE.test(plainToolLine(line));
8266
+ }
8267
+ function isToolGroupBoundary(cur, next) {
8268
+ return isToolTreeLeafLine(cur) && isToolTreeHeaderLine(next);
8269
+ }
8270
+ function statusColorSeq(marker, brightness) {
8271
+ if (marker === "\u2713") return colorSeq("success", brightness);
8272
+ if (marker === "\u2717") return colorSeq("danger", brightness);
8273
+ return colorSeq("warning", brightness);
8274
+ }
8275
+ function styleTuiToolLine(line, brightness) {
8276
+ const plain = plainToolLine(line);
8277
+ const chrome = colorSeq("chrome", brightness);
8278
+ const muted = colorSeq("muted", brightness);
8279
+ const header = toolTreeHeaderMatch(plain);
8280
+ if (header) {
8281
+ return `${chrome}\u2022${STYLE.reset} ${STYLE.bold}${muted}${header[1]}${STYLE.reset} ${chrome}${STYLE.dim}(${header[2]})${STYLE.reset}`;
8282
+ }
8283
+ const leaf = plain.match(TOOL_TREE_LEAF_RE);
8284
+ if (leaf) {
8285
+ const [, connector, detail, marker, statusDetail] = leaf;
8286
+ let rendered = `${chrome}${connector}${STYLE.reset}${chrome}${detail}${STYLE.reset}`;
8287
+ rendered += ` ${statusColorSeq(marker, brightness)}${marker}${STYLE.reset}`;
8288
+ if (statusDetail) {
8289
+ const metaSeq = marker === "\u2713" ? chrome : statusColorSeq(marker, brightness);
8290
+ rendered += ` ${metaSeq}${STYLE.dim}${statusDetail}${STYLE.reset}`;
8291
+ }
8292
+ return rendered;
8293
+ }
8294
+ const single = plain.match(TOOL_SINGLE_RE);
8295
+ if (single) {
8296
+ const [, label, detail, marker, statusDetail] = single;
8297
+ let rendered = `${chrome}\u25B8${STYLE.reset} ${STYLE.bold}${muted}${label}${STYLE.reset}`;
8298
+ if (detail) rendered += ` ${chrome}\xB7 ${detail}${STYLE.reset}`;
8299
+ rendered += ` ${statusColorSeq(marker, brightness)}${marker}${STYLE.reset}`;
8300
+ if (statusDetail) {
8301
+ const metaSeq = marker === "\u2713" ? chrome : statusColorSeq(marker, brightness);
8302
+ rendered += ` ${metaSeq}${STYLE.dim}${statusDetail}${STYLE.reset}`;
8303
+ }
8304
+ return rendered;
8305
+ }
8306
+ return null;
8307
+ }
8225
8308
  function isPolishListLikeLine(line) {
8226
- return LIST_LIKE_RE_FOR_GUARD.test(normalizeListLine(line));
8309
+ return LIST_LIKE_RE_FOR_GUARD.test(normalizeListLine(plainToolLine(line)));
8310
+ }
8311
+ var LIST_LIKE_RE_FOR_GUARD = /^\s*(?:•|◦|☐|☑|\d+\.)\s|^\s*[\u2460-\u2473]|^\s*[├└]──\s|^\s*▸\s/;
8312
+ function isPolishFenceInteriorLine(line) {
8313
+ return /^\x00F\d+\x00$/.test(line);
8314
+ }
8315
+ function polishHeadingLevel(line) {
8316
+ const match = stripAnsi2(line).match(/^(#{1,6})\s/);
8317
+ return match ? match[1].length : null;
8318
+ }
8319
+ function isPolishHeadingLine(line) {
8320
+ return polishHeadingLevel(line) !== null;
8321
+ }
8322
+ function isPolishIntroLine(line) {
8323
+ const plain = stripAnsi2(line).trimEnd();
8324
+ return plain.endsWith("\uFF1A") || plain.endsWith(":");
8227
8325
  }
8228
- var LIST_LIKE_RE_FOR_GUARD = /^\s*(?:•|☐|☑|\d+\.)\s|^\s*[\u2460-\u2473]|^\s*[├└]──\s/;
8229
8326
  function polishBreathInsertsBlankBetween(cur, next) {
8230
8327
  if (cur === "" || next === "") return false;
8328
+ if (isPolishFenceInteriorLine(cur) || isPolishFenceInteriorLine(next)) {
8329
+ return false;
8330
+ }
8331
+ if (isPolishIntroLine(cur) && isPolishListLikeLine(next)) return false;
8332
+ if (isPolishHeadingLine(cur) || isPolishHeadingLine(next)) return false;
8333
+ if (isCodeFenceLine(cur) !== isCodeFenceLine(next)) return true;
8334
+ if (isToolGroupBoundary(cur, next)) return true;
8231
8335
  return isPolishListLikeLine(cur) !== isPolishListLikeLine(next);
8232
8336
  }
8233
8337
  function convertMarkdownTablesForTerminal(text) {
@@ -8296,17 +8400,15 @@ function polishAssistantStructure(text, options = {}) {
8296
8400
  }
8297
8401
  return line;
8298
8402
  });
8299
- const afterHeading = maskedLines.join("\n").replace(/([^\n])\n(#{1,3} )/g, "$1\n\n$2").replace(/^(#{1,3} .+)\n(?!\n)/gm, "$1\n\n").replace(/\n{4,}/g, "\n\n\n");
8300
- const LIST_LIKE = /^\s*(?:•|☐|☑|\d+\.)\s|^\s*[\u2460-\u2473]|^\s*[├└]──\s/;
8403
+ const afterHeading = maskedLines.join("\n").replace(/([^\n])\n(#{1,6} )/g, "$1\n\n$2").replace(/^(#{1,2} .+)\n(?!\n)/gm, "$1\n\n").replace(new RegExp(`([^\\n])\\n([ ]{0,3}${THEMATIC_BREAK_PATTERN})$`, "gm"), "$1\n\n$2").replace(new RegExp(`^([ ]{0,3}${THEMATIC_BREAK_PATTERN})\\n(?!\\n)`, "gm"), "$1\n\n").replace(/\n{3,}/g, "\n\n");
8301
8404
  const headingLines = afterHeading.split("\n");
8302
8405
  const breathed = [];
8303
8406
  for (let i = 0; i < headingLines.length; i++) {
8304
8407
  breathed.push(headingLines[i]);
8305
8408
  const cur = headingLines[i];
8306
8409
  const next = headingLines[i + 1];
8307
- if (cur === "" || next === void 0 || next === "") continue;
8308
- if (LIST_LIKE.test(cur) === LIST_LIKE.test(next)) continue;
8309
- breathed.push("");
8410
+ if (next === void 0) continue;
8411
+ if (polishBreathInsertsBlankBetween(cur, next)) breathed.push("");
8310
8412
  }
8311
8413
  const polishedMasked = breathed.join("\n");
8312
8414
  const polished = polishedMasked.replace(
@@ -8316,17 +8418,23 @@ function polishAssistantStructure(text, options = {}) {
8316
8418
  return options.trimEdges === false ? polished : polished.trim();
8317
8419
  }
8318
8420
  function styleRichMarkdownLine(line, brightness) {
8319
- const heading = line.match(/^(#{1,3})\s+(.+)$/);
8421
+ const toolLine = styleTuiToolLine(line, brightness);
8422
+ if (toolLine !== null) return toolLine;
8423
+ const heading = line.match(/^(#{1,6})\s+(.+)$/);
8320
8424
  if (heading) {
8321
8425
  const level = heading[1].length;
8322
8426
  const title = heading[2];
8427
+ const styledTitle = styleInlineMarkdown(title, brightness);
8323
8428
  if (level === 1) {
8324
- return `${STYLE.bold}\x1B[4m${colorSeq("accent", brightness)}${title}${STYLE.reset}`;
8429
+ return `${STYLE.bold}${colorSeq("accent", brightness)}${styledTitle}${STYLE.reset}`;
8325
8430
  }
8326
8431
  if (level === 2) {
8327
- return `${STYLE.bold}${colorSeq("warning", brightness)}${title}${STYLE.reset}`;
8432
+ return `${STYLE.bold}${colorSeq("warning", brightness)}${styledTitle}${STYLE.reset}`;
8433
+ }
8434
+ if (level === 3) {
8435
+ return `${STYLE.bold}${colorSeq("info", brightness)}${styledTitle}${STYLE.reset}`;
8328
8436
  }
8329
- return `${STYLE.bold}${colorSeq("info", brightness)}${title}${STYLE.reset}`;
8437
+ return `${STYLE.bold}${colorSeq("muted", brightness)}${styledTitle}${STYLE.reset}`;
8330
8438
  }
8331
8439
  if (line.startsWith("\u8FDB\u5165 nolo-plan")) {
8332
8440
  return `${colorSeq("chrome", brightness)}${STYLE.dim}${line}${STYLE.reset}`;
@@ -8335,15 +8443,19 @@ function styleRichMarkdownLine(line, brightness) {
8335
8443
  if (blockquote) {
8336
8444
  const border = colorSeq("chrome", brightness);
8337
8445
  const content = blockquote[1];
8338
- return `${border}\u2502${STYLE.reset} ${STYLE.dim}${content}${STYLE.reset}`;
8446
+ const styled = styleInlineMarkdown(content, brightness);
8447
+ return `${border}\u2502${STYLE.reset} ${STYLE.dim}${styled}${STYLE.reset}`;
8339
8448
  }
8340
- if (/^---+$/.test(line.trim())) {
8341
- return `${colorSeq("chrome", brightness)}${"\u2500".repeat(Math.min(line.trim().length, 40))}${STYLE.reset}`;
8449
+ if (THEMATIC_BREAK_RE.test(line)) {
8450
+ return `${colorSeq("chrome", brightness)}${STYLE.dim}${"\u2500".repeat(36)}${STYLE.reset}`;
8342
8451
  }
8343
8452
  const bullet = line.match(/^(\s*)(•)\s(.+)$/);
8344
8453
  if (bullet) {
8454
+ const indent = bullet[1];
8345
8455
  const styled = styleInlineMarkdown(bullet[3], brightness);
8346
- return `${bullet[1]}${colorSeq("accent", brightness)}\u2022${STYLE.reset} ${styled}`;
8456
+ const marker = indent.length >= 2 ? "\u25E6" : "\u2022";
8457
+ const markerColor = indent.length >= 2 ? colorSeq("chrome", brightness) : colorSeq("accent", brightness);
8458
+ return `${indent}${markerColor}${marker}${STYLE.reset} ${styled}`;
8347
8459
  }
8348
8460
  const ordered = line.match(/^(\s*)(\d+\.)\s(.+)$/);
8349
8461
  if (ordered) {
@@ -8467,16 +8579,28 @@ function emitFormattedAssistantBlock(write, text, trailingNewline = false) {
8467
8579
  }
8468
8580
  function classifyStreamLine(line) {
8469
8581
  if (line === "") return "blank";
8470
- if (TASK_LIST_RE.test(line) || UNORDERED_LIST_RE.test(line) || ORDERED_LIST_RE.test(line) || /^\s*(?:•|☐|☑)\s/.test(line) || /^\s*[\u2460-\u2473]/.test(line)) {
8582
+ const plain = plainToolLine(line);
8583
+ if (isToolTreeHeaderLine(plain)) return "tool-header";
8584
+ if (isToolTreeLeafLine(plain)) return "tool-leaf";
8585
+ if (isToolSingleLine(plain)) return "tool";
8586
+ if (TASK_LIST_RE.test(plain) || UNORDERED_LIST_RE.test(plain) || ORDERED_LIST_RE.test(plain) || /^\s*(?:•|◦|☐|☑)\s/.test(plain) || /^\s*[\u2460-\u2473]/.test(plain)) {
8471
8587
  return "list";
8472
8588
  }
8589
+ if (isPolishListLikeLine(plain)) return "list";
8590
+ if (polishHeadingLevel(plain) !== null) return "heading";
8473
8591
  return "prose";
8474
8592
  }
8475
- function needsListProseBreath(prev, next) {
8593
+ function isStreamListLike(kind) {
8594
+ return kind === "list" || kind === "tool-header" || kind === "tool-leaf" || kind === "tool";
8595
+ }
8596
+ function needsListProseBreath(prev, next, prevLine = "") {
8476
8597
  if (prev === null || prev === "blank" || next === "blank") return false;
8477
- const prevList = prev === "list";
8478
- const nextList = next === "list";
8479
- return prevList !== nextList;
8598
+ if (next === "heading") return true;
8599
+ if (prev === "heading") return (polishHeadingLevel(prevLine) ?? 7) <= 2;
8600
+ if (prev === "fence" !== (next === "fence")) return true;
8601
+ if (isStreamListLike(next) && isPolishIntroLine(prevLine)) return false;
8602
+ if (prev === "tool-leaf" && next === "tool-header") return true;
8603
+ return isStreamListLike(prev) !== isStreamListLike(next);
8480
8604
  }
8481
8605
  function createRenderAwareStreamWriter(args) {
8482
8606
  const brightness = resolveTuiBrightness();
@@ -8486,9 +8610,16 @@ function createRenderAwareStreamWriter(args) {
8486
8610
  let inMermaid = false;
8487
8611
  let mermaidBody = [];
8488
8612
  let lastKind = null;
8613
+ let lastLine = "";
8614
+ let pendingBlankRow = false;
8489
8615
  const PARTIAL_FLUSH_THRESHOLD = 48;
8490
8616
  const emitBreathIfNeeded = (nextKind) => {
8491
- if (needsListProseBreath(lastKind, nextKind)) args.write("\n");
8617
+ if (pendingBlankRow) {
8618
+ args.write("\n");
8619
+ pendingBlankRow = false;
8620
+ lastKind = "blank";
8621
+ }
8622
+ if (needsListProseBreath(lastKind, nextKind, lastLine)) args.write("\n");
8492
8623
  };
8493
8624
  const flushPartialProse = () => {
8494
8625
  if (inFence || buffer.length < PARTIAL_FLUSH_THRESHOLD) return;
@@ -8506,6 +8637,7 @@ function createRenderAwareStreamWriter(args) {
8506
8637
  emitBreathIfNeeded("prose");
8507
8638
  emitFormattedAssistantBlock(args.write, prefix, false);
8508
8639
  lastKind = "prose";
8640
+ lastLine = prefix;
8509
8641
  buffer = prefix.length === buffer.length ? "" : buffer.slice(prefix.length);
8510
8642
  };
8511
8643
  const flushCompleteBlocks = () => {
@@ -8521,10 +8653,11 @@ function createRenderAwareStreamWriter(args) {
8521
8653
  inMermaid = false;
8522
8654
  inFence = false;
8523
8655
  fenceLang = "unknown";
8524
- emitBreathIfNeeded("other");
8656
+ emitBreathIfNeeded("fence");
8525
8657
  args.write(`${STYLE.dim}${firstLine}${STYLE.reset}
8526
8658
  `);
8527
- lastKind = "other";
8659
+ lastKind = "fence";
8660
+ lastLine = firstLine;
8528
8661
  buffer = lines.slice(1).join("\n");
8529
8662
  continue;
8530
8663
  }
@@ -8540,10 +8673,11 @@ function createRenderAwareStreamWriter(args) {
8540
8673
  }
8541
8674
  inFence = true;
8542
8675
  }
8543
- emitBreathIfNeeded("other");
8676
+ emitBreathIfNeeded("fence");
8544
8677
  args.write(`${STYLE.dim}${firstLine}${STYLE.reset}
8545
8678
  `);
8546
- lastKind = "other";
8679
+ lastKind = "fence";
8680
+ lastLine = firstLine;
8547
8681
  buffer = lines.slice(1).join("\n");
8548
8682
  continue;
8549
8683
  }
@@ -8555,7 +8689,8 @@ function createRenderAwareStreamWriter(args) {
8555
8689
  if (inFence) {
8556
8690
  args.write(`${highlightCodeLine(firstLine, fenceLang, brightness)}
8557
8691
  `);
8558
- lastKind = "other";
8692
+ lastKind = "fence";
8693
+ lastLine = firstLine;
8559
8694
  buffer = lines.slice(1).join("\n");
8560
8695
  continue;
8561
8696
  }
@@ -8568,6 +8703,7 @@ function createRenderAwareStreamWriter(args) {
8568
8703
  const inner = trimmedFirst.slice(2, trimmedFirst.length - 2);
8569
8704
  args.write(renderMathBlock(inner) + "\n");
8570
8705
  lastKind = "other";
8706
+ lastLine = trimmedFirst;
8571
8707
  buffer = lines.slice(1).join("\n");
8572
8708
  continue;
8573
8709
  }
@@ -8594,6 +8730,7 @@ function createRenderAwareStreamWriter(args) {
8594
8730
  if (lastInner) innerParts.push(lastInner);
8595
8731
  args.write(renderMathBlock(innerParts.join("\n")) + "\n");
8596
8732
  lastKind = "other";
8733
+ lastLine = trimmedFirst;
8597
8734
  buffer = lines.slice(closeIndex + 1).join("\n");
8598
8735
  continue;
8599
8736
  }
@@ -8614,14 +8751,23 @@ function createRenderAwareStreamWriter(args) {
8614
8751
  true
8615
8752
  );
8616
8753
  lastKind = "list";
8754
+ lastLine = lines[end - 1] ?? firstLine;
8617
8755
  buffer = lines.slice(end).join("\n");
8618
8756
  continue;
8619
8757
  }
8620
8758
  }
8621
8759
  const kind = classifyStreamLine(firstLine);
8760
+ if (kind === "blank") {
8761
+ if (lastKind !== null && lastKind !== "blank") pendingBlankRow = true;
8762
+ lastKind = "blank";
8763
+ lastLine = "";
8764
+ buffer = lines.slice(1).join("\n");
8765
+ continue;
8766
+ }
8622
8767
  emitBreathIfNeeded(kind);
8623
8768
  emitFormattedAssistantBlock(args.write, firstLine, true);
8624
8769
  lastKind = kind;
8770
+ lastLine = firstLine;
8625
8771
  buffer = lines.slice(1).join("\n");
8626
8772
  }
8627
8773
  };
@@ -9834,6 +9980,7 @@ ${this.text}
9834
9980
  // packages/cli/client/agentRunOutput.ts
9835
9981
  var IDENTITY_LABEL_SEPARATOR = " > ";
9836
9982
  var THINKING_PREVIEW_BUFFER_LIMIT = 512;
9983
+ var TUI_PROGRESS_BUFFER_LIMIT = 1200;
9837
9984
  function appendThinkingPreview(current, chunk, limit = THINKING_PREVIEW_BUFFER_LIMIT) {
9838
9985
  if (limit <= 0) return "";
9839
9986
  const combined = current + chunk;
@@ -9895,6 +10042,14 @@ function formatToolJsonEvent(event) {
9895
10042
  })}
9896
10043
  `;
9897
10044
  }
10045
+ function shouldPromoteTuiNarration(text) {
10046
+ if (text.length >= TUI_PROGRESS_BUFFER_LIMIT) return true;
10047
+ return /(^|\n)\s*(?:#{1,3}\s|```|[-*+]\s|\d+[.)]\s)/.test(text);
10048
+ }
10049
+ function narrationActivityLabel(text) {
10050
+ const oneLine = stripAnsi2(text).replace(/[`*_#>]/g, "").replace(/\s+/g, " ").trim();
10051
+ return truncateThinkingHint(oneLine, 60);
10052
+ }
9898
10053
  function createCliTurnOutput(params) {
9899
10054
  const { options } = params;
9900
10055
  const workingLabel = params.workingLabel ?? `${options.agentName} -> working`;
@@ -9903,14 +10058,36 @@ function createCliTurnOutput(params) {
9903
10058
  tuiTrees: options.output.tuiTrees === true
9904
10059
  });
9905
10060
  const eventMode = resolveAgentEventMode(options);
9906
- const showThinking = options.showThinking !== false;
10061
+ const assistantLabelManaged = options.output.assistantLabelManaged === true;
10062
+ const showThinking = !assistantLabelManaged && options.showThinking !== false;
10063
+ const hidesRoutineTuiToolDetail = (event) => {
10064
+ if (!assistantLabelManaged || event.toolName !== "editFile") return false;
10065
+ if (event.type === "tool-error") return false;
10066
+ if (readActionGate(event.metadata?.actionGate)) return false;
10067
+ if (event.metadata?.timedOut || event.metadata?.failed || event.metadata?.error) return false;
10068
+ if (typeof event.metadata?.exitCode === "number" && event.metadata.exitCode !== 0) return false;
10069
+ return true;
10070
+ };
9907
10071
  let streamedAssistantText = false;
9908
10072
  let everStreamedAnyText = false;
9909
10073
  let printedAssistantLabel = false;
9910
10074
  let thinkState = createThinkParserState();
9911
10075
  let thinkingFirstAt = null;
9912
10076
  let thinkingPreview = "";
10077
+ let tuiThinkingReported = false;
10078
+ const clearTuiThinkingLabel = () => {
10079
+ if (!tuiThinkingReported) return;
10080
+ tuiThinkingReported = false;
10081
+ options.activityReporter?.(null);
10082
+ };
9913
10083
  const markThinkingDelta = (chunk) => {
10084
+ if (assistantLabelManaged) {
10085
+ if (!tuiThinkingReported && !streamedAssistantText) {
10086
+ tuiThinkingReported = true;
10087
+ options.activityReporter?.(t("thinkingActive"));
10088
+ }
10089
+ return;
10090
+ }
9914
10091
  if (!showThinking) return;
9915
10092
  if (streamedAssistantText) return;
9916
10093
  if (thinkingFirstAt === null) {
@@ -9928,6 +10105,7 @@ function createCliTurnOutput(params) {
9928
10105
  options.activityReporter?.(label);
9929
10106
  };
9930
10107
  const endThinkingPhase = () => {
10108
+ clearTuiThinkingLabel();
9931
10109
  if (thinkingFirstAt === null) return;
9932
10110
  const seconds = Math.max(0, Math.round((Date.now() - thinkingFirstAt) / 1e3));
9933
10111
  thinkingFirstAt = null;
@@ -9940,7 +10118,6 @@ function createCliTurnOutput(params) {
9940
10118
  }
9941
10119
  };
9942
10120
  let compactionEvent = null;
9943
- const assistantLabelManaged = options.output.assistantLabelManaged === true;
9944
10121
  const writeToolOutput = (chunk) => {
9945
10122
  if (!chunk) return;
9946
10123
  if (typeof options.output.writeToolBlock === "function") {
@@ -9952,9 +10129,25 @@ function createCliTurnOutput(params) {
9952
10129
  const renderWriter = createRenderAwareStreamWriter({
9953
10130
  write: (chunk) => options.output.write(chunk)
9954
10131
  });
10132
+ let pendingTuiNarration = "";
10133
+ let tuiNarrationPromoted = false;
10134
+ const flushPendingTuiNarration = () => {
10135
+ if (!pendingTuiNarration) return;
10136
+ formatToolEvent.reset?.();
10137
+ renderWriter.push(pendingTuiNarration);
10138
+ pendingTuiNarration = "";
10139
+ tuiNarrationPromoted = true;
10140
+ streamedAssistantText = true;
10141
+ options.activityReporter?.(null);
10142
+ };
10143
+ const dropPendingTuiProgress = () => {
10144
+ pendingTuiNarration = "";
10145
+ tuiNarrationPromoted = false;
10146
+ options.activityReporter?.(null);
10147
+ };
9955
10148
  const writeVisibleAssistantChunk = (chunk) => {
9956
10149
  if (!chunk) return;
9957
- formatToolEvent.reset?.();
10150
+ if (!assistantLabelManaged) formatToolEvent.reset?.();
9958
10151
  const parsed = processThinkChunk(chunk, thinkState);
9959
10152
  thinkState = parsed.state;
9960
10153
  if (!parsed.content && !parsed.reasoning) return;
@@ -9970,8 +10163,23 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
9970
10163
  }
9971
10164
  printedAssistantLabel = true;
9972
10165
  }
9973
- streamedAssistantText = true;
9974
10166
  everStreamedAnyText = true;
10167
+ if (assistantLabelManaged) {
10168
+ if (tuiNarrationPromoted) {
10169
+ renderWriter.push(parsed.content);
10170
+ streamedAssistantText = true;
10171
+ return;
10172
+ }
10173
+ pendingTuiNarration += parsed.content;
10174
+ if (shouldPromoteTuiNarration(pendingTuiNarration)) {
10175
+ flushPendingTuiNarration();
10176
+ } else {
10177
+ const label = narrationActivityLabel(pendingTuiNarration);
10178
+ if (label) options.activityReporter?.(label);
10179
+ }
10180
+ return;
10181
+ }
10182
+ streamedAssistantText = true;
9975
10183
  renderWriter.push(parsed.content);
9976
10184
  };
9977
10185
  const handleToolEvent = (event) => {
@@ -9987,13 +10195,19 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
9987
10195
  return;
9988
10196
  }
9989
10197
  if (event.type === "tool-call") {
10198
+ if (assistantLabelManaged && pendingTuiNarration) {
10199
+ dropPendingTuiProgress();
10200
+ }
9990
10201
  renderWriter.flush();
9991
- formatToolEvent(event);
10202
+ if (!hidesRoutineTuiToolDetail(event)) {
10203
+ formatToolEvent(event);
10204
+ }
9992
10205
  endThinkingPhase();
9993
10206
  if (streamedAssistantText) {
9994
10207
  options.output.write("\n");
9995
10208
  streamedAssistantText = false;
9996
10209
  }
10210
+ if (assistantLabelManaged) tuiNarrationPromoted = false;
9997
10211
  const activeLabel = formatConservativeActiveToolLabel(event);
9998
10212
  spinner.show(activeLabel);
9999
10213
  options.activityReporter?.(activeLabel);
@@ -10005,6 +10219,9 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
10005
10219
  }
10006
10220
  spinner.stop();
10007
10221
  options.activityReporter?.(null);
10222
+ if (hidesRoutineTuiToolDetail(event)) {
10223
+ return;
10224
+ }
10008
10225
  if (isLiveAgentRunObservation(event, parsedRunEvent)) {
10009
10226
  formatToolEvent.consume?.(event);
10010
10227
  return;
@@ -10017,6 +10234,26 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
10017
10234
  return {
10018
10235
  spinner,
10019
10236
  eventMode,
10237
+ /**
10238
+ * Terminal cleanup for abort/error paths that never reach `finish()`.
10239
+ *
10240
+ * A user abort discards the transient TUI progress buffer: the user stopped
10241
+ * on purpose and the dock already showed that text as activity. A genuine
10242
+ * failure must not swallow prose that never got the chance to be *proven*
10243
+ * durable (only a following tool call proves "progress"), so it promotes the
10244
+ * pending buffer and flushes what was already promoted — otherwise a short
10245
+ * final answer followed by a transport error disappears from the transcript.
10246
+ */
10247
+ cancel(cleanup) {
10248
+ if (assistantLabelManaged && cleanup?.preservePendingNarration) {
10249
+ flushPendingTuiNarration();
10250
+ if (streamedAssistantText) {
10251
+ renderWriter.flush();
10252
+ options.output.write("\n");
10253
+ }
10254
+ }
10255
+ dropPendingTuiProgress();
10256
+ },
10020
10257
  pushText(chunk) {
10021
10258
  writeVisibleAssistantChunk(chunk);
10022
10259
  },
@@ -10024,10 +10261,6 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
10024
10261
  markThinkingDelta(chunk);
10025
10262
  },
10026
10263
  handleToolEvent,
10027
- /** 记录一条 compaction 观测事件(TUI 在 turn 结束时渲染一行 dim 摘要)。
10028
- * 一轮内可能来多条(轮开始 + 每个 round),按显著性保留最高者:
10029
- * 失败 > 新生成摘要 > 投影复用 > 跳过,避免末尾的例行跳过事件
10030
- * 覆盖掉中途真正发生的压缩。 */
10031
10264
  recordCompaction(event) {
10032
10265
  const significance = (e) => e.failed ? 4 : e.summaryGenerated ? 3 : e.compressed ? 2 : 1;
10033
10266
  if (!compactionEvent || significance(event) >= significance(compactionEvent)) {
@@ -10039,12 +10272,28 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
10039
10272
  spinner.show(activeLabel);
10040
10273
  options.activityReporter?.(activeLabel);
10041
10274
  },
10275
+ /**
10276
+ * Pre-delta turn phase label (ctx-overflow-feedback batch 3).
10277
+ *
10278
+ * localLoop 在首个 provider delta 之前依次发出 turn-phase 事件
10279
+ * (validating-context → compacting → waiting-provider);此前 CLI 只有
10280
+ * llm-start 才进入明确 working 状态,压缩期间 spinner 停在通用
10281
+ * working 文案上,用户无法区分「卡在检查上下文 / 压缩 / 等模型」。
10282
+ * 两个显示面(bare CLI 的 spinner 与 TUI 的 dock activityReporter)与
10283
+ * showWorking 走同一条投影,保证两端文案不漂移。
10284
+ */
10285
+ showPhase(phase) {
10286
+ const label = phase === "validating-context" ? t("contextChecking") : phase === "compacting" ? t("contextCompacting") : t("waitingForModel");
10287
+ spinner.show(label);
10288
+ options.activityReporter?.(label);
10289
+ },
10042
10290
  finish(fallbackContent) {
10043
10291
  const flushedThink = flushThinkParser(thinkState);
10044
10292
  thinkState = flushedThink.state;
10045
10293
  if (flushedThink.content) {
10046
10294
  writeVisibleAssistantChunk(flushedThink.content);
10047
10295
  }
10296
+ if (assistantLabelManaged) flushPendingTuiNarration();
10048
10297
  endThinkingPhase();
10049
10298
  spinner.stop();
10050
10299
  options.activityReporter?.(null);
@@ -10149,6 +10398,7 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
10149
10398
  let content = "";
10150
10399
  let dialogId;
10151
10400
  let usage;
10401
+ let sawDone = false;
10152
10402
  const handlePayload = (payload) => {
10153
10403
  if (typeof payload?.dialogId === "string" && payload.dialogId.trim()) {
10154
10404
  dialogId = payload.dialogId;
@@ -10161,6 +10411,7 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
10161
10411
  }
10162
10412
  if (payload?.type === "done") {
10163
10413
  usage = payload.usage;
10414
+ sawDone = true;
10164
10415
  return;
10165
10416
  }
10166
10417
  if (payload?.type === "dialog" || payload?.type === "status") {
@@ -10214,6 +10465,9 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
10214
10465
  }
10215
10466
  } catch (error) {
10216
10467
  turnOutput.spinner.stop();
10468
+ turnOutput.cancel({
10469
+ preservePendingNarration: !options.abortSignal?.aborted
10470
+ });
10217
10471
  if (options.abortSignal?.aborted) {
10218
10472
  return {
10219
10473
  exitCode: 0,
@@ -10243,6 +10497,15 @@ ${describeClientVersionTooOldFailure(message, error)}`);
10243
10497
  `);
10244
10498
  return { exitCode: 1 };
10245
10499
  }
10500
+ if (options.abortSignal?.aborted && !sawDone) {
10501
+ turnOutput.spinner.stop();
10502
+ turnOutput.cancel();
10503
+ return {
10504
+ exitCode: 0,
10505
+ ...dialogId ? { dialogId } : {},
10506
+ streamInterrupted: true
10507
+ };
10508
+ }
10246
10509
  turnOutput.finish(content);
10247
10510
  const usageText = formatUsage(usage, dialogId);
10248
10511
  if (usageText && shouldShowUsage(options.env))
@@ -10459,7 +10722,7 @@ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
10459
10722
  // packages/cli/client/agentRun.ts
10460
10723
  import { ulid as ulid2 } from "ulid";
10461
10724
  async function loadRunLocalAgentTurn() {
10462
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-FRUE5P2V.js");
10725
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-PV6AZOEU.js");
10463
10726
  return runLocalAgentTurn;
10464
10727
  }
10465
10728
  var stripDebugNoise = (s) => s.replace(/\s*raw="[\s\S]*"/g, "").replace(/\s*raw=\S+/g, "").replace(/\s*headers=\[[^\]]*\]/g, "").replace(/\s*headers=\S+/g, "").trim();
@@ -10779,7 +11042,8 @@ function classifyLocalRunError(message) {
10779
11042
  }
10780
11043
  return { kind: "generic" };
10781
11044
  }
10782
- var HISTORY_REPLAY_REJECTION_RE = /invalid_request_error|invalid\s+tool\s+call\s+arguments?/i;
11045
+ var HISTORY_REPLAY_REJECTION_RE = /invalid\s+tool\s+call\s+arguments?/i;
11046
+ var REASONING_REPLAY_CONTRACT_RE = /reasoning_content[^.]*must be passed back/i;
10783
11047
  var RUN_UNAVAILABLE_PREFIX = "[nolo] auto runtime: local run unavailable";
10784
11048
  var NO_FALLBACK = "Not falling back to server.";
10785
11049
  var SERVER_FALLBACK_HINT = "or use --server to run on the server explicitly.";
@@ -10788,27 +11052,30 @@ function buildAuthFailure(ctx) {
10788
11052
  const fix = platformNoToken ? `This install is not logged in \u2014 run \`nolo login\`, or set AUTH_TOKEN / NOLO_SERVER` : ctx.where === "server chat proxy" ? `Check the agent's provider/api-key settings on nolo.chat` : `Fix the local credential/config and retry`;
10789
11053
  const { url: validationUrl, text: validationText } = extractGoogleValidationLink(ctx.message);
10790
11054
  const validationLabel = validationText || "Verify your account";
10791
- const validationHint = validationUrl ? `
10792
- \u24D8 This provider requires a one-time account verification. Open this link in a browser signed into that account, then retry:
10793
- ${formatCliHyperlink(
10794
- validationUrl,
10795
- validationLabel
10796
- )}` + // A 200-char Google url wraps on a narrow terminal, and a wrapped link
10797
- // loses its hit area in several terminals — so even when the clickable
10798
- // form is available, the raw url still gets its own copyable line. (In
10799
- // the disabled path `label (url)` already carries it.)
10800
- (resolveCliHyperlinkEnabled() ? `
10801
- \u6216\u590D\u5236\u6B64\u94FE\u63A5: ${validationUrl}` : "") : "";
10802
- return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}, auth rejected).${validationHint ? `${validationHint}
10803
- ` : " "}Detail: ${ctx.message} ${NO_FALLBACK} ${fix}, ${SERVER_FALLBACK_HINT}.
11055
+ if (validationUrl) {
11056
+ const linkLine = `
11057
+ ${formatCliHyperlink(validationUrl, validationLabel)}`;
11058
+ const rawLine = resolveCliHyperlinkEnabled() ? `
11059
+ \u70B9\u4E0D\u4E86\u5C31\u590D\u5236\u8FD9\u884C: ${validationUrl}` : "";
11060
+ const verifyHint = `
11061
+ \u24D8 \u60F3\u4E00\u952E\u6253\u5F00\uFF1F\u8DD1 \`nolo auth antigravity --verify\` \u2014\u2014 \u5B83\u4F1A\u7528\u672C\u5730\u51ED\u8BC1\u62FF\u5230\u5F53\u524D\u9A8C\u8BC1\u94FE\u63A5\u5E76\u76F4\u63A5\u62C9\u8D77\u6D4F\u89C8\u5668\u3002`;
11062
+ const retryLine = `
11063
+ \u9A8C\u8BC1\u5B8C\u6210\u540E\u76F4\u63A5\u91CD\u8BD5\u521A\u624D\u7684\u547D\u4EE4\u5373\u53EF\uFF0Ctoken \u4E0D\u7528\u91CD\u65B0\u767B\u5F55\u3002`;
11064
+ return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}: Google requires a one-time account verification \u2014 your credential is fine).
11065
+ Open this link in a browser signed into ${ctx.credentialAccountId ? `\`${ctx.credentialAccountId}\`` : "the Google account behind this credential"}:${linkLine}${rawLine}${verifyHint}${retryLine}
11066
+ Detail: ${ctx.message} ${NO_FALLBACK} Use --server to run on the server explicitly.
11067
+ `;
11068
+ }
11069
+ return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}, auth rejected). Detail: ${ctx.message} ${NO_FALLBACK} ${fix}, ${SERVER_FALLBACK_HINT}.
10804
11070
  `;
10805
11071
  }
10806
11072
  function isAuthNoTokenBody(message) {
10807
11073
  return /"authCode"\s*:\s*"AUTH_NO_TOKEN"/i.test(message) || /no authentication token provided/i.test(message);
10808
11074
  }
10809
11075
  function buildRejectedPayloadFailure(ctx) {
10810
- const looksLikeHistoryReplay = HISTORY_REPLAY_REJECTION_RE.test(ctx.message);
10811
- const cause = looksLikeHistoryReplay ? ` This usually happens when the dialog history contains tool_calls or reasoning produced by a different model/provider (e.g. after /switch); the new provider rejects that history. Start a fresh dialog, or clean the offending history.` : "";
11076
+ const looksLikeReasoningReplay = REASONING_REPLAY_CONTRACT_RE.test(ctx.message);
11077
+ const looksLikeHistoryReplay = !looksLikeReasoningReplay && HISTORY_REPLAY_REJECTION_RE.test(ctx.message);
11078
+ const cause = looksLikeReasoningReplay ? ` This is a thinking-mode replay contract violation: the history contains an assistant tool-call turn without reasoning_content, but this model requires every such turn to pass reasoning back to the API. The upstream may not have returned reasoning for that turn, or the history came from a different model.` : looksLikeHistoryReplay ? ` This usually happens when the dialog history contains tool_calls or reasoning produced by a different model/provider (e.g. after /switch); the new provider rejects that history. Start a fresh dialog, or clean the offending history.` : "";
10812
11079
  return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}, the provider rejected the request body \u2014 this is NOT a local credential/config issue). Detail: ${ctx.message}${cause} ${NO_FALLBACK} Use --server to run on the server explicitly, or start a fresh dialog.
10813
11080
  `;
10814
11081
  }
@@ -10835,6 +11102,17 @@ function buildUpstreamFailure(ctx) {
10835
11102
  return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}). Detail: ${ctx.message} ${NO_FALLBACK} ${fix}, ${SERVER_FALLBACK_HINT}.
10836
11103
  `;
10837
11104
  }
11105
+ function formatLocalTurnFailureLine(error) {
11106
+ const message = toErrorMessage(error);
11107
+ if (error?.code === "LLM_REQUEST_TIMEOUT") {
11108
+ const msMatch = /after (\d+)ms/.exec(message);
11109
+ const deadline = msMatch && Number.isFinite(Number(msMatch[1])) ? formatElapsed(Math.round(Number(msMatch[1]) / 1e3)) : "the configured window";
11110
+ return `[nolo] ${t("llmRequestTimedOut", deadline)}
11111
+ `;
11112
+ }
11113
+ return `[nolo] Local agent run failed: ${message}
11114
+ `;
11115
+ }
10838
11116
  var FAILURE_BUILDERS = {
10839
11117
  auth: buildAuthFailure,
10840
11118
  "rejected-payload": buildRejectedPayloadFailure,
@@ -10843,6 +11121,7 @@ var FAILURE_BUILDERS = {
10843
11121
  upstream: buildUpstreamFailure
10844
11122
  };
10845
11123
  function describeLocalRunFailure(message, rawError) {
11124
+ const credentialAccountId = rawError && typeof rawError === "object" && typeof rawError.credentialAccountId === "string" ? rawError.credentialAccountId.trim() || void 0 : void 0;
10846
11125
  if (rawError && typeof rawError === "object" && "code" in rawError && rawError.code === "PLATFORM_STREAM_INTERRUPTED") {
10847
11126
  return "[nolo] The platform LLM stream was interrupted before the turn completed. Your conversation was preserved. Send another message to continue.\n";
10848
11127
  }
@@ -10891,6 +11170,10 @@ function describeLocalRunFailure(message, rawError) {
10891
11170
  }
10892
11171
  if (/CLI authority broker could not attach or take ownership/i.test(message)) {
10893
11172
  const cleaned = stripDebugNoise(message);
11173
+ if (/EADDRINUSE/i.test(message)) {
11174
+ return `${RUN_UNAVAILABLE_PREFIX} (${cleaned}). ${NO_FALLBACK} Use --server to run on the server explicitly.
11175
+ `;
11176
+ }
10894
11177
  return `${RUN_UNAVAILABLE_PREFIX} (${cleaned}). ${NO_FALLBACK} The local runtime could not attach to an existing broker or take database ownership. Check running broker processes holding the local authority store or retry, ${SERVER_FALLBACK_HINT}.
10895
11178
  `;
10896
11179
  }
@@ -10920,7 +11203,8 @@ function describeLocalRunFailure(message, rawError) {
10920
11203
  status: cls.status,
10921
11204
  ...cls.statusInferred ? { statusInferred: true } : {},
10922
11205
  ...cls.quotaExhausted ? { quotaExhausted: true } : {},
10923
- ...cooldownUntil ? { cooldownUntil } : {}
11206
+ ...cooldownUntil ? { cooldownUntil } : {},
11207
+ ...credentialAccountId ? { credentialAccountId } : {}
10924
11208
  };
10925
11209
  return FAILURE_BUILDERS[cls.kind](ctx);
10926
11210
  }
@@ -11237,6 +11521,18 @@ async function runLocalAgentTurnForCli(options, settings) {
11237
11521
  if (event.kind === "llm-start") {
11238
11522
  turnOutput.showWorking();
11239
11523
  }
11524
+ if (event.kind === "turn-phase") {
11525
+ turnOutput.showPhase(event.phase);
11526
+ }
11527
+ if (event.kind === "compaction-start") {
11528
+ turnOutput.showPhase("compacting");
11529
+ }
11530
+ if (event.kind === "compaction-end" || // 压缩失败(timeout/provider-error)时 localLoop 按失败原子性语义
11531
+ // 带着裁剪后的历史继续本轮,切回等待模型文案;aborted 时 turn 随即
11532
+ // 结束,不再切文案(终态由 abort 路径收尾)。
11533
+ event.kind === "compaction-failed" && event.reason !== "aborted") {
11534
+ turnOutput.showPhase("waiting-provider");
11535
+ }
11240
11536
  if (event.kind === "image-downgraded") {
11241
11537
  options.output.write(
11242
11538
  "[nolo] \u5F53\u524D agent \u88AB\u914D\u7F6E\u4E3A\u4E0D\u652F\u6301\u56FE\u7247\u8F93\u5165\uFF0C\u56FE\u7247\u5DF2\u7528\u5360\u4F4D\u6587\u672C\u66FF\u4EE3\u3002\u8BF7\u68C0\u67E5\u6A21\u578B\u7684\u56FE\u7247\u80FD\u529B\u914D\u7F6E\uFF0C\u6216\u7528 /switch \u9009\u62E9\u652F\u6301\u56FE\u7247\u7684 agent \u540E\u91CD\u65B0\u53D1\u9001\u56FE\u7247\u3002\n"
@@ -11282,6 +11578,9 @@ async function runLocalAgentTurnForCli(options, settings) {
11282
11578
  };
11283
11579
  } catch (error) {
11284
11580
  turnOutput.spinner.stop();
11581
+ turnOutput.cancel({
11582
+ preservePendingNarration: error?.code !== LOCAL_TURN_ABORTED_CODE && !options.abortSignal?.aborted
11583
+ });
11285
11584
  const savedDialogId = error?.dialogId;
11286
11585
  const abortedUsageRecords = error?.usageRecords;
11287
11586
  const abortedTurnCredits = sumPlatformCredits(abortedUsageRecords);
@@ -11305,10 +11604,12 @@ async function runLocalAgentTurnForCli(options, settings) {
11305
11604
  error.cooldownUntil = cooldownUntil;
11306
11605
  }
11307
11606
  if (settings.reportFailure) {
11308
- options.output.write(
11309
- `[nolo] Local agent run failed: ${toErrorMessage(error)}
11310
- `
11311
- );
11607
+ const failureLine = formatLocalTurnFailureLine(error);
11608
+ if (typeof options.output.writeErr === "function") {
11609
+ options.output.writeErr(failureLine);
11610
+ } else {
11611
+ options.output.write(failureLine);
11612
+ }
11312
11613
  if (cooldownUntil) {
11313
11614
  options.output.write(
11314
11615
  `[nolo] \u5DF2\u6807\u8BB0\u51B7\u5374\u81F3 ${cooldownUntil}\uFF0C\u5230\u671F\u524D\u6D3E\u53D1\u8BE5 agent \u4F1A\u88AB\u51B7\u5374\u95E8\u63A7\u62E6\u622A\u3002
@@ -11446,7 +11747,7 @@ async function runAgentTurn(options) {
11446
11747
  return { exitCode: 1 };
11447
11748
  }
11448
11749
  const localAvailability = await checkLocalAvailabilityBeforeHttpDispatch(options);
11449
- if (localAvailability?.exitCode) {
11750
+ if (localAvailability && "exitCode" in localAvailability) {
11450
11751
  return { exitCode: localAvailability.exitCode };
11451
11752
  }
11452
11753
  const httpResult = await runHttpAgentTurn(options, authToken);
@@ -12188,72 +12489,6 @@ var rankMemoryCandidates = (items, query, context) => {
12188
12489
  });
12189
12490
  };
12190
12491
 
12191
- // packages/ai/memory/vnext/store.ts
12192
- var enc = (value) => encodeURIComponent(value).replace(/-/g, "%2D");
12193
- var rangeOf = (prefix) => ({ gte: prefix, lte: `${prefix}\uFFFF` });
12194
- var entityKey = (ownerId, id) => `mem2-e-${enc(ownerId)}-${enc(id)}`;
12195
- var entityOwnerPrefix = (ownerId) => `mem2-e-${enc(ownerId)}-`;
12196
- var stateKey = (ownerId, id) => `mem2-s-${enc(ownerId)}-${enc(id)}`;
12197
- var stateEntityIndexKey = (ownerId, entityId, stateId) => `mem2-si-${enc(ownerId)}-${enc(entityId)}-${enc(stateId)}`;
12198
- var stateEntityIndexPrefix = (ownerId, entityId) => `mem2-si-${enc(ownerId)}-${enc(entityId)}-`;
12199
- var evidenceKey = (ownerId, id) => `mem2-v-${enc(ownerId)}-${enc(id)}`;
12200
- var relationKey = (ownerId, id) => `mem2-r-${enc(ownerId)}-${enc(id)}`;
12201
- var relationFromIndexKey = (ownerId, from, relationId) => `mem2-rf-${enc(ownerId)}-${enc(from)}-${enc(relationId)}`;
12202
- var relationToIndexKey = (ownerId, to, relationId) => `mem2-rt-${enc(ownerId)}-${enc(to)}-${enc(relationId)}`;
12203
- var readIndexed = async (db, prefix) => {
12204
- const refs = [];
12205
- for await (const [, value] of db.iterator({ ...rangeOf(prefix), reverse: false })) {
12206
- if (typeof value?.key === "string") refs.push(value.key);
12207
- }
12208
- const rows = await Promise.all(refs.map((key) => db.get(key).catch(() => null)));
12209
- return rows.filter((row) => !!row);
12210
- };
12211
- var getMemoryEntityVNext = async (db, ownerId, entityId) => db.get(entityKey(ownerId, entityId)).catch(() => null);
12212
- var listMemoryEntitiesVNext = async (db, ownerId) => {
12213
- const rows = [];
12214
- for await (const [, value] of db.iterator({
12215
- ...rangeOf(entityOwnerPrefix(ownerId)),
12216
- reverse: false
12217
- })) {
12218
- if (value) rows.push(value);
12219
- }
12220
- return rows;
12221
- };
12222
- var getMemoryStateVNext = async (db, ownerId, stateId) => db.get(stateKey(ownerId, stateId)).catch(() => null);
12223
- var listMemoryStatesForEntityVNext = (db, ownerId, entityId) => readIndexed(db, stateEntityIndexPrefix(ownerId, entityId));
12224
- var putMemoryEvidenceVNext = async (db, evidence) => {
12225
- await db.put(evidenceKey(evidence.ownerId, evidence.id), evidence);
12226
- };
12227
- var getMemoryEvidenceVNext = async (db, ownerId, evidenceId) => db.get(evidenceKey(ownerId, evidenceId)).catch(() => null);
12228
- var getMemoryEvidenceVNextStrict = async (db, ownerId, evidenceId) => {
12229
- try {
12230
- return await db.get(evidenceKey(ownerId, evidenceId));
12231
- } catch (error) {
12232
- if (isLevelNotFoundError(error)) return null;
12233
- throw error;
12234
- }
12235
- };
12236
- var _appendEntityBatch = (batch, entity) => {
12237
- batch.put(entityKey(entity.ownerId, entity.id), entity);
12238
- };
12239
- var _appendEvidenceBatch = (batch, evidence) => {
12240
- batch.put(evidenceKey(evidence.ownerId, evidence.id), evidence);
12241
- };
12242
- var _appendStateBatch = (batch, state2) => {
12243
- const key = stateKey(state2.ownerId, state2.id);
12244
- batch.put(key, state2);
12245
- batch.put(stateEntityIndexKey(state2.ownerId, state2.entityId, state2.id), { key });
12246
- };
12247
- var _appendRetiredStateBatch = (batch, state2) => {
12248
- batch.put(stateKey(state2.ownerId, state2.id), state2);
12249
- };
12250
- var _appendRelationBatch = (batch, relation) => {
12251
- const key = relationKey(relation.ownerId, relation.id);
12252
- batch.put(key, relation);
12253
- batch.put(relationFromIndexKey(relation.ownerId, relation.from, relation.id), { key });
12254
- batch.put(relationToIndexKey(relation.ownerId, relation.to, relation.id), { key });
12255
- };
12256
-
12257
12492
  // packages/ai/memory/vnext/recall.ts
12258
12493
  var MAX_RECALL_REFS = 6;
12259
12494
  var stripFence = (raw) => {
@@ -12283,14 +12518,6 @@ var parseSelection = (raw) => {
12283
12518
  reason: obj.reason
12284
12519
  };
12285
12520
  };
12286
- var buildCatalog = async (db, ownerId) => {
12287
- const entities = await listMemoryEntitiesVNext(db, ownerId);
12288
- const states = [];
12289
- for (const entity of entities) {
12290
- states.push(...await listMemoryStatesForEntityVNext(db, ownerId, entity.id));
12291
- }
12292
- return { entities, states };
12293
- };
12294
12521
  var catalogText = (entities, states) => JSON.stringify(
12295
12522
  {
12296
12523
  entities: entities.map((entity) => ({
@@ -12316,7 +12543,7 @@ var catalogText = (entities, states) => JSON.stringify(
12316
12543
  );
12317
12544
  var createMemoryVNextRecall = (input) => async (query) => {
12318
12545
  const startedAt = performance.now();
12319
- const { entities, states } = await buildCatalog(input.db, input.ownerId);
12546
+ const { entities, states } = await loadMemoryVNextCatalog(input.db, input.ownerId);
12320
12547
  if (entities.length === 0 && states.length === 0) {
12321
12548
  return {
12322
12549
  query,
@@ -13187,14 +13414,74 @@ var shortError2 = (error) => {
13187
13414
  return message.length > ERROR_MESSAGE_MAX2 ? `${message.slice(0, ERROR_MESSAGE_MAX2)}\u2026` : message;
13188
13415
  };
13189
13416
  var loadExistingContext = async (db, ownerId) => {
13190
- const entities = await listMemoryEntitiesVNext(db, ownerId);
13191
- const states = (await Promise.all(
13192
- entities.map((entity) => listMemoryStatesForEntityVNext(db, ownerId, entity.id))
13193
- )).flat();
13194
- return {
13195
- entityIds: entities.map((entity) => entity.id),
13196
- states
13417
+ const { entities, states } = await loadMemoryVNextCatalog(db, ownerId);
13418
+ return { entityIds: entities.map((entity) => entity.id), states };
13419
+ };
13420
+ var currentStatesCitingEvidence = (states, evidenceId) => states.filter((state2) => !state2.retiredAt && (state2.evidenceIds ?? []).includes(evidenceId));
13421
+ var isEvidenceCoveredByCurrentStates = (states, evidenceId) => currentStatesCitingEvidence(states, evidenceId).length > 0;
13422
+ var memoryVNextContextFingerprint = (existing) => {
13423
+ const states = existing.states ?? [];
13424
+ const entityIds = existing.entityIds ?? [];
13425
+ const canonical = [
13426
+ ...entityIds.map((id) => `e\0${id}`),
13427
+ ...states.map((state2) => `s\0${state2.id}\0${state2.updatedAt}\0${state2.retiredAt ?? ""}`)
13428
+ ].sort().join("");
13429
+ let hash = 2166136261;
13430
+ for (let i = 0; i < canonical.length; i++) {
13431
+ hash ^= canonical.charCodeAt(i);
13432
+ hash = Math.imul(hash, 16777619);
13433
+ }
13434
+ return `${entityIds.length}.${states.length}:${(hash >>> 0).toString(16)}`;
13435
+ };
13436
+ var MAX_NOOP_SUPPRESSIONS = 512;
13437
+ var noOpSuppressions = /* @__PURE__ */ new Map();
13438
+ var suppressionKey = (ownerId, evidenceId) => `${ownerId}\0${evidenceId}`;
13439
+ var recordNoOpSuppression = (ownerId, evidenceId, fingerprint) => {
13440
+ const key = suppressionKey(ownerId, evidenceId);
13441
+ noOpSuppressions.delete(key);
13442
+ noOpSuppressions.set(key, fingerprint);
13443
+ while (noOpSuppressions.size > MAX_NOOP_SUPPRESSIONS) {
13444
+ noOpSuppressions.delete(noOpSuppressions.keys().next().value);
13445
+ }
13446
+ };
13447
+ var noOpHistory = (ownerId, evidenceId, fingerprint) => {
13448
+ const recorded = noOpSuppressions.get(suppressionKey(ownerId, evidenceId));
13449
+ if (recorded === void 0) return "fresh";
13450
+ return recorded === fingerprint ? "suppressed" : "stale";
13451
+ };
13452
+ var pickFirstUncoveredLazyPromotionItem = async (db, selected) => {
13453
+ const contextByOwner = /* @__PURE__ */ new Map();
13454
+ const contextFor = (ownerId) => {
13455
+ let pending = contextByOwner.get(ownerId);
13456
+ if (!pending) {
13457
+ pending = loadExistingContext(db, ownerId).then((existing) => ({
13458
+ states: existing.states ?? [],
13459
+ fingerprint: memoryVNextContextFingerprint(existing)
13460
+ }));
13461
+ contextByOwner.set(ownerId, pending);
13462
+ }
13463
+ return pending;
13197
13464
  };
13465
+ let skippedCoveredCount = 0;
13466
+ let skippedNoOpCount = 0;
13467
+ let firstStale = null;
13468
+ for (const [selectedIndex, item] of selected.entries()) {
13469
+ const evidence = buildLegacyMemoryEvidence(item);
13470
+ const context = await contextFor(evidence.ownerId);
13471
+ if (isEvidenceCoveredByCurrentStates(context.states, evidence.id)) {
13472
+ skippedCoveredCount++;
13473
+ continue;
13474
+ }
13475
+ const history = noOpHistory(evidence.ownerId, evidence.id, context.fingerprint);
13476
+ if (history === "fresh") {
13477
+ return { item, selectedIndex, skippedCoveredCount, skippedNoOpCount };
13478
+ }
13479
+ if (history === "stale" && !firstStale) {
13480
+ firstStale = { item, selectedIndex, skippedCoveredCount, skippedNoOpCount };
13481
+ }
13482
+ skippedNoOpCount++;
13483
+ }
13484
+ return firstStale;
13198
13485
  };
13199
13486
  var withoutImportedEvidence = (mutation, importedEvidenceId) => ({
13200
13487
  ...mutation,
@@ -13210,6 +13497,11 @@ var runMemoryVNextLazyPromotion = async (input) => {
13210
13497
  }));
13211
13498
  const finish = (partial) => {
13212
13499
  const observation = {
13500
+ legacyItemId: input.item.id,
13501
+ evidenceId: deterministicEvidence.id,
13502
+ ...input.selectedIndex === void 0 ? {} : { selectedIndex: input.selectedIndex },
13503
+ ...input.skippedCoveredCount === void 0 ? {} : { skippedCoveredCount: input.skippedCoveredCount },
13504
+ ...input.skippedNoOpCount === void 0 ? {} : { skippedNoOpCount: input.skippedNoOpCount },
13213
13505
  ...partial,
13214
13506
  latencyMs: Math.round((clock() - startedAt) * 10) / 10
13215
13507
  };
@@ -13232,8 +13524,9 @@ var runMemoryVNextLazyPromotion = async (input) => {
13232
13524
  }
13233
13525
  const evidence = evidenceResult.evidence;
13234
13526
  const existing = await loadExistingContext(input.db, evidence.ownerId);
13235
- const alreadyCovered = (existing.states ?? []).some(
13236
- (state2) => !state2.retiredAt && state2.evidenceIds.includes(evidence.id)
13527
+ const alreadyCovered = isEvidenceCoveredByCurrentStates(
13528
+ existing.states ?? [],
13529
+ evidence.id
13237
13530
  );
13238
13531
  if (alreadyCovered) {
13239
13532
  return finish({ status: "already_covered" });
@@ -13248,6 +13541,11 @@ var runMemoryVNextLazyPromotion = async (input) => {
13248
13541
  });
13249
13542
  const semanticMutation = withoutImportedEvidence(interpreted.mutation, evidence.id);
13250
13543
  if (!hasWrites(semanticMutation)) {
13544
+ recordNoOpSuppression(
13545
+ evidence.ownerId,
13546
+ evidence.id,
13547
+ memoryVNextContextFingerprint(existing)
13548
+ );
13251
13549
  return finish({ status: "no_op", action: semanticMutation.action });
13252
13550
  }
13253
13551
  await applyMemoryInterpreterMutation(input.db, evidence.ownerId, semanticMutation);
@@ -13260,6 +13558,179 @@ var runMemoryVNextLazyPromotion = async (input) => {
13260
13558
  };
13261
13559
  var isMemoryVNextLazyPromotionEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_LAZY_PROMOTION === "1" || env.NOLO_MEMORY_VNEXT_LAZY_PROMOTION === "true";
13262
13560
 
13561
+ // packages/ai/memory/vnext/pureReadGate.ts
13562
+ var isMemoryVNextPureReadEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_PURE_READ === "1" || env.NOLO_MEMORY_VNEXT_PURE_READ === "true";
13563
+
13564
+ // packages/ai/memory/vnext/localRecall.ts
13565
+ var MIN_SHARED_TOKENS = 2;
13566
+ var MAX_LOCAL_RECALL_STATES = 8;
13567
+ var SAFE_TECHNICAL_SYNONYMS = {
13568
+ pr: ["\u5BA1\u67E5", "\u4EE3\u7801\u5BA1\u67E5", "diff"],
13569
+ diff: ["\u5BA1\u67E5", "\u4EE3\u7801\u5BA1\u67E5"],
13570
+ review: ["\u5BA1\u67E5", "\u4EE3\u7801\u5BA1\u67E5"],
13571
+ deploy: ["\u90E8\u7F72", "\u53D1\u7248"],
13572
+ release: ["\u53D1\u7248", "\u53D1\u5E03"],
13573
+ desktop: ["\u684C\u9762", "\u684C\u9762\u7AEF"]
13574
+ };
13575
+ var distinctTokens = (text) => new Set(tokenize2(text).filter((token) => token.length >= 2));
13576
+ var recallMemoryVNextLocal = (input) => {
13577
+ const rawTokens = distinctTokens(input.query);
13578
+ if (rawTokens.size === 0) return [];
13579
+ const queryTokens = new Set(rawTokens);
13580
+ for (const token of rawTokens) {
13581
+ const syns = SAFE_TECHNICAL_SYNONYMS[token.toLowerCase()];
13582
+ if (syns) {
13583
+ for (const syn of syns) {
13584
+ for (const t2 of distinctTokens(syn)) queryTokens.add(t2);
13585
+ }
13586
+ }
13587
+ }
13588
+ const entityById = new Map(input.entities.map((entity) => [entity.id, entity]));
13589
+ const hits = [];
13590
+ for (const state2 of input.states) {
13591
+ if (state2.retiredAt || !state2.text.trim()) continue;
13592
+ const entity = entityById.get(state2.entityId);
13593
+ const haystack = distinctTokens(
13594
+ [state2.facet, state2.text, entity?.name ?? "", ...entity?.aliases ?? []].join(" ")
13595
+ );
13596
+ let sharedTokens = 0;
13597
+ for (const token of queryTokens) if (haystack.has(token)) sharedTokens++;
13598
+ if (sharedTokens >= MIN_SHARED_TOKENS) hits.push({ state: state2, sharedTokens });
13599
+ }
13600
+ return hits.sort((a, b) => b.sharedTokens - a.sharedTokens || a.state.id.localeCompare(b.state.id)).slice(0, input.limit ?? MAX_LOCAL_RECALL_STATES);
13601
+ };
13602
+
13603
+ // packages/ai/memory/vnext/pureVNextRuntime.ts
13604
+ var buildSynthesizedStateItem = (state2, entity, ownerType, ownerId) => ({
13605
+ id: `vnext-state-${state2.id}`,
13606
+ ownerType,
13607
+ ownerId,
13608
+ visibility: "private",
13609
+ subjectType: "user",
13610
+ subjectId: ownerId,
13611
+ kind: "semantic",
13612
+ content: state2.text.trim(),
13613
+ createdAt: state2.createdAt,
13614
+ lastActivatedAt: state2.createdAt,
13615
+ activationCount: 1,
13616
+ importance: 0.9,
13617
+ confidence: 0.9,
13618
+ resident: state2.facet === "preference" || state2.facet === "style"
13619
+ });
13620
+ async function resolvePureVNextRuntime(input) {
13621
+ const { db, owners, userInput } = input;
13622
+ if (owners.length === 0 || !userInput.trim()) {
13623
+ return { selectedItems: [], promptBlock: null, recalledStateCount: 0 };
13624
+ }
13625
+ const ownerIds = owners.map((o) => `${o.ownerType}:${encodeURIComponent(o.ownerId)}`);
13626
+ const catalogs = await Promise.all(
13627
+ ownerIds.map((ownerId) => loadMemoryVNextCatalog(db, ownerId))
13628
+ );
13629
+ const selectedItems = [];
13630
+ const seenStateKeys = /* @__PURE__ */ new Set();
13631
+ for (let i = 0; i < owners.length; i++) {
13632
+ const owner = owners[i];
13633
+ const catalog = catalogs[i];
13634
+ const currentStates = catalog.states.filter((s) => !s.retiredAt && s.text.trim());
13635
+ const hits = recallMemoryVNextLocal({
13636
+ query: userInput,
13637
+ entities: catalog.entities,
13638
+ states: currentStates
13639
+ });
13640
+ const entityById = new Map(catalog.entities.map((e) => [e.id, e]));
13641
+ for (const hit of hits) {
13642
+ const stateKey = `${hit.state.ownerId}\0${hit.state.id}`;
13643
+ if (seenStateKeys.has(stateKey)) continue;
13644
+ seenStateKeys.add(stateKey);
13645
+ selectedItems.push(
13646
+ buildSynthesizedStateItem(hit.state, entityById.get(hit.state.entityId), owner.ownerType, owner.ownerId)
13647
+ );
13648
+ }
13649
+ }
13650
+ const promptBlock = selectedItems.length === 0 ? null : buildMemoryOverlay(selectedItems, {
13651
+ maxTokens: input.maxTokens ?? DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET
13652
+ });
13653
+ return {
13654
+ selectedItems,
13655
+ promptBlock,
13656
+ recalledStateCount: selectedItems.length
13657
+ };
13658
+ }
13659
+
13660
+ // packages/ai/memory/vnext/primaryRead.ts
13661
+ var MEMORY_VNEXT_PRIMARY_READ_TIMEOUT_MS = 300;
13662
+ var isMemoryVNextPrimaryReadEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_PRIMARY_READ === "1" || env.NOLO_MEMORY_VNEXT_PRIMARY_READ === "true";
13663
+ var buildSynthesizedStateItem2 = (state2, entity, ownerType, ownerId) => ({
13664
+ id: `vnext-state-${state2.id}`,
13665
+ ownerType,
13666
+ ownerId,
13667
+ visibility: "private",
13668
+ subjectType: "user",
13669
+ subjectId: ownerId,
13670
+ kind: "semantic",
13671
+ content: state2.text.trim(),
13672
+ createdAt: state2.createdAt,
13673
+ importance: 0.9,
13674
+ confidence: 0.9,
13675
+ // Flag resident preferences so they flow into overlay's resident section.
13676
+ resident: state2.facet === "preference" || state2.facet === "style",
13677
+ lastActivatedAt: state2.createdAt,
13678
+ activationCount: 1
13679
+ });
13680
+ var resolveMemoryVNextM4Selection = async (input) => {
13681
+ const { db, owners, query, selected } = input;
13682
+ const ownerIds = owners.map((o) => `${o.ownerType}:${encodeURIComponent(o.ownerId)}`);
13683
+ const catalogs = new Map(
13684
+ await Promise.all(
13685
+ ownerIds.map(async (ownerId) => [
13686
+ ownerId,
13687
+ await loadMemoryVNextCatalog(db, ownerId)
13688
+ ])
13689
+ )
13690
+ );
13691
+ const recalledStates = [];
13692
+ const recalledStateIds = /* @__PURE__ */ new Set();
13693
+ for (const owner of owners) {
13694
+ const principalId = `${owner.ownerType}:${encodeURIComponent(owner.ownerId)}`;
13695
+ const catalog = catalogs.get(principalId);
13696
+ if (!catalog) continue;
13697
+ const currentStates = catalog.states.filter((s) => !s.retiredAt && s.text.trim());
13698
+ const hits = recallMemoryVNextLocal({
13699
+ query,
13700
+ entities: catalog.entities,
13701
+ states: currentStates
13702
+ });
13703
+ const entityById = new Map(catalog.entities.map((e) => [e.id, e]));
13704
+ for (const hit of hits) {
13705
+ if (recalledStateIds.has(hit.state.id)) continue;
13706
+ recalledStateIds.add(hit.state.id);
13707
+ recalledStates.push(
13708
+ buildSynthesizedStateItem2(hit.state, entityById.get(hit.state.entityId), owner.ownerType, owner.ownerId)
13709
+ );
13710
+ }
13711
+ }
13712
+ const uncoveredLegacy = [];
13713
+ let coveredSuppressedCount = 0;
13714
+ for (const item of selected) {
13715
+ const evidence = buildLegacyMemoryEvidence(item);
13716
+ const catalog = catalogs.get(evidence.ownerId);
13717
+ const states = catalog?.states ?? [];
13718
+ const covering = currentStatesCitingEvidence(states, evidence.id);
13719
+ if (covering.length > 0) {
13720
+ coveredSuppressedCount++;
13721
+ } else {
13722
+ uncoveredLegacy.push(item);
13723
+ }
13724
+ }
13725
+ const renderItems = [...recalledStates, ...uncoveredLegacy];
13726
+ return {
13727
+ renderItems,
13728
+ recalledStateCount: recalledStates.length,
13729
+ uncoveredLegacyCount: uncoveredLegacy.length,
13730
+ coveredSuppressedCount
13731
+ };
13732
+ };
13733
+
13263
13734
  // packages/ai/memory/runtime.ts
13264
13735
  var COLD_STORAGE_CONFIDENCE = 0.3;
13265
13736
  var MEMORY_OVERLAY_TOKEN_BUDGET = DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET;
@@ -13382,6 +13853,18 @@ var resolveMemoryRuntime = async (input) => {
13382
13853
  if (owners.length === 0) {
13383
13854
  return { selectedItems: [], promptBlock: null };
13384
13855
  }
13856
+ if (isMemoryVNextPureReadEnabled()) {
13857
+ const pure = await resolvePureVNextRuntime({
13858
+ db: input.db,
13859
+ owners,
13860
+ userInput: input.userInput,
13861
+ maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET
13862
+ });
13863
+ return {
13864
+ selectedItems: pure.selectedItems,
13865
+ promptBlock: pure.promptBlock
13866
+ };
13867
+ }
13385
13868
  const policy = resolveAgentMemoryPolicy({ agentKey: input.agentKey });
13386
13869
  const legacyStartedAt = performance.now();
13387
13870
  const candidates = await loadMemoryCandidatesFromDb(input.db, {
@@ -13411,10 +13894,62 @@ var resolveMemoryRuntime = async (input) => {
13411
13894
  );
13412
13895
  const selected = [...residentItems, ...ranked];
13413
13896
  const legacyLatencyMs = Math.round((performance.now() - legacyStartedAt) * 10) / 10;
13414
- const promptBlock = selected.length === 0 ? null : buildMemoryOverlay(selected, { maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET });
13415
- const shadowEnabled = input.vNextShadowProvider != null && isMemoryVNextShadowReadEnabled();
13897
+ const renderOverlay = (items) => items.length === 0 ? null : buildMemoryOverlay(items, { maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET });
13898
+ let promptBlock = renderOverlay(selected);
13899
+ const primaryRead = isMemoryVNextPrimaryReadEnabled();
13900
+ let allCoveredByVNext = false;
13901
+ if (primaryRead) {
13902
+ const emitPrimary = (observation) => {
13903
+ try {
13904
+ (input.primaryReadEmit ?? ((o) => console.info("[memory] vnext primary read", { event: "memory_vnext_primary_read", ...o })))(observation);
13905
+ } catch {
13906
+ }
13907
+ };
13908
+ const base = { legacyHitCount: selected.length, legacyLatencyMs };
13909
+ const vnextStartedAt = performance.now();
13910
+ const vnextLatency = () => Math.round((performance.now() - vnextStartedAt) * 10) / 10;
13911
+ if (selected.length === 0) {
13912
+ emitPrimary({ ...base, source: "none" });
13913
+ } else {
13914
+ try {
13915
+ let timer;
13916
+ const m4 = await Promise.race([
13917
+ resolveMemoryVNextM4Selection({ db: input.db, owners, query: input.userInput, selected }),
13918
+ new Promise((_, reject) => {
13919
+ timer = setTimeout(
13920
+ () => reject(Object.assign(new Error("timeout"), { name: "TimeoutError" })),
13921
+ MEMORY_VNEXT_PRIMARY_READ_TIMEOUT_MS
13922
+ );
13923
+ })
13924
+ ]).finally(() => clearTimeout(timer));
13925
+ promptBlock = renderOverlay(m4.renderItems);
13926
+ allCoveredByVNext = m4.uncoveredLegacyCount === 0 && m4.recalledStateCount > 0;
13927
+ const source = m4.recalledStateCount > 0 ? m4.uncoveredLegacyCount === 0 ? "vnext" : "hybrid" : m4.uncoveredLegacyCount > 0 ? "legacy_fallback" : "none";
13928
+ emitPrimary({
13929
+ ...base,
13930
+ source,
13931
+ uncoveredLegacyCount: m4.uncoveredLegacyCount,
13932
+ coveredSuppressedCount: m4.coveredSuppressedCount,
13933
+ recalledStateCount: m4.recalledStateCount,
13934
+ vnextLatencyMs: vnextLatency(),
13935
+ contextChars: promptBlock?.length ?? 0,
13936
+ ...source === "legacy_fallback" ? { fallbackReason: "no_vnext_context" } : {}
13937
+ });
13938
+ } catch (error) {
13939
+ emitPrimary({
13940
+ ...base,
13941
+ source: "legacy_fallback",
13942
+ vnextLatencyMs: vnextLatency(),
13943
+ contextChars: promptBlock?.length ?? 0,
13944
+ fallbackReason: "vnext_error",
13945
+ error: error instanceof Error ? error.name : "UnknownError"
13946
+ });
13947
+ }
13948
+ }
13949
+ }
13950
+ const shadowEnabled = !primaryRead && input.vNextShadowProvider != null && isMemoryVNextShadowReadEnabled();
13416
13951
  if (shadowEnabled) {
13417
- await runMemoryVNextShadowRead({
13952
+ void runMemoryVNextShadowRead({
13418
13953
  ctx: {
13419
13954
  db: input.db,
13420
13955
  owners,
@@ -13424,17 +13959,28 @@ var resolveMemoryRuntime = async (input) => {
13424
13959
  legacyItems: selected,
13425
13960
  legacyLatencyMs,
13426
13961
  legacyContextChars: promptBlock?.length ?? 0
13962
+ }).catch(() => {
13427
13963
  });
13428
13964
  }
13429
- const promotionCandidate = selected[0];
13430
13965
  const lazyPromotionEnabled = input.vNextShadowProvider != null && isMemoryVNextLazyPromotionEnabled();
13431
- if (lazyPromotionEnabled && promotionCandidate) {
13432
- void runMemoryVNextLazyPromotion({
13433
- db: input.db,
13434
- item: promotionCandidate,
13435
- provider: input.vNextShadowProvider,
13436
- ...input.lazyPromotionEmit ? { emit: input.lazyPromotionEmit } : {}
13437
- }).catch(() => {
13966
+ if (lazyPromotionEnabled && selected.length > 0 && !allCoveredByVNext) {
13967
+ void (async () => {
13968
+ const promotionPick = await pickFirstUncoveredLazyPromotionItem(
13969
+ input.db,
13970
+ selected
13971
+ );
13972
+ if (promotionPick) {
13973
+ await runMemoryVNextLazyPromotion({
13974
+ db: input.db,
13975
+ item: promotionPick.item,
13976
+ selectedIndex: promotionPick.selectedIndex,
13977
+ skippedCoveredCount: promotionPick.skippedCoveredCount,
13978
+ skippedNoOpCount: promotionPick.skippedNoOpCount,
13979
+ provider: input.vNextShadowProvider,
13980
+ ...input.lazyPromotionEmit ? { emit: input.lazyPromotionEmit } : {}
13981
+ });
13982
+ }
13983
+ })().catch(() => {
13438
13984
  });
13439
13985
  }
13440
13986
  if (selected.length === 0) {
@@ -13448,6 +13994,52 @@ var resolveMemoryRuntime = async (input) => {
13448
13994
  };
13449
13995
 
13450
13996
  // packages/cli/memoryRecall.ts
13997
+ var logger = getLogger("cli.memoryRecall");
13998
+ var DEDUP_WINDOW_MS = 5 * 60 * 1e3;
13999
+ var DEDUP_MAX_KEYS = 100;
14000
+ var dedupMap = /* @__PURE__ */ new Map();
14001
+ function evictDedupIfNeeded() {
14002
+ if (dedupMap.size < DEDUP_MAX_KEYS) return;
14003
+ let oldestKey = null;
14004
+ let oldestTs = Infinity;
14005
+ for (const [k, v] of dedupMap) {
14006
+ if (v.lastLog < oldestTs) {
14007
+ oldestTs = v.lastLog;
14008
+ oldestKey = k;
14009
+ }
14010
+ }
14011
+ if (oldestKey !== null) dedupMap.delete(oldestKey);
14012
+ }
14013
+ function logDeduped(level, fingerprint, message, error) {
14014
+ const now = Date.now();
14015
+ const entry = dedupMap.get(fingerprint);
14016
+ if (!entry) {
14017
+ evictDedupIfNeeded();
14018
+ dedupMap.set(fingerprint, { count: 1, suppressed: 0, lastLog: now });
14019
+ if (error !== void 0) logger[level](message, error);
14020
+ else logger[level](message);
14021
+ return;
14022
+ }
14023
+ entry.count += 1;
14024
+ if (now - entry.lastLog >= DEDUP_WINDOW_MS) {
14025
+ const suppressed = entry.suppressed;
14026
+ const summary = `${message} (deduplicated: ${entry.count} occurrences, ${suppressed} suppressed over ${Math.round((now - entry.lastLog) / 1e3)}s)`;
14027
+ if (error !== void 0) logger[level](summary, error);
14028
+ else logger[level](summary);
14029
+ entry.count = 1;
14030
+ entry.suppressed = 0;
14031
+ entry.lastLog = now;
14032
+ } else {
14033
+ entry.suppressed += 1;
14034
+ }
14035
+ }
14036
+ function fingerprintFor(kind, detail) {
14037
+ const d = detail === void 0 ? "" : sanitizeFp(String(detail));
14038
+ return `mem-${kind}:${d}`;
14039
+ }
14040
+ function sanitizeFp(s) {
14041
+ return s.replace(/\s+/g, " ").slice(0, 80);
14042
+ }
13451
14043
  var queryRemoteMemory = async (serverUrl, authToken, agentKey, userInput, spaceId) => {
13452
14044
  try {
13453
14045
  const response = await fetch(`${serverUrl}/api/memory/query`, {
@@ -13464,10 +14056,10 @@ var queryRemoteMemory = async (serverUrl, authToken, agentKey, userInput, spaceI
13464
14056
  signal: AbortSignal.timeout(5e3)
13465
14057
  });
13466
14058
  if (!response.ok) {
13467
- console.warn(
13468
- "[cli-memory] remote query returned non-ok status:",
13469
- response.status,
13470
- "\u2014 falling back to local"
14059
+ logDeduped(
14060
+ "warn",
14061
+ fingerprintFor("remote-nonok", response.status),
14062
+ `remote query returned non-ok status ${response.status} \u2014 falling back to local`
13471
14063
  );
13472
14064
  return null;
13473
14065
  }
@@ -13475,7 +14067,12 @@ var queryRemoteMemory = async (serverUrl, authToken, agentKey, userInput, spaceI
13475
14067
  const block = typeof payload?.promptBlock === "string" ? payload.promptBlock.trim() : "";
13476
14068
  return block || null;
13477
14069
  } catch (error) {
13478
- console.warn("[cli-memory] remote query failed, falling back to local:", error);
14070
+ logDeduped(
14071
+ "info",
14072
+ fingerprintFor("remote-failed", error instanceof Error ? error.name : void 0),
14073
+ "remote query failed, falling back to local",
14074
+ normalizeError(error)
14075
+ );
13479
14076
  return null;
13480
14077
  }
13481
14078
  };
@@ -13511,7 +14108,12 @@ var resolveCliMemory = async (input) => {
13511
14108
  input.spaceId
13512
14109
  );
13513
14110
  } catch (error) {
13514
- console.warn("[cli-memory] local recall failed, omitting memory layer:", error);
14111
+ logDeduped(
14112
+ "warn",
14113
+ fingerprintFor("local-failed", error instanceof Error ? error.name : void 0),
14114
+ "local recall failed, omitting memory layer",
14115
+ normalizeError(error)
14116
+ );
13515
14117
  return null;
13516
14118
  }
13517
14119
  };
@@ -13566,7 +14168,10 @@ async function resolveAgentRunAgentKey(args) {
13566
14168
  }
13567
14169
  async function runAgentRunCommand(args, deps) {
13568
14170
  const env = deps.env ?? process.env;
13569
- const output = deps.output ?? process.stdout;
14171
+ const output = deps.output ?? {
14172
+ write: (chunk) => process.stdout.write(chunk),
14173
+ writeErr: (chunk) => process.stderr.write(chunk)
14174
+ };
13570
14175
  if (args.includes("--help") || args.includes("-h")) {
13571
14176
  writeUsage(output, deps.commandPath);
13572
14177
  return 0;
@@ -14108,12 +14713,6 @@ function isBalanceExhaustedError(error) {
14108
14713
  }
14109
14714
 
14110
14715
  export {
14111
- resolveAgentModelIdentity,
14112
- resolveAgentContextWindow,
14113
- platformCreditsFromUsage,
14114
- formatCreditsChip,
14115
- formatTokenCount,
14116
- renderTokenStatus,
14117
14716
  resolveCliColorEnabled,
14118
14717
  dimCliText,
14119
14718
  ANSI_ESCAPE_REGEX,
@@ -14154,6 +14753,12 @@ export {
14154
14753
  formatAssistantDisplay,
14155
14754
  redactSecrets,
14156
14755
  TUI_TREE_MARKER,
14756
+ resolveAgentModelIdentity,
14757
+ resolveAgentContextWindow,
14758
+ platformCreditsFromUsage,
14759
+ formatCreditsChip,
14760
+ formatTokenCount,
14761
+ renderTokenStatus,
14157
14762
  COLLAPSED_PASTE_PLACEHOLDER_RE,
14158
14763
  shouldCollapsePaste,
14159
14764
  createCollapsedPasteStore,
@@ -14165,14 +14770,14 @@ export {
14165
14770
  expandRangeToCollapsedPasteChips,
14166
14771
  findCollapsedPasteSpanAt,
14167
14772
  runAgentTurn,
14168
- readAgentsMdLayerFromDisk,
14169
14773
  resolveWorkflowReference,
14170
14774
  resolveSkillReference,
14171
14775
  buildSkillContextBlocks,
14172
14776
  prependSubjectDialogMarker,
14173
14777
  normalizeCliImageInput,
14174
- inspectLocalRunWorkspace,
14778
+ readAgentsMdLayerFromDisk,
14175
14779
  resolveCliMemory,
14780
+ inspectLocalRunWorkspace,
14176
14781
  resolveRunOutcome,
14177
14782
  isRunResultStalledOrTruncated,
14178
14783
  resolveRunSettlementNote,