nolo-cli 0.108.0-alpha.2 → 0.108.1

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 (606) hide show
  1. package/README.md +1 -1
  2. package/{_executeModel-BY3P5LBB.js → _executeModel-T7PIVJIW.js} +128 -83
  3. package/action-RHUT4OHH.js +23 -0
  4. package/{addContentAction-MB2HHMDZ.js → addContentAction-BQ3LJLUW.js} +19 -13
  5. package/{addDialogAgentAction-MCEABSBA.js → addDialogAgentAction-B6X7BXR4.js} +24 -20
  6. package/{agentDeleteCommand-66KXCSRR.js → agentDeleteCommand-VIDCZAFG.js} +154 -68
  7. package/{agentEmailCommands-63UTONDK.js → agentEmailCommands-PCHDY4ZP.js} +125 -105
  8. package/{agentGrantCommands-M3XFO6EN.js → agentGrantCommands-HOJ3JBBQ.js} +3 -3
  9. package/agentListCommands-QNUAN3YH.js +800 -0
  10. package/{agentMachineCommands-Z6RGPZSG.js → agentMachineCommands-C2TMTQNU.js} +54 -58
  11. package/{agentProviderCommands-X3UNW77C.js → agentProviderCommands-7PCGR77I.js} +97 -2
  12. package/{agentPullCommand-O5MPVJ5E.js → agentPullCommand-7GCDM4BK.js} +7 -7
  13. package/agentRecordCommands-T4XAUFF5.js +149 -0
  14. package/agentRunCommand-T3AW43I6.js +179 -0
  15. package/{agentRunControl-AVJR4JW4.js → agentRunControl-2CDZNHXV.js} +10 -2
  16. package/{agentRuntimeLocal-E67CTV45.js → agentRuntimeLocal-SQUDRZWE.js} +41 -46
  17. package/{agentSlice-DG5TIQHE.js → agentSlice-HBGFNXUG.js} +22 -16
  18. package/{appDeleteCommands-Z36CLGUK.js → appDeleteCommands-CLLYGEBC.js} +55 -56
  19. package/{appDeployCommands-ECMUWG6S.js → appDeployCommands-HY2NBNDQ.js} +64 -60
  20. package/{appDeployStatusCommands-CL24TDMA.js → appDeployStatusCommands-SGO5GEXH.js} +53 -53
  21. package/{appGetCommands-ITHGOYGJ.js → appGetCommands-ZPYK2N5D.js} +53 -53
  22. package/{appListCommands-EEOSI6RC.js → appListCommands-O2BHIMKS.js} +54 -56
  23. package/{authCommand-HGP2XTKC.js → authCommand-GUIREPHK.js} +132 -83
  24. package/{authCommands-RGOGCPP6.js → authCommands-K3BDSTJ4.js} +10 -7
  25. package/{builtinSkillRegistry-FUAVTRVZ.js → builtinSkillRegistry-MUOUTRNJ.js} +13 -10
  26. package/{chromeCommands-FZYAU75D.js → chromeCommands-Z2WRJB7O.js} +290 -38
  27. package/{chromeOpsCommands-62P2Q2YB.js → chromeOpsCommands-YWYXZTIR.js} +157 -23
  28. package/{chunk-2F7RJC6L.js → chunk-2C47W7IJ.js} +1 -1
  29. package/chunk-2DRYS3G3.js +13941 -0
  30. package/{chunk-VLTIYV3X.js → chunk-2ECUZDEL.js} +37 -11
  31. package/{chunk-LPIYPEME.js → chunk-2FY3GHBV.js} +1449 -1094
  32. package/{chunk-ALXHV7NK.js → chunk-2GGXHQIW.js} +43 -4
  33. package/{chunk-AHAHBQMU.js → chunk-2OMUAIKR.js} +2 -2
  34. package/{chunk-DHDMC6FO.js → chunk-3CZM6HGQ.js} +53 -23
  35. package/{chunk-BNGW5ASC.js → chunk-3LI5UCTU.js} +23 -3
  36. package/{chunk-FDTR4QJ6.js → chunk-3MZAGMYY.js} +48 -1
  37. package/chunk-3PVYUPXK.js +40 -0
  38. package/{chunk-FV3JEYR3.js → chunk-3SK3J3IF.js} +69 -10
  39. package/chunk-4LCOCOR5.js +50 -0
  40. package/{chunk-V7E4PXQD.js → chunk-4MSYSHZD.js} +15 -7
  41. package/{chunk-2GRGFCF6.js → chunk-4VJAC32I.js} +2 -1
  42. package/{chunk-MP64VFGD.js → chunk-4XEYAFLY.js} +60 -18
  43. package/chunk-4YRTZIVN.js +871 -0
  44. package/{chunk-MC4XLIJ7.js → chunk-523DITKR.js} +1 -1
  45. package/{chunk-N7J63Q6C.js → chunk-56GBUMO5.js} +10 -1
  46. package/chunk-5MMAK75Q.js +15 -0
  47. package/{chunk-KZJP33ZK.js → chunk-5WLADF62.js} +90 -36
  48. package/chunk-5XN3OSCT.js +164 -0
  49. package/{chunk-T3GEOSRJ.js → chunk-5YJWHTKD.js} +69 -57
  50. package/chunk-6CCAXGFK.js +1712 -0
  51. package/{chunk-42V6BK2E.js → chunk-6MXDOUMH.js} +18 -36
  52. package/{chunk-QOKAKDPE.js → chunk-6Q7UTJKR.js} +6 -94
  53. package/{chunk-J4MOO56S.js → chunk-6VRWNU5J.js} +10 -2
  54. package/{chunk-IQPFGYO3.js → chunk-726TCFLQ.js} +5 -5
  55. package/{chunk-CW67PN7L.js → chunk-7B3BVGU3.js} +61 -11
  56. package/chunk-7DPNBQSV.js +9 -0
  57. package/{chunk-LWKP7AWH.js → chunk-A337PRRR.js} +41 -17
  58. package/chunk-AGIM7IMJ.js +147 -0
  59. package/chunk-AI7XJMMQ.js +1858 -0
  60. package/{chunk-ABQYVJBJ.js → chunk-AIZE5TDM.js} +3 -3
  61. package/{chunk-LJ5VW2UJ.js → chunk-ALKCVCA5.js} +4 -4
  62. package/{chunk-5UTFL4QJ.js → chunk-APO5TOXO.js} +1 -1
  63. package/{chunk-E4MARS3Q.js → chunk-AU7AXHUL.js} +1 -1
  64. package/{chunk-DOTZ5GTO.js → chunk-AWYWIWTU.js} +310 -95
  65. package/chunk-B77W7P7J.js +95 -0
  66. package/{chunk-PBA4UJBK.js → chunk-BFYDNHYW.js} +12 -12
  67. package/{chunk-QTGQ2LTL.js → chunk-BIAETTOB.js} +5 -9
  68. package/{chunk-OIVSQH2O.js → chunk-CGEK73JN.js} +311 -12
  69. package/chunk-CHOZJMJS.js +78 -0
  70. package/{chunk-GBRG75BQ.js → chunk-D2MDMY2M.js} +1 -0
  71. package/{chunk-TRV2MIDW.js → chunk-EXAJ6DCR.js} +1 -0
  72. package/chunk-EYLGAEB4.js +784 -0
  73. package/{chunk-3BMYXEUW.js → chunk-F2UJW3EK.js} +1 -1
  74. package/{chunk-RVE4DCV3.js → chunk-FBLRSLZH.js} +26 -31
  75. package/{chunk-P5EVSOPA.js → chunk-FWY6BHIJ.js} +363 -248
  76. package/{chunk-4MK3I7Y4.js → chunk-G23MQWLJ.js} +7 -128
  77. package/chunk-G6OOUQWJ.js +417 -0
  78. package/{chunk-WV42OMV7.js → chunk-GHZ2H2HJ.js} +11 -15
  79. package/chunk-I42VC5KR.js +15 -0
  80. package/{chunk-H4AHY5BU.js → chunk-IFALJPEX.js} +69 -20
  81. package/{chunk-O6OSWFZQ.js → chunk-IHPDK6UD.js} +6 -0
  82. package/{chunk-UKWGR5SS.js → chunk-IJERIUXS.js} +242 -1146
  83. package/chunk-IN5UVHHP.js +843 -0
  84. package/{chunk-QDSINZM3.js → chunk-IXH3HKY2.js} +1 -22
  85. package/{chunk-SYXOBWOC.js → chunk-JGLKZGGZ.js} +124 -703
  86. package/chunk-JJM3WS6W.js +132 -0
  87. package/{chunk-TR22GEUU.js → chunk-JKDL7BRF.js} +20 -11
  88. package/chunk-JONVI6DK.js +593 -0
  89. package/{chunk-SH43IESU.js → chunk-KQ7DAEZ7.js} +202 -32
  90. package/chunk-KWEDNOZZ.js +7546 -0
  91. package/{chunk-6OZ36FXI.js → chunk-KY6GPQ7O.js} +36 -12
  92. package/{chunk-RZGLXO2B.js → chunk-L5YKEQLD.js} +1715 -451
  93. package/{chunk-MRIHM22T.js → chunk-LAVSW2C2.js} +77 -144
  94. package/{chunk-HSSRGGXJ.js → chunk-LNEKN523.js} +10 -7
  95. package/chunk-LWLNLZC5.js +265 -0
  96. package/{chunk-YTLRHRH3.js → chunk-MDOZSLDE.js} +17 -15
  97. package/{chunk-I3TQJXQ7.js → chunk-MHD5JBSS.js} +131 -10
  98. package/{chunk-QU7KDSZX.js → chunk-MW533QT3.js} +190 -8
  99. package/{chunk-4NNTATRH.js → chunk-NLEJWKF5.js} +10394 -8549
  100. package/{chunk-BFU6C242.js → chunk-NMFV26UG.js} +1 -1
  101. package/{chunk-GQBOR3G6.js → chunk-NN4UUYGB.js} +18 -4
  102. package/{chunk-FZGV4FGK.js → chunk-NUHHBEJC.js} +378 -187
  103. package/chunk-OKARGYFT.js +15 -0
  104. package/{chunk-KQHGZWSV.js → chunk-OXME3PEE.js} +1 -1
  105. package/{chunk-Z5625XML.js → chunk-OYBAT7RT.js} +113 -17
  106. package/chunk-P3SFAHIL.js +134 -0
  107. package/{chunk-XD2MJFUG.js → chunk-PBGO5AFD.js} +1 -1
  108. package/{chunk-EYAQT56M.js → chunk-PFEK4SA2.js} +13 -10
  109. package/{chunk-Z77CRGTW.js → chunk-PHHFVGOJ.js} +1 -1
  110. package/{chunk-3VNWWVKB.js → chunk-PJNFNEJE.js} +114 -28
  111. package/{chunk-HVURBGF3.js → chunk-PWRS2SU2.js} +27 -9
  112. package/chunk-QFEW2ULV.js +42 -0
  113. package/{chunk-IIVGDG4I.js → chunk-QLQ573SU.js} +124 -77
  114. package/chunk-QQ56R7KS.js +88 -0
  115. package/{chunk-PWBDVI4R.js → chunk-QRFI5NHO.js} +269 -141
  116. package/chunk-QYPE3TS3.js +43 -0
  117. package/{chunk-VMFTFOWF.js → chunk-RLRYVSCD.js} +31 -14
  118. package/{chunk-VRTTFDBM.js → chunk-RNNWTMKT.js} +56 -63
  119. package/{chunk-JRQFUXY7.js → chunk-RRQQAG7W.js} +93 -24
  120. package/chunk-SJ3QFSQS.js +1147 -0
  121. package/{chunk-Q67DOFOO.js → chunk-SZC4REES.js} +212 -105
  122. package/{chunk-BYMV6QZG.js → chunk-TNIX77YM.js} +4 -0
  123. package/{chunk-GNCCNNZD.js → chunk-TSBCYK5F.js} +7 -7
  124. package/chunk-TY3TIUJK.js +89 -0
  125. package/chunk-U4STABYN.js +81 -0
  126. package/chunk-UEILX4EV.js +15 -0
  127. package/{chunk-AODJ7WSF.js → chunk-UIYVU3S4.js} +90 -79
  128. package/{chunk-YYLHWIW6.js → chunk-UKZX3NHN.js} +1 -1
  129. package/{chunk-7S4YWN7P.js → chunk-V2UPLOXT.js} +4 -4
  130. package/{chunk-LS2ZANRJ.js → chunk-V6WXGTUJ.js} +1 -1
  131. package/{chunk-6YTOJY35.js → chunk-VBG7GWWR.js} +253 -8
  132. package/{chunk-DVINR3PL.js → chunk-VEA7H5FG.js} +3 -3
  133. package/chunk-VIWDGTDA.js +8 -0
  134. package/chunk-VJVNU77E.js +83 -0
  135. package/{chunk-EADNWBAZ.js → chunk-VP3BINY7.js} +13 -0
  136. package/{chunk-HKNXJGEC.js → chunk-VSPO4S33.js} +47 -192
  137. package/{chunk-PHXD6JTX.js → chunk-W2N3ZC4P.js} +7 -7
  138. package/{chunk-EOARMOVD.js → chunk-W4S6OTSC.js} +6 -3
  139. package/{chunk-6Z7MY3V7.js → chunk-WCQNEMXG.js} +3 -3
  140. package/chunk-WJZOQR2J.js +151 -0
  141. package/{chunk-BFDFRLLQ.js → chunk-WW2USJ3C.js} +3 -3
  142. package/chunk-X5BIY654.js +29 -0
  143. package/{chunk-Q554LLSI.js → chunk-XETG4RIX.js} +5 -5
  144. package/{chunk-3L2WKC3W.js → chunk-XPWGOTBQ.js} +8 -1
  145. package/{chunk-2OASQKU2.js → chunk-XRXYRHE5.js} +187 -16
  146. package/{chunk-JEDZAO7L.js → chunk-YBNHPX4S.js} +257 -37
  147. package/{chunk-JPGCXHNM.js → chunk-YLMMECCH.js} +1 -1
  148. package/{chunk-6D6VBVEW.js → chunk-YVTZMLXZ.js} +96 -25
  149. package/{chunk-G4VIHCGJ.js → chunk-ZR5RAAVI.js} +35 -30
  150. package/chunk-ZRAU6T47.js +56 -0
  151. package/{chunk-ONXOABJR.js → chunk-ZWQUWF6W.js} +36 -1
  152. package/{cliExecutor-HG3S345O.js → cliExecutor-AWYR3T33.js} +1 -1
  153. package/commandRegistry-3XWUYELA.js +839 -0
  154. package/contentThunks-ALRPUDRE.js +83 -0
  155. package/{cooldownCommands-REAWYVTY.js → cooldownCommands-JFKTYS2D.js} +2 -2
  156. package/{createAgentAutomationAction-7HX7KBES.js → createAgentAutomationAction-XXRXCDFJ.js} +51 -43
  157. package/createDialogAction-FVSAW7WZ.js +75 -0
  158. package/{createPageAction-QWNMGO3O.js → createPageAction-RT6DPYP5.js} +60 -51
  159. package/{chunk-UDIIVXKA.js → cursorProvider-YGGNMVWX.js} +2822 -10269
  160. package/{dbSlice-A6C6H32X.js → dbSlice-JQFBMJ55.js} +18 -12
  161. package/{deleteFile-YG6QMJLU.js → deleteFile-6JWDDRVP.js} +9 -5
  162. package/dialogCommands-K734RXEQ.js +108 -0
  163. package/{dialogSlice-P2K47T3P.js → dialogSlice-GFCT74GI.js} +66 -41
  164. package/{dist-VODFSGNG.js → dist-NJC2W7I4.js} +61 -54
  165. package/{docCreateCommands-43JKQEIH.js → docCreateCommands-N3KPGP4A.js} +51 -54
  166. package/{docDeleteCommands-RL6D46XE.js → docDeleteCommands-4CR4TXZ7.js} +53 -55
  167. package/{docReadCommands-TOEUEQDG.js → docReadCommands-62XK57VS.js} +50 -53
  168. package/{docStore-3AHKTJRI.js → docStore-Z7KBPFXX.js} +24 -15
  169. package/{docUpdateCommands-FWU5G2XB.js → docUpdateCommands-DRAAWIDC.js} +51 -54
  170. package/{fetchMessages-EIU7UFFK.js → fetchMessages-LM6OMMQQ.js} +5 -4
  171. package/{getPricing-LUSEABA6.js → getPricing-XDF4OLTC.js} +6 -6
  172. package/handleSendMessageAction-NRKUSHK2.js +1849 -0
  173. package/index.js +91 -884
  174. package/{lib-FRRS27KN.js → lib-PU2G2MSO.js} +523 -191
  175. package/{localDialogRead-BTFJ4V2I.js → localDialogRead-BOETO2TD.js} +2 -2
  176. package/localRuntimeAdapter-S6UEEOSA.js +239 -0
  177. package/{localRuntimeAuthority-6IR6BBXE.js → localRuntimeAuthority-YSE6NH7B.js} +12 -9
  178. package/{localRuntimeDb-SYQGUF4U.js → localRuntimeDb-7FBKDEQY.js} +1 -1
  179. package/{machineCommands-TTKK4F7C.js → machineCommands-IQYHOOVH.js} +493 -152
  180. package/machineWsRunDispatch-3ZUMZUGP.js +164 -0
  181. package/{memberThunks-P2ECUJ56.js → memberThunks-Y3Q7GZTG.js} +24 -17
  182. package/{models-T3SG6MJ5.js → models-6V4ZCHEE.js} +2 -2
  183. package/node_modules/abstract-level/CHANGELOG.md +150 -0
  184. package/node_modules/abstract-level/LICENSE +21 -0
  185. package/node_modules/abstract-level/README.md +1957 -0
  186. package/node_modules/abstract-level/UPGRADING.md +669 -0
  187. package/node_modules/abstract-level/abstract-chained-batch.js +397 -0
  188. package/node_modules/abstract-level/abstract-iterator.js +404 -0
  189. package/node_modules/abstract-level/abstract-level.js +1127 -0
  190. package/node_modules/abstract-level/abstract-snapshot.js +84 -0
  191. package/node_modules/abstract-level/index.d.ts +52 -0
  192. package/node_modules/abstract-level/index.js +9 -0
  193. package/node_modules/abstract-level/lib/abstract-sublevel-iterator.js +141 -0
  194. package/node_modules/abstract-level/lib/abstract-sublevel.js +290 -0
  195. package/node_modules/abstract-level/lib/common.js +33 -0
  196. package/node_modules/abstract-level/lib/default-chained-batch.js +29 -0
  197. package/node_modules/abstract-level/lib/default-kv-iterator.js +74 -0
  198. package/node_modules/abstract-level/lib/deferred-iterator.js +110 -0
  199. package/node_modules/abstract-level/lib/deferred-queue.js +84 -0
  200. package/node_modules/abstract-level/lib/errors.js +21 -0
  201. package/node_modules/abstract-level/lib/event-monitor.js +30 -0
  202. package/node_modules/abstract-level/lib/hooks.js +78 -0
  203. package/node_modules/abstract-level/lib/prefixes.js +21 -0
  204. package/node_modules/abstract-level/lib/prewrite-batch.js +96 -0
  205. package/node_modules/abstract-level/lib/range-options.js +26 -0
  206. package/node_modules/abstract-level/package.json +66 -0
  207. package/node_modules/abstract-level/test/async-iterator-test.js +132 -0
  208. package/node_modules/abstract-level/test/batch-test.js +214 -0
  209. package/node_modules/abstract-level/test/chained-batch-test.js +315 -0
  210. package/node_modules/abstract-level/test/clear-range-test.js +262 -0
  211. package/node_modules/abstract-level/test/clear-test.js +110 -0
  212. package/node_modules/abstract-level/test/common.js +90 -0
  213. package/node_modules/abstract-level/test/deferred-open-test.js +209 -0
  214. package/node_modules/abstract-level/test/del-test.js +65 -0
  215. package/node_modules/abstract-level/test/encoding-buffer-test.js +336 -0
  216. package/node_modules/abstract-level/test/encoding-custom-test.js +92 -0
  217. package/node_modules/abstract-level/test/encoding-decode-error-test.js +85 -0
  218. package/node_modules/abstract-level/test/encoding-json-test.js +75 -0
  219. package/node_modules/abstract-level/test/encoding-test.js +130 -0
  220. package/node_modules/abstract-level/test/events/write.js +132 -0
  221. package/node_modules/abstract-level/test/factory-test.js +36 -0
  222. package/node_modules/abstract-level/test/get-many-test.js +157 -0
  223. package/node_modules/abstract-level/test/get-sync-test.js +61 -0
  224. package/node_modules/abstract-level/test/get-test.js +83 -0
  225. package/node_modules/abstract-level/test/has-many-test.js +144 -0
  226. package/node_modules/abstract-level/test/has-test.js +81 -0
  227. package/node_modules/abstract-level/test/hooks/newsub.js +57 -0
  228. package/node_modules/abstract-level/test/hooks/postopen.js +229 -0
  229. package/node_modules/abstract-level/test/hooks/prewrite.js +816 -0
  230. package/node_modules/abstract-level/test/hooks/shared.js +38 -0
  231. package/node_modules/abstract-level/test/index.js +86 -0
  232. package/node_modules/abstract-level/test/iterator-explicit-snapshot-test.js +393 -0
  233. package/node_modules/abstract-level/test/iterator-no-snapshot-test.js +49 -0
  234. package/node_modules/abstract-level/test/iterator-range-test.js +277 -0
  235. package/node_modules/abstract-level/test/iterator-seek-test.js +335 -0
  236. package/node_modules/abstract-level/test/iterator-snapshot-test.js +56 -0
  237. package/node_modules/abstract-level/test/iterator-test.js +621 -0
  238. package/node_modules/abstract-level/test/manifest-test.js +21 -0
  239. package/node_modules/abstract-level/test/open-create-if-missing-test.js +39 -0
  240. package/node_modules/abstract-level/test/open-error-if-exists-test.js +25 -0
  241. package/node_modules/abstract-level/test/open-test.js +263 -0
  242. package/node_modules/abstract-level/test/put-get-del-test.js +97 -0
  243. package/node_modules/abstract-level/test/put-test.js +70 -0
  244. package/node_modules/abstract-level/test/self/abstract-iterator-test.js +182 -0
  245. package/node_modules/abstract-level/test/self/async-iterator-test.js +242 -0
  246. package/node_modules/abstract-level/test/self/attach-resource-test.js +74 -0
  247. package/node_modules/abstract-level/test/self/defer-test.js +140 -0
  248. package/node_modules/abstract-level/test/self/deferred-iterator-test.js +314 -0
  249. package/node_modules/abstract-level/test/self/deferred-operations-test.js +86 -0
  250. package/node_modules/abstract-level/test/self/deferred-queue-test.js +93 -0
  251. package/node_modules/abstract-level/test/self/encoding-test.js +391 -0
  252. package/node_modules/abstract-level/test/self/errors-test.js +11 -0
  253. package/node_modules/abstract-level/test/self/iterator-test.js +1050 -0
  254. package/node_modules/abstract-level/test/self/sublevel-test.js +1039 -0
  255. package/node_modules/abstract-level/test/self.js +905 -0
  256. package/node_modules/abstract-level/test/sublevel-test.js +209 -0
  257. package/node_modules/abstract-level/test/traits/closed.js +42 -0
  258. package/node_modules/abstract-level/test/traits/index.js +4 -0
  259. package/node_modules/abstract-level/test/traits/open.js +62 -0
  260. package/node_modules/abstract-level/test/util.js +275 -0
  261. package/node_modules/abstract-level/types/abstract-chained-batch.d.ts +124 -0
  262. package/node_modules/abstract-level/types/abstract-iterator.d.ts +241 -0
  263. package/node_modules/abstract-level/types/abstract-level.d.ts +636 -0
  264. package/node_modules/abstract-level/types/abstract-snapshot.d.ts +30 -0
  265. package/node_modules/abstract-level/types/abstract-sublevel.d.ts +76 -0
  266. package/node_modules/abstract-level/types/interfaces.d.ts +43 -0
  267. package/node_modules/base64-js/LICENSE +21 -0
  268. package/node_modules/base64-js/README.md +34 -0
  269. package/node_modules/base64-js/base64js.min.js +1 -0
  270. package/node_modules/base64-js/index.d.ts +3 -0
  271. package/node_modules/base64-js/index.js +150 -0
  272. package/node_modules/base64-js/package.json +47 -0
  273. package/node_modules/browser-level/CHANGELOG.md +44 -0
  274. package/node_modules/browser-level/LICENSE +21 -0
  275. package/node_modules/browser-level/README.md +124 -0
  276. package/node_modules/browser-level/UPGRADING.md +143 -0
  277. package/node_modules/browser-level/index.d.ts +108 -0
  278. package/node_modules/browser-level/index.js +323 -0
  279. package/node_modules/browser-level/iterator.js +239 -0
  280. package/node_modules/browser-level/package.json +48 -0
  281. package/node_modules/browser-level/util/clear.js +38 -0
  282. package/node_modules/browser-level/util/deserialize.js +17 -0
  283. package/node_modules/browser-level/util/key-range.js +20 -0
  284. package/node_modules/buffer/AUTHORS.md +73 -0
  285. package/node_modules/buffer/LICENSE +21 -0
  286. package/node_modules/buffer/README.md +410 -0
  287. package/node_modules/buffer/index.d.ts +194 -0
  288. package/node_modules/buffer/index.js +2106 -0
  289. package/node_modules/buffer/package.json +93 -0
  290. package/node_modules/classic-level/CHANGELOG.md +115 -0
  291. package/node_modules/classic-level/LICENSE +21 -0
  292. package/node_modules/classic-level/README.md +274 -0
  293. package/node_modules/classic-level/UPGRADING.md +131 -0
  294. package/node_modules/classic-level/binding.cc +2652 -0
  295. package/node_modules/classic-level/binding.gyp +71 -0
  296. package/node_modules/classic-level/binding.js +1 -0
  297. package/node_modules/classic-level/chained-batch.js +35 -0
  298. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/LICENSE +27 -0
  299. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/Makefile +424 -0
  300. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/build_detect_platform +256 -0
  301. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/autocompact_test.cc +118 -0
  302. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/builder.cc +88 -0
  303. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/builder.h +34 -0
  304. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/c.cc +595 -0
  305. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/c_test.c +390 -0
  306. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/corruption_test.cc +374 -0
  307. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_bench.cc +1020 -0
  308. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_impl.cc +1568 -0
  309. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_impl.h +212 -0
  310. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_iter.cc +317 -0
  311. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_iter.h +28 -0
  312. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/db_test.cc +2158 -0
  313. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/dbformat.cc +140 -0
  314. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/dbformat.h +230 -0
  315. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/dbformat_test.cc +112 -0
  316. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/dumpfile.cc +225 -0
  317. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/fault_injection_test.cc +554 -0
  318. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/filename.cc +144 -0
  319. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/filename.h +85 -0
  320. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/filename_test.cc +123 -0
  321. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/leveldbutil.cc +64 -0
  322. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_format.h +35 -0
  323. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_reader.cc +284 -0
  324. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_reader.h +113 -0
  325. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_test.cc +591 -0
  326. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_writer.cc +112 -0
  327. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/log_writer.h +54 -0
  328. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/memtable.cc +145 -0
  329. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/memtable.h +89 -0
  330. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/recovery_test.cc +324 -0
  331. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/repair.cc +461 -0
  332. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/skiplist.h +384 -0
  333. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/skiplist_test.cc +378 -0
  334. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/snapshot.h +67 -0
  335. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/table_cache.cc +127 -0
  336. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/table_cache.h +61 -0
  337. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_edit.cc +266 -0
  338. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_edit.h +107 -0
  339. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_edit_test.cc +46 -0
  340. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_set.cc +1535 -0
  341. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_set.h +399 -0
  342. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/version_set_test.cc +179 -0
  343. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/write_batch.cc +147 -0
  344. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/write_batch_internal.h +50 -0
  345. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/db/write_batch_test.cc +120 -0
  346. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/helpers/memenv/memenv.cc +398 -0
  347. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/helpers/memenv/memenv.h +20 -0
  348. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/helpers/memenv/memenv_test.cc +241 -0
  349. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/c.h +290 -0
  350. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/cache.h +110 -0
  351. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/comparator.h +63 -0
  352. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/db.h +164 -0
  353. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/dumpfile.h +25 -0
  354. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/env.h +351 -0
  355. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/filter_policy.h +70 -0
  356. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/iterator.h +100 -0
  357. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/options.h +213 -0
  358. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/slice.h +109 -0
  359. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/status.h +112 -0
  360. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/table.h +85 -0
  361. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/table_builder.h +92 -0
  362. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/value_sink.h +26 -0
  363. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/include/leveldb/write_batch.h +64 -0
  364. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/issues/issue178_test.cc +92 -0
  365. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/issues/issue200_test.cc +59 -0
  366. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/atomic_pointer.h +242 -0
  367. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/port.h +21 -0
  368. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/port_example.h +141 -0
  369. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/port_posix.cc +53 -0
  370. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/port_posix.h +156 -0
  371. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/port_posix_sse.cc +129 -0
  372. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/thread_annotations.h +60 -0
  373. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/port/win/stdint.h +24 -0
  374. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/block.cc +268 -0
  375. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/block.h +44 -0
  376. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/block_builder.cc +109 -0
  377. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/block_builder.h +57 -0
  378. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/filter_block.cc +111 -0
  379. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/filter_block.h +68 -0
  380. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/filter_block_test.cc +128 -0
  381. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/format.cc +144 -0
  382. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/format.h +108 -0
  383. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/iterator.cc +67 -0
  384. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/iterator_wrapper.h +66 -0
  385. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/merger.cc +197 -0
  386. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/merger.h +26 -0
  387. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/table.cc +285 -0
  388. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/table_builder.cc +270 -0
  389. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/table_test.cc +876 -0
  390. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/two_level_iterator.cc +182 -0
  391. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/table/two_level_iterator.h +34 -0
  392. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/arena.cc +68 -0
  393. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/arena.h +68 -0
  394. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/arena_test.cc +68 -0
  395. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/bloom.cc +95 -0
  396. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/bloom_test.cc +162 -0
  397. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/cache.cc +405 -0
  398. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/cache_test.cc +226 -0
  399. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/coding.cc +194 -0
  400. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/coding.h +104 -0
  401. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/coding_test.cc +196 -0
  402. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/comparator.cc +81 -0
  403. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/crc32c.cc +350 -0
  404. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/crc32c.h +45 -0
  405. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/crc32c_test.cc +72 -0
  406. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/env.cc +100 -0
  407. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/env_posix.cc +695 -0
  408. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/env_posix_test.cc +66 -0
  409. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/env_posix_test_helper.h +28 -0
  410. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/env_test.cc +106 -0
  411. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/filter_policy.cc +11 -0
  412. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/hash.cc +52 -0
  413. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/hash.h +19 -0
  414. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/hash_test.cc +54 -0
  415. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/histogram.cc +139 -0
  416. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/histogram.h +42 -0
  417. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/logging.cc +72 -0
  418. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/logging.h +43 -0
  419. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/mutexlock.h +41 -0
  420. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/options.cc +30 -0
  421. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/posix_logger.h +98 -0
  422. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/random.h +64 -0
  423. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/status.cc +75 -0
  424. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/testharness.cc +77 -0
  425. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/testharness.h +138 -0
  426. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/testutil.cc +51 -0
  427. package/node_modules/classic-level/deps/leveldb/leveldb-1.20/util/testutil.h +63 -0
  428. package/node_modules/classic-level/deps/leveldb/leveldb.gyp +282 -0
  429. package/node_modules/classic-level/deps/leveldb/patches/001-value-sink.patch +164 -0
  430. package/node_modules/classic-level/deps/leveldb/port-libuv/atomic_pointer_win.h +48 -0
  431. package/node_modules/classic-level/deps/leveldb/port-libuv/env_win.cc +692 -0
  432. package/node_modules/classic-level/deps/leveldb/port-libuv/port_uv.cc +36 -0
  433. package/node_modules/classic-level/deps/leveldb/port-libuv/port_uv.h +157 -0
  434. package/node_modules/classic-level/deps/leveldb/port-libuv/port_uv.h.bak +153 -0
  435. package/node_modules/classic-level/deps/leveldb/port-libuv/stdint-msvc2008.h +247 -0
  436. package/node_modules/classic-level/deps/leveldb/port-libuv/uv_condvar.h +45 -0
  437. package/node_modules/classic-level/deps/leveldb/port-libuv/uv_condvar_posix.cc +139 -0
  438. package/node_modules/classic-level/deps/leveldb/port-libuv/win_logger.cc +79 -0
  439. package/node_modules/classic-level/deps/leveldb/port-libuv/win_logger.h +28 -0
  440. package/node_modules/classic-level/deps/snappy/freebsd/config.h +135 -0
  441. package/node_modules/classic-level/deps/snappy/freebsd/snappy-stubs-public.h +100 -0
  442. package/node_modules/classic-level/deps/snappy/linux/config.h +135 -0
  443. package/node_modules/classic-level/deps/snappy/linux/snappy-stubs-public.h +100 -0
  444. package/node_modules/classic-level/deps/snappy/mac/config.h +137 -0
  445. package/node_modules/classic-level/deps/snappy/mac/snappy-stubs-public.h +100 -0
  446. package/node_modules/classic-level/deps/snappy/openbsd/config.h +135 -0
  447. package/node_modules/classic-level/deps/snappy/openbsd/snappy-stubs-public.h +100 -0
  448. package/node_modules/classic-level/deps/snappy/snappy/COPYING +54 -0
  449. package/node_modules/classic-level/deps/snappy/snappy/cmake/SnappyConfig.cmake +1 -0
  450. package/node_modules/classic-level/deps/snappy/snappy/cmake/config.h.in +62 -0
  451. package/node_modules/classic-level/deps/snappy/snappy/snappy-c.cc +90 -0
  452. package/node_modules/classic-level/deps/snappy/snappy/snappy-c.h +138 -0
  453. package/node_modules/classic-level/deps/snappy/snappy/snappy-internal.h +224 -0
  454. package/node_modules/classic-level/deps/snappy/snappy/snappy-sinksource.cc +104 -0
  455. package/node_modules/classic-level/deps/snappy/snappy/snappy-sinksource.h +182 -0
  456. package/node_modules/classic-level/deps/snappy/snappy/snappy-stubs-internal.cc +42 -0
  457. package/node_modules/classic-level/deps/snappy/snappy/snappy-stubs-internal.h +561 -0
  458. package/node_modules/classic-level/deps/snappy/snappy/snappy-stubs-public.h.in +94 -0
  459. package/node_modules/classic-level/deps/snappy/snappy/snappy-test.cc +612 -0
  460. package/node_modules/classic-level/deps/snappy/snappy/snappy-test.h +573 -0
  461. package/node_modules/classic-level/deps/snappy/snappy/snappy.cc +1515 -0
  462. package/node_modules/classic-level/deps/snappy/snappy/snappy.h +203 -0
  463. package/node_modules/classic-level/deps/snappy/snappy/snappy_unittest.cc +1410 -0
  464. package/node_modules/classic-level/deps/snappy/snappy.gyp +119 -0
  465. package/node_modules/classic-level/deps/snappy/solaris/config.h +135 -0
  466. package/node_modules/classic-level/deps/snappy/solaris/snappy-stubs-public.h +100 -0
  467. package/node_modules/classic-level/deps/snappy/win32/config.h +29 -0
  468. package/node_modules/classic-level/deps/snappy/win32/snappy-stubs-public.h +100 -0
  469. package/node_modules/classic-level/index.d.ts +343 -0
  470. package/node_modules/classic-level/index.js +311 -0
  471. package/node_modules/classic-level/iterator.js +122 -0
  472. package/node_modules/classic-level/package.json +70 -0
  473. package/node_modules/classic-level/prebuilds/android-arm/classic-level.armv7.node +0 -0
  474. package/node_modules/classic-level/prebuilds/android-arm64/classic-level.armv8.node +0 -0
  475. package/node_modules/classic-level/prebuilds/darwin-x64+arm64/classic-level.node +0 -0
  476. package/node_modules/classic-level/prebuilds/linux-arm/classic-level.armv6.node +0 -0
  477. package/node_modules/classic-level/prebuilds/linux-arm/classic-level.armv7.node +0 -0
  478. package/node_modules/classic-level/prebuilds/linux-arm64/classic-level.armv8.node +0 -0
  479. package/node_modules/classic-level/prebuilds/linux-x64/classic-level.musl.node +0 -0
  480. package/node_modules/classic-level/prebuilds/linux-x64/classic-level.node +0 -0
  481. package/node_modules/classic-level/prebuilds/win32-ia32/classic-level.node +0 -0
  482. package/node_modules/classic-level/prebuilds/win32-x64/classic-level.node +0 -0
  483. package/node_modules/ieee754/LICENSE +11 -0
  484. package/node_modules/ieee754/README.md +51 -0
  485. package/node_modules/ieee754/index.d.ts +10 -0
  486. package/node_modules/ieee754/index.js +85 -0
  487. package/node_modules/ieee754/package.json +52 -0
  488. package/node_modules/is-buffer/LICENSE +21 -0
  489. package/node_modules/is-buffer/README.md +54 -0
  490. package/node_modules/is-buffer/index.d.ts +2 -0
  491. package/node_modules/is-buffer/index.js +11 -0
  492. package/node_modules/is-buffer/package.json +65 -0
  493. package/node_modules/level/CHANGELOG.md +532 -0
  494. package/node_modules/level/LICENSE +21 -0
  495. package/node_modules/level/README.md +107 -0
  496. package/node_modules/level/UPGRADING.md +413 -0
  497. package/node_modules/level/browser.js +1 -0
  498. package/node_modules/level/index.d.ts +75 -0
  499. package/node_modules/level/index.js +1 -0
  500. package/node_modules/level/package.json +62 -0
  501. package/node_modules/level-supports/CHANGELOG.md +140 -0
  502. package/node_modules/level-supports/LICENSE +21 -0
  503. package/node_modules/level-supports/README.md +276 -0
  504. package/node_modules/level-supports/index.d.ts +137 -0
  505. package/node_modules/level-supports/index.js +26 -0
  506. package/node_modules/level-supports/package.json +46 -0
  507. package/node_modules/level-supports/test/cloneable.js +26 -0
  508. package/node_modules/level-supports/test/index.js +24 -0
  509. package/node_modules/level-supports/test/self.js +86 -0
  510. package/node_modules/level-supports/test/shape.js +23 -0
  511. package/node_modules/level-transcoder/CHANGELOG.md +15 -0
  512. package/node_modules/level-transcoder/LICENSE +21 -0
  513. package/node_modules/level-transcoder/README.md +214 -0
  514. package/node_modules/level-transcoder/UPGRADING.md +13 -0
  515. package/node_modules/level-transcoder/index.d.ts +27 -0
  516. package/node_modules/level-transcoder/index.js +158 -0
  517. package/node_modules/level-transcoder/lib/encoding.d.ts +158 -0
  518. package/node_modules/level-transcoder/lib/encoding.js +105 -0
  519. package/node_modules/level-transcoder/lib/encodings.d.ts +9 -0
  520. package/node_modules/level-transcoder/lib/encodings.js +135 -0
  521. package/node_modules/level-transcoder/lib/formats.d.ts +13 -0
  522. package/node_modules/level-transcoder/lib/formats.js +111 -0
  523. package/node_modules/level-transcoder/lib/text-endec.d.ts +6 -0
  524. package/node_modules/level-transcoder/lib/text-endec.js +19 -0
  525. package/node_modules/level-transcoder/package.json +46 -0
  526. package/node_modules/maybe-combine-errors/LICENSE.md +21 -0
  527. package/node_modules/maybe-combine-errors/README.md +94 -0
  528. package/node_modules/maybe-combine-errors/index.js +60 -0
  529. package/node_modules/maybe-combine-errors/package.json +33 -0
  530. package/node_modules/module-error/CHANGELOG.md +23 -0
  531. package/node_modules/module-error/LICENSE +21 -0
  532. package/node_modules/module-error/README.md +89 -0
  533. package/node_modules/module-error/index.d.ts +18 -0
  534. package/node_modules/module-error/index.js +22 -0
  535. package/node_modules/module-error/package.json +36 -0
  536. package/node_modules/napi-macros/LICENSE +21 -0
  537. package/node_modules/napi-macros/README.md +277 -0
  538. package/node_modules/napi-macros/index.js +1 -0
  539. package/node_modules/napi-macros/napi-macros.h +255 -0
  540. package/node_modules/napi-macros/package.json +22 -0
  541. package/node_modules/node-gyp-build/LICENSE +21 -0
  542. package/node_modules/node-gyp-build/README.md +58 -0
  543. package/node_modules/node-gyp-build/SECURITY.md +5 -0
  544. package/node_modules/node-gyp-build/bin.js +84 -0
  545. package/node_modules/node-gyp-build/build-test.js +19 -0
  546. package/node_modules/node-gyp-build/index.js +6 -0
  547. package/node_modules/node-gyp-build/node-gyp-build.js +207 -0
  548. package/node_modules/node-gyp-build/optional.js +7 -0
  549. package/node_modules/node-gyp-build/package.json +43 -0
  550. package/oauthTokenStore-PADKLNOC.js +23 -0
  551. package/package.json +6 -3
  552. package/processSpawn-SOAV3FEV.js +11 -0
  553. package/profileConfig-ZGOFORWV.js +43 -0
  554. package/{providerPresetApply-XI3WUPTI.js → providerPresetApply-HIPK67DU.js} +9 -9
  555. package/{providerRegistry-KEPWWGXD.js → providerRegistry-AI4U2FNM.js} +13 -9
  556. package/{read-COE3ZYR6.js → read-RNUQ7F34.js} +11 -7
  557. package/{readDocTool-5USN4A6V.js → readDocTool-6WIZHE6O.js} +5 -3
  558. package/{readlineWorkspace-KIMUDPPV.js → readlineWorkspace-BCDVMOR5.js} +6947 -3879
  559. package/{removeDialogAgentAction-J6X5QMTA.js → removeDialogAgentAction-EFQ4O2IQ.js} +27 -26
  560. package/{runAgentClientLoop-AN4WIRPQ.js → runAgentClientLoop-5RBD3DE6.js} +150 -90
  561. package/{runtimeDoctorCommands-X6WDBEQX.js → runtimeDoctorCommands-5CIWJEZ3.js} +36 -8
  562. package/runtimeModeArgs-2Y7BALTO.js +31 -0
  563. package/setDialogExtraReferencesAction-MXAH2KPV.js +37 -0
  564. package/{setPrimaryDialogAgentAction-FN22THHT.js → setPrimaryDialogAgentAction-7OPVNK4M.js} +28 -27
  565. package/{chunk-GP5LKBUZ.js → settingThunks-GHVLHABJ.js} +240 -945
  566. package/{skillDiscovery-CYUCJMAG.js → skillDiscovery-QC35EQY4.js} +3 -3
  567. package/{slateUtils-RIZES3PV.js → slateUtils-NGV2NMKM.js} +1 -1
  568. package/{spaceCommands-NA4JMIGT.js → spaceCommands-WZCLRGBO.js} +56 -56
  569. package/{streamAgentChatTurn-3TYTHZPJ.js → streamAgentChatTurn-YJTEHUH7.js} +371 -1556
  570. package/{switchDialogAgentAction-LVTEV3FR.js → switchDialogAgentAction-4PANDG3L.js} +24 -20
  571. package/{tableCommands-O6NWHFKV.js → tableCommands-U3QDY4L6.js} +19 -17
  572. package/{toolApiClient-QVJ6HDNN.js → toolApiClient-54CXTU7C.js} +5 -4
  573. package/tools-ZT4GXXDQ.js +122 -0
  574. package/{tuiSummaryLlmCaller-UFGFOIIW.js → tuiSummaryLlmCaller-ISODIW2O.js} +14 -29
  575. package/{updateCommands-2M74UL7P.js → updateCommands-NQXAGFM7.js} +3 -3
  576. package/{updateDialogTitleAction-RDHNT265.js → updateDialogTitleAction-2PQTFUUV.js} +101 -57
  577. package/action-P4TNFGAD.js +0 -31
  578. package/agentListCommands-NXCOTTZL.js +0 -411
  579. package/agentRecordCommands-JP54ZWND.js +0 -129
  580. package/agentRunCommand-RMQWWSHF.js +0 -157
  581. package/browser-image-compression-MFDTD7K6.js +0 -1763
  582. package/chatQueueReduxAdapter-DKLWTT3G.js +0 -186
  583. package/chunk-ACTMNVHM.js +0 -93
  584. package/chunk-CQ3WA2NE.js +0 -299
  585. package/chunk-M76ECQRD.js +0 -13658
  586. package/chunk-MEYIRKDN.js +0 -8967
  587. package/chunk-N4G4PKQ6.js +0 -23
  588. package/chunk-P3GYTNDF.js +0 -34
  589. package/chunk-PUOC4YRO.js +0 -394
  590. package/chunk-S7Z2HMCN.js +0 -25
  591. package/chunk-Y5GCAMGP.js +0 -9
  592. package/chunk-YPREESF4.js +0 -225
  593. package/chunk-YWIEQS6H.js +0 -21409
  594. package/contentThunks-JHK6X2KU.js +0 -73
  595. package/createDialogAction-VUUUZL54.js +0 -65
  596. package/dialogCommands-EN7TYD3I.js +0 -100
  597. package/handleSendMessageAction-ID5IKXUE.js +0 -633
  598. package/machineWsRunDispatch-RX64L3ET.js +0 -145
  599. package/setDialogExtraReferencesAction-WX5VTY6O.js +0 -30
  600. package/settingSlice-P4ZW7K5X.js +0 -204
  601. package/syncMapping-N6RGXGBW.js +0 -437
  602. package/tools-34SEJSLQ.js +0 -110
  603. package/{chunk-SV5IJK6K.js → chunk-NBTY7YJF.js} +3 -3
  604. package/{chunk-X7HHHIOZ.js → chunk-Y6ROFCZO.js} +0 -0
  605. package/{db-WK5MDZVN.js → db-VQSAOWAO.js} +1 -1
  606. package/{offlineMarxistsAgentCommand-HGXZV4XJ.js → offlineMarxistsAgentCommand-2QTHJCHV.js} +4 -4
@@ -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,
@@ -9,15 +9,34 @@ import {
9
9
  resolveRawAgentInput,
10
10
  resolveServerUrl,
11
11
  writeUsage
12
- } from "./chunk-V7E4PXQD.js";
12
+ } from "./chunk-4MSYSHZD.js";
13
+ import {
14
+ getReadableCliDb
15
+ } from "./chunk-V6WXGTUJ.js";
16
+ import {
17
+ _appendEntityBatch,
18
+ _appendEvidenceBatch,
19
+ _appendRelationBatch,
20
+ _appendRetiredStateBatch,
21
+ _appendStateBatch,
22
+ getMemoryEntityVNext,
23
+ getMemoryEvidenceVNext,
24
+ getMemoryEvidenceVNextStrict,
25
+ getMemoryStateVNext,
26
+ listMemoryStatesForEntityVNext,
27
+ loadMemoryVNextCatalog,
28
+ putMemoryEvidenceVNext
29
+ } from "./chunk-TY3TIUJK.js";
30
+ import {
31
+ readDbRecord,
32
+ resolveAgentRecordFromHybridStore
33
+ } from "./chunk-A337PRRR.js";
13
34
  import {
14
35
  resolveMachineId
15
36
  } from "./chunk-ESHYE7WU.js";
16
37
  import {
17
- agentRunCardLabels,
18
38
  createCliLocalRuntimeAdapter,
19
39
  detectCurrentMachineId,
20
- getCliLocale,
21
40
  isBuiltinNoloAgentRef,
22
41
  isCliProviderAgentConfig,
23
42
  isLiveAgentRunObservation,
@@ -27,179 +46,303 @@ import {
27
46
  resolveAuthToken as resolveAuthToken2,
28
47
  resolveBoundMachineId,
29
48
  resolveFileWriteGateEnabled,
30
- resolveLocalUserId,
31
- t,
32
- toolLabel
33
- } from "./chunk-UDIIVXKA.js";
34
- import {
35
- createRunActivityTracker,
36
- popSingleQueueMessage,
37
- readRunRecord,
38
- resolveRunQueuePath,
39
- settleRunTerminalAuthoritatively,
40
- spawnLocalBackgroundRun
41
- } from "./chunk-I3TQJXQ7.js";
49
+ resolveLocalUserId
50
+ } from "./chunk-KWEDNOZZ.js";
42
51
  import {
43
52
  clearCredentialAvailability,
44
53
  readCredentialEntry,
45
- recordCredentialProbe,
46
- resolveCredentialKeyWithFallback
47
- } from "./chunk-42V6BK2E.js";
48
- import {
49
- getReadableCliDb
50
- } from "./chunk-LS2ZANRJ.js";
54
+ recordCredentialProbe
55
+ } from "./chunk-6MXDOUMH.js";
51
56
  import {
52
- readDbRecord,
53
- resolveAgentRecordFromHybridStore
54
- } from "./chunk-LWKP7AWH.js";
57
+ agentRunCardLabels,
58
+ getCliLocale,
59
+ t,
60
+ toolLabel,
61
+ toolLabelVariants
62
+ } from "./chunk-6CCAXGFK.js";
55
63
  import {
56
64
  isLocalCliAgentKey
57
- } from "./chunk-SV5IJK6K.js";
65
+ } from "./chunk-NBTY7YJF.js";
58
66
  import {
59
67
  CliProviderQuotaError
60
- } from "./chunk-MP64VFGD.js";
68
+ } from "./chunk-4XEYAFLY.js";
69
+ import {
70
+ extractGoogleValidationLink
71
+ } from "./chunk-BMQ2MJUK.js";
61
72
  import {
62
73
  applyModelLayerOverride,
63
74
  buildModelLayerOverride
64
75
  } from "./chunk-LTRXGFMS.js";
65
- import {
66
- formatAgentListCard
67
- } from "./chunk-LPIYPEME.js";
68
76
  import {
69
77
  isTransientFetchError
70
- } from "./chunk-5UTFL4QJ.js";
78
+ } from "./chunk-APO5TOXO.js";
79
+ import {
80
+ parseUiCard,
81
+ uiCardFallback
82
+ } from "./chunk-JONVI6DK.js";
71
83
  import {
72
84
  isGatewayHttpStatus
73
85
  } from "./chunk-NF64D32W.js";
74
86
  import {
75
- formatFinishedRunCard,
76
- formatListRunsCard,
77
- formatNotFoundRunCard,
78
- formatStartRunCard,
79
- formatStatusRunCard,
80
- formatStopRunCard,
81
- isAgentRunTerminalStatus
82
- } from "./chunk-3VNWWVKB.js";
83
- import {
84
- extractGoogleValidationLink
85
- } from "./chunk-BMQ2MJUK.js";
87
+ parsePositiveFiniteNumberOrFallback
88
+ } from "./chunk-XPWGOTBQ.js";
86
89
  import {
87
90
  buildMemorySubjectsForAgent,
88
91
  chooseMemoryOwners,
89
92
  loadMemoryCandidatesFromDb,
90
93
  resolveAgentMemoryPolicy
91
- } from "./chunk-RVE4DCV3.js";
94
+ } from "./chunk-FBLRSLZH.js";
92
95
  import {
93
96
  API_REPORTED_COST_MULTIPLIER,
94
97
  parseUiAskChoiceContent
95
- } from "./chunk-YWIEQS6H.js";
98
+ } from "./chunk-2DRYS3G3.js";
96
99
  import {
97
100
  isOAuthApiKeyRef
98
- } from "./chunk-YYLHWIW6.js";
99
- import {
100
- isCliAuthorityBrokerProtocolError,
101
- isCliAuthorityBrokerTimeoutError,
102
- isCliAuthorityBrokerUnavailableError
103
- } from "./chunk-TRV2MIDW.js";
104
- import {
105
- getDefaultCliLocalRuntimeDb
106
- } from "./chunk-2F7RJC6L.js";
107
- import {
108
- buildSkillDiscoveryContextLayer
109
- } from "./chunk-E4MARS3Q.js";
101
+ } from "./chunk-UKZX3NHN.js";
110
102
  import {
111
103
  parseExternalSkillMarkdown,
112
104
  parseSkillDocProtocol
113
- } from "./chunk-Q554LLSI.js";
105
+ } from "./chunk-XETG4RIX.js";
114
106
  import {
115
107
  LOCAL_AGENT_CONFIG_MISSING_CODE,
116
108
  LOCAL_TURN_ABORTED_CODE,
117
109
  readActionGate
118
- } from "./chunk-4NNTATRH.js";
110
+ } from "./chunk-NLEJWKF5.js";
119
111
  import {
120
112
  resolveAgentRuntimeConfigFromRecord
121
- } from "./chunk-4MK3I7Y4.js";
113
+ } from "./chunk-G23MQWLJ.js";
122
114
  import {
123
115
  createThinkParserState,
124
116
  flushThinkParser,
125
117
  processThinkChunk
126
- } from "./chunk-N7J63Q6C.js";
118
+ } from "./chunk-56GBUMO5.js";
127
119
  import {
120
+ ATTACHMENT_PART_TYPE,
121
+ ATTACHMENT_PART_VERSION,
122
+ describeAttachmentForModel,
123
+ normalizeAttachmentPart
124
+ } from "./chunk-WJZOQR2J.js";
125
+ import {
126
+ PROBE_INTERVAL_MS,
128
127
  QUOTA_ERROR_PATTERNS,
129
128
  isQuotaExhaustedError,
130
129
  isQuotaLimited403Body,
131
130
  mergeAvailabilityDeadline,
132
- resolveCooldownGate
133
- } from "./chunk-FDTR4QJ6.js";
134
- import {
135
- isAntigravityOAuthAgent
136
- } from "./chunk-GNCCNNZD.js";
131
+ resolveCooldownGate,
132
+ resolveCredentialKeyWithFallback
133
+ } from "./chunk-3MZAGMYY.js";
137
134
  import {
138
- resolveClientVersion
139
- } from "./chunk-6OZ36FXI.js";
135
+ normalizeUsage
136
+ } from "./chunk-VSPO4S33.js";
140
137
  import {
141
138
  DEFAULT_CONTEXT_WINDOW,
142
- getModelContextWindow,
143
- normalizeUsage
144
- } from "./chunk-HKNXJGEC.js";
139
+ getModelContextWindow
140
+ } from "./chunk-FWY6BHIJ.js";
145
141
  import {
146
142
  clipCompactText
147
- } from "./chunk-P5EVSOPA.js";
148
- import {
149
- findModelConfig
150
- } from "./chunk-OIVSQH2O.js";
143
+ } from "./chunk-5MMAK75Q.js";
151
144
  import {
152
145
  compactWhitespace
153
146
  } from "./chunk-DWLEOOGR.js";
147
+ import {
148
+ BUILTIN_NOLO_AGENT_KEY,
149
+ BUILTIN_NOLO_AGENT_NAME,
150
+ builtinAgentCatalogEntryById,
151
+ parseBuiltinPlatformAgentId
152
+ } from "./chunk-3LI5UCTU.js";
153
+ import {
154
+ parsePublicAgentId
155
+ } from "./chunk-M2EJHDJP.js";
156
+ import {
157
+ createMemoryKey,
158
+ ulid
159
+ } from "./chunk-RLRYVSCD.js";
160
+ import {
161
+ isAntigravityOAuthAgent
162
+ } from "./chunk-TSBCYK5F.js";
163
+ import {
164
+ createRunActivityTracker,
165
+ getRunResultHeaderMeta,
166
+ popSingleQueueMessage,
167
+ readRunRecord,
168
+ recordRunResultHeaderMeta,
169
+ resolveResultServerMeta,
170
+ resolveRunQueuePath,
171
+ serverOriginForDialog,
172
+ settleRunTerminalAuthoritatively,
173
+ spawnLocalBackgroundRun
174
+ } from "./chunk-MHD5JBSS.js";
175
+ import {
176
+ formatAgentListCard,
177
+ formatFinishedRunCard,
178
+ formatListRunsCard,
179
+ formatNotFoundRunCard,
180
+ formatStartRunCard,
181
+ formatStatusRunCard,
182
+ formatStopRunCard,
183
+ isAgentRunTerminalStatus
184
+ } from "./chunk-PJNFNEJE.js";
185
+ import {
186
+ resolveClientVersion
187
+ } from "./chunk-KY6GPQ7O.js";
188
+ import {
189
+ findModelConfig
190
+ } from "./chunk-CGEK73JN.js";
191
+ import {
192
+ asTrimmedString
193
+ } from "./chunk-3EUW3WEO.js";
194
+ import {
195
+ isCliAuthorityBrokerProtocolError,
196
+ isCliAuthorityBrokerTimeoutError,
197
+ isCliAuthorityBrokerUnavailableError
198
+ } from "./chunk-EXAJ6DCR.js";
154
199
  import {
155
200
  toErrorMessage
156
201
  } from "./chunk-HNMXYYJR.js";
157
202
  import {
158
- buildAgentsMdLayer,
159
- buildMemoryOverlayLayer,
160
- buildMemoryUseGuidanceLayer,
161
- partitionScopedBlocks,
162
- renderTurnContextBlocksWithScope
163
- } from "./chunk-DVINR3PL.js";
203
+ getDefaultCliLocalRuntimeDb
204
+ } from "./chunk-2C47W7IJ.js";
164
205
  import {
165
- readPipeText,
166
- spawnProcess
167
- } from "./chunk-X7HHHIOZ.js";
206
+ getLogger,
207
+ normalizeError
208
+ } from "./chunk-EYLGAEB4.js";
168
209
  import {
169
210
  resolveAuthToken
170
211
  } from "./chunk-A7GB5UGH.js";
212
+ import {
213
+ asOptionalTrimmedString
214
+ } from "./chunk-G3SUCT4W.js";
215
+ import {
216
+ readPipeText,
217
+ spawnProcess
218
+ } from "./chunk-Y6ROFCZO.js";
171
219
  import {
172
220
  CLIENT_VERSION_TOO_OLD_CODE,
173
221
  NOLO_CLIENT_VERSION_HEADER,
174
222
  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";
223
+ } from "./chunk-SZC4REES.js";
183
224
  import {
184
225
  asTrimmedLowercaseString
185
226
  } from "./chunk-QSJ3HFEF.js";
186
227
  import {
187
- BUILTIN_NOLO_AGENT_KEY,
188
- BUILTIN_NOLO_AGENT_NAME,
189
- builtinAgentCatalogEntryById
190
- } from "./chunk-BNGW5ASC.js";
191
- import {
192
- parsePublicAgentId
193
- } from "./chunk-M2EJHDJP.js";
194
- import {
195
- isLevelNotFoundError
196
- } from "./chunk-OW765XBU.js";
197
- import {
198
- asTrimmedString
199
- } from "./chunk-3EUW3WEO.js";
228
+ buildSkillDiscoveryContextLayer
229
+ } from "./chunk-AU7AXHUL.js";
200
230
  import {
201
- asOptionalTrimmedString
202
- } from "./chunk-G3SUCT4W.js";
231
+ buildAgentsMdLayer,
232
+ buildMemoryOverlayLayer,
233
+ buildMemoryUseGuidanceLayer,
234
+ partitionScopedBlocks,
235
+ renderTurnContextBlocksWithScope
236
+ } from "./chunk-VEA7H5FG.js";
237
+
238
+ // packages/cli/tui/localAttachmentParts.ts
239
+ import { statSync } from "node:fs";
240
+ import path from "node:path";
241
+ var EXT_MIME = {
242
+ jpg: "image/jpeg",
243
+ jpeg: "image/jpeg",
244
+ png: "image/png",
245
+ gif: "image/gif",
246
+ webp: "image/webp",
247
+ bmp: "image/bmp",
248
+ tif: "image/tiff",
249
+ tiff: "image/tiff",
250
+ heic: "image/heic",
251
+ heif: "image/heif",
252
+ svg: "image/svg+xml",
253
+ mp3: "audio/mpeg",
254
+ m4a: "audio/mp4",
255
+ wav: "audio/wav",
256
+ ogg: "audio/ogg",
257
+ oga: "audio/ogg",
258
+ opus: "audio/opus",
259
+ flac: "audio/flac",
260
+ aac: "audio/aac",
261
+ amr: "audio/amr",
262
+ wma: "audio/x-ms-wma",
263
+ mp4: "video/mp4",
264
+ m4v: "video/x-m4v",
265
+ mov: "video/quicktime",
266
+ mkv: "video/x-matroska",
267
+ webm: "video/webm",
268
+ avi: "video/x-msvideo",
269
+ wmv: "video/x-ms-wmv",
270
+ mpg: "video/mpeg",
271
+ mpeg: "video/mpeg",
272
+ "3gp": "video/3gpp",
273
+ flv: "video/x-flv",
274
+ pdf: "application/pdf",
275
+ txt: "text/plain",
276
+ md: "text/markdown",
277
+ json: "application/json",
278
+ csv: "text/csv",
279
+ zip: "application/zip",
280
+ apk: "application/vnd.android.package-archive"
281
+ };
282
+ var mimeTypeForLocalPath = (filePath) => {
283
+ const ext = path.extname(filePath).slice(1).toLowerCase();
284
+ return EXT_MIME[ext] ?? "application/octet-stream";
285
+ };
286
+ var defaultStatSize = (filePath) => {
287
+ try {
288
+ const stat = statSync(filePath);
289
+ return stat.isFile() ? stat.size : null;
290
+ } catch {
291
+ return null;
292
+ }
293
+ };
294
+ var buildLocalAttachments = (input) => {
295
+ const machineId = typeof input.machineId === "string" ? input.machineId.trim() : "";
296
+ const workspaceRoot = typeof input.workspaceRoot === "string" ? input.workspaceRoot.trim() : "";
297
+ const statSize = input.statSize ?? defaultStatSize;
298
+ const mimeTypeOf = input.mimeTypeOf ?? mimeTypeForLocalPath;
299
+ const parts = [];
300
+ const skipped = [];
301
+ const seen = /* @__PURE__ */ new Set();
302
+ for (const raw of input.paths) {
303
+ const filePath = typeof raw === "string" ? raw.trim() : "";
304
+ if (!filePath || seen.has(filePath)) continue;
305
+ seen.add(filePath);
306
+ if (!machineId) {
307
+ skipped.push({ path: filePath, reason: "machine-unbound" });
308
+ continue;
309
+ }
310
+ const size = statSize(filePath);
311
+ if (size === null || !Number.isFinite(size) || size < 0) {
312
+ skipped.push({ path: filePath, reason: "unreadable" });
313
+ continue;
314
+ }
315
+ const normalized = normalizeAttachmentPart({
316
+ type: ATTACHMENT_PART_TYPE,
317
+ v: ATTACHMENT_PART_VERSION,
318
+ source: {
319
+ kind: "local-file",
320
+ path: filePath,
321
+ machineId,
322
+ ...workspaceRoot ? { workspaceRoot } : {}
323
+ },
324
+ name: path.basename(filePath),
325
+ mimeType: mimeTypeOf(filePath),
326
+ size
327
+ });
328
+ if (normalized.status !== "valid") {
329
+ skipped.push({ path: filePath, reason: "invalid-part" });
330
+ continue;
331
+ }
332
+ parts.push(normalized.attachment);
333
+ }
334
+ const cardText = parts.map((part) => describeAttachmentForModel(part)).join("\n");
335
+ return { parts, skipped, cardText };
336
+ };
337
+ var appendAttachmentCard = (message, cardText) => {
338
+ if (!cardText) return message;
339
+ return message.trim() ? `${message}
340
+
341
+ ${cardText}` : cardText;
342
+ };
343
+
344
+ // packages/chat/messages/attachmentWriteRollout.ts
345
+ var ENABLE_REMOTE_ATTACHMENT_PART_WRITES = false;
203
346
 
204
347
  // packages/cli/client/tokenUsage.ts
205
348
  var PLATFORM_CREDIT_UNIT = "credits";
@@ -211,7 +354,9 @@ function resolveEffectiveModel(opts) {
211
354
  if (isUsableModelId(opts.model)) return opts.model;
212
355
  const agentKey = opts.agentKey?.trim();
213
356
  if (!agentKey) return void 0;
214
- return builtinAgentCatalogEntryById(parsePublicAgentId(agentKey))?.model;
357
+ return builtinAgentCatalogEntryById(
358
+ parseBuiltinPlatformAgentId(agentKey) ?? parsePublicAgentId(agentKey)
359
+ )?.model;
215
360
  }
216
361
  function resolveAgentModelIdentity(opts) {
217
362
  const model = resolveEffectiveModel(opts);
@@ -1008,11 +1153,17 @@ function wrapTranscriptLineWithLayout(line, columns, hangingIndent = "", lineSou
1008
1153
  activeStyles.push(value);
1009
1154
  }
1010
1155
  };
1156
+ let lastContentTokenIndex = -1;
1157
+ for (let i = tokens.length - 1; i >= 0; i -= 1) {
1158
+ if (tokens[i].kind !== "sgr") {
1159
+ lastContentTokenIndex = i;
1160
+ break;
1161
+ }
1162
+ }
1163
+ let plainCharIndexAtStart = 0;
1011
1164
  let start = 0;
1012
1165
  while (start < tokens.length) {
1013
- if (tokens.slice(start).every((token) => token.kind === "sgr")) {
1014
- if (rows.length > 0) break;
1015
- }
1166
+ if (start > lastContentTokenIndex && rows.length > 0) break;
1016
1167
  const openingStyles = [...activeStyles];
1017
1168
  const isContinuation = rows.length > 0;
1018
1169
  const currentPrefixWidth = isContinuation ? visibleWidth(hangingIndent) : prefixWidth;
@@ -1060,13 +1211,7 @@ function wrapTranscriptLineWithLayout(line, columns, hangingIndent = "", lineSou
1060
1211
  let segSourceEnd = lineSourceStart;
1061
1212
  let foundFirst = false;
1062
1213
  const rowMapping = [];
1063
- let plainCharIndex = 0;
1064
- for (let i = 0; i < start; i++) {
1065
- const tok = tokens[i];
1066
- if (tok.kind === "char" && tok.charIndex >= prefixCharCount) {
1067
- plainCharIndex += tok.value.length;
1068
- }
1069
- }
1214
+ let plainCharIndex = plainCharIndexAtStart;
1070
1215
  for (let i = start; i < segmentEnd; i++) {
1071
1216
  const tok = tokens[i];
1072
1217
  if (tok.kind === "char" && tok.charIndex >= prefixCharCount) {
@@ -1103,6 +1248,7 @@ function wrapTranscriptLineWithLayout(line, columns, hangingIndent = "", lineSou
1103
1248
  if (start >= tokens.length && rawLineLength !== void 0) {
1104
1249
  segSourceEnd = lineSourceStart + rawLineLength;
1105
1250
  }
1251
+ plainCharIndexAtStart = plainCharIndex;
1106
1252
  rows.push({
1107
1253
  rendered: rowRendered,
1108
1254
  sourceStart: segSourceStart,
@@ -8206,7 +8352,12 @@ function emitPlainGap(text, keywords, info, accent, warning, reset) {
8206
8352
  var UNORDERED_LIST_RE = /^(\s*)([-*+])\s+(.+)$/;
8207
8353
  var ORDERED_LIST_RE = /^(\s*)(\d+)\.\s+(.+)$/;
8208
8354
  var TASK_LIST_RE = /^(\s*)([-*+])\s+\[([ xX])\]\s+(.+)$/;
8355
+ var THEMATIC_BREAK_PATTERN = "(?:(-[ \\t]*){3,}|(\\*[ \\t]*){3,}|(_[ \\t]*){3,})";
8356
+ var THEMATIC_BREAK_RE = new RegExp(`^[ ]{0,3}${THEMATIC_BREAK_PATTERN}$`);
8209
8357
  function normalizeListLine(line) {
8358
+ if (THEMATIC_BREAK_RE.test(line)) {
8359
+ return line;
8360
+ }
8210
8361
  const task = line.match(TASK_LIST_RE);
8211
8362
  if (task) {
8212
8363
  const checked = task[3] === "x" || task[3] === "X";
@@ -8222,12 +8373,99 @@ function normalizeListLine(line) {
8222
8373
  }
8223
8374
  return line;
8224
8375
  }
8376
+ var TOOL_TREE_HEADER_RE = /^•\s+(.+?)\s+\((\d+)\)$/;
8377
+ var TOOL_TREE_LEAF_RE = /^([├└]──\s+)(.*?)\s{2}(✓|✗|!)(?:\s+(.*))?$/;
8378
+ var TOOL_SINGLE_RE = /^▸\s+(.+?)(?:\s+·\s+(.*?))?(?:\s{2}(✓|✗|!)(?:\s+(.*))?)$/;
8379
+ function plainToolLine(line) {
8380
+ return stripAnsi2(line);
8381
+ }
8382
+ var TOOL_TREE_GROUP_LABELS = new Set(
8383
+ ["execShell", "readFile", "fetchWebpage", "exa_search"].flatMap(toolLabelVariants)
8384
+ );
8385
+ function isKnownToolGroupLabel(label) {
8386
+ return TOOL_TREE_GROUP_LABELS.has(label);
8387
+ }
8388
+ function toolTreeHeaderMatch(line) {
8389
+ const match = plainToolLine(line).match(TOOL_TREE_HEADER_RE);
8390
+ return match && isKnownToolGroupLabel(match[1]) ? match : null;
8391
+ }
8392
+ function isToolTreeHeaderLine(line) {
8393
+ return toolTreeHeaderMatch(line) !== null;
8394
+ }
8395
+ function isToolTreeLeafLine(line) {
8396
+ return TOOL_TREE_LEAF_RE.test(plainToolLine(line));
8397
+ }
8398
+ function isToolSingleLine(line) {
8399
+ return TOOL_SINGLE_RE.test(plainToolLine(line));
8400
+ }
8401
+ function isToolGroupBoundary(cur, next) {
8402
+ return isToolTreeLeafLine(cur) && isToolTreeHeaderLine(next);
8403
+ }
8404
+ function statusColorSeq(marker, brightness) {
8405
+ if (marker === "\u2713") return colorSeq("success", brightness);
8406
+ if (marker === "\u2717") return colorSeq("danger", brightness);
8407
+ return colorSeq("warning", brightness);
8408
+ }
8409
+ function styleTuiToolLine(line, brightness) {
8410
+ const plain = plainToolLine(line);
8411
+ const chrome = colorSeq("chrome", brightness);
8412
+ const muted = colorSeq("muted", brightness);
8413
+ const header = toolTreeHeaderMatch(plain);
8414
+ if (header) {
8415
+ return `${chrome}\u2022${STYLE.reset} ${STYLE.bold}${muted}${header[1]}${STYLE.reset} ${chrome}${STYLE.dim}(${header[2]})${STYLE.reset}`;
8416
+ }
8417
+ const leaf = plain.match(TOOL_TREE_LEAF_RE);
8418
+ if (leaf) {
8419
+ const [, connector, detail, marker, statusDetail] = leaf;
8420
+ let rendered = `${chrome}${connector}${STYLE.reset}${chrome}${detail}${STYLE.reset}`;
8421
+ rendered += ` ${statusColorSeq(marker, brightness)}${marker}${STYLE.reset}`;
8422
+ if (statusDetail) {
8423
+ const metaSeq = marker === "\u2713" ? chrome : statusColorSeq(marker, brightness);
8424
+ rendered += ` ${metaSeq}${STYLE.dim}${statusDetail}${STYLE.reset}`;
8425
+ }
8426
+ return rendered;
8427
+ }
8428
+ const single = plain.match(TOOL_SINGLE_RE);
8429
+ if (single) {
8430
+ const [, label, detail, marker, statusDetail] = single;
8431
+ let rendered = `${chrome}\u25B8${STYLE.reset} ${STYLE.bold}${muted}${label}${STYLE.reset}`;
8432
+ if (detail) rendered += ` ${chrome}\xB7 ${detail}${STYLE.reset}`;
8433
+ rendered += ` ${statusColorSeq(marker, brightness)}${marker}${STYLE.reset}`;
8434
+ if (statusDetail) {
8435
+ const metaSeq = marker === "\u2713" ? chrome : statusColorSeq(marker, brightness);
8436
+ rendered += ` ${metaSeq}${STYLE.dim}${statusDetail}${STYLE.reset}`;
8437
+ }
8438
+ return rendered;
8439
+ }
8440
+ return null;
8441
+ }
8225
8442
  function isPolishListLikeLine(line) {
8226
- return LIST_LIKE_RE_FOR_GUARD.test(normalizeListLine(line));
8443
+ return LIST_LIKE_RE_FOR_GUARD.test(normalizeListLine(plainToolLine(line)));
8444
+ }
8445
+ var LIST_LIKE_RE_FOR_GUARD = /^\s*(?:•|◦|☐|☑|\d+\.)\s|^\s*[\u2460-\u2473]|^\s*[├└]──\s|^\s*▸\s/;
8446
+ function isPolishFenceInteriorLine(line) {
8447
+ return /^\x00F\d+\x00$/.test(line);
8448
+ }
8449
+ function polishHeadingLevel(line) {
8450
+ const match = stripAnsi2(line).match(/^(#{1,6})\s/);
8451
+ return match ? match[1].length : null;
8452
+ }
8453
+ function isPolishHeadingLine(line) {
8454
+ return polishHeadingLevel(line) !== null;
8455
+ }
8456
+ function isPolishIntroLine(line) {
8457
+ const plain = stripAnsi2(line).trimEnd();
8458
+ return plain.endsWith("\uFF1A") || plain.endsWith(":");
8227
8459
  }
8228
- var LIST_LIKE_RE_FOR_GUARD = /^\s*(?:•|☐|☑|\d+\.)\s|^\s*[\u2460-\u2473]|^\s*[├└]──\s/;
8229
8460
  function polishBreathInsertsBlankBetween(cur, next) {
8230
8461
  if (cur === "" || next === "") return false;
8462
+ if (isPolishFenceInteriorLine(cur) || isPolishFenceInteriorLine(next)) {
8463
+ return false;
8464
+ }
8465
+ if (isPolishIntroLine(cur) && isPolishListLikeLine(next)) return false;
8466
+ if (isPolishHeadingLine(cur) || isPolishHeadingLine(next)) return false;
8467
+ if (isCodeFenceLine(cur) !== isCodeFenceLine(next)) return true;
8468
+ if (isToolGroupBoundary(cur, next)) return true;
8231
8469
  return isPolishListLikeLine(cur) !== isPolishListLikeLine(next);
8232
8470
  }
8233
8471
  function convertMarkdownTablesForTerminal(text) {
@@ -8296,17 +8534,15 @@ function polishAssistantStructure(text, options = {}) {
8296
8534
  }
8297
8535
  return line;
8298
8536
  });
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/;
8537
+ 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
8538
  const headingLines = afterHeading.split("\n");
8302
8539
  const breathed = [];
8303
8540
  for (let i = 0; i < headingLines.length; i++) {
8304
8541
  breathed.push(headingLines[i]);
8305
8542
  const cur = headingLines[i];
8306
8543
  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("");
8544
+ if (next === void 0) continue;
8545
+ if (polishBreathInsertsBlankBetween(cur, next)) breathed.push("");
8310
8546
  }
8311
8547
  const polishedMasked = breathed.join("\n");
8312
8548
  const polished = polishedMasked.replace(
@@ -8316,17 +8552,23 @@ function polishAssistantStructure(text, options = {}) {
8316
8552
  return options.trimEdges === false ? polished : polished.trim();
8317
8553
  }
8318
8554
  function styleRichMarkdownLine(line, brightness) {
8319
- const heading = line.match(/^(#{1,3})\s+(.+)$/);
8555
+ const toolLine = styleTuiToolLine(line, brightness);
8556
+ if (toolLine !== null) return toolLine;
8557
+ const heading = line.match(/^(#{1,6})\s+(.+)$/);
8320
8558
  if (heading) {
8321
8559
  const level = heading[1].length;
8322
8560
  const title = heading[2];
8561
+ const styledTitle = styleInlineMarkdown(title, brightness);
8323
8562
  if (level === 1) {
8324
- return `${STYLE.bold}\x1B[4m${colorSeq("accent", brightness)}${title}${STYLE.reset}`;
8563
+ return `${STYLE.bold}${colorSeq("accent", brightness)}${styledTitle}${STYLE.reset}`;
8325
8564
  }
8326
8565
  if (level === 2) {
8327
- return `${STYLE.bold}${colorSeq("warning", brightness)}${title}${STYLE.reset}`;
8566
+ return `${STYLE.bold}${colorSeq("warning", brightness)}${styledTitle}${STYLE.reset}`;
8567
+ }
8568
+ if (level === 3) {
8569
+ return `${STYLE.bold}${colorSeq("info", brightness)}${styledTitle}${STYLE.reset}`;
8328
8570
  }
8329
- return `${STYLE.bold}${colorSeq("info", brightness)}${title}${STYLE.reset}`;
8571
+ return `${STYLE.bold}${colorSeq("muted", brightness)}${styledTitle}${STYLE.reset}`;
8330
8572
  }
8331
8573
  if (line.startsWith("\u8FDB\u5165 nolo-plan")) {
8332
8574
  return `${colorSeq("chrome", brightness)}${STYLE.dim}${line}${STYLE.reset}`;
@@ -8335,15 +8577,19 @@ function styleRichMarkdownLine(line, brightness) {
8335
8577
  if (blockquote) {
8336
8578
  const border = colorSeq("chrome", brightness);
8337
8579
  const content = blockquote[1];
8338
- return `${border}\u2502${STYLE.reset} ${STYLE.dim}${content}${STYLE.reset}`;
8580
+ const styled = styleInlineMarkdown(content, brightness);
8581
+ return `${border}\u2502${STYLE.reset} ${STYLE.dim}${styled}${STYLE.reset}`;
8339
8582
  }
8340
- if (/^---+$/.test(line.trim())) {
8341
- return `${colorSeq("chrome", brightness)}${"\u2500".repeat(Math.min(line.trim().length, 40))}${STYLE.reset}`;
8583
+ if (THEMATIC_BREAK_RE.test(line)) {
8584
+ return `${colorSeq("chrome", brightness)}${STYLE.dim}${"\u2500".repeat(36)}${STYLE.reset}`;
8342
8585
  }
8343
8586
  const bullet = line.match(/^(\s*)(•)\s(.+)$/);
8344
8587
  if (bullet) {
8588
+ const indent = bullet[1];
8345
8589
  const styled = styleInlineMarkdown(bullet[3], brightness);
8346
- return `${bullet[1]}${colorSeq("accent", brightness)}\u2022${STYLE.reset} ${styled}`;
8590
+ const marker = indent.length >= 2 ? "\u25E6" : "\u2022";
8591
+ const markerColor = indent.length >= 2 ? colorSeq("chrome", brightness) : colorSeq("accent", brightness);
8592
+ return `${indent}${markerColor}${marker}${STYLE.reset} ${styled}`;
8347
8593
  }
8348
8594
  const ordered = line.match(/^(\s*)(\d+\.)\s(.+)$/);
8349
8595
  if (ordered) {
@@ -8467,16 +8713,28 @@ function emitFormattedAssistantBlock(write, text, trailingNewline = false) {
8467
8713
  }
8468
8714
  function classifyStreamLine(line) {
8469
8715
  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)) {
8716
+ const plain = plainToolLine(line);
8717
+ if (isToolTreeHeaderLine(plain)) return "tool-header";
8718
+ if (isToolTreeLeafLine(plain)) return "tool-leaf";
8719
+ if (isToolSingleLine(plain)) return "tool";
8720
+ 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
8721
  return "list";
8472
8722
  }
8723
+ if (isPolishListLikeLine(plain)) return "list";
8724
+ if (polishHeadingLevel(plain) !== null) return "heading";
8473
8725
  return "prose";
8474
8726
  }
8475
- function needsListProseBreath(prev, next) {
8727
+ function isStreamListLike(kind) {
8728
+ return kind === "list" || kind === "tool-header" || kind === "tool-leaf" || kind === "tool";
8729
+ }
8730
+ function needsListProseBreath(prev, next, prevLine = "") {
8476
8731
  if (prev === null || prev === "blank" || next === "blank") return false;
8477
- const prevList = prev === "list";
8478
- const nextList = next === "list";
8479
- return prevList !== nextList;
8732
+ if (next === "heading") return true;
8733
+ if (prev === "heading") return (polishHeadingLevel(prevLine) ?? 7) <= 2;
8734
+ if (prev === "fence" !== (next === "fence")) return true;
8735
+ if (isStreamListLike(next) && isPolishIntroLine(prevLine)) return false;
8736
+ if (prev === "tool-leaf" && next === "tool-header") return true;
8737
+ return isStreamListLike(prev) !== isStreamListLike(next);
8480
8738
  }
8481
8739
  function createRenderAwareStreamWriter(args) {
8482
8740
  const brightness = resolveTuiBrightness();
@@ -8486,9 +8744,16 @@ function createRenderAwareStreamWriter(args) {
8486
8744
  let inMermaid = false;
8487
8745
  let mermaidBody = [];
8488
8746
  let lastKind = null;
8747
+ let lastLine = "";
8748
+ let pendingBlankRow = false;
8489
8749
  const PARTIAL_FLUSH_THRESHOLD = 48;
8490
8750
  const emitBreathIfNeeded = (nextKind) => {
8491
- if (needsListProseBreath(lastKind, nextKind)) args.write("\n");
8751
+ if (pendingBlankRow) {
8752
+ args.write("\n");
8753
+ pendingBlankRow = false;
8754
+ lastKind = "blank";
8755
+ }
8756
+ if (needsListProseBreath(lastKind, nextKind, lastLine)) args.write("\n");
8492
8757
  };
8493
8758
  const flushPartialProse = () => {
8494
8759
  if (inFence || buffer.length < PARTIAL_FLUSH_THRESHOLD) return;
@@ -8506,6 +8771,7 @@ function createRenderAwareStreamWriter(args) {
8506
8771
  emitBreathIfNeeded("prose");
8507
8772
  emitFormattedAssistantBlock(args.write, prefix, false);
8508
8773
  lastKind = "prose";
8774
+ lastLine = prefix;
8509
8775
  buffer = prefix.length === buffer.length ? "" : buffer.slice(prefix.length);
8510
8776
  };
8511
8777
  const flushCompleteBlocks = () => {
@@ -8521,10 +8787,11 @@ function createRenderAwareStreamWriter(args) {
8521
8787
  inMermaid = false;
8522
8788
  inFence = false;
8523
8789
  fenceLang = "unknown";
8524
- emitBreathIfNeeded("other");
8790
+ emitBreathIfNeeded("fence");
8525
8791
  args.write(`${STYLE.dim}${firstLine}${STYLE.reset}
8526
8792
  `);
8527
- lastKind = "other";
8793
+ lastKind = "fence";
8794
+ lastLine = firstLine;
8528
8795
  buffer = lines.slice(1).join("\n");
8529
8796
  continue;
8530
8797
  }
@@ -8540,10 +8807,11 @@ function createRenderAwareStreamWriter(args) {
8540
8807
  }
8541
8808
  inFence = true;
8542
8809
  }
8543
- emitBreathIfNeeded("other");
8810
+ emitBreathIfNeeded("fence");
8544
8811
  args.write(`${STYLE.dim}${firstLine}${STYLE.reset}
8545
8812
  `);
8546
- lastKind = "other";
8813
+ lastKind = "fence";
8814
+ lastLine = firstLine;
8547
8815
  buffer = lines.slice(1).join("\n");
8548
8816
  continue;
8549
8817
  }
@@ -8555,7 +8823,8 @@ function createRenderAwareStreamWriter(args) {
8555
8823
  if (inFence) {
8556
8824
  args.write(`${highlightCodeLine(firstLine, fenceLang, brightness)}
8557
8825
  `);
8558
- lastKind = "other";
8826
+ lastKind = "fence";
8827
+ lastLine = firstLine;
8559
8828
  buffer = lines.slice(1).join("\n");
8560
8829
  continue;
8561
8830
  }
@@ -8568,6 +8837,7 @@ function createRenderAwareStreamWriter(args) {
8568
8837
  const inner = trimmedFirst.slice(2, trimmedFirst.length - 2);
8569
8838
  args.write(renderMathBlock(inner) + "\n");
8570
8839
  lastKind = "other";
8840
+ lastLine = trimmedFirst;
8571
8841
  buffer = lines.slice(1).join("\n");
8572
8842
  continue;
8573
8843
  }
@@ -8594,6 +8864,7 @@ function createRenderAwareStreamWriter(args) {
8594
8864
  if (lastInner) innerParts.push(lastInner);
8595
8865
  args.write(renderMathBlock(innerParts.join("\n")) + "\n");
8596
8866
  lastKind = "other";
8867
+ lastLine = trimmedFirst;
8597
8868
  buffer = lines.slice(closeIndex + 1).join("\n");
8598
8869
  continue;
8599
8870
  }
@@ -8614,14 +8885,23 @@ function createRenderAwareStreamWriter(args) {
8614
8885
  true
8615
8886
  );
8616
8887
  lastKind = "list";
8888
+ lastLine = lines[end - 1] ?? firstLine;
8617
8889
  buffer = lines.slice(end).join("\n");
8618
8890
  continue;
8619
8891
  }
8620
8892
  }
8621
8893
  const kind = classifyStreamLine(firstLine);
8894
+ if (kind === "blank") {
8895
+ if (lastKind !== null && lastKind !== "blank") pendingBlankRow = true;
8896
+ lastKind = "blank";
8897
+ lastLine = "";
8898
+ buffer = lines.slice(1).join("\n");
8899
+ continue;
8900
+ }
8622
8901
  emitBreathIfNeeded(kind);
8623
8902
  emitFormattedAssistantBlock(args.write, firstLine, true);
8624
8903
  lastKind = kind;
8904
+ lastLine = firstLine;
8625
8905
  buffer = lines.slice(1).join("\n");
8626
8906
  }
8627
8907
  };
@@ -8667,6 +8947,34 @@ function redactSecrets(text) {
8667
8947
  );
8668
8948
  }
8669
8949
 
8950
+ // packages/cli/tui/askTextSanitize.ts
8951
+ var ASK_SECRET_PLACEHOLDER = "\u27E8redacted\u27E9";
8952
+ var C0_C1_CONTROL_REGEX = /[\x00-\x1f\x7f-\x9f]/g;
8953
+ var NORMAL_GIST_SECRET_PATTERNS = [
8954
+ /\bbearer\s+[A-Za-z0-9._~+/=-]{8,}/i,
8955
+ /\bsk-(?:ant-)?(?:api)?[0-9a-zA-Z-]{10,}/,
8956
+ /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{10,}/,
8957
+ /\bxox[baprs]-[A-Za-z0-9-]{10,}/
8958
+ ];
8959
+ function withholdIfSecretLike(gist) {
8960
+ if (!gist) return "";
8961
+ if (findPotentialSecrets(gist).length > 0) return "";
8962
+ if (NORMAL_GIST_SECRET_PATTERNS.some((pattern) => pattern.test(gist))) return "";
8963
+ return gist;
8964
+ }
8965
+ function toText(value) {
8966
+ return typeof value === "string" ? value : String(value ?? "");
8967
+ }
8968
+ function cleanAskText(value) {
8969
+ return stripAnsi2(toText(value)).replace(/[\r\n]+/g, " ").replace(/\s+/g, " ").replace(C0_C1_CONTROL_REGEX, "").replace(/\s+/g, " ").trim();
8970
+ }
8971
+ function safeAskText(value, max) {
8972
+ const cleaned = redactSecrets(cleanAskText(value));
8973
+ if (!cleaned) return "";
8974
+ const guarded = withholdIfSecretLike(cleaned) || ASK_SECRET_PLACEHOLDER;
8975
+ return max === void 0 ? guarded : clipCompactText(guarded, max, "\u2026");
8976
+ }
8977
+
8670
8978
  // node_modules/diff/libesm/diff/base.js
8671
8979
  var Diff = class {
8672
8980
  diff(oldStr, newStr, options = {}) {
@@ -8767,16 +9075,16 @@ var Diff = class {
8767
9075
  }
8768
9076
  }
8769
9077
  }
8770
- addToPath(path, added, removed, oldPosInc, options) {
8771
- const last = path.lastComponent;
9078
+ addToPath(path2, added, removed, oldPosInc, options) {
9079
+ const last = path2.lastComponent;
8772
9080
  if (last && !options.oneChangePerToken && last.added === added && last.removed === removed) {
8773
9081
  return {
8774
- oldPos: path.oldPos + oldPosInc,
9082
+ oldPos: path2.oldPos + oldPosInc,
8775
9083
  lastComponent: { count: last.count + 1, added, removed, previousComponent: last.previousComponent }
8776
9084
  };
8777
9085
  } else {
8778
9086
  return {
8779
- oldPos: path.oldPos + oldPosInc,
9087
+ oldPos: path2.oldPos + oldPosInc,
8780
9088
  lastComponent: { count: 1, added, removed, previousComponent: last }
8781
9089
  };
8782
9090
  }
@@ -8921,14 +9229,14 @@ function tokenize(value, options) {
8921
9229
  import { homedir as osHomedir } from "node:os";
8922
9230
 
8923
9231
  // packages/core/foldHomePath.ts
8924
- function foldHomePath(path, home) {
8925
- if (!path) return path;
9232
+ function foldHomePath(path2, home) {
9233
+ if (!path2) return path2;
8926
9234
  if (home) {
8927
9235
  const cleanHome = home.endsWith("/") ? home.slice(0, -1) : home;
8928
- if (path === cleanHome) return "~";
8929
- if (path.startsWith(cleanHome + "/")) return `~${path.slice(cleanHome.length)}`;
9236
+ if (path2 === cleanHome) return "~";
9237
+ if (path2.startsWith(cleanHome + "/")) return `~${path2.slice(cleanHome.length)}`;
8930
9238
  }
8931
- return path.replace(/^(\/Users\/[^/]+|\/home\/[^/]+)(\/|$)/, "~$2");
9239
+ return path2.replace(/^(\/Users\/[^/]+|\/home\/[^/]+)(\/|$)/, "~$2");
8932
9240
  }
8933
9241
 
8934
9242
  // packages/cli/client/formatReadPathTree.ts
@@ -8955,10 +9263,10 @@ function clipPathAware(value, max = 72) {
8955
9263
  if (filenameOnly.length <= max) return filenameOnly;
8956
9264
  return clipCompactText(value, max, "\u2026");
8957
9265
  }
8958
- function formatHomePath(path, customHomedir) {
8959
- if (!path) return "";
9266
+ function formatHomePath(path2, customHomedir) {
9267
+ if (!path2) return "";
8960
9268
  const home = customHomedir || (typeof process !== "undefined" ? process.env?.HOME : void 0) || (typeof osHomedir === "function" ? osHomedir() : "");
8961
- return foldHomePath(path, home);
9269
+ return foldHomePath(path2, home);
8962
9270
  }
8963
9271
  function formatReadItemPath(rawPath, metadata, customHomedir) {
8964
9272
  const inputPath = rawPath || (typeof metadata?.path === "string" ? metadata.path : void 0) || (typeof metadata?.filePath === "string" ? metadata.filePath : void 0) || "file";
@@ -8978,10 +9286,10 @@ function formatReadItemPath(rawPath, metadata, customHomedir) {
8978
9286
  const clippedPath = clipPathAware(formattedPath, 72);
8979
9287
  return `${clippedPath}${rangePart}`;
8980
9288
  }
8981
- function formatSearchItemQuery(query, path, customHomedir) {
9289
+ function formatSearchItemQuery(query, path2, customHomedir) {
8982
9290
  let text = (query || "").trim();
8983
- if (path) {
8984
- const formattedPath = formatHomePath(path, customHomedir);
9291
+ if (path2) {
9292
+ const formattedPath = formatHomePath(path2, customHomedir);
8985
9293
  if (formattedPath) {
8986
9294
  text = text ? `${text} in ${formattedPath}` : formattedPath;
8987
9295
  }
@@ -9037,7 +9345,7 @@ function parseUiAskChoiceForCli(event) {
9037
9345
  label: String(parsed.selected.label ?? "").trim(),
9038
9346
  userMessage: String(parsed.selected.userMessage ?? "").trim()
9039
9347
  } : void 0;
9040
- const answers = Array.isArray(parsed.answers) ? parsed.answers : void 0;
9348
+ const answers = Array.isArray(parsed.answers) ? parsed.answers.filter((a) => Boolean(a && typeof a === "object")) : void 0;
9041
9349
  const cancelled = Boolean(parsed.cancelled);
9042
9350
  const resolved = Boolean(
9043
9351
  event.metadata?.resolved || selected || cancelled || answers && answers.length > 0
@@ -9058,7 +9366,7 @@ function formatUiAskChoiceBlock(event, colorEnabled) {
9058
9366
  if (!parsed) return null;
9059
9367
  const lines = [];
9060
9368
  lines.push("");
9061
- const questionText = parsed.question || "";
9369
+ const questionText = safeAskText(parsed.question, 200);
9062
9370
  if (colorEnabled) {
9063
9371
  lines.push(`${themeText("\u2753 ", "info", true)}${styleCliText(questionText, "cyan", true)}`);
9064
9372
  } else {
@@ -9073,7 +9381,8 @@ function formatUiAskChoiceBlock(event, colorEnabled) {
9073
9381
  return `${lines.join("\n")}
9074
9382
  `;
9075
9383
  }
9076
- const selectedLabel = parsed.selected?.label || parsed.selected?.userMessage || (parsed.answers ? parsed.answers.map((a) => a.userMessage).filter(Boolean).join(", ") : "");
9384
+ const rawSelected = parsed.selected?.label || parsed.selected?.userMessage;
9385
+ const selectedLabel = rawSelected ? safeAskText(rawSelected, 160) : parsed.answers ? parsed.answers.map((a) => safeAskText(a.userMessage, 160)).filter(Boolean).join(", ") : "";
9077
9386
  const marker = t("askChoiceHistorySelected");
9078
9387
  const displayLabel = selectedLabel || "\u2014";
9079
9388
  if (colorEnabled) {
@@ -9086,8 +9395,9 @@ function formatUiAskChoiceBlock(event, colorEnabled) {
9086
9395
  if (parsed.answers && parsed.answers.length > 1) {
9087
9396
  for (const answer of parsed.answers) {
9088
9397
  if (!answer.userMessage) continue;
9398
+ const answerText = safeAskText(answer.userMessage, 160);
9089
9399
  lines.push(
9090
- colorEnabled ? ` ${themeText("\xB7", "chrome", true)} ${answer.userMessage}` : ` \xB7 ${answer.userMessage}`
9400
+ colorEnabled ? ` ${themeText("\xB7", "chrome", true)} ${answerText}` : ` \xB7 ${answerText}`
9091
9401
  );
9092
9402
  }
9093
9403
  }
@@ -9096,7 +9406,7 @@ function formatUiAskChoiceBlock(event, colorEnabled) {
9096
9406
  }
9097
9407
  parsed.choices.forEach((choice, i) => {
9098
9408
  const num = String(i + 1);
9099
- const label = choice.label;
9409
+ const label = safeAskText(choice.label, 160);
9100
9410
  if (colorEnabled) {
9101
9411
  lines.push(
9102
9412
  ` ${themeText(num + ".", "chrome", true)} ${label}`
@@ -9112,6 +9422,87 @@ function formatUiAskChoiceBlock(event, colorEnabled) {
9112
9422
  lines.push(` ${hint}`);
9113
9423
  }
9114
9424
  return `${lines.join("\n")}
9425
+ `;
9426
+ }
9427
+ function formatShowInteractionBlock(event, colorEnabled) {
9428
+ const label = toolLabel(event.toolName || "show_interaction");
9429
+ let parsedPayload;
9430
+ if (typeof event.content === "string") {
9431
+ try {
9432
+ parsedPayload = JSON.parse(event.content);
9433
+ } catch {
9434
+ const metadata = event.metadata ?? {};
9435
+ const rawMetaError = metadata.error ?? metadata.errorMessage;
9436
+ const rawMessage = event.message?.trim();
9437
+ const rawContent = event.content.trim();
9438
+ let reason = "";
9439
+ if (typeof rawMetaError === "string" && rawMetaError.trim()) {
9440
+ reason = rawMetaError.trim();
9441
+ } else if (rawMessage) {
9442
+ reason = rawMessage;
9443
+ } else if (/^\[工具\s*"[^"]+"\s*执行失败:\s*[^\]]+\]$/.test(rawContent)) {
9444
+ reason = rawContent;
9445
+ }
9446
+ const detail = reason ? clip(redactSecrets(cleanUserText(reason)), 96) : "invalid card payload";
9447
+ return formatToolTraceLine(`\u25B8 ${label} \u2717 ${detail}`, colorEnabled, "error");
9448
+ }
9449
+ } else if (event.content && typeof event.content === "object") {
9450
+ parsedPayload = event.content;
9451
+ } else {
9452
+ const metadata = event.metadata ?? {};
9453
+ const rawMetaError = metadata.error ?? metadata.errorMessage;
9454
+ const reason = typeof rawMetaError === "string" && rawMetaError.trim() || event.message?.trim() || "";
9455
+ const detail = reason ? clip(redactSecrets(cleanUserText(reason)), 96) : "invalid card payload";
9456
+ return formatToolTraceLine(`\u25B8 ${label} \u2717 ${detail}`, colorEnabled, "error");
9457
+ }
9458
+ if (parsedPayload && typeof parsedPayload === "object" && parsedPayload.error) {
9459
+ const detail = typeof parsedPayload.detail === "string" && parsedPayload.detail.trim() ? clip(redactSecrets(cleanUserText(parsedPayload.detail)), 96) : "card error";
9460
+ return formatToolTraceLine(`\u25B8 ${label} \u2717 ${detail}`, colorEnabled, "error");
9461
+ }
9462
+ const rawCard = parsedPayload && typeof parsedPayload === "object" && (parsedPayload.type === "show_interaction" || parsedPayload.card !== void 0) ? parsedPayload.card : parsedPayload;
9463
+ const parsedCard = parseUiCard(rawCard);
9464
+ if (!parsedCard.ok) {
9465
+ const errorText = clip(redactSecrets(cleanUserText(parsedCard.error)), 96);
9466
+ return formatToolTraceLine(`\u25B8 ${label} \u2717 ${errorText}`, colorEnabled, "error");
9467
+ }
9468
+ const fallback = uiCardFallback(parsedCard.value);
9469
+ const maxLines = 12;
9470
+ const maxDisplayWidth = 400;
9471
+ const rawLines = fallback.split("\n");
9472
+ const clippedLines = [];
9473
+ let currentWidth = 0;
9474
+ let wasClipped = false;
9475
+ for (let i = 0; i < rawLines.length; i++) {
9476
+ if (clippedLines.length >= maxLines) {
9477
+ wasClipped = true;
9478
+ break;
9479
+ }
9480
+ const cleanLine = redactSecrets(cleanUserText(rawLines[i]));
9481
+ const lineWidth = displayWidth(cleanLine);
9482
+ const separatorWidth = clippedLines.length > 0 ? 1 : 0;
9483
+ if (currentWidth + lineWidth + separatorWidth > maxDisplayWidth) {
9484
+ const remainingWidth = maxDisplayWidth - currentWidth - separatorWidth;
9485
+ if (remainingWidth > 0) {
9486
+ clippedLines.push(truncateByDisplayWidth(cleanLine, remainingWidth));
9487
+ }
9488
+ wasClipped = true;
9489
+ break;
9490
+ }
9491
+ clippedLines.push(cleanLine);
9492
+ currentWidth += lineWidth + separatorWidth;
9493
+ }
9494
+ if (clippedLines.length === 0 && rawLines.length > 0 && maxDisplayWidth > 0) {
9495
+ const cleanLine = redactSecrets(cleanUserText(rawLines[0]));
9496
+ clippedLines.push(truncateByDisplayWidth(cleanLine, maxDisplayWidth));
9497
+ wasClipped = true;
9498
+ }
9499
+ if (wasClipped) {
9500
+ clippedLines.push("\u2026");
9501
+ }
9502
+ const cleanLines = clippedLines.map((l) => colorEnabled ? themeText(l, "muted", true) : l);
9503
+ return `
9504
+ ${cleanLines.join("\n")}
9505
+
9115
9506
  `;
9116
9507
  }
9117
9508
  function formatToolTraceLine(text, colorEnabled, accent = "none") {
@@ -9134,6 +9525,7 @@ function renderRunCard(snapshot, opts) {
9134
9525
  ...snapshot,
9135
9526
  agentName: snapshot.agentName ? cleanUserText(snapshot.agentName) : snapshot.agentName,
9136
9527
  taskPreview: snapshot.taskPreview ? cleanUserText(snapshot.taskPreview) : snapshot.taskPreview,
9528
+ title: snapshot.title ? cleanUserText(snapshot.title) : snapshot.title,
9137
9529
  lastAssistantText: snapshot.lastAssistantText ? cleanUserText(snapshot.lastAssistantText) : snapshot.lastAssistantText,
9138
9530
  lastToolNames: snapshot.lastToolNames?.map(cleanUserText)
9139
9531
  } : snapshot;
@@ -9144,6 +9536,7 @@ function renderRunCard(snapshot, opts) {
9144
9536
  } : { errorMessage: source.errorMessage, logLines: source.logLines };
9145
9537
  const body = isAgentRunTerminalStatus(snapshot.status) ? formatFinishedRunCard(name, snapshot.status, {
9146
9538
  runId: snapshot.runId,
9539
+ ...snapshot.title ? { title: snapshot.title } : {},
9147
9540
  toolCallCount: source.toolCallCount,
9148
9541
  lastToolNames: source.lastToolNames,
9149
9542
  lastAssistantText: source.lastAssistantText,
@@ -9153,6 +9546,7 @@ function renderRunCard(snapshot, opts) {
9153
9546
  labels
9154
9547
  }) : formatStatusRunCard(name, snapshot.status, {
9155
9548
  runId: snapshot.runId,
9549
+ ...snapshot.title ? { title: snapshot.title } : {},
9156
9550
  toolCallCount: source.toolCallCount,
9157
9551
  lastToolNames: source.lastToolNames,
9158
9552
  lastAssistantText: source.lastAssistantText,
@@ -9173,7 +9567,10 @@ function recoverOrchestrationCard(event, toolName, opts) {
9173
9567
  try {
9174
9568
  const parsed = JSON.parse(trimmed);
9175
9569
  const agents = Array.isArray(parsed.agents) ? parsed.agents : [];
9176
- return formatAgentListCard(agents);
9570
+ const card = formatAgentListCard(agents);
9571
+ const lines = card.split("\n");
9572
+ lines[0] = t("agentsListLabel", String(agents.length));
9573
+ return lines.join("\n");
9177
9574
  } catch {
9178
9575
  return null;
9179
9576
  }
@@ -9197,9 +9594,11 @@ function recoverOrchestrationCard(event, toolName, opts) {
9197
9594
  if (kind === "start") {
9198
9595
  const name = safe ? cleanUserText(snapshot.agentName ?? "agent") : snapshot.agentName ?? "agent";
9199
9596
  const task = snapshot.taskPreview ? safe ? cleanUserText(snapshot.taskPreview) : snapshot.taskPreview : snapshot.taskPreview;
9597
+ const title = snapshot.title ? safe ? cleanUserText(snapshot.title) : snapshot.title : snapshot.title;
9200
9598
  return formatStartRunCard(name, snapshot.status, {
9201
9599
  task,
9202
9600
  runId: snapshot.runId,
9601
+ ...title ? { title } : {},
9203
9602
  labels
9204
9603
  });
9205
9604
  }
@@ -9297,8 +9696,8 @@ function commandFullGist(command, max) {
9297
9696
  if (!oneLine) return "";
9298
9697
  return truncateByDisplayWidth(redactSecrets(oneLine), max);
9299
9698
  }
9300
- function pathBasenameGist(path) {
9301
- const segments = path.split(/[\\/]/).filter((segment) => segment.length > 0);
9699
+ function pathBasenameGist(path2) {
9700
+ const segments = path2.split(/[\\/]/).filter((segment) => segment.length > 0);
9302
9701
  const base = segments.pop();
9303
9702
  return base ? gistClip(base) : "";
9304
9703
  }
@@ -9426,12 +9825,36 @@ function buildHighlightedEditLine(line, lang, brightness, env) {
9426
9825
  const highlightedBody = highlightCodeLine(body, lang, brightness);
9427
9826
  return `${coloredPrefix}${highlightedBody}`;
9428
9827
  }
9828
+ var MEMORY_TOOL_GIST_MAX = 64;
9829
+ function memoryToolGist(toolName, metadata) {
9830
+ const body = (value) => {
9831
+ if (typeof value !== "string" || !value) return "";
9832
+ return clipCompactText(redactSecrets(value), MEMORY_TOOL_GIST_MAX, "\u2026");
9833
+ };
9834
+ if (toolName === "rememberMemory") {
9835
+ const content = body(metadata.content);
9836
+ return content ? `+ ${content}` : "";
9837
+ }
9838
+ if (toolName === "queryMemory") {
9839
+ const query = body(metadata.query);
9840
+ return query ? `? ${query}` : "";
9841
+ }
9842
+ if (toolName === "deleteMemory") {
9843
+ const reason = body(metadata.reason);
9844
+ if (reason) return `- ${reason}`;
9845
+ const keyword = body(metadata.contentKeyword);
9846
+ if (keyword) return `- ${keyword}`;
9847
+ const idsCount = typeof metadata.idsCount === "number" ? metadata.idsCount : 0;
9848
+ if (idsCount > 0) return `- ${t("memoryDeleteRequestedCount", String(idsCount))}`;
9849
+ }
9850
+ return "";
9851
+ }
9429
9852
  function normalToolGistRaw(event) {
9430
9853
  const metadata = event.metadata ?? {};
9431
9854
  const toolName = event.toolName || "";
9432
9855
  if (toolName === "readFile") {
9433
- const path2 = typeof metadata.path === "string" ? metadata.path : typeof metadata.filePath === "string" ? metadata.filePath : "";
9434
- if (path2) return gistClip(formatReadItemPath(path2, metadata), 52);
9856
+ const path3 = typeof metadata.path === "string" ? metadata.path : typeof metadata.filePath === "string" ? metadata.filePath : "";
9857
+ if (path3) return gistClip(formatReadItemPath(path3, metadata), 52);
9435
9858
  }
9436
9859
  if (toolName === "fetchWebpage") {
9437
9860
  const url = typeof metadata.url === "string" ? metadata.url : "";
@@ -9439,8 +9862,8 @@ function normalToolGistRaw(event) {
9439
9862
  }
9440
9863
  if (toolName === "exa_search") {
9441
9864
  const query2 = typeof metadata.query === "string" ? metadata.query : typeof metadata.pattern === "string" ? metadata.pattern : "";
9442
- const path2 = typeof metadata.path === "string" ? metadata.path : void 0;
9443
- if (query2 || path2) return formatSearchItemQuery(query2, path2);
9865
+ const path3 = typeof metadata.path === "string" ? metadata.path : void 0;
9866
+ if (query2 || path3) return formatSearchItemQuery(query2, path3);
9444
9867
  }
9445
9868
  if (isRunToolName(toolName)) {
9446
9869
  const command2 = typeof metadata.command === "string" ? metadata.command : "";
@@ -9448,28 +9871,16 @@ function normalToolGistRaw(event) {
9448
9871
  return commandFullGist(command2, normalRunGistMaxWidth());
9449
9872
  }
9450
9873
  }
9451
- const path = typeof metadata.path === "string" ? metadata.path : "";
9452
- if (path) return pathBasenameGist(path);
9874
+ const memoryGist = memoryToolGist(toolName, metadata);
9875
+ if (memoryGist) return memoryGist;
9876
+ const path2 = typeof metadata.path === "string" ? metadata.path : "";
9877
+ if (path2) return pathBasenameGist(path2);
9453
9878
  const command = typeof metadata.command === "string" ? metadata.command : "";
9454
9879
  if (command) return commandFullGist(command, normalRunGistMaxWidth());
9455
9880
  const query = typeof metadata.query === "string" ? metadata.query : "";
9456
9881
  if (query) return clipCompactText(query, 64, "\u2026");
9457
- const remembered = event.toolName === "rememberMemory" && typeof metadata.content === "string" ? metadata.content : "";
9458
- if (remembered) return clipCompactText(redactSecrets(remembered), 64, "\u2026");
9459
9882
  return "";
9460
9883
  }
9461
- var NORMAL_GIST_SECRET_PATTERNS = [
9462
- /\bbearer\s+[A-Za-z0-9._~+/=-]{8,}/i,
9463
- /\bsk-(?:ant-)?(?:api)?[0-9a-zA-Z-]{10,}/,
9464
- /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{10,}/,
9465
- /\bxox[baprs]-[A-Za-z0-9-]{10,}/
9466
- ];
9467
- function withholdIfSecretLike(gist) {
9468
- if (!gist) return "";
9469
- if (findPotentialSecrets(gist).length > 0) return "";
9470
- if (NORMAL_GIST_SECRET_PATTERNS.some((pattern) => pattern.test(gist))) return "";
9471
- return gist;
9472
- }
9473
9884
  function normalToolGist(event) {
9474
9885
  return withholdIfSecretLike(normalToolGistRaw(event));
9475
9886
  }
@@ -9481,8 +9892,6 @@ function formatNormalToolDuration(elapsedMs) {
9481
9892
  function formatNormalToolLine(event, pending, colorEnabled) {
9482
9893
  if (event.type === "tool-call") return "";
9483
9894
  const toolName = event.toolName || pending?.toolName || "tool";
9484
- const todoBlock = formatTodoListForCli(event, colorEnabled);
9485
- if (todoBlock) return todoBlock;
9486
9895
  if (event.type === "tool-result" && (event.toolName === "ask_user" || event.metadata?.uiAskChoice)) {
9487
9896
  const block = formatUiAskChoiceBlock(event, colorEnabled);
9488
9897
  if (block) return block;
@@ -9493,6 +9902,9 @@ function formatNormalToolLine(event, pending, colorEnabled) {
9493
9902
  if (event.type === "tool-result" && toolName === "loadSkill") {
9494
9903
  return formatLoadSkillBlock(event, colorEnabled, { safe: true }) ?? "";
9495
9904
  }
9905
+ if (event.type === "tool-result" && toolName === "show_interaction") {
9906
+ return formatShowInteractionBlock(event, colorEnabled);
9907
+ }
9496
9908
  const label = toolLabel(toolName);
9497
9909
  if (readActionGate(event.metadata?.actionGate)) {
9498
9910
  return formatToolTraceLine(`\u25B8 ${label} ! ${t("toolNeedsAction")}`, colorEnabled, "error");
@@ -9545,39 +9957,6 @@ function resolveLoadSkillName(event) {
9545
9957
  if (match?.[1]) return match[1];
9546
9958
  return argName || "skill";
9547
9959
  }
9548
- function formatTodoListForCli(event, colorEnabled) {
9549
- if (event.type !== "tool-result" || event.toolName !== "setTodoList") {
9550
- return void 0;
9551
- }
9552
- let raw = event.metadata?.displayData;
9553
- let parsed = typeof raw === "object" && raw !== null;
9554
- if (typeof raw === "string") {
9555
- try {
9556
- raw = JSON.parse(raw);
9557
- parsed = true;
9558
- } catch {
9559
- raw = void 0;
9560
- }
9561
- }
9562
- if (!parsed && typeof event.content === "string") {
9563
- try {
9564
- raw = JSON.parse(event.content);
9565
- parsed = true;
9566
- } catch {
9567
- raw = void 0;
9568
- }
9569
- }
9570
- const todos = Array.isArray(raw?.todos) ? raw.todos : void 0;
9571
- if (!todos) return void 0;
9572
- if (todos.length === 0) return "\u2611 Todo\n (empty)\n";
9573
- const lines = todos.map((todo) => {
9574
- const status = todo?.status === "done" ? "\u2713" : todo?.status === "in_progress" ? "\u25D0" : "\u25CB";
9575
- const title = typeof todo?.title === "string" ? todo.title : "Untitled task";
9576
- return ` ${status} ${title}`;
9577
- });
9578
- const text = [`\u2611 Todo (${todos.length})`, ...lines].join("\n") + "\n";
9579
- return colorEnabled ? themeText(text, "chrome") : text;
9580
- }
9581
9960
  function formatLoadSkillBlock(event, colorEnabled, opts) {
9582
9961
  if (event.type !== "tool-result" || event.toolName !== "loadSkill") return null;
9583
9962
  const skillName = resolveLoadSkillName(event);
@@ -9834,6 +10213,7 @@ ${this.text}
9834
10213
  // packages/cli/client/agentRunOutput.ts
9835
10214
  var IDENTITY_LABEL_SEPARATOR = " > ";
9836
10215
  var THINKING_PREVIEW_BUFFER_LIMIT = 512;
10216
+ var TUI_PROGRESS_BUFFER_LIMIT = 1200;
9837
10217
  function appendThinkingPreview(current, chunk, limit = THINKING_PREVIEW_BUFFER_LIMIT) {
9838
10218
  if (limit <= 0) return "";
9839
10219
  const combined = current + chunk;
@@ -9895,6 +10275,14 @@ function formatToolJsonEvent(event) {
9895
10275
  })}
9896
10276
  `;
9897
10277
  }
10278
+ function shouldPromoteTuiNarration(text) {
10279
+ if (text.length >= TUI_PROGRESS_BUFFER_LIMIT) return true;
10280
+ return /(^|\n)\s*(?:#{1,3}\s|```|[-*+]\s|\d+[.)]\s)/.test(text);
10281
+ }
10282
+ function narrationActivityLabel(text) {
10283
+ const oneLine = stripAnsi2(text).replace(/[`*_#>]/g, "").replace(/\s+/g, " ").trim();
10284
+ return truncateThinkingHint(oneLine, 60);
10285
+ }
9898
10286
  function createCliTurnOutput(params) {
9899
10287
  const { options } = params;
9900
10288
  const workingLabel = params.workingLabel ?? `${options.agentName} -> working`;
@@ -9903,14 +10291,36 @@ function createCliTurnOutput(params) {
9903
10291
  tuiTrees: options.output.tuiTrees === true
9904
10292
  });
9905
10293
  const eventMode = resolveAgentEventMode(options);
9906
- const showThinking = options.showThinking !== false;
10294
+ const assistantLabelManaged = options.output.assistantLabelManaged === true;
10295
+ const showThinking = !assistantLabelManaged && options.showThinking !== false;
10296
+ const hidesRoutineTuiToolDetail = (event) => {
10297
+ if (!assistantLabelManaged || event.toolName !== "editFile") return false;
10298
+ if (event.type === "tool-error") return false;
10299
+ if (readActionGate(event.metadata?.actionGate)) return false;
10300
+ if (event.metadata?.timedOut || event.metadata?.failed || event.metadata?.error) return false;
10301
+ if (typeof event.metadata?.exitCode === "number" && event.metadata.exitCode !== 0) return false;
10302
+ return true;
10303
+ };
9907
10304
  let streamedAssistantText = false;
9908
10305
  let everStreamedAnyText = false;
9909
10306
  let printedAssistantLabel = false;
9910
10307
  let thinkState = createThinkParserState();
9911
10308
  let thinkingFirstAt = null;
9912
10309
  let thinkingPreview = "";
10310
+ let tuiThinkingReported = false;
10311
+ const clearTuiThinkingLabel = () => {
10312
+ if (!tuiThinkingReported) return;
10313
+ tuiThinkingReported = false;
10314
+ options.activityReporter?.(null);
10315
+ };
9913
10316
  const markThinkingDelta = (chunk) => {
10317
+ if (assistantLabelManaged) {
10318
+ if (!tuiThinkingReported && !streamedAssistantText) {
10319
+ tuiThinkingReported = true;
10320
+ options.activityReporter?.(t("thinkingActive"));
10321
+ }
10322
+ return;
10323
+ }
9914
10324
  if (!showThinking) return;
9915
10325
  if (streamedAssistantText) return;
9916
10326
  if (thinkingFirstAt === null) {
@@ -9928,6 +10338,7 @@ function createCliTurnOutput(params) {
9928
10338
  options.activityReporter?.(label);
9929
10339
  };
9930
10340
  const endThinkingPhase = () => {
10341
+ clearTuiThinkingLabel();
9931
10342
  if (thinkingFirstAt === null) return;
9932
10343
  const seconds = Math.max(0, Math.round((Date.now() - thinkingFirstAt) / 1e3));
9933
10344
  thinkingFirstAt = null;
@@ -9940,7 +10351,6 @@ function createCliTurnOutput(params) {
9940
10351
  }
9941
10352
  };
9942
10353
  let compactionEvent = null;
9943
- const assistantLabelManaged = options.output.assistantLabelManaged === true;
9944
10354
  const writeToolOutput = (chunk) => {
9945
10355
  if (!chunk) return;
9946
10356
  if (typeof options.output.writeToolBlock === "function") {
@@ -9952,9 +10362,25 @@ function createCliTurnOutput(params) {
9952
10362
  const renderWriter = createRenderAwareStreamWriter({
9953
10363
  write: (chunk) => options.output.write(chunk)
9954
10364
  });
10365
+ let pendingTuiNarration = "";
10366
+ let tuiNarrationPromoted = false;
10367
+ const flushPendingTuiNarration = () => {
10368
+ if (!pendingTuiNarration) return;
10369
+ formatToolEvent.reset?.();
10370
+ renderWriter.push(pendingTuiNarration);
10371
+ pendingTuiNarration = "";
10372
+ tuiNarrationPromoted = true;
10373
+ streamedAssistantText = true;
10374
+ options.activityReporter?.(null);
10375
+ };
10376
+ const dropPendingTuiProgress = () => {
10377
+ pendingTuiNarration = "";
10378
+ tuiNarrationPromoted = false;
10379
+ options.activityReporter?.(null);
10380
+ };
9955
10381
  const writeVisibleAssistantChunk = (chunk) => {
9956
10382
  if (!chunk) return;
9957
- formatToolEvent.reset?.();
10383
+ if (!assistantLabelManaged) formatToolEvent.reset?.();
9958
10384
  const parsed = processThinkChunk(chunk, thinkState);
9959
10385
  thinkState = parsed.state;
9960
10386
  if (!parsed.content && !parsed.reasoning) return;
@@ -9970,8 +10396,23 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
9970
10396
  }
9971
10397
  printedAssistantLabel = true;
9972
10398
  }
9973
- streamedAssistantText = true;
9974
10399
  everStreamedAnyText = true;
10400
+ if (assistantLabelManaged) {
10401
+ if (tuiNarrationPromoted) {
10402
+ renderWriter.push(parsed.content);
10403
+ streamedAssistantText = true;
10404
+ return;
10405
+ }
10406
+ pendingTuiNarration += parsed.content;
10407
+ if (shouldPromoteTuiNarration(pendingTuiNarration)) {
10408
+ flushPendingTuiNarration();
10409
+ } else {
10410
+ const label = narrationActivityLabel(pendingTuiNarration);
10411
+ if (label) options.activityReporter?.(label);
10412
+ }
10413
+ return;
10414
+ }
10415
+ streamedAssistantText = true;
9975
10416
  renderWriter.push(parsed.content);
9976
10417
  };
9977
10418
  const handleToolEvent = (event) => {
@@ -9987,13 +10428,19 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
9987
10428
  return;
9988
10429
  }
9989
10430
  if (event.type === "tool-call") {
10431
+ if (assistantLabelManaged && pendingTuiNarration) {
10432
+ dropPendingTuiProgress();
10433
+ }
9990
10434
  renderWriter.flush();
9991
- formatToolEvent(event);
10435
+ if (!hidesRoutineTuiToolDetail(event)) {
10436
+ formatToolEvent(event);
10437
+ }
9992
10438
  endThinkingPhase();
9993
10439
  if (streamedAssistantText) {
9994
10440
  options.output.write("\n");
9995
10441
  streamedAssistantText = false;
9996
10442
  }
10443
+ if (assistantLabelManaged) tuiNarrationPromoted = false;
9997
10444
  const activeLabel = formatConservativeActiveToolLabel(event);
9998
10445
  spinner.show(activeLabel);
9999
10446
  options.activityReporter?.(activeLabel);
@@ -10005,6 +10452,9 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
10005
10452
  }
10006
10453
  spinner.stop();
10007
10454
  options.activityReporter?.(null);
10455
+ if (hidesRoutineTuiToolDetail(event)) {
10456
+ return;
10457
+ }
10008
10458
  if (isLiveAgentRunObservation(event, parsedRunEvent)) {
10009
10459
  formatToolEvent.consume?.(event);
10010
10460
  return;
@@ -10017,6 +10467,26 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
10017
10467
  return {
10018
10468
  spinner,
10019
10469
  eventMode,
10470
+ /**
10471
+ * Terminal cleanup for abort/error paths that never reach `finish()`.
10472
+ *
10473
+ * A user abort discards the transient TUI progress buffer: the user stopped
10474
+ * on purpose and the dock already showed that text as activity. A genuine
10475
+ * failure must not swallow prose that never got the chance to be *proven*
10476
+ * durable (only a following tool call proves "progress"), so it promotes the
10477
+ * pending buffer and flushes what was already promoted — otherwise a short
10478
+ * final answer followed by a transport error disappears from the transcript.
10479
+ */
10480
+ cancel(cleanup) {
10481
+ if (assistantLabelManaged && cleanup?.preservePendingNarration) {
10482
+ flushPendingTuiNarration();
10483
+ if (streamedAssistantText) {
10484
+ renderWriter.flush();
10485
+ options.output.write("\n");
10486
+ }
10487
+ }
10488
+ dropPendingTuiProgress();
10489
+ },
10020
10490
  pushText(chunk) {
10021
10491
  writeVisibleAssistantChunk(chunk);
10022
10492
  },
@@ -10024,10 +10494,6 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
10024
10494
  markThinkingDelta(chunk);
10025
10495
  },
10026
10496
  handleToolEvent,
10027
- /** 记录一条 compaction 观测事件(TUI 在 turn 结束时渲染一行 dim 摘要)。
10028
- * 一轮内可能来多条(轮开始 + 每个 round),按显著性保留最高者:
10029
- * 失败 > 新生成摘要 > 投影复用 > 跳过,避免末尾的例行跳过事件
10030
- * 覆盖掉中途真正发生的压缩。 */
10031
10497
  recordCompaction(event) {
10032
10498
  const significance = (e) => e.failed ? 4 : e.summaryGenerated ? 3 : e.compressed ? 2 : 1;
10033
10499
  if (!compactionEvent || significance(event) >= significance(compactionEvent)) {
@@ -10039,12 +10505,28 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
10039
10505
  spinner.show(activeLabel);
10040
10506
  options.activityReporter?.(activeLabel);
10041
10507
  },
10508
+ /**
10509
+ * Pre-delta turn phase label (ctx-overflow-feedback batch 3).
10510
+ *
10511
+ * localLoop 在首个 provider delta 之前依次发出 turn-phase 事件
10512
+ * (validating-context → compacting → waiting-provider);此前 CLI 只有
10513
+ * llm-start 才进入明确 working 状态,压缩期间 spinner 停在通用
10514
+ * working 文案上,用户无法区分「卡在检查上下文 / 压缩 / 等模型」。
10515
+ * 两个显示面(bare CLI 的 spinner 与 TUI 的 dock activityReporter)与
10516
+ * showWorking 走同一条投影,保证两端文案不漂移。
10517
+ */
10518
+ showPhase(phase) {
10519
+ const label = phase === "validating-context" ? t("contextChecking") : phase === "compacting" ? t("contextCompacting") : t("waitingForModel");
10520
+ spinner.show(label);
10521
+ options.activityReporter?.(label);
10522
+ },
10042
10523
  finish(fallbackContent) {
10043
10524
  const flushedThink = flushThinkParser(thinkState);
10044
10525
  thinkState = flushedThink.state;
10045
10526
  if (flushedThink.content) {
10046
10527
  writeVisibleAssistantChunk(flushedThink.content);
10047
10528
  }
10529
+ if (assistantLabelManaged) flushPendingTuiNarration();
10048
10530
  endThinkingPhase();
10049
10531
  spinner.stop();
10050
10532
  options.activityReporter?.(null);
@@ -10119,6 +10601,12 @@ var describeClientVersionTooOldFailure = (message, rawError) => {
10119
10601
  };
10120
10602
 
10121
10603
  // packages/cli/client/agentRunStream.ts
10604
+ function isMalformedFunctionCallFailure(message) {
10605
+ return message.includes("MALFORMED_FUNCTION_CALL");
10606
+ }
10607
+ function shouldAppendStreamRawErrorDetail(env) {
10608
+ return env?.NOLO_DEBUG === "1" || env?.NOLO_CLI_DEBUG_DETAIL === "1";
10609
+ }
10122
10610
  async function readStreamingAgentRun(options, res, existingSpinner) {
10123
10611
  const reader = res.body?.getReader();
10124
10612
  if (!reader) {
@@ -10149,6 +10637,7 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
10149
10637
  let content = "";
10150
10638
  let dialogId;
10151
10639
  let usage;
10640
+ let sawDone = false;
10152
10641
  const handlePayload = (payload) => {
10153
10642
  if (typeof payload?.dialogId === "string" && payload.dialogId.trim()) {
10154
10643
  dialogId = payload.dialogId;
@@ -10161,6 +10650,7 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
10161
10650
  }
10162
10651
  if (payload?.type === "done") {
10163
10652
  usage = payload.usage;
10653
+ sawDone = true;
10164
10654
  return;
10165
10655
  }
10166
10656
  if (payload?.type === "dialog" || payload?.type === "status") {
@@ -10214,6 +10704,9 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
10214
10704
  }
10215
10705
  } catch (error) {
10216
10706
  turnOutput.spinner.stop();
10707
+ turnOutput.cancel({
10708
+ preservePendingNarration: !options.abortSignal?.aborted
10709
+ });
10217
10710
  if (options.abortSignal?.aborted) {
10218
10711
  return {
10219
10712
  exitCode: 0,
@@ -10222,15 +10715,18 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
10222
10715
  };
10223
10716
  }
10224
10717
  const message = toErrorMessage(error);
10718
+ const malformedToolCall = isMalformedFunctionCallFailure(message);
10719
+ const rawDetail = shouldAppendStreamRawErrorDetail(options.env) ? t("agentRunStream.rawErrorDetail", message) : null;
10225
10720
  if (dialogId) {
10226
- options.output.write(
10227
- `
10228
- [nolo] Agent stream transport interrupted after dialog ${dialogId} was created: ${message}
10229
- `
10230
- );
10231
- options.output.write(
10232
- "[nolo] The agent run may still finish on the server; read the dialog before retrying.\n"
10233
- );
10721
+ if (malformedToolCall) {
10722
+ options.output.write(`
10723
+ ${t("agentRunStream.malformedToolCallRejected", dialogId)}
10724
+ `);
10725
+ if (rawDetail) options.output.write(rawDetail);
10726
+ return { exitCode: 0, dialogId, streamInterrupted: true };
10727
+ }
10728
+ options.output.write(t("agentRunStream.interruptedAfterDialog", dialogId, message));
10729
+ options.output.write(t("agentRunStream.mayStillFinishOnServer"));
10234
10730
  return { exitCode: 0, dialogId, streamInterrupted: true };
10235
10731
  }
10236
10732
  if (isClientVersionTooOldFailure(message, error)) {
@@ -10238,11 +10734,25 @@ async function readStreamingAgentRun(options, res, existingSpinner) {
10238
10734
  ${describeClientVersionTooOldFailure(message, error)}`);
10239
10735
  return { exitCode: 1 };
10240
10736
  }
10241
- options.output.write(`
10242
- [nolo] Agent stream failed: ${message}
10737
+ if (malformedToolCall) {
10738
+ options.output.write(`
10739
+ ${t("agentRunStream.malformedToolCallRejectedNoDialog")}
10243
10740
  `);
10741
+ if (rawDetail) options.output.write(rawDetail);
10742
+ return { exitCode: 1 };
10743
+ }
10744
+ options.output.write(t("agentRunStream.failed", message));
10244
10745
  return { exitCode: 1 };
10245
10746
  }
10747
+ if (options.abortSignal?.aborted && !sawDone) {
10748
+ turnOutput.spinner.stop();
10749
+ turnOutput.cancel();
10750
+ return {
10751
+ exitCode: 0,
10752
+ ...dialogId ? { dialogId } : {},
10753
+ streamInterrupted: true
10754
+ };
10755
+ }
10246
10756
  turnOutput.finish(content);
10247
10757
  const usageText = formatUsage(usage, dialogId);
10248
10758
  if (usageText && shouldShowUsage(options.env))
@@ -10252,6 +10762,9 @@ ${describeClientVersionTooOldFailure(message, error)}`);
10252
10762
  return {
10253
10763
  exitCode: 0,
10254
10764
  ...dialogId ? { dialogId } : {},
10765
+ // 结论载体与 local / 非流式 HTTP 路径同契约:流式分支已经把 assistant
10766
+ // 正文累加在 content 里,不随行则 server 流式 run 的结算也拿不到结论。
10767
+ ...content ? { finalText: content } : {},
10255
10768
  turnTokens: buildTurnTokenUsage(usage, options.agentKey),
10256
10769
  ...turnCredits !== void 0 ? { turnCredits } : {}
10257
10770
  };
@@ -10459,7 +10972,7 @@ function findCollapsedPasteSpanAt(buffer, pos, opts = {}) {
10459
10972
  // packages/cli/client/agentRun.ts
10460
10973
  import { ulid as ulid2 } from "ulid";
10461
10974
  async function loadRunLocalAgentTurn() {
10462
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-E67CTV45.js");
10975
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-SQUDRZWE.js");
10463
10976
  return runLocalAgentTurn;
10464
10977
  }
10465
10978
  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();
@@ -10557,6 +11070,13 @@ function buildDefaultLocalRuntimeAdapter(options) {
10557
11070
  fetchImpl: options.fetchImpl,
10558
11071
  cwd: options.localRuntimeCwd,
10559
11072
  output: options.output,
11073
+ // TUI 显式注入的真实会话身份;缺省时 adapter 内仍回退 parentDialogId。
11074
+ ...options.originSession ? { originSession: options.originSession } : {},
11075
+ // 分享 OAuth agent 的 shell 会话授权(块 D):仅 owner-required 场景生效。
11076
+ ...options.shellGrant ? { shellGrant: options.shellGrant } : {},
11077
+ // 运行位置展示(块 D):TUI 消费 projectToolExecutionLocation 渲染工具实际
11078
+ // 执行设备/工作区;非 owner-required 场景 adapter 不回调。
11079
+ ...options.onToolExecutionLocation ? { onToolExecutionLocation: options.onToolExecutionLocation } : {},
10560
11080
  ...options.confirmDestructiveAction ? { confirmDestructiveAction: options.confirmDestructiveAction } : {},
10561
11081
  ...options.requestUserChoice ? { requestUserChoice: options.requestUserChoice } : {},
10562
11082
  ...options.pastedTextStore?.items.size ? { pastedTextStore: options.pastedTextStore } : {},
@@ -10594,7 +11114,7 @@ function wrapLoadAgentConfigWithModelOverride(adapter, targetAgentKey, override)
10594
11114
  }
10595
11115
  };
10596
11116
  }
10597
- var oauthChannelSkipReportedOutputs = /* @__PURE__ */ new WeakSet();
11117
+ var oauthChannelSkipReportedAgentKeys = /* @__PURE__ */ new Set();
10598
11118
  function resolveOAuthChannelOwnerSkip(agentConfig, options) {
10599
11119
  if (!agentConfig) return null;
10600
11120
  const apiKeyRef = typeof agentConfig.apiKeyRef === "string" ? agentConfig.apiKeyRef : void 0;
@@ -10606,8 +11126,12 @@ function resolveOAuthChannelOwnerSkip(agentConfig, options) {
10606
11126
  if (!ownerUserId) return null;
10607
11127
  const localUserId = resolveLocalUserId(options.env);
10608
11128
  if (ownerUserId === localUserId) return null;
10609
- return `[nolo] auto runtime: skipping local runtime because ${options.agentKey} runs on its owner's OAuth subscription channel (owner ${ownerUserId}, this machine runs as ${localUserId}). Use --local explicitly to force this machine's own subscription.
10610
- `;
11129
+ return t(
11130
+ "agentRun.oauthChannelOwnerSkip",
11131
+ options.agentKey,
11132
+ ownerUserId,
11133
+ localUserId
11134
+ ) + "\n";
10611
11135
  }
10612
11136
  async function shouldSkipAutoLocalForServerPlatformTools(options) {
10613
11137
  if (isBuiltinNoloAgentRef(options.agentKey)) return false;
@@ -10623,13 +11147,13 @@ async function shouldSkipAutoLocalForServerPlatformTools(options) {
10623
11147
  }
10624
11148
  const oauthChannelOwnerSkip = resolveOAuthChannelOwnerSkip(agentConfig, options);
10625
11149
  if (oauthChannelOwnerSkip) {
10626
- if (!options.output || typeof options.output !== "object" || !oauthChannelSkipReportedOutputs.has(options.output)) {
11150
+ if (!options.output || typeof options.output !== "object" || !oauthChannelSkipReportedAgentKeys.has(options.agentKey)) {
10627
11151
  if (options.output && typeof options.output === "object") {
10628
- oauthChannelSkipReportedOutputs.add(options.output);
11152
+ oauthChannelSkipReportedAgentKeys.add(options.agentKey);
10629
11153
  }
10630
11154
  options.output.write(oauthChannelOwnerSkip);
10631
11155
  }
10632
- return true;
11156
+ return false;
10633
11157
  }
10634
11158
  if (options.localRuntimeCwd) {
10635
11159
  return false;
@@ -10668,14 +11192,15 @@ async function shouldSkipAutoLocalForServerPlatformTools(options) {
10668
11192
  );
10669
11193
  return true;
10670
11194
  }
10671
- function buildUserInputContent(message, imageUrls = []) {
10672
- if (imageUrls.length === 0) return message;
11195
+ function buildUserInputContent(message, imageUrls = [], attachmentParts = []) {
11196
+ if (imageUrls.length === 0 && attachmentParts.length === 0) return message;
10673
11197
  return [
10674
11198
  ...message.trim() ? [{ type: "text", text: message }] : [],
10675
11199
  ...imageUrls.map((url) => ({
10676
11200
  type: "image_url",
10677
11201
  image_url: { url }
10678
- }))
11202
+ })),
11203
+ ...attachmentParts
10679
11204
  ];
10680
11205
  }
10681
11206
  function buildSubjectRefs(options) {
@@ -10720,8 +11245,8 @@ function isMissingLocalAgentConfigError(error, agentRef) {
10720
11245
  error && typeof error === "object" && "code" in error && error.code === LOCAL_AGENT_CONFIG_MISSING_CODE && error.agentRef === agentRef
10721
11246
  );
10722
11247
  }
10723
- var PROVIDER_HTTP_FAILED_RE = /(.+?) provider failed:\s*HTTP\s+(\d+)\b/i;
10724
- var PLATFORM_TRANSPORT_RE = /\bplatform provider failed\b/i;
11248
+ var PROVIDER_HTTP_FAILED_RE = /(.+?)(?:\s+provider|\s+proxy) failed:\s*HTTP\s+(\d+)\b/i;
11249
+ var PLATFORM_TRANSPORT_RE = /\b(?:platform provider failed|owner-required proxy failed)\b/i;
10725
11250
  var EXTRA_RATE_LIMIT_TEXT_RE = /\brate[\s_-]?limit(?:ed|ing|s)?\b|\bresource[_\s-]?exhausted\b|\bmax_concurrent_reached\b/i;
10726
11251
  function looksLikeRateLimitedText(message) {
10727
11252
  return EXTRA_RATE_LIMIT_TEXT_RE.test(message) || QUOTA_ERROR_PATTERNS.some((pattern) => pattern.test(message));
@@ -10779,13 +11304,26 @@ function classifyLocalRunError(message) {
10779
11304
  }
10780
11305
  return { kind: "generic" };
10781
11306
  }
10782
- var HISTORY_REPLAY_REJECTION_RE = /invalid_request_error|invalid\s+tool\s+call\s+arguments?/i;
11307
+ var HISTORY_REPLAY_REJECTION_RE = /invalid\s+tool\s+call\s+arguments?/i;
11308
+ var REASONING_REPLAY_CONTRACT_RE = /reasoning_content[^.]*must be passed back/i;
10783
11309
  var RUN_UNAVAILABLE_PREFIX = "[nolo] auto runtime: local run unavailable";
10784
11310
  var NO_FALLBACK = "Not falling back to server.";
10785
11311
  var SERVER_FALLBACK_HINT = "or use --server to run on the server explicitly.";
10786
11312
  function buildAuthFailure(ctx) {
10787
11313
  const platformNoToken = ctx.where === "server chat proxy" && isAuthNoTokenBody(ctx.message);
10788
- 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`;
11314
+ if (platformNoToken) {
11315
+ const guidance = `
11316
+ This turn did not run: you are not logged in to Nolo and no local model credential is available.
11317
+ \xB7 Use the Nolo platform: /login (or run \`nolo login\` after exiting the TUI)
11318
+ \xB7 Use your own subscription: nolo auth antigravity | claude | chatgpt | xai
11319
+ \xB7 No login at all: nolo run "<task>" (runs on local Codex)`;
11320
+ const detail = process.env.NOLO_DEBUG === "1" || process.env.NOLO_CLI_DEBUG_DETAIL === "1" ? `
11321
+ Detail: ${ctx.message}` : `
11322
+ Detail: platform returned AUTH_NO_TOKEN (no authentication token provided)`;
11323
+ return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}, no token was sent).${guidance}${detail} ${NO_FALLBACK} ${SERVER_FALLBACK_HINT}
11324
+ `;
11325
+ }
11326
+ const fix = ctx.where === "server chat proxy" ? `Check the agent's provider/api-key settings on nolo.chat` : `Fix the local credential/config and retry`;
10789
11327
  const { url: validationUrl, text: validationText } = extractGoogleValidationLink(ctx.message);
10790
11328
  const validationLabel = validationText || "Verify your account";
10791
11329
  if (validationUrl) {
@@ -10809,8 +11347,9 @@ function isAuthNoTokenBody(message) {
10809
11347
  return /"authCode"\s*:\s*"AUTH_NO_TOKEN"/i.test(message) || /no authentication token provided/i.test(message);
10810
11348
  }
10811
11349
  function buildRejectedPayloadFailure(ctx) {
10812
- const looksLikeHistoryReplay = HISTORY_REPLAY_REJECTION_RE.test(ctx.message);
10813
- 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.` : "";
11350
+ const looksLikeReasoningReplay = REASONING_REPLAY_CONTRACT_RE.test(ctx.message);
11351
+ const looksLikeHistoryReplay = !looksLikeReasoningReplay && HISTORY_REPLAY_REJECTION_RE.test(ctx.message);
11352
+ 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.` : "";
10814
11353
  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.
10815
11354
  `;
10816
11355
  }
@@ -10820,7 +11359,7 @@ function extractRateLimitResetHint(message) {
10820
11359
  return match ? match[0].trim() : void 0;
10821
11360
  }
10822
11361
  function buildRateLimitFailure(ctx) {
10823
- const cooldownNote = ctx.cooldownUntil ? ` \u5DF2\u6807\u8BB0\u51B7\u5374\u81F3 ${ctx.cooldownUntil}\uFF0C\u5230\u671F\u524D\u6D3E\u53D1\u4F1A\u88AB\u51B7\u5374\u95E8\u63A7\u62E6\u622A\uFF08\u5230\u671F\u81EA\u52A8 probe \u6062\u590D\uFF09\u3002` : "";
11362
+ const cooldownNote = ctx.cooldownUntil ? ` \u5DF2\u6682\u505C\u8BE5\u51ED\u8BC1\u7684\u6D3E\u53D1\uFF0C\u672C\u5730\u51B7\u5374\u6700\u665A ${ctx.cooldownUntil} \u5230\u671F\uFF08\u4E0D\u4EE3\u8868\u4E0A\u6E38\u989D\u5EA6\u5C4A\u65F6\u4E00\u5B9A\u6062\u590D\uFF09\uFF1B\u51B7\u5374\u671F\u95F4\u518D\u6B21\u6D3E\u53D1\u65F6\uFF0C\u7EA6\u6BCF ${Math.round(PROBE_INTERVAL_MS / 6e4)} \u5206\u949F\u653E\u884C\u4E00\u6B21\u8BD5\u63A2\u8BF7\u6C42\uFF0C\u6210\u529F\u5373\u6062\u590D\u3002\u82E5\u5DF2\u5145\u503C\u6216\u91CD\u7F6E\u989D\u5EA6\uFF0C\u53EF\u8FD0\u884C \`nolo auth cooldown\` \u67E5\u770B\u88AB\u6682\u505C\u7684\u51ED\u8BC1\u540D\uFF0C\u518D\u7528 \`nolo auth cooldown --clear <\u51ED\u8BC1\u540D>\` \u7ACB\u5373\u6062\u590D\u3002` : "";
10824
11363
  const headline = ctx.statusInferred ? `${ctx.where} hit an upstream rate-limit/quota error` : `${ctx.where} returned HTTP ${ctx.status}, rate limited`;
10825
11364
  const cause = ctx.quotaExhausted ? "The upstream quota/balance for this agent is exhausted \u2014 NOT a local credential/config issue" : "This agent is being throttled by the upstream provider \u2014 NOT a local credential/config issue";
10826
11365
  const reset = extractRateLimitResetHint(ctx.message);
@@ -10837,6 +11376,17 @@ function buildUpstreamFailure(ctx) {
10837
11376
  return `${RUN_UNAVAILABLE_PREFIX} (${ctx.where} returned HTTP ${ctx.status}). Detail: ${ctx.message} ${NO_FALLBACK} ${fix}, ${SERVER_FALLBACK_HINT}.
10838
11377
  `;
10839
11378
  }
11379
+ function formatLocalTurnFailureLine(error) {
11380
+ const message = toErrorMessage(error);
11381
+ if (error?.code === "LLM_REQUEST_TIMEOUT") {
11382
+ const msMatch = /after (\d+)ms/.exec(message);
11383
+ const deadline = msMatch && Number.isFinite(Number(msMatch[1])) ? formatElapsed(Math.round(Number(msMatch[1]) / 1e3)) : "the configured window";
11384
+ return `[nolo] ${t("llmRequestTimedOut", deadline)}
11385
+ `;
11386
+ }
11387
+ return `[nolo] Local agent run failed: ${message}
11388
+ `;
11389
+ }
10840
11390
  var FAILURE_BUILDERS = {
10841
11391
  auth: buildAuthFailure,
10842
11392
  "rejected-payload": buildRejectedPayloadFailure,
@@ -10894,6 +11444,10 @@ function describeLocalRunFailure(message, rawError) {
10894
11444
  }
10895
11445
  if (/CLI authority broker could not attach or take ownership/i.test(message)) {
10896
11446
  const cleaned = stripDebugNoise(message);
11447
+ if (/EADDRINUSE/i.test(message)) {
11448
+ return `${RUN_UNAVAILABLE_PREFIX} (${cleaned}). ${NO_FALLBACK} Use --server to run on the server explicitly.
11449
+ `;
11450
+ }
10897
11451
  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}.
10898
11452
  `;
10899
11453
  }
@@ -10909,6 +11463,10 @@ function describeLocalRunFailure(message, rawError) {
10909
11463
  }
10910
11464
  const cls = classifyLocalRunError(message);
10911
11465
  if (cls.kind === "generic") {
11466
+ if (/owner-required route not acknowledged/i.test(message)) {
11467
+ return `${RUN_UNAVAILABLE_PREFIX} (${message}). ${NO_FALLBACK} The server returned a successful response but did not acknowledge the owner route. Check server version or proxy configuration, ${SERVER_FALLBACK_HINT}.
11468
+ `;
11469
+ }
10912
11470
  if (isTransientFetchError(message)) {
10913
11471
  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.
10914
11472
  `;
@@ -11137,15 +11695,24 @@ ${options.agentName} > (no text response)
11137
11695
  const turnCredits = platformCreditsFromUsage(
11138
11696
  data?.usage
11139
11697
  );
11140
- return {
11698
+ const serverResult = {
11141
11699
  exitCode: 0,
11142
11700
  ...typeof data?.dialogId === "string" && data.dialogId ? { dialogId: data.dialogId } : {},
11701
+ // 结论载体与 local 路径同契约(server 模式 / 本地配置缺失时的兜底通道):
11702
+ // 结算点只认 result.finalText,HTTP 派发不给就等于这批 run 没有结论载体,
11703
+ // status 里既无 lastAssistantText 也无 resultFile。content 已在上面算好。
11704
+ ...content ? { finalText: content } : {},
11143
11705
  turnTokens: buildTurnTokenUsage(
11144
11706
  data?.usage,
11145
11707
  typeof data?.model === "string" ? data.model : options.agentKey
11146
11708
  ),
11147
11709
  ...turnCredits !== void 0 ? { turnCredits } : {}
11148
11710
  };
11711
+ recordRunResultHeaderMeta(serverResult, {
11712
+ model: typeof data?.model === "string" ? data.model : void 0,
11713
+ dialogServer: serverOriginForDialog(options.serverUrl)
11714
+ });
11715
+ return serverResult;
11149
11716
  }
11150
11717
  async function runInjectedLocalAgentTurn(options) {
11151
11718
  return runLocalAgentTurnForCli(options, { reportFailure: true });
@@ -11204,21 +11771,37 @@ async function runLocalAgentTurnForCli(options, settings) {
11204
11771
  });
11205
11772
  turnOutput.spinner.start();
11206
11773
  try {
11774
+ const localAttachmentPaths = (options.localAttachmentPaths ?? []).filter(
11775
+ (p) => typeof p === "string" && p.trim().length > 0
11776
+ );
11777
+ const { cardText: localAttachmentCard, parts: localAttachmentParts } = buildLocalAttachments({
11778
+ paths: localAttachmentPaths,
11779
+ machineId: localAttachmentPaths.length > 0 ? await resolveCurrentMachineId(options) : void 0,
11780
+ ...options.localRuntimeCwd ? { workspaceRoot: options.localRuntimeCwd } : {}
11781
+ });
11782
+ const messageForLocal = appendAttachmentCard(options.message, localAttachmentCard);
11783
+ const durableAttachmentParts = ENABLE_REMOTE_ATTACHMENT_PART_WRITES ? localAttachmentParts : [];
11784
+ const hasDurableAttachments = durableAttachmentParts.length > 0;
11207
11785
  const runLocalAgentTurn = await loadRunLocalAgentTurn();
11208
11786
  const result = await runLocalAgentTurn({
11209
11787
  adapter,
11210
11788
  agentRef: options.agentKey,
11211
11789
  userLanguage: options.userLanguage ?? options.env.NOLO_LANG ?? null,
11212
- input: buildUserInputContent(options.message, options.imageUrls),
11213
- ...expandedMessage !== options.message ? {
11214
- persistedInput: buildUserInputContent(
11790
+ input: buildUserInputContent(messageForLocal, options.imageUrls),
11791
+ ...expandedMessage !== options.message || localAttachmentCard !== "" ? {
11792
+ persistedInput: hasDurableAttachments ? buildUserInputContent(
11215
11793
  expandedMessage,
11794
+ options.imageUrls,
11795
+ durableAttachmentParts
11796
+ ) : buildUserInputContent(
11797
+ appendAttachmentCard(expandedMessage, localAttachmentCard),
11216
11798
  options.imageUrls
11217
11799
  ),
11218
- persistedInputReference: buildUserInputContent(
11800
+ persistedInputReference: hasDurableAttachments ? buildUserInputContent(
11219
11801
  options.message,
11220
- options.imageUrls
11221
- )
11802
+ options.imageUrls,
11803
+ durableAttachmentParts
11804
+ ) : buildUserInputContent(messageForLocal, options.imageUrls)
11222
11805
  } : {},
11223
11806
  ...options.pastedTextStore ? {
11224
11807
  contextReferenceResolver: (reference) => canResolveCollapsedPasteReference(options.pastedTextStore, reference)
@@ -11241,6 +11824,18 @@ async function runLocalAgentTurnForCli(options, settings) {
11241
11824
  if (event.kind === "llm-start") {
11242
11825
  turnOutput.showWorking();
11243
11826
  }
11827
+ if (event.kind === "turn-phase") {
11828
+ turnOutput.showPhase(event.phase);
11829
+ }
11830
+ if (event.kind === "compaction-start") {
11831
+ turnOutput.showPhase("compacting");
11832
+ }
11833
+ if (event.kind === "compaction-end" || // 压缩失败(timeout/provider-error)时 localLoop 按失败原子性语义
11834
+ // 带着裁剪后的历史继续本轮,切回等待模型文案;aborted 时 turn 随即
11835
+ // 结束,不再切文案(终态由 abort 路径收尾)。
11836
+ event.kind === "compaction-failed" && event.reason !== "aborted") {
11837
+ turnOutput.showPhase("waiting-provider");
11838
+ }
11244
11839
  if (event.kind === "image-downgraded") {
11245
11840
  options.output.write(
11246
11841
  "[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"
@@ -11270,9 +11865,10 @@ async function runLocalAgentTurnForCli(options, settings) {
11270
11865
  });
11271
11866
  turnOutput.finish(result.content);
11272
11867
  const turnCredits = sumPlatformCredits(result.usageRecords);
11273
- return {
11868
+ const turnResult = {
11274
11869
  exitCode: 0,
11275
11870
  dialogId: result.dialogId,
11871
+ ...typeof result.content === "string" && result.content.trim() ? { finalText: result.content } : {},
11276
11872
  title: result.title,
11277
11873
  ...result.titlePatchPromise ? { titlePatchPromise: result.titlePatchPromise } : {},
11278
11874
  ...pickEmptyAssistantFlags(result),
@@ -11284,8 +11880,22 @@ async function runLocalAgentTurnForCli(options, settings) {
11284
11880
  ...turnCredits !== void 0 ? { turnCredits } : {},
11285
11881
  ...result.usageRecords?.length ? { usageRecords: result.usageRecords } : {}
11286
11882
  };
11883
+ const serverMeta = resolveResultServerMeta({
11884
+ env: options.env ?? {},
11885
+ userId: resolveLocalUserId(options.env ?? {}),
11886
+ hasSubjectRefs: (buildSubjectRefs(options)?.length ?? 0) > 0
11887
+ });
11888
+ recordRunResultHeaderMeta(turnResult, {
11889
+ model: result.model,
11890
+ dialogServer: serverMeta.server,
11891
+ serverSync: serverMeta.serverSync
11892
+ });
11893
+ return turnResult;
11287
11894
  } catch (error) {
11288
11895
  turnOutput.spinner.stop();
11896
+ turnOutput.cancel({
11897
+ preservePendingNarration: error?.code !== LOCAL_TURN_ABORTED_CODE && !options.abortSignal?.aborted
11898
+ });
11289
11899
  const savedDialogId = error?.dialogId;
11290
11900
  const abortedUsageRecords = error?.usageRecords;
11291
11901
  const abortedTurnCredits = sumPlatformCredits(abortedUsageRecords);
@@ -11309,13 +11919,15 @@ async function runLocalAgentTurnForCli(options, settings) {
11309
11919
  error.cooldownUntil = cooldownUntil;
11310
11920
  }
11311
11921
  if (settings.reportFailure) {
11312
- options.output.write(
11313
- `[nolo] Local agent run failed: ${toErrorMessage(error)}
11314
- `
11315
- );
11922
+ const failureLine = formatLocalTurnFailureLine(error);
11923
+ if (typeof options.output.writeErr === "function") {
11924
+ options.output.writeErr(failureLine);
11925
+ } else {
11926
+ options.output.write(failureLine);
11927
+ }
11316
11928
  if (cooldownUntil) {
11317
11929
  options.output.write(
11318
- `[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
11930
+ `[nolo] \u5DF2\u6682\u505C\u8BE5\u51ED\u8BC1\u7684\u6D3E\u53D1\uFF0C\u672C\u5730\u51B7\u5374\u6700\u665A ${cooldownUntil} \u5230\u671F\uFF08\u4E0D\u4EE3\u8868\u4E0A\u6E38\u989D\u5EA6\u5C4A\u65F6\u4E00\u5B9A\u6062\u590D\uFF09\uFF1B\u51B7\u5374\u671F\u95F4\u518D\u6B21\u6D3E\u53D1\u65F6\uFF0C\u7EA6\u6BCF ${Math.round(PROBE_INTERVAL_MS / 6e4)} \u5206\u949F\u653E\u884C\u4E00\u6B21\u8BD5\u63A2\u8BF7\u6C42\uFF0C\u6210\u529F\u5373\u6062\u590D\u3002\u82E5\u5DF2\u5145\u503C\u6216\u91CD\u7F6E\u989D\u5EA6\uFF0C\u53EF\u8FD0\u884C \`nolo auth cooldown\` \u67E5\u770B\u88AB\u6682\u505C\u7684\u51ED\u8BC1\u540D\uFF0C\u518D\u7528 \`nolo auth cooldown --clear <\u51ED\u8BC1\u540D>\` \u7ACB\u5373\u6062\u590D\u3002
11319
11931
  `
11320
11932
  );
11321
11933
  }
@@ -11375,7 +11987,7 @@ Dispatch aborted before reaching the server. Pick another agent via listAgents,
11375
11987
  return { exitCode: 1 };
11376
11988
  }
11377
11989
  function foldLocalResultForTui(localResult) {
11378
- return {
11990
+ const folded = {
11379
11991
  exitCode: localResult.exitCode,
11380
11992
  ...localResult.dialogId ? { dialogId: localResult.dialogId } : {},
11381
11993
  title: localResult.title,
@@ -11392,8 +12004,17 @@ function foldLocalResultForTui(localResult) {
11392
12004
  // 漏过 turnCredits(fix/tui-session-credits),usageRecords 是同坑位新字段。
11393
12005
  ...localResult.usageRecords?.length ? { usageRecords: localResult.usageRecords } : {},
11394
12006
  ...localResult.streamInterrupted ? { streamInterrupted: localResult.streamInterrupted } : {},
11395
- ...localResult.pendingToolName ? { pendingToolName: localResult.pendingToolName } : {}
12007
+ ...localResult.pendingToolName ? { pendingToolName: localResult.pendingToolName } : {},
12008
+ // 结论正文必须随行:auto→local 是本函数的唯一出口(runAgentTurn 的两处
12009
+ // 成功分支都 return foldLocalResultForTui(...)),漏掉它 = 默认派发路径
12010
+ // 上 finalText 永远到不了结算点 → agentRunCommand 的 settleRunTerminal-
12011
+ // Authoritatively 拿不到 lastAssistantText → `.result.md` 不写、status 无
12012
+ // resultFile,编排者只能去啃带 ANSI 的 .log(同坑位历史:turnCredits)。
12013
+ ...localResult.finalText ? { finalText: localResult.finalText } : {}
11396
12014
  };
12015
+ const headerMeta = getRunResultHeaderMeta(localResult);
12016
+ recordRunResultHeaderMeta(folded, headerMeta);
12017
+ return folded;
11397
12018
  }
11398
12019
  async function runAgentTurn(options) {
11399
12020
  const authToken = resolveAuthToken2(options.env);
@@ -11463,23 +12084,204 @@ async function runAgentTurn(options) {
11463
12084
  return httpResult;
11464
12085
  }
11465
12086
 
12087
+ // packages/cli/client/terminalProgramStatus.ts
12088
+ var TERMINAL_PROGRAM_STATUS_APP = "nolo";
12089
+ var KNOWN_STATES = /* @__PURE__ */ new Set([
12090
+ "idle",
12091
+ "working",
12092
+ "blocked",
12093
+ "done",
12094
+ "error"
12095
+ ]);
12096
+ var KNOWN_KINDS = /* @__PURE__ */ new Set([
12097
+ "permission",
12098
+ "question",
12099
+ "auth"
12100
+ ]);
12101
+ function encodeTerminalProgramStatus(report) {
12102
+ const state2 = report?.state;
12103
+ if (typeof state2 !== "string" || !KNOWN_STATES.has(state2)) return null;
12104
+ const pairs = [`state=${state2}`, `app=${TERMINAL_PROGRAM_STATUS_APP}`];
12105
+ if (state2 === "blocked" && typeof report.kind === "string" && KNOWN_KINDS.has(report.kind)) {
12106
+ pairs.push(`kind=${report.kind}`);
12107
+ }
12108
+ return `\x1B]7501;${pairs.join(":")}\x1B\\`;
12109
+ }
12110
+ function emitTerminalProgramStatus(output, report) {
12111
+ if (!output || typeof output.write !== "function") return false;
12112
+ if (output.isTTY !== true) return false;
12113
+ const sequence2 = encodeTerminalProgramStatus(report);
12114
+ if (sequence2 === null) return false;
12115
+ try {
12116
+ output.write(sequence2);
12117
+ return true;
12118
+ } catch {
12119
+ return false;
12120
+ }
12121
+ }
12122
+
12123
+ // packages/cli/client/terminalRunStatus.ts
12124
+ var FAILED_EMPTY_ASSISTANT_REASONS = /* @__PURE__ */ new Set([
12125
+ "length_truncated",
12126
+ "stream_truncated",
12127
+ "repetition_loop",
12128
+ "stagnant_tool_calls"
12129
+ ]);
12130
+ var isRunResultStalledOrTruncated = (result) => !result.emptyAssistantOutputUsable && FAILED_EMPTY_ASSISTANT_REASONS.has(result.emptyAssistantFallbackReason ?? "");
12131
+ function resolveTerminalProgramStatusState(input) {
12132
+ if (input.interrupted) return "idle";
12133
+ if (input.stalledOrTruncated || input.exitCode !== 0) return "error";
12134
+ return "done";
12135
+ }
12136
+
12137
+ // packages/cli/client/oneShotTerminalStatus.ts
12138
+ function resolveOneShotTerminalState(result) {
12139
+ return resolveTerminalProgramStatusState({
12140
+ exitCode: result.exitCode,
12141
+ interrupted: result.streamInterrupted,
12142
+ stalledOrTruncated: result.stalledOrTruncated
12143
+ });
12144
+ }
12145
+ function createOneShotTerminalStatus(output) {
12146
+ let last;
12147
+ let terminal = false;
12148
+ const report = (state2) => {
12149
+ if (!output || terminal || last === state2) return;
12150
+ last = state2;
12151
+ if (state2 === "done" || state2 === "error") terminal = true;
12152
+ emitTerminalProgramStatus(output, { state: state2 });
12153
+ };
12154
+ return {
12155
+ working: () => report("working"),
12156
+ settle: (result) => report(resolveOneShotTerminalState(result)),
12157
+ fail: () => report("error")
12158
+ };
12159
+ }
12160
+
11466
12161
  // packages/cli/agentRunCommand.ts
11467
12162
  import * as nodeFs from "node:fs";
11468
12163
 
11469
12164
  // packages/cli/client/autoModelRouter.ts
11470
12165
  var CLI_AUTO_ROUTE_AGENT_KEY = BUILTIN_NOLO_AGENT_KEY;
11471
12166
 
11472
- // packages/agent-runtime/agentsMd.ts
12167
+ // packages/agent-runtime/hostEnvironment.ts
11473
12168
  import { existsSync, readFileSync } from "node:fs";
12169
+ import os from "node:os";
12170
+ function parseLinuxOsRelease(content) {
12171
+ let prettyName;
12172
+ let name;
12173
+ let version;
12174
+ for (const line of content.split("\n")) {
12175
+ const trimmed = line.trim();
12176
+ if (!trimmed || trimmed.startsWith("#")) continue;
12177
+ const eqIdx = trimmed.indexOf("=");
12178
+ if (eqIdx === -1) continue;
12179
+ const key = trimmed.slice(0, eqIdx).trim();
12180
+ let val = trimmed.slice(eqIdx + 1).trim();
12181
+ if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
12182
+ val = val.slice(1, -1);
12183
+ }
12184
+ if (key === "PRETTY_NAME") {
12185
+ prettyName = val;
12186
+ } else if (key === "NAME") {
12187
+ name = val;
12188
+ } else if (key === "VERSION") {
12189
+ version = val;
12190
+ }
12191
+ }
12192
+ if (prettyName) return prettyName;
12193
+ if (name && version) return `${name} ${version}`;
12194
+ return name;
12195
+ }
12196
+ function probeHostEnvironment(options) {
12197
+ const platform = options?.platform ?? process.platform;
12198
+ const arch = options?.arch ?? os.arch();
12199
+ const release = options?.release ?? os.release();
12200
+ const env = options?.env ?? process.env;
12201
+ let osName = `${platform} ${release}`;
12202
+ if (platform === "linux") {
12203
+ let osReleaseText = options?.osReleaseContent;
12204
+ if (osReleaseText === void 0) {
12205
+ try {
12206
+ if (existsSync("/etc/os-release")) {
12207
+ osReleaseText = readFileSync("/etc/os-release", "utf8");
12208
+ } else if (existsSync("/usr/lib/os-release")) {
12209
+ osReleaseText = readFileSync("/usr/lib/os-release", "utf8");
12210
+ }
12211
+ } catch {
12212
+ }
12213
+ }
12214
+ if (osReleaseText) {
12215
+ const parsed = parseLinuxOsRelease(osReleaseText);
12216
+ if (parsed) {
12217
+ osName = parsed;
12218
+ } else {
12219
+ osName = `Linux ${release}`;
12220
+ }
12221
+ } else {
12222
+ osName = `Linux ${release}`;
12223
+ }
12224
+ } else if (platform === "darwin") {
12225
+ osName = `macOS (${release})`;
12226
+ } else if (platform === "win32") {
12227
+ osName = `Windows (${release})`;
12228
+ }
12229
+ const desktop = env.XDG_CURRENT_DESKTOP || env.XDG_SESSION_DESKTOP || env.DESKTOP_SESSION || void 0;
12230
+ const sessionType = env.XDG_SESSION_TYPE || void 0;
12231
+ const shell = env.SHELL || (platform === "win32" ? env.COMSPEC || "PowerShell" : void 0);
12232
+ return {
12233
+ platform,
12234
+ osName,
12235
+ arch,
12236
+ desktop,
12237
+ sessionType,
12238
+ shell
12239
+ };
12240
+ }
12241
+ function formatHostEnvironmentContent(details) {
12242
+ const lines = ["--- \u5BBF\u4E3B\u73AF\u5883\uFF08Host Environment\uFF09---"];
12243
+ lines.push(`\u64CD\u4F5C\u7CFB\u7EDF: ${details.osName} (${details.arch})`);
12244
+ if (details.desktop || details.sessionType) {
12245
+ const desktopParts = [];
12246
+ if (details.desktop) desktopParts.push(details.desktop);
12247
+ if (details.sessionType) desktopParts.push(details.sessionType);
12248
+ lines.push(`\u684C\u9762\u73AF\u5883: ${desktopParts.join(" / ")}`);
12249
+ }
12250
+ if (details.shell) {
12251
+ lines.push(`\u9ED8\u8BA4 Shell: ${details.shell}`);
12252
+ }
12253
+ return lines.join("\n");
12254
+ }
12255
+ var cachedLayer = null;
12256
+ function buildHostEnvironmentLayer(options) {
12257
+ if (!options && cachedLayer) {
12258
+ return cachedLayer;
12259
+ }
12260
+ const details = probeHostEnvironment(options);
12261
+ const content = formatHostEnvironmentContent(details);
12262
+ const layer = {
12263
+ id: "host-environment",
12264
+ owner: "runtime",
12265
+ cacheScope: "session",
12266
+ content
12267
+ };
12268
+ if (!options) {
12269
+ cachedLayer = layer;
12270
+ }
12271
+ return layer;
12272
+ }
12273
+
12274
+ // packages/agent-runtime/agentsMd.ts
12275
+ import { existsSync as existsSync2, readFileSync as readFileSync2 } from "node:fs";
11474
12276
  import { join } from "node:path";
11475
12277
  var AGENTS_MD_MAX_BYTES = 8192;
11476
12278
  var AGENTS_MD_CANDIDATES = ["AGENTS.md", "CLAUDE.md"];
11477
12279
  function readAgentsMdLayerFromDisk(cwd) {
11478
12280
  for (const name of AGENTS_MD_CANDIDATES) {
11479
12281
  const filePath = join(cwd, name);
11480
- if (!existsSync(filePath)) continue;
12282
+ if (!existsSync2(filePath)) continue;
11481
12283
  try {
11482
- let content = readFileSync(filePath, "utf8").trim();
12284
+ let content = readFileSync2(filePath, "utf8").trim();
11483
12285
  if (!content) continue;
11484
12286
  if (Buffer.byteLength(content, "utf8") > AGENTS_MD_MAX_BYTES) {
11485
12287
  content = Buffer.from(content, "utf8").subarray(0, AGENTS_MD_MAX_BYTES).toString("utf8") + "\n\n<!-- AGENTS.md truncated -->";
@@ -11549,14 +12351,14 @@ function runDoDCommands(commands, cwd, deps = {}) {
11549
12351
  }
11550
12352
 
11551
12353
  // packages/cli/agentRunPrompts.ts
11552
- import { existsSync as existsSync2, readFileSync as readFileSync2, readdirSync, statSync } from "node:fs";
12354
+ import { existsSync as existsSync3, readFileSync as readFileSync3, readdirSync, statSync as statSync2 } from "node:fs";
11553
12355
  import { dirname, extname, isAbsolute, join as join2, relative as relativePath, resolve, sep } from "node:path";
11554
12356
  function workflowRefToCandidatePath(cwd, ref) {
11555
12357
  const normalized = ref.trim();
11556
12358
  if (!normalized) return "";
11557
12359
  if (normalized.endsWith(".md") || normalized.includes("/") || normalized.includes("\\")) {
11558
12360
  const directPath = resolve(cwd, normalized);
11559
- if (existsSync2(directPath)) return directPath;
12361
+ if (existsSync3(directPath)) return directPath;
11560
12362
  }
11561
12363
  const fileName = normalized.replace(/[^a-zA-Z0-9一-鿿]+/g, "-").replace(/^-+|-+$/g, "");
11562
12364
  return resolve(cwd, "docs", "workflows", `${fileName}.md`);
@@ -11569,21 +12371,21 @@ function skillRefToCandidatePath(cwd, ref) {
11569
12371
  if (!normalized) return "";
11570
12372
  if (normalized.endsWith(".md") || normalized.includes("/") || normalized.includes("\\")) {
11571
12373
  const directPath = resolve(cwd, normalized);
11572
- if (existsSync2(directPath)) return directPath;
12374
+ if (existsSync3(directPath)) return directPath;
11573
12375
  }
11574
12376
  const fileName = normalized.replace(/[^a-zA-Z0-9一-鿿]+/g, "-").replace(/^-+|-+$/g, "");
11575
12377
  for (const dir of SKILL_SEARCH_DIRS) {
11576
12378
  const skillMdPath = resolve(cwd, dir, fileName, "SKILL.md");
11577
- if (existsSync2(skillMdPath)) return skillMdPath;
12379
+ if (existsSync3(skillMdPath)) return skillMdPath;
11578
12380
  }
11579
12381
  return resolve(cwd, ".agents", "skills", fileName, "SKILL.md");
11580
12382
  }
11581
12383
  async function resolveWorkflowReference(ref, cwd = process.cwd()) {
11582
- const path = workflowRefToCandidatePath(cwd, ref);
11583
- if (!path || !existsSync2(path)) {
12384
+ const path2 = workflowRefToCandidatePath(cwd, ref);
12385
+ if (!path2 || !existsSync3(path2)) {
11584
12386
  throw new Error(`Workflow reference not found: ${ref}`);
11585
12387
  }
11586
- const markdown = readFileSync2(path, "utf8");
12388
+ const markdown = readFileSync3(path2, "utf8");
11587
12389
  const parsed = parseSkillDocProtocol(markdown);
11588
12390
  return {
11589
12391
  ref,
@@ -11600,8 +12402,8 @@ function inlineRelativeRefs(body, skillDir) {
11600
12402
  const absPath = resolve(skillDir, cleaned);
11601
12403
  const relative = relativePath(normalizedSkillDir, absPath);
11602
12404
  if (relative.startsWith("..") || isAbsolute(relative)) return match;
11603
- if (!existsSync2(absPath) || !absPath.endsWith(".md")) return match;
11604
- const refContent = readFileSync2(absPath, "utf8");
12405
+ if (!existsSync3(absPath) || !absPath.endsWith(".md")) return match;
12406
+ const refContent = readFileSync3(absPath, "utf8");
11605
12407
  return `
11606
12408
 
11607
12409
  ### ${label}
@@ -11613,7 +12415,7 @@ ${refContent}
11613
12415
  }
11614
12416
  function listSkillScripts(skillDir) {
11615
12417
  const scriptsDir = join2(skillDir, "scripts");
11616
- if (!existsSync2(scriptsDir) || !statSync(scriptsDir).isDirectory()) return null;
12418
+ if (!existsSync3(scriptsDir) || !statSync2(scriptsDir).isDirectory()) return null;
11617
12419
  const entries = readdirSync(scriptsDir).filter((e) => !e.startsWith("."));
11618
12420
  if (entries.length === 0) return null;
11619
12421
  return [
@@ -11639,13 +12441,13 @@ async function resolveSkillReference(ref, options = {}) {
11639
12441
  markdown = String(contentText);
11640
12442
  } else {
11641
12443
  const cwd = options.cwd ?? process.cwd();
11642
- const path = skillRefToCandidatePath(cwd, ref);
11643
- if (!path || !existsSync2(path)) {
12444
+ const path2 = skillRefToCandidatePath(cwd, ref);
12445
+ if (!path2 || !existsSync3(path2)) {
11644
12446
  throw new Error(`Skill reference not found: ${ref}`);
11645
12447
  }
11646
- markdown = readFileSync2(path, "utf8");
11647
- filePath = path;
11648
- skillDir = dirname(path);
12448
+ markdown = readFileSync3(path2, "utf8");
12449
+ filePath = path2;
12450
+ skillDir = dirname(path2);
11649
12451
  }
11650
12452
  const parsed = parseSkillDocProtocol(markdown);
11651
12453
  const name = parsed.meta?.skillConfig?.name;
@@ -11748,12 +12550,12 @@ function prependSubjectDialogMarker(message, subjectDialogKey) {
11748
12550
  function normalizeCliImageInput(input) {
11749
12551
  if (/^(https?:|data:|file:)/i.test(input)) return input;
11750
12552
  const absolutePath = resolve(input);
11751
- if (!existsSync2(absolutePath)) return input;
11752
- const base64 = readFileSync2(absolutePath).toString("base64");
12553
+ if (!existsSync3(absolutePath)) return input;
12554
+ const base64 = readFileSync3(absolutePath).toString("base64");
11753
12555
  return `data:${imageMimeTypeForPath(absolutePath)};base64,${base64}`;
11754
12556
  }
11755
- function imageMimeTypeForPath(path) {
11756
- switch (extname(path).toLowerCase()) {
12557
+ function imageMimeTypeForPath(path2) {
12558
+ switch (extname(path2).toLowerCase()) {
11757
12559
  case ".jpg":
11758
12560
  case ".jpeg":
11759
12561
  return "image/jpeg";
@@ -12175,8 +12977,8 @@ var scoreMemoryItem = (item, query, nowMs = Date.now(), context) => {
12175
12977
  const confidence = item.confidence ?? 0;
12176
12978
  const typeFit = typeFitScore(item);
12177
12979
  const understanding = understandingScore(item);
12178
- const path = pathScore(item, context);
12179
- return 0.25 * queryMatch + 0.2 * identifierMatch + 0.2 * path + 0.09 * retrieval + // weak retrieval signal, NOT successful-use reinforcement
12980
+ const path2 = pathScore(item, context);
12981
+ return 0.25 * queryMatch + 0.2 * identifierMatch + 0.2 * path2 + 0.09 * retrieval + // weak retrieval signal, NOT successful-use reinforcement
12180
12982
  0.16 * createdRecency + 0.06 * importance + 0.03 * confidence + 0.02 * typeFit + 0.01 * understanding;
12181
12983
  };
12182
12984
  var rankMemoryCandidates = (items, query, context) => {
@@ -12192,70 +12994,52 @@ var rankMemoryCandidates = (items, query, context) => {
12192
12994
  });
12193
12995
  };
12194
12996
 
12195
- // packages/ai/memory/vnext/store.ts
12196
- var enc = (value) => encodeURIComponent(value).replace(/-/g, "%2D");
12197
- var rangeOf = (prefix) => ({ gte: prefix, lte: `${prefix}\uFFFF` });
12198
- var entityKey = (ownerId, id) => `mem2-e-${enc(ownerId)}-${enc(id)}`;
12199
- var entityOwnerPrefix = (ownerId) => `mem2-e-${enc(ownerId)}-`;
12200
- var stateKey = (ownerId, id) => `mem2-s-${enc(ownerId)}-${enc(id)}`;
12201
- var stateEntityIndexKey = (ownerId, entityId, stateId) => `mem2-si-${enc(ownerId)}-${enc(entityId)}-${enc(stateId)}`;
12202
- var stateEntityIndexPrefix = (ownerId, entityId) => `mem2-si-${enc(ownerId)}-${enc(entityId)}-`;
12203
- var evidenceKey = (ownerId, id) => `mem2-v-${enc(ownerId)}-${enc(id)}`;
12204
- var relationKey = (ownerId, id) => `mem2-r-${enc(ownerId)}-${enc(id)}`;
12205
- var relationFromIndexKey = (ownerId, from, relationId) => `mem2-rf-${enc(ownerId)}-${enc(from)}-${enc(relationId)}`;
12206
- var relationToIndexKey = (ownerId, to, relationId) => `mem2-rt-${enc(ownerId)}-${enc(to)}-${enc(relationId)}`;
12207
- var readIndexed = async (db, prefix) => {
12208
- const refs = [];
12209
- for await (const [, value] of db.iterator({ ...rangeOf(prefix), reverse: false })) {
12210
- if (typeof value?.key === "string") refs.push(value.key);
12211
- }
12212
- const rows = await Promise.all(refs.map((key) => db.get(key).catch(() => null)));
12213
- return rows.filter((row) => !!row);
12214
- };
12215
- var getMemoryEntityVNext = async (db, ownerId, entityId) => db.get(entityKey(ownerId, entityId)).catch(() => null);
12216
- var listMemoryEntitiesVNext = async (db, ownerId) => {
12217
- const rows = [];
12218
- for await (const [, value] of db.iterator({
12219
- ...rangeOf(entityOwnerPrefix(ownerId)),
12220
- reverse: false
12221
- })) {
12222
- if (value) rows.push(value);
12223
- }
12224
- return rows;
12225
- };
12226
- var getMemoryStateVNext = async (db, ownerId, stateId) => db.get(stateKey(ownerId, stateId)).catch(() => null);
12227
- var listMemoryStatesForEntityVNext = (db, ownerId, entityId) => readIndexed(db, stateEntityIndexPrefix(ownerId, entityId));
12228
- var putMemoryEvidenceVNext = async (db, evidence) => {
12229
- await db.put(evidenceKey(evidence.ownerId, evidence.id), evidence);
12997
+ // packages/ai/memory/vnext/detachedThrottle.ts
12998
+ var DEFAULT_DETACHED_MEMORY_COOLDOWN_MS = 10 * 60 * 1e3;
12999
+ var MAX_COOLDOWN_KEYS = 512;
13000
+ var readMsEnv = (raw, fallback, allowZero) => {
13001
+ if (raw === void 0 || raw.trim() === "") return fallback;
13002
+ const parsed = Number(raw);
13003
+ if (!Number.isFinite(parsed) || parsed < 0) return fallback;
13004
+ if (parsed === 0 && !allowZero) return fallback;
13005
+ return parsed;
12230
13006
  };
12231
- var getMemoryEvidenceVNext = async (db, ownerId, evidenceId) => db.get(evidenceKey(ownerId, evidenceId)).catch(() => null);
12232
- var getMemoryEvidenceVNextStrict = async (db, ownerId, evidenceId) => {
12233
- try {
12234
- return await db.get(evidenceKey(ownerId, evidenceId));
12235
- } catch (error) {
12236
- if (isLevelNotFoundError(error)) return null;
12237
- throw error;
12238
- }
12239
- };
12240
- var _appendEntityBatch = (batch, entity) => {
12241
- batch.put(entityKey(entity.ownerId, entity.id), entity);
12242
- };
12243
- var _appendEvidenceBatch = (batch, evidence) => {
12244
- batch.put(evidenceKey(evidence.ownerId, evidence.id), evidence);
12245
- };
12246
- var _appendStateBatch = (batch, state2) => {
12247
- const key = stateKey(state2.ownerId, state2.id);
12248
- batch.put(key, state2);
12249
- batch.put(stateEntityIndexKey(state2.ownerId, state2.entityId, state2.id), { key });
12250
- };
12251
- var _appendRetiredStateBatch = (batch, state2) => {
12252
- batch.put(stateKey(state2.ownerId, state2.id), state2);
12253
- };
12254
- var _appendRelationBatch = (batch, relation) => {
12255
- const key = relationKey(relation.ownerId, relation.id);
12256
- batch.put(key, relation);
12257
- batch.put(relationFromIndexKey(relation.ownerId, relation.from, relation.id), { key });
12258
- batch.put(relationToIndexKey(relation.ownerId, relation.to, relation.id), { key });
13007
+ var createDetachedThrottle = (input) => {
13008
+ let inFlight2 = false;
13009
+ const lastStartedAt = /* @__PURE__ */ new Map();
13010
+ const resolveCooldownMs = (env = typeof process !== "undefined" ? process.env : {}) => readMsEnv(env[input.cooldownEnvKey], input.defaultCooldownMs, true);
13011
+ const rememberStart = (key, clockMs) => {
13012
+ lastStartedAt.delete(key);
13013
+ lastStartedAt.set(key, clockMs);
13014
+ while (lastStartedAt.size > MAX_COOLDOWN_KEYS) {
13015
+ lastStartedAt.delete(lastStartedAt.keys().next().value);
13016
+ }
13017
+ };
13018
+ return {
13019
+ name: input.name,
13020
+ defaultCooldownMs: input.defaultCooldownMs,
13021
+ cooldownEnvKey: input.cooldownEnvKey,
13022
+ resolveCooldownMs,
13023
+ tryAcquire(key, clockMs, cooldownMs) {
13024
+ if (inFlight2) return "busy";
13025
+ const interval = cooldownMs ?? resolveCooldownMs();
13026
+ const lastStarted = lastStartedAt.get(key);
13027
+ if (interval > 0 && lastStarted !== void 0 && clockMs - lastStarted < interval) {
13028
+ return "cooldown";
13029
+ }
13030
+ inFlight2 = true;
13031
+ rememberStart(key, clockMs);
13032
+ return "run";
13033
+ },
13034
+ release() {
13035
+ inFlight2 = false;
13036
+ },
13037
+ isInFlight: () => inFlight2,
13038
+ reset() {
13039
+ inFlight2 = false;
13040
+ lastStartedAt.clear();
13041
+ }
13042
+ };
12259
13043
  };
12260
13044
 
12261
13045
  // packages/ai/memory/vnext/recall.ts
@@ -12287,14 +13071,6 @@ var parseSelection = (raw) => {
12287
13071
  reason: obj.reason
12288
13072
  };
12289
13073
  };
12290
- var buildCatalog = async (db, ownerId) => {
12291
- const entities = await listMemoryEntitiesVNext(db, ownerId);
12292
- const states = [];
12293
- for (const entity of entities) {
12294
- states.push(...await listMemoryStatesForEntityVNext(db, ownerId, entity.id));
12295
- }
12296
- return { entities, states };
12297
- };
12298
13074
  var catalogText = (entities, states) => JSON.stringify(
12299
13075
  {
12300
13076
  entities: entities.map((entity) => ({
@@ -12320,7 +13096,7 @@ var catalogText = (entities, states) => JSON.stringify(
12320
13096
  );
12321
13097
  var createMemoryVNextRecall = (input) => async (query) => {
12322
13098
  const startedAt = performance.now();
12323
- const { entities, states } = await buildCatalog(input.db, input.ownerId);
13099
+ const { entities, states } = await loadMemoryVNextCatalog(input.db, input.ownerId);
12324
13100
  if (entities.length === 0 && states.length === 0) {
12325
13101
  return {
12326
13102
  query,
@@ -12426,6 +13202,20 @@ var buildLegacyMemoryEvidence = (item) => {
12426
13202
  // packages/ai/memory/vnext/shadowRead.ts
12427
13203
  var SHADOW_TIMEOUT_MS = 2e4;
12428
13204
  var ERROR_MESSAGE_MAX = 120;
13205
+ var MEMORY_VNEXT_SHADOW_READ_COOLDOWN_ENV = "NOLO_MEMORY_VNEXT_SHADOW_READ_COOLDOWN_MS";
13206
+ var DEFAULT_SHADOW_READ_COOLDOWN_MS = DEFAULT_DETACHED_MEMORY_COOLDOWN_MS;
13207
+ var shadowReadThrottle = createDetachedThrottle({
13208
+ name: "shadow_read",
13209
+ defaultCooldownMs: DEFAULT_SHADOW_READ_COOLDOWN_MS,
13210
+ cooldownEnvKey: MEMORY_VNEXT_SHADOW_READ_COOLDOWN_ENV
13211
+ });
13212
+ var resolveShadowReadCooldownMs = (env) => shadowReadThrottle.resolveCooldownMs(env);
13213
+ var shadowReadThrottleKey = (owners) => owners.map(
13214
+ (owner) => resolveLegacyMemoryPrincipal({
13215
+ ownerType: owner.ownerType,
13216
+ ownerId: owner.ownerId
13217
+ }).principalId
13218
+ ).sort().join("");
12429
13219
  var normalizeTextKey = (text) => text.trim().replace(/\s+/g, " ").toLowerCase();
12430
13220
  var legacyItemKeys = (item) => {
12431
13221
  const keys = [normalizeTextKey(item.content ?? "")];
@@ -12462,14 +13252,35 @@ var withTimeout = async (promise, timeoutMs, label) => {
12462
13252
  };
12463
13253
  var runMemoryVNextShadowRead = async (input) => {
12464
13254
  const now = input.ctx.now ?? (() => performance.now());
12465
- const defaultEmit = (observation2) => {
13255
+ const defaultEmit = (observation) => {
12466
13256
  const payload = {
12467
13257
  event: "memory_vnext_shadow_read",
12468
- ...observation2
13258
+ ...observation
12469
13259
  };
12470
13260
  console.info("[memory] vnext shadow read", payload);
12471
13261
  };
12472
13262
  const emit = input.emit ?? defaultEmit;
13263
+ const throttle = shadowReadThrottle.tryAcquire(
13264
+ shadowReadThrottleKey(input.ctx.owners),
13265
+ now(),
13266
+ input.ctx.cooldownMs ?? resolveShadowReadCooldownMs()
13267
+ );
13268
+ if (throttle !== "run") {
13269
+ const skippedObservation = {
13270
+ legacyHitCount: input.legacyItems.length,
13271
+ vnextHitCount: 0,
13272
+ overlapCount: null,
13273
+ legacyOnlyCount: null,
13274
+ vnextOnlyCount: null,
13275
+ legacyLatencyMs: input.legacyLatencyMs,
13276
+ vnextLatencyMs: 0,
13277
+ legacyContextChars: input.legacyContextChars,
13278
+ vnextContextChars: 0,
13279
+ skipped: throttle === "busy" ? "skipped_busy" : "skipped_cooldown"
13280
+ };
13281
+ emit(skippedObservation);
13282
+ return skippedObservation;
13283
+ }
12473
13284
  const legacyKeys = new Set(
12474
13285
  input.legacyItems.flatMap((item) => legacyItemKeys(item))
12475
13286
  );
@@ -12506,31 +13317,35 @@ var runMemoryVNextShadowRead = async (input) => {
12506
13317
  } catch (error) {
12507
13318
  vnextError = shortError(error);
12508
13319
  }
12509
- const vnextLatencyMs = Math.round((now() - vnextStartedAt) * 10) / 10;
12510
- let overlapCount = null;
12511
- let legacyOnlyCount = null;
12512
- let vnextOnlyCount = null;
12513
- if (!vnextError) {
12514
- let overlap = 0;
12515
- for (const key of vnextKeys) if (legacyKeys.has(key)) overlap += 1;
12516
- overlapCount = overlap;
12517
- legacyOnlyCount = Math.max(0, legacyKeys.size - overlap);
12518
- vnextOnlyCount = Math.max(0, vnextKeys.size - overlap);
12519
- }
12520
- const observation = {
12521
- legacyHitCount: input.legacyItems.length,
12522
- vnextHitCount,
12523
- overlapCount,
12524
- legacyOnlyCount,
12525
- vnextOnlyCount,
12526
- legacyLatencyMs: input.legacyLatencyMs,
12527
- vnextLatencyMs,
12528
- legacyContextChars: input.legacyContextChars,
12529
- vnextContextChars: vnextChars,
12530
- ...vnextError ? { vnextError } : {}
12531
- };
12532
- emit(observation);
12533
- return observation;
13320
+ try {
13321
+ const vnextLatencyMs = Math.round((now() - vnextStartedAt) * 10) / 10;
13322
+ let overlapCount = null;
13323
+ let legacyOnlyCount = null;
13324
+ let vnextOnlyCount = null;
13325
+ if (!vnextError) {
13326
+ let overlap = 0;
13327
+ for (const key of vnextKeys) if (legacyKeys.has(key)) overlap += 1;
13328
+ overlapCount = overlap;
13329
+ legacyOnlyCount = Math.max(0, legacyKeys.size - overlap);
13330
+ vnextOnlyCount = Math.max(0, vnextKeys.size - overlap);
13331
+ }
13332
+ const observation = {
13333
+ legacyHitCount: input.legacyItems.length,
13334
+ vnextHitCount,
13335
+ overlapCount,
13336
+ legacyOnlyCount,
13337
+ vnextOnlyCount,
13338
+ legacyLatencyMs: input.legacyLatencyMs,
13339
+ vnextLatencyMs,
13340
+ legacyContextChars: input.legacyContextChars,
13341
+ vnextContextChars: vnextChars,
13342
+ ...vnextError ? { vnextError } : {}
13343
+ };
13344
+ emit(observation);
13345
+ return observation;
13346
+ } finally {
13347
+ shadowReadThrottle.release();
13348
+ }
12534
13349
  };
12535
13350
  var isMemoryVNextShadowReadEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_SHADOW_READ === "1" || env.NOLO_MEMORY_VNEXT_SHADOW_READ === "true";
12536
13351
 
@@ -13190,15 +14005,100 @@ var shortError2 = (error) => {
13190
14005
  const message = error instanceof Error ? `${error.name}: ${error.message}` : String(error);
13191
14006
  return message.length > ERROR_MESSAGE_MAX2 ? `${message.slice(0, ERROR_MESSAGE_MAX2)}\u2026` : message;
13192
14007
  };
14008
+ var DEFAULT_LAZY_PROMOTION_COOLDOWN_MS = DEFAULT_DETACHED_MEMORY_COOLDOWN_MS;
14009
+ var DEFAULT_LAZY_PROMOTION_TIMEOUT_MS = 2e4;
14010
+ var MEMORY_VNEXT_LAZY_PROMOTION_COOLDOWN_ENV = "NOLO_MEMORY_VNEXT_LAZY_PROMOTION_COOLDOWN_MS";
14011
+ var MEMORY_VNEXT_LAZY_PROMOTION_TIMEOUT_ENV = "NOLO_MEMORY_VNEXT_LAZY_PROMOTION_TIMEOUT_MS";
14012
+ var promotionThrottle = createDetachedThrottle({
14013
+ name: "lazy_promotion",
14014
+ defaultCooldownMs: DEFAULT_LAZY_PROMOTION_COOLDOWN_MS,
14015
+ cooldownEnvKey: MEMORY_VNEXT_LAZY_PROMOTION_COOLDOWN_ENV
14016
+ });
14017
+ var resolveLazyPromotionTimeoutMs = (env = typeof process !== "undefined" ? process.env : {}) => readMsEnv(
14018
+ env[MEMORY_VNEXT_LAZY_PROMOTION_TIMEOUT_ENV],
14019
+ DEFAULT_LAZY_PROMOTION_TIMEOUT_MS,
14020
+ false
14021
+ );
14022
+ var withTimeout2 = async (promise, timeoutMs, label) => {
14023
+ let timer;
14024
+ const timeout = new Promise((_, reject) => {
14025
+ timer = setTimeout(() => reject(new Error(label)), timeoutMs);
14026
+ });
14027
+ try {
14028
+ return await Promise.race([promise, timeout]);
14029
+ } finally {
14030
+ if (timer) clearTimeout(timer);
14031
+ }
14032
+ };
13193
14033
  var loadExistingContext = async (db, ownerId) => {
13194
- const entities = await listMemoryEntitiesVNext(db, ownerId);
13195
- const states = (await Promise.all(
13196
- entities.map((entity) => listMemoryStatesForEntityVNext(db, ownerId, entity.id))
13197
- )).flat();
13198
- return {
13199
- entityIds: entities.map((entity) => entity.id),
13200
- states
14034
+ const { entities, states } = await loadMemoryVNextCatalog(db, ownerId);
14035
+ return { entityIds: entities.map((entity) => entity.id), states };
14036
+ };
14037
+ var currentStatesCitingEvidence = (states, evidenceId) => states.filter((state2) => !state2.retiredAt && (state2.evidenceIds ?? []).includes(evidenceId));
14038
+ var isEvidenceCoveredByCurrentStates = (states, evidenceId) => currentStatesCitingEvidence(states, evidenceId).length > 0;
14039
+ var memoryVNextContextFingerprint = (existing) => {
14040
+ const states = existing.states ?? [];
14041
+ const entityIds = existing.entityIds ?? [];
14042
+ const canonical = [
14043
+ ...entityIds.map((id) => `e\0${id}`),
14044
+ ...states.map((state2) => `s\0${state2.id}\0${state2.updatedAt}\0${state2.retiredAt ?? ""}`)
14045
+ ].sort().join("");
14046
+ let hash = 2166136261;
14047
+ for (let i = 0; i < canonical.length; i++) {
14048
+ hash ^= canonical.charCodeAt(i);
14049
+ hash = Math.imul(hash, 16777619);
14050
+ }
14051
+ return `${entityIds.length}.${states.length}:${(hash >>> 0).toString(16)}`;
14052
+ };
14053
+ var MAX_NOOP_SUPPRESSIONS = 512;
14054
+ var noOpSuppressions = /* @__PURE__ */ new Map();
14055
+ var suppressionKey = (ownerId, evidenceId) => `${ownerId}\0${evidenceId}`;
14056
+ var recordNoOpSuppression = (ownerId, evidenceId, fingerprint) => {
14057
+ const key = suppressionKey(ownerId, evidenceId);
14058
+ noOpSuppressions.delete(key);
14059
+ noOpSuppressions.set(key, fingerprint);
14060
+ while (noOpSuppressions.size > MAX_NOOP_SUPPRESSIONS) {
14061
+ noOpSuppressions.delete(noOpSuppressions.keys().next().value);
14062
+ }
14063
+ };
14064
+ var noOpHistory = (ownerId, evidenceId, fingerprint) => {
14065
+ const recorded = noOpSuppressions.get(suppressionKey(ownerId, evidenceId));
14066
+ if (recorded === void 0) return "fresh";
14067
+ return recorded === fingerprint ? "suppressed" : "stale";
14068
+ };
14069
+ var pickFirstUncoveredLazyPromotionItem = async (db, selected) => {
14070
+ const contextByOwner = /* @__PURE__ */ new Map();
14071
+ const contextFor = (ownerId) => {
14072
+ let pending = contextByOwner.get(ownerId);
14073
+ if (!pending) {
14074
+ pending = loadExistingContext(db, ownerId).then((existing) => ({
14075
+ states: existing.states ?? [],
14076
+ fingerprint: memoryVNextContextFingerprint(existing)
14077
+ }));
14078
+ contextByOwner.set(ownerId, pending);
14079
+ }
14080
+ return pending;
13201
14081
  };
14082
+ let skippedCoveredCount = 0;
14083
+ let skippedNoOpCount = 0;
14084
+ let firstStale = null;
14085
+ for (const [selectedIndex, item] of selected.entries()) {
14086
+ const evidence = buildLegacyMemoryEvidence(item);
14087
+ const context = await contextFor(evidence.ownerId);
14088
+ if (isEvidenceCoveredByCurrentStates(context.states, evidence.id)) {
14089
+ skippedCoveredCount++;
14090
+ continue;
14091
+ }
14092
+ const history = noOpHistory(evidence.ownerId, evidence.id, context.fingerprint);
14093
+ if (history === "fresh") {
14094
+ return { item, selectedIndex, skippedCoveredCount, skippedNoOpCount };
14095
+ }
14096
+ if (history === "stale" && !firstStale) {
14097
+ firstStale = { item, selectedIndex, skippedCoveredCount, skippedNoOpCount };
14098
+ }
14099
+ skippedNoOpCount++;
14100
+ }
14101
+ return firstStale;
13202
14102
  };
13203
14103
  var withoutImportedEvidence = (mutation, importedEvidenceId) => ({
13204
14104
  ...mutation,
@@ -13214,6 +14114,11 @@ var runMemoryVNextLazyPromotion = async (input) => {
13214
14114
  }));
13215
14115
  const finish = (partial) => {
13216
14116
  const observation = {
14117
+ legacyItemId: input.item.id,
14118
+ evidenceId: deterministicEvidence.id,
14119
+ ...input.selectedIndex === void 0 ? {} : { selectedIndex: input.selectedIndex },
14120
+ ...input.skippedCoveredCount === void 0 ? {} : { skippedCoveredCount: input.skippedCoveredCount },
14121
+ ...input.skippedNoOpCount === void 0 ? {} : { skippedNoOpCount: input.skippedNoOpCount },
13217
14122
  ...partial,
13218
14123
  latencyMs: Math.round((clock() - startedAt) * 10) / 10
13219
14124
  };
@@ -13228,6 +14133,17 @@ var runMemoryVNextLazyPromotion = async (input) => {
13228
14133
  if (inFlight.has(flightKey)) {
13229
14134
  return finish({ status: "in_flight" });
13230
14135
  }
14136
+ const throttle = promotionThrottle.tryAcquire(
14137
+ deterministicEvidence.ownerId,
14138
+ clock(),
14139
+ input.cooldownMs
14140
+ );
14141
+ if (throttle === "busy") {
14142
+ return finish({ status: "skipped_busy" });
14143
+ }
14144
+ if (throttle === "cooldown") {
14145
+ return finish({ status: "skipped_cooldown" });
14146
+ }
13231
14147
  inFlight.add(flightKey);
13232
14148
  try {
13233
14149
  const evidenceResult = await applyLegacyMemoryEvidence(input.db, input.item);
@@ -13236,22 +14152,33 @@ var runMemoryVNextLazyPromotion = async (input) => {
13236
14152
  }
13237
14153
  const evidence = evidenceResult.evidence;
13238
14154
  const existing = await loadExistingContext(input.db, evidence.ownerId);
13239
- const alreadyCovered = (existing.states ?? []).some(
13240
- (state2) => !state2.retiredAt && state2.evidenceIds.includes(evidence.id)
14155
+ const alreadyCovered = isEvidenceCoveredByCurrentStates(
14156
+ existing.states ?? [],
14157
+ evidence.id
13241
14158
  );
13242
14159
  if (alreadyCovered) {
13243
14160
  return finish({ status: "already_covered" });
13244
14161
  }
13245
- const interpreted = await runLegacyMemoryMigrationShadow({
13246
- item: input.item,
13247
- provider: input.provider,
13248
- existing,
13249
- ...input.timeoutMs === void 0 ? {} : { timeoutMs: input.timeoutMs },
13250
- ...input.now === void 0 ? {} : { now: input.now },
13251
- ...input.nextId ? { nextId: input.nextId } : {}
13252
- });
14162
+ const timeoutMs = input.timeoutMs ?? resolveLazyPromotionTimeoutMs();
14163
+ const interpreted = await withTimeout2(
14164
+ runLegacyMemoryMigrationShadow({
14165
+ item: input.item,
14166
+ provider: input.provider,
14167
+ existing,
14168
+ timeoutMs,
14169
+ ...input.now === void 0 ? {} : { now: input.now },
14170
+ ...input.nextId ? { nextId: input.nextId } : {}
14171
+ }),
14172
+ timeoutMs,
14173
+ `memory vnext lazy promotion interpreter timed out after ${timeoutMs}ms`
14174
+ );
13253
14175
  const semanticMutation = withoutImportedEvidence(interpreted.mutation, evidence.id);
13254
14176
  if (!hasWrites(semanticMutation)) {
14177
+ recordNoOpSuppression(
14178
+ evidence.ownerId,
14179
+ evidence.id,
14180
+ memoryVNextContextFingerprint(existing)
14181
+ );
13255
14182
  return finish({ status: "no_op", action: semanticMutation.action });
13256
14183
  }
13257
14184
  await applyMemoryInterpreterMutation(input.db, evidence.ownerId, semanticMutation);
@@ -13260,10 +14187,184 @@ var runMemoryVNextLazyPromotion = async (input) => {
13260
14187
  return finish({ status: "error", error: shortError2(error) });
13261
14188
  } finally {
13262
14189
  inFlight.delete(flightKey);
14190
+ promotionThrottle.release();
13263
14191
  }
13264
14192
  };
13265
14193
  var isMemoryVNextLazyPromotionEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_LAZY_PROMOTION === "1" || env.NOLO_MEMORY_VNEXT_LAZY_PROMOTION === "true";
13266
14194
 
14195
+ // packages/ai/memory/vnext/pureReadGate.ts
14196
+ var isMemoryVNextPureReadEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_PURE_READ === "1" || env.NOLO_MEMORY_VNEXT_PURE_READ === "true";
14197
+
14198
+ // packages/ai/memory/vnext/localRecall.ts
14199
+ var MIN_SHARED_TOKENS = 2;
14200
+ var MAX_LOCAL_RECALL_STATES = 8;
14201
+ var SAFE_TECHNICAL_SYNONYMS = {
14202
+ pr: ["\u5BA1\u67E5", "\u4EE3\u7801\u5BA1\u67E5", "diff"],
14203
+ diff: ["\u5BA1\u67E5", "\u4EE3\u7801\u5BA1\u67E5"],
14204
+ review: ["\u5BA1\u67E5", "\u4EE3\u7801\u5BA1\u67E5"],
14205
+ deploy: ["\u90E8\u7F72", "\u53D1\u7248"],
14206
+ release: ["\u53D1\u7248", "\u53D1\u5E03"],
14207
+ desktop: ["\u684C\u9762", "\u684C\u9762\u7AEF"]
14208
+ };
14209
+ var distinctTokens = (text) => new Set(tokenize2(text).filter((token) => token.length >= 2));
14210
+ var recallMemoryVNextLocal = (input) => {
14211
+ const rawTokens = distinctTokens(input.query);
14212
+ if (rawTokens.size === 0) return [];
14213
+ const queryTokens = new Set(rawTokens);
14214
+ for (const token of rawTokens) {
14215
+ const syns = SAFE_TECHNICAL_SYNONYMS[token.toLowerCase()];
14216
+ if (syns) {
14217
+ for (const syn of syns) {
14218
+ for (const t2 of distinctTokens(syn)) queryTokens.add(t2);
14219
+ }
14220
+ }
14221
+ }
14222
+ const entityById = new Map(input.entities.map((entity) => [entity.id, entity]));
14223
+ const hits = [];
14224
+ for (const state2 of input.states) {
14225
+ if (state2.retiredAt || !state2.text.trim()) continue;
14226
+ const entity = entityById.get(state2.entityId);
14227
+ const haystack = distinctTokens(
14228
+ [state2.facet, state2.text, entity?.name ?? "", ...entity?.aliases ?? []].join(" ")
14229
+ );
14230
+ let sharedTokens = 0;
14231
+ for (const token of queryTokens) if (haystack.has(token)) sharedTokens++;
14232
+ if (sharedTokens >= MIN_SHARED_TOKENS) hits.push({ state: state2, sharedTokens });
14233
+ }
14234
+ return hits.sort((a, b) => b.sharedTokens - a.sharedTokens || a.state.id.localeCompare(b.state.id)).slice(0, input.limit ?? MAX_LOCAL_RECALL_STATES);
14235
+ };
14236
+
14237
+ // packages/ai/memory/vnext/pureVNextRuntime.ts
14238
+ var buildSynthesizedStateItem = (state2, entity, ownerType, ownerId) => ({
14239
+ id: `vnext-state-${state2.id}`,
14240
+ ownerType,
14241
+ ownerId,
14242
+ visibility: "private",
14243
+ subjectType: "user",
14244
+ subjectId: ownerId,
14245
+ kind: "semantic",
14246
+ content: state2.text.trim(),
14247
+ createdAt: state2.createdAt,
14248
+ lastActivatedAt: state2.createdAt,
14249
+ activationCount: 1,
14250
+ importance: 0.9,
14251
+ confidence: 0.9,
14252
+ resident: state2.facet === "preference" || state2.facet === "style"
14253
+ });
14254
+ async function resolvePureVNextRuntime(input) {
14255
+ const { db, owners, userInput } = input;
14256
+ if (owners.length === 0 || !userInput.trim()) {
14257
+ return { selectedItems: [], promptBlock: null, recalledStateCount: 0 };
14258
+ }
14259
+ const ownerIds = owners.map((o) => `${o.ownerType}:${encodeURIComponent(o.ownerId)}`);
14260
+ const catalogs = await Promise.all(
14261
+ ownerIds.map((ownerId) => loadMemoryVNextCatalog(db, ownerId))
14262
+ );
14263
+ const selectedItems = [];
14264
+ const seenStateKeys = /* @__PURE__ */ new Set();
14265
+ for (let i = 0; i < owners.length; i++) {
14266
+ const owner = owners[i];
14267
+ const catalog = catalogs[i];
14268
+ const currentStates = catalog.states.filter((s) => !s.retiredAt && s.text.trim());
14269
+ const hits = recallMemoryVNextLocal({
14270
+ query: userInput,
14271
+ entities: catalog.entities,
14272
+ states: currentStates
14273
+ });
14274
+ const entityById = new Map(catalog.entities.map((e) => [e.id, e]));
14275
+ for (const hit of hits) {
14276
+ const stateKey = `${hit.state.ownerId}\0${hit.state.id}`;
14277
+ if (seenStateKeys.has(stateKey)) continue;
14278
+ seenStateKeys.add(stateKey);
14279
+ selectedItems.push(
14280
+ buildSynthesizedStateItem(hit.state, entityById.get(hit.state.entityId), owner.ownerType, owner.ownerId)
14281
+ );
14282
+ }
14283
+ }
14284
+ const promptBlock = selectedItems.length === 0 ? null : buildMemoryOverlay(selectedItems, {
14285
+ maxTokens: input.maxTokens ?? DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET
14286
+ });
14287
+ return {
14288
+ selectedItems,
14289
+ promptBlock,
14290
+ recalledStateCount: selectedItems.length
14291
+ };
14292
+ }
14293
+
14294
+ // packages/ai/memory/vnext/primaryRead.ts
14295
+ var MEMORY_VNEXT_PRIMARY_READ_TIMEOUT_MS = 300;
14296
+ var isMemoryVNextPrimaryReadEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_PRIMARY_READ === "1" || env.NOLO_MEMORY_VNEXT_PRIMARY_READ === "true";
14297
+ var buildSynthesizedStateItem2 = (state2, entity, ownerType, ownerId) => ({
14298
+ id: `vnext-state-${state2.id}`,
14299
+ ownerType,
14300
+ ownerId,
14301
+ visibility: "private",
14302
+ subjectType: "user",
14303
+ subjectId: ownerId,
14304
+ kind: "semantic",
14305
+ content: state2.text.trim(),
14306
+ createdAt: state2.createdAt,
14307
+ importance: 0.9,
14308
+ confidence: 0.9,
14309
+ // Flag resident preferences so they flow into overlay's resident section.
14310
+ resident: state2.facet === "preference" || state2.facet === "style",
14311
+ lastActivatedAt: state2.createdAt,
14312
+ activationCount: 1
14313
+ });
14314
+ var resolveMemoryVNextM4Selection = async (input) => {
14315
+ const { db, owners, query, selected } = input;
14316
+ const ownerIds = owners.map((o) => `${o.ownerType}:${encodeURIComponent(o.ownerId)}`);
14317
+ const catalogs = new Map(
14318
+ await Promise.all(
14319
+ ownerIds.map(async (ownerId) => [
14320
+ ownerId,
14321
+ await loadMemoryVNextCatalog(db, ownerId)
14322
+ ])
14323
+ )
14324
+ );
14325
+ const recalledStates = [];
14326
+ const recalledStateIds = /* @__PURE__ */ new Set();
14327
+ for (const owner of owners) {
14328
+ const principalId = `${owner.ownerType}:${encodeURIComponent(owner.ownerId)}`;
14329
+ const catalog = catalogs.get(principalId);
14330
+ if (!catalog) continue;
14331
+ const currentStates = catalog.states.filter((s) => !s.retiredAt && s.text.trim());
14332
+ const hits = recallMemoryVNextLocal({
14333
+ query,
14334
+ entities: catalog.entities,
14335
+ states: currentStates
14336
+ });
14337
+ const entityById = new Map(catalog.entities.map((e) => [e.id, e]));
14338
+ for (const hit of hits) {
14339
+ if (recalledStateIds.has(hit.state.id)) continue;
14340
+ recalledStateIds.add(hit.state.id);
14341
+ recalledStates.push(
14342
+ buildSynthesizedStateItem2(hit.state, entityById.get(hit.state.entityId), owner.ownerType, owner.ownerId)
14343
+ );
14344
+ }
14345
+ }
14346
+ const uncoveredLegacy = [];
14347
+ let coveredSuppressedCount = 0;
14348
+ for (const item of selected) {
14349
+ const evidence = buildLegacyMemoryEvidence(item);
14350
+ const catalog = catalogs.get(evidence.ownerId);
14351
+ const states = catalog?.states ?? [];
14352
+ const covering = currentStatesCitingEvidence(states, evidence.id);
14353
+ if (covering.length > 0) {
14354
+ coveredSuppressedCount++;
14355
+ } else {
14356
+ uncoveredLegacy.push(item);
14357
+ }
14358
+ }
14359
+ const renderItems = [...recalledStates, ...uncoveredLegacy];
14360
+ return {
14361
+ renderItems,
14362
+ recalledStateCount: recalledStates.length,
14363
+ uncoveredLegacyCount: uncoveredLegacy.length,
14364
+ coveredSuppressedCount
14365
+ };
14366
+ };
14367
+
13267
14368
  // packages/ai/memory/runtime.ts
13268
14369
  var COLD_STORAGE_CONFIDENCE = 0.3;
13269
14370
  var MEMORY_OVERLAY_TOKEN_BUDGET = DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET;
@@ -13386,6 +14487,18 @@ var resolveMemoryRuntime = async (input) => {
13386
14487
  if (owners.length === 0) {
13387
14488
  return { selectedItems: [], promptBlock: null };
13388
14489
  }
14490
+ if (isMemoryVNextPureReadEnabled()) {
14491
+ const pure = await resolvePureVNextRuntime({
14492
+ db: input.db,
14493
+ owners,
14494
+ userInput: input.userInput,
14495
+ maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET
14496
+ });
14497
+ return {
14498
+ selectedItems: pure.selectedItems,
14499
+ promptBlock: pure.promptBlock
14500
+ };
14501
+ }
13389
14502
  const policy = resolveAgentMemoryPolicy({ agentKey: input.agentKey });
13390
14503
  const legacyStartedAt = performance.now();
13391
14504
  const candidates = await loadMemoryCandidatesFromDb(input.db, {
@@ -13415,10 +14528,62 @@ var resolveMemoryRuntime = async (input) => {
13415
14528
  );
13416
14529
  const selected = [...residentItems, ...ranked];
13417
14530
  const legacyLatencyMs = Math.round((performance.now() - legacyStartedAt) * 10) / 10;
13418
- const promptBlock = selected.length === 0 ? null : buildMemoryOverlay(selected, { maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET });
13419
- const shadowEnabled = input.vNextShadowProvider != null && isMemoryVNextShadowReadEnabled();
14531
+ const renderOverlay = (items) => items.length === 0 ? null : buildMemoryOverlay(items, { maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET });
14532
+ let promptBlock = renderOverlay(selected);
14533
+ const primaryRead = isMemoryVNextPrimaryReadEnabled();
14534
+ let allCoveredByVNext = false;
14535
+ if (primaryRead) {
14536
+ const emitPrimary = (observation) => {
14537
+ try {
14538
+ (input.primaryReadEmit ?? ((o) => console.info("[memory] vnext primary read", { event: "memory_vnext_primary_read", ...o })))(observation);
14539
+ } catch {
14540
+ }
14541
+ };
14542
+ const base = { legacyHitCount: selected.length, legacyLatencyMs };
14543
+ const vnextStartedAt = performance.now();
14544
+ const vnextLatency = () => Math.round((performance.now() - vnextStartedAt) * 10) / 10;
14545
+ if (selected.length === 0) {
14546
+ emitPrimary({ ...base, source: "none" });
14547
+ } else {
14548
+ try {
14549
+ let timer;
14550
+ const m4 = await Promise.race([
14551
+ resolveMemoryVNextM4Selection({ db: input.db, owners, query: input.userInput, selected }),
14552
+ new Promise((_, reject) => {
14553
+ timer = setTimeout(
14554
+ () => reject(Object.assign(new Error("timeout"), { name: "TimeoutError" })),
14555
+ MEMORY_VNEXT_PRIMARY_READ_TIMEOUT_MS
14556
+ );
14557
+ })
14558
+ ]).finally(() => clearTimeout(timer));
14559
+ promptBlock = renderOverlay(m4.renderItems);
14560
+ allCoveredByVNext = m4.uncoveredLegacyCount === 0 && m4.recalledStateCount > 0;
14561
+ const source = m4.recalledStateCount > 0 ? m4.uncoveredLegacyCount === 0 ? "vnext" : "hybrid" : m4.uncoveredLegacyCount > 0 ? "legacy_fallback" : "none";
14562
+ emitPrimary({
14563
+ ...base,
14564
+ source,
14565
+ uncoveredLegacyCount: m4.uncoveredLegacyCount,
14566
+ coveredSuppressedCount: m4.coveredSuppressedCount,
14567
+ recalledStateCount: m4.recalledStateCount,
14568
+ vnextLatencyMs: vnextLatency(),
14569
+ contextChars: promptBlock?.length ?? 0,
14570
+ ...source === "legacy_fallback" ? { fallbackReason: "no_vnext_context" } : {}
14571
+ });
14572
+ } catch (error) {
14573
+ emitPrimary({
14574
+ ...base,
14575
+ source: "legacy_fallback",
14576
+ vnextLatencyMs: vnextLatency(),
14577
+ contextChars: promptBlock?.length ?? 0,
14578
+ fallbackReason: "vnext_error",
14579
+ error: error instanceof Error ? error.name : "UnknownError"
14580
+ });
14581
+ }
14582
+ }
14583
+ }
14584
+ const shadowEnabled = !primaryRead && input.vNextShadowProvider != null && isMemoryVNextShadowReadEnabled();
13420
14585
  if (shadowEnabled) {
13421
- await runMemoryVNextShadowRead({
14586
+ void runMemoryVNextShadowRead({
13422
14587
  ctx: {
13423
14588
  db: input.db,
13424
14589
  owners,
@@ -13428,17 +14593,28 @@ var resolveMemoryRuntime = async (input) => {
13428
14593
  legacyItems: selected,
13429
14594
  legacyLatencyMs,
13430
14595
  legacyContextChars: promptBlock?.length ?? 0
14596
+ }).catch(() => {
13431
14597
  });
13432
14598
  }
13433
- const promotionCandidate = selected[0];
13434
14599
  const lazyPromotionEnabled = input.vNextShadowProvider != null && isMemoryVNextLazyPromotionEnabled();
13435
- if (lazyPromotionEnabled && promotionCandidate) {
13436
- void runMemoryVNextLazyPromotion({
13437
- db: input.db,
13438
- item: promotionCandidate,
13439
- provider: input.vNextShadowProvider,
13440
- ...input.lazyPromotionEmit ? { emit: input.lazyPromotionEmit } : {}
13441
- }).catch(() => {
14600
+ if (lazyPromotionEnabled && selected.length > 0 && !allCoveredByVNext) {
14601
+ void (async () => {
14602
+ const promotionPick = await pickFirstUncoveredLazyPromotionItem(
14603
+ input.db,
14604
+ selected
14605
+ );
14606
+ if (promotionPick) {
14607
+ await runMemoryVNextLazyPromotion({
14608
+ db: input.db,
14609
+ item: promotionPick.item,
14610
+ selectedIndex: promotionPick.selectedIndex,
14611
+ skippedCoveredCount: promotionPick.skippedCoveredCount,
14612
+ skippedNoOpCount: promotionPick.skippedNoOpCount,
14613
+ provider: input.vNextShadowProvider,
14614
+ ...input.lazyPromotionEmit ? { emit: input.lazyPromotionEmit } : {}
14615
+ });
14616
+ }
14617
+ })().catch(() => {
13442
14618
  });
13443
14619
  }
13444
14620
  if (selected.length === 0) {
@@ -13452,6 +14628,52 @@ var resolveMemoryRuntime = async (input) => {
13452
14628
  };
13453
14629
 
13454
14630
  // packages/cli/memoryRecall.ts
14631
+ var logger = getLogger("cli.memoryRecall");
14632
+ var DEDUP_WINDOW_MS = 5 * 60 * 1e3;
14633
+ var DEDUP_MAX_KEYS = 100;
14634
+ var dedupMap = /* @__PURE__ */ new Map();
14635
+ function evictDedupIfNeeded() {
14636
+ if (dedupMap.size < DEDUP_MAX_KEYS) return;
14637
+ let oldestKey = null;
14638
+ let oldestTs = Infinity;
14639
+ for (const [k, v] of dedupMap) {
14640
+ if (v.lastLog < oldestTs) {
14641
+ oldestTs = v.lastLog;
14642
+ oldestKey = k;
14643
+ }
14644
+ }
14645
+ if (oldestKey !== null) dedupMap.delete(oldestKey);
14646
+ }
14647
+ function logDeduped(level, fingerprint, message, error) {
14648
+ const now = Date.now();
14649
+ const entry = dedupMap.get(fingerprint);
14650
+ if (!entry) {
14651
+ evictDedupIfNeeded();
14652
+ dedupMap.set(fingerprint, { count: 1, suppressed: 0, lastLog: now });
14653
+ if (error !== void 0) logger[level](message, error);
14654
+ else logger[level](message);
14655
+ return;
14656
+ }
14657
+ entry.count += 1;
14658
+ if (now - entry.lastLog >= DEDUP_WINDOW_MS) {
14659
+ const suppressed = entry.suppressed;
14660
+ const summary = `${message} (deduplicated: ${entry.count} occurrences, ${suppressed} suppressed over ${Math.round((now - entry.lastLog) / 1e3)}s)`;
14661
+ if (error !== void 0) logger[level](summary, error);
14662
+ else logger[level](summary);
14663
+ entry.count = 1;
14664
+ entry.suppressed = 0;
14665
+ entry.lastLog = now;
14666
+ } else {
14667
+ entry.suppressed += 1;
14668
+ }
14669
+ }
14670
+ function fingerprintFor(kind, detail) {
14671
+ const d = detail === void 0 ? "" : sanitizeFp(String(detail));
14672
+ return `mem-${kind}:${d}`;
14673
+ }
14674
+ function sanitizeFp(s) {
14675
+ return s.replace(/\s+/g, " ").slice(0, 80);
14676
+ }
13455
14677
  var queryRemoteMemory = async (serverUrl, authToken, agentKey, userInput, spaceId) => {
13456
14678
  try {
13457
14679
  const response = await fetch(`${serverUrl}/api/memory/query`, {
@@ -13468,10 +14690,10 @@ var queryRemoteMemory = async (serverUrl, authToken, agentKey, userInput, spaceI
13468
14690
  signal: AbortSignal.timeout(5e3)
13469
14691
  });
13470
14692
  if (!response.ok) {
13471
- console.warn(
13472
- "[cli-memory] remote query returned non-ok status:",
13473
- response.status,
13474
- "\u2014 falling back to local"
14693
+ logDeduped(
14694
+ "warn",
14695
+ fingerprintFor("remote-nonok", response.status),
14696
+ `remote query returned non-ok status ${response.status} \u2014 falling back to local`
13475
14697
  );
13476
14698
  return null;
13477
14699
  }
@@ -13479,7 +14701,12 @@ var queryRemoteMemory = async (serverUrl, authToken, agentKey, userInput, spaceI
13479
14701
  const block = typeof payload?.promptBlock === "string" ? payload.promptBlock.trim() : "";
13480
14702
  return block || null;
13481
14703
  } catch (error) {
13482
- console.warn("[cli-memory] remote query failed, falling back to local:", error);
14704
+ logDeduped(
14705
+ "info",
14706
+ fingerprintFor("remote-failed", error instanceof Error ? error.name : void 0),
14707
+ "remote query failed, falling back to local",
14708
+ normalizeError(error)
14709
+ );
13483
14710
  return null;
13484
14711
  }
13485
14712
  };
@@ -13515,7 +14742,12 @@ var resolveCliMemory = async (input) => {
13515
14742
  input.spaceId
13516
14743
  );
13517
14744
  } catch (error) {
13518
- console.warn("[cli-memory] local recall failed, omitting memory layer:", error);
14745
+ logDeduped(
14746
+ "warn",
14747
+ fingerprintFor("local-failed", error instanceof Error ? error.name : void 0),
14748
+ "local recall failed, omitting memory layer",
14749
+ normalizeError(error)
14750
+ );
13519
14751
  return null;
13520
14752
  }
13521
14753
  };
@@ -13539,13 +14771,6 @@ function resolveRunOutcome(input) {
13539
14771
  }
13540
14772
  }
13541
14773
  }
13542
- var FAILED_EMPTY_ASSISTANT_REASONS = /* @__PURE__ */ new Set([
13543
- "length_truncated",
13544
- "stream_truncated",
13545
- "repetition_loop",
13546
- "stagnant_tool_calls"
13547
- ]);
13548
- var isRunResultStalledOrTruncated = (result) => !result.emptyAssistantOutputUsable && FAILED_EMPTY_ASSISTANT_REASONS.has(result.emptyAssistantFallbackReason ?? "");
13549
14774
  var resolveRunSettlementNote = (result) => {
13550
14775
  const reason = result.emptyAssistantFallbackReason;
13551
14776
  if (!reason || !FAILED_EMPTY_ASSISTANT_REASONS.has(reason)) return {};
@@ -13570,7 +14795,10 @@ async function resolveAgentRunAgentKey(args) {
13570
14795
  }
13571
14796
  async function runAgentRunCommand(args, deps) {
13572
14797
  const env = deps.env ?? process.env;
13573
- const output = deps.output ?? process.stdout;
14798
+ const output = deps.output ?? {
14799
+ write: (chunk) => process.stdout.write(chunk),
14800
+ writeErr: (chunk) => process.stderr.write(chunk)
14801
+ };
13574
14802
  if (args.includes("--help") || args.includes("-h")) {
13575
14803
  writeUsage(output, deps.commandPath);
13576
14804
  return 0;
@@ -13612,7 +14840,19 @@ async function runAgentRunCommand(args, deps) {
13612
14840
  const watchdogFailure = armStallWatchdog || armTimeoutWatchdog ? new Promise((_, reject) => {
13613
14841
  rejectOnWatchdogFailure = reject;
13614
14842
  }) : void 0;
13615
- const raceWithWatchdog = (work) => watchdogFailure ? Promise.race([work, watchdogFailure]) : work;
14843
+ const terminalStatus = createOneShotTerminalStatus(
14844
+ parsed.eventsMode || parsed.background || hasRegistry ? null : deps.output ? deps.output : {
14845
+ write: (chunk) => process.stdout.write(chunk),
14846
+ isTTY: process.stdout.isTTY === true
14847
+ }
14848
+ );
14849
+ const raceWithWatchdog = (work) => {
14850
+ const raced = watchdogFailure ? Promise.race([work, watchdogFailure]) : work;
14851
+ return raced.catch((error) => {
14852
+ terminalStatus.fail();
14853
+ throw error;
14854
+ });
14855
+ };
13616
14856
  const exitFromWatchdog = (code) => {
13617
14857
  try {
13618
14858
  processExit(code);
@@ -13657,6 +14897,7 @@ async function runAgentRunCommand(args, deps) {
13657
14897
  const note = `stalled: no progress for ${stallTimeoutMs}ms`;
13658
14898
  output.write(`[nolo] local run ${note}
13659
14899
  `);
14900
+ terminalStatus.fail();
13660
14901
  const outcome = resolveRunOutcome({ kind: "stall" });
13661
14902
  const currentActivity = activityTracker?.getActivity();
13662
14903
  await finalizeWatchdogOutcome(outcome, note, {
@@ -13675,6 +14916,7 @@ async function runAgentRunCommand(args, deps) {
13675
14916
  const note = `timed out after ${parsed.timeoutMs}ms`;
13676
14917
  output.write(`[nolo] local run ${note}
13677
14918
  `);
14919
+ terminalStatus.fail();
13678
14920
  const outcome = resolveRunOutcome({ kind: "timeout" });
13679
14921
  await finalizeWatchdogOutcome(outcome, note);
13680
14922
  rejectOnWatchdogFailure?.(new Error(`[nolo] local run ${note}`));
@@ -13720,13 +14962,12 @@ async function runAgentRunCommand(args, deps) {
13720
14962
  }
13721
14963
  if (hasExplicitAgent && !modelOverride) {
13722
14964
  output.write(
13723
- "[nolo] auto-route: \u8986\u76D6\u6E90 agent \u8BFB\u53D6\u5931\u8D25\uFF0C\u6309\u539F\u6837\u76F4\u8DD1\u6240\u9009 agent\u3002\n"
14965
+ t("agentRun.autoRouteOverrideFailed")
13724
14966
  );
13725
14967
  } else {
13726
14968
  effectiveAgentKey = CLI_AUTO_ROUTE_AGENT_KEY;
13727
14969
  if (modelOverride) {
13728
- output.write(`[nolo] auto-route: model \u5C42\u8986\u76D6\u4E3A ${agentKey}
13729
- `);
14970
+ output.write(t("agentRun.autoRouteModelOverride", agentKey));
13730
14971
  }
13731
14972
  }
13732
14973
  }
@@ -13838,6 +15079,7 @@ async function runAgentRunCommand(args, deps) {
13838
15079
  if (agentsMdLayer) scopedLayers.push(agentsMdLayer);
13839
15080
  skillContentBlocks.push(...buildSkillContextBlocks(skillReferences));
13840
15081
  scopedLayers.push(buildSkillDiscoveryContextLayer(cliCwd));
15082
+ scopedLayers.push(buildHostEnvironmentLayer());
13841
15083
  if (!deps.memoryRecallDisabled) {
13842
15084
  try {
13843
15085
  memoryPromptBlock = await resolveCliMemory({
@@ -13866,6 +15108,14 @@ async function runAgentRunCommand(args, deps) {
13866
15108
  );
13867
15109
  extraContextBlocks.push(...contextBlockScopes.map((block) => block.content));
13868
15110
  }
15111
+ const runRecordParentDialogId = !parsed.parentDialogId && typeof childRunId === "string" && childRunId.length > 0 ? asOptionalTrimmedString(
15112
+ (deps.readRunRecord ?? readRunRecord)(childRunId, {
15113
+ env,
15114
+ homedir: deps.homedir,
15115
+ fs: deps.fs
15116
+ })?.parentDialogId
15117
+ ) : void 0;
15118
+ const effectiveParentDialogId = parsed.parentDialogId ?? runRecordParentDialogId;
13869
15119
  const formatTurnMessage = (msg) => prependWorkflowReferencePrompt(
13870
15120
  prependSubjectDialogMarker(
13871
15121
  prependFeatureWorktreeInstruction(
@@ -13892,7 +15142,7 @@ async function runAgentRunCommand(args, deps) {
13892
15142
  ...parsed.spaceId ? { spaceId: parsed.spaceId } : {},
13893
15143
  ...parsed.category ? { category: parsed.category } : {},
13894
15144
  ...parsed.inheritedFromDialogKey ? { inheritedFromDialogKey: parsed.inheritedFromDialogKey } : {},
13895
- ...parsed.parentDialogId ? { parentDialogId: parsed.parentDialogId } : {},
15145
+ ...effectiveParentDialogId ? { parentDialogId: effectiveParentDialogId } : {},
13896
15146
  ...parsed.parentWakeOnTerminal ? { parentWakeOnTerminal: true } : {},
13897
15147
  ...parsed.subjectDialogKey ? { subjectDialogKey: parsed.subjectDialogKey } : {},
13898
15148
  ...parsed.subjectRefs?.length ? { subjectRefs: parsed.subjectRefs } : {},
@@ -13908,6 +15158,7 @@ async function runAgentRunCommand(args, deps) {
13908
15158
  ...parsed.taskEvidence ? { taskEvidence: parsed.taskEvidence } : {},
13909
15159
  ...contextBlockScopes.length > 0 ? { contextBlockScopes } : extraContextBlocks.length > 0 ? { extraContextBlocks } : {}
13910
15160
  });
15161
+ terminalStatus.working();
13911
15162
  let result = await raceWithWatchdog(
13912
15163
  runner({
13913
15164
  ...buildRunOptions(effectiveAgentKey),
@@ -14001,6 +15252,11 @@ async function runAgentRunCommand(args, deps) {
14001
15252
  );
14002
15253
  }
14003
15254
  }
15255
+ terminalStatus.settle({
15256
+ exitCode: result.exitCode,
15257
+ streamInterrupted: result.streamInterrupted,
15258
+ stalledOrTruncated: isRunResultStalledOrTruncated(result)
15259
+ });
14004
15260
  if (result.dialogId) {
14005
15261
  if (parsed.background) {
14006
15262
  output.write(`
@@ -14085,6 +15341,9 @@ async function runAgentRunCommand(args, deps) {
14085
15341
  ...runCreditsTotal !== void 0 ? { credits: runCreditsTotal } : {},
14086
15342
  ...failureReason ? { failureReason } : {},
14087
15343
  ...toolCallCount !== void 0 ? { toolCallCount } : {},
15344
+ ...result.finalText ? { lastAssistantText: result.finalText } : {},
15345
+ // 仅用于 .result.md 头(front matter):旁路读取,不改 result 形状。
15346
+ ...getRunResultHeaderMeta(result),
14088
15347
  ...truncationNote
14089
15348
  },
14090
15349
  {
@@ -14112,12 +15371,6 @@ function isBalanceExhaustedError(error) {
14112
15371
  }
14113
15372
 
14114
15373
  export {
14115
- resolveAgentModelIdentity,
14116
- resolveAgentContextWindow,
14117
- platformCreditsFromUsage,
14118
- formatCreditsChip,
14119
- formatTokenCount,
14120
- renderTokenStatus,
14121
15374
  resolveCliColorEnabled,
14122
15375
  dimCliText,
14123
15376
  ANSI_ESCAPE_REGEX,
@@ -14157,7 +15410,14 @@ export {
14157
15410
  polishBreathInsertsBlankBetween,
14158
15411
  formatAssistantDisplay,
14159
15412
  redactSecrets,
15413
+ safeAskText,
14160
15414
  TUI_TREE_MARKER,
15415
+ resolveAgentModelIdentity,
15416
+ resolveAgentContextWindow,
15417
+ platformCreditsFromUsage,
15418
+ formatCreditsChip,
15419
+ formatTokenCount,
15420
+ renderTokenStatus,
14161
15421
  COLLAPSED_PASTE_PLACEHOLDER_RE,
14162
15422
  shouldCollapsePaste,
14163
15423
  createCollapsedPasteStore,
@@ -14168,17 +15428,21 @@ export {
14168
15428
  releaseCollapsedPasteReferences,
14169
15429
  expandRangeToCollapsedPasteChips,
14170
15430
  findCollapsedPasteSpanAt,
15431
+ emitTerminalProgramStatus,
14171
15432
  runAgentTurn,
14172
- readAgentsMdLayerFromDisk,
14173
15433
  resolveWorkflowReference,
14174
15434
  resolveSkillReference,
14175
15435
  buildSkillContextBlocks,
14176
15436
  prependSubjectDialogMarker,
14177
15437
  normalizeCliImageInput,
14178
- inspectLocalRunWorkspace,
15438
+ buildHostEnvironmentLayer,
15439
+ readAgentsMdLayerFromDisk,
14179
15440
  resolveCliMemory,
14180
- resolveRunOutcome,
15441
+ FAILED_EMPTY_ASSISTANT_REASONS,
14181
15442
  isRunResultStalledOrTruncated,
15443
+ resolveTerminalProgramStatusState,
15444
+ inspectLocalRunWorkspace,
15445
+ resolveRunOutcome,
14182
15446
  resolveRunSettlementNote,
14183
15447
  runAgentRunCommand,
14184
15448
  isBalanceExhaustedError