nolo-cli 0.227.0-alpha.1 → 0.228.0-alpha.2

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 (199) hide show
  1. package/{_executeModel-JKQGZ3HU.js → _executeModel-VYCHHZVT.js} +78 -77
  2. package/{action-CK64LS6S.js → action-GDZDXPMB.js} +9 -9
  3. package/{addContentAction-CARFID6E.js → addContentAction-7RO4AMRI.js} +14 -14
  4. package/{addDialogAgentAction-APLZLFW5.js → addDialogAgentAction-EVYBGTXB.js} +16 -16
  5. package/{agentDeleteCommand-NVR2V2HH.js → agentDeleteCommand-QWQKT54A.js} +116 -115
  6. package/{agentEmailCommands-UCVOWD3S.js → agentEmailCommands-EISMBIRE.js} +119 -118
  7. package/{agentFavoriteCommands-4PDOP3GW.js → agentFavoriteCommands-7LOP3HUD.js} +6 -6
  8. package/{agentGrantCommands-FLCEXLUH.js → agentGrantCommands-L6O2HVJI.js} +7 -7
  9. package/{agentListCommands-C65UESYM.js → agentListCommands-4WLG32IW.js} +79 -470
  10. package/{agentMachineCommands-V3DGEJU4.js → agentMachineCommands-DC6NKWTU.js} +59 -57
  11. package/{agentProviderCommands-7QBFRFRK.js → agentProviderCommands-STI3DQ6A.js} +7 -7
  12. package/{agentPullCommand-E6JBGBVG.js → agentPullCommand-KHV4EELF.js} +6 -6
  13. package/{agentRecordCommands-6RCJS2EY.js → agentRecordCommands-IZYUVHME.js} +107 -106
  14. package/{agentRunCommand-P3GRKXKS.js → agentRunCommand-QM7ETUTX.js} +113 -112
  15. package/{agentRunControl-SNZZ5XP4.js → agentRunControl-MBG4U6SL.js} +23 -17
  16. package/{agentRuntimeLocal-GOX2DIY7.js → agentRuntimeLocal-HOXKWCYO.js} +46 -45
  17. package/{agentSlice-N7H2FRJA.js → agentSlice-UG76KEBH.js} +17 -17
  18. package/{appDeleteCommands-LZDN26FU.js → appDeleteCommands-WWCC6WA5.js} +54 -52
  19. package/{appDeployCommands-6IO6TTZH.js → appDeployCommands-AU4IUN33.js} +54 -52
  20. package/{appDeployStatusCommands-FG3LX24J.js → appDeployStatusCommands-STUW7WXL.js} +54 -52
  21. package/{appGetCommands-NAKVDVD4.js → appGetCommands-BGTLIQ4K.js} +54 -52
  22. package/{appListCommands-KL56RN73.js → appListCommands-CUCPRUXW.js} +54 -52
  23. package/{authCommand-AUN5MXV2.js → authCommand-OZ2KTP4Z.js} +30 -31
  24. package/{authCommands-D2IPS6ES.js → authCommands-55OGQGCR.js} +12 -13
  25. package/{builtinSkillRegistry-UQGLKRYP.js → builtinSkillRegistry-BAE2LDXF.js} +4 -4
  26. package/{chromeOpsCommands-UJWN5HWH.js → chromeOpsCommands-WAA45NCS.js} +8 -8
  27. package/{chunk-OB6DVWPF.js → chunk-262R3XNN.js} +16 -2
  28. package/{chunk-UN7HIYMH.js → chunk-2X7WFDT6.js} +1 -1
  29. package/{chunk-XI2BWJM5.js → chunk-324FWHUA.js} +20 -3
  30. package/{chunk-CVERLOJM.js → chunk-3QIYD3VM.js} +639 -513
  31. package/{chunk-RU6DULV4.js → chunk-3U44JB3O.js} +1 -1
  32. package/{chunk-IAJJYHIB.js → chunk-3VZLEKV2.js} +7 -7
  33. package/{chunk-JWXITTQB.js → chunk-42OKN2LI.js} +1 -1
  34. package/{chunk-UAPNPNSG.js → chunk-45CAVC35.js} +1072 -859
  35. package/{chunk-EUCFKKDM.js → chunk-4I2MXV5Q.js} +38 -10
  36. package/{chunk-SW6OD4KE.js → chunk-4QYJPWHH.js} +123 -12
  37. package/{chunk-PLPLH2XZ.js → chunk-4ZGPHFLE.js} +2 -2
  38. package/{chunk-NO3VBWTL.js → chunk-547ENH5T.js} +1 -1
  39. package/{chunk-CKT6QUE2.js → chunk-5YMA6DDZ.js} +1 -1
  40. package/chunk-5ZUOVCKT.js +32 -0
  41. package/{chunk-XZODOEKU.js → chunk-6QHKRARD.js} +2 -2
  42. package/{chunk-YGMBIXCF.js → chunk-6XRPBZRS.js} +4 -2
  43. package/{chunk-PVAWNHP5.js → chunk-7BCG67EI.js} +295 -102
  44. package/{chunk-VZW34YUL.js → chunk-7FEP5USX.js} +8 -5
  45. package/{chunk-VPAZ6BEN.js → chunk-7JGMNKKG.js} +18 -14
  46. package/{chunk-5HL4KC4A.js → chunk-ALAES342.js} +57 -86
  47. package/{chunk-VREDDN25.js → chunk-ATEKLSLR.js} +1 -1
  48. package/chunk-BIDSIRTS.js +307 -0
  49. package/chunk-BIWI5M4E.js +62 -0
  50. package/{chunk-UCFPVYP7.js → chunk-BP5ZJ6B4.js} +1 -1
  51. package/{chunk-2G3YSVO6.js → chunk-CBUZ6DKA.js} +3 -3
  52. package/{chunk-KYH7XW3K.js → chunk-CD3RU7XL.js} +16 -1
  53. package/{chunk-SFTTXGPM.js → chunk-CMMI3DAT.js} +16 -16
  54. package/{chunk-VIHDJ3FK.js → chunk-CNMY2XM6.js} +14 -14
  55. package/{chunk-UVUVQVZ6.js → chunk-DBUR22G5.js} +2 -2
  56. package/{chunk-G6HJUMST.js → chunk-DEA37IUY.js} +2 -2
  57. package/{chunk-5RKRXQ2H.js → chunk-DGYCDA6W.js} +2 -2
  58. package/{chunk-FKEZOMIF.js → chunk-DLXMMTGM.js} +523 -202
  59. package/{chunk-3HTP4WZQ.js → chunk-DUUDXSLX.js} +21 -7
  60. package/{chunk-KFHREHUQ.js → chunk-DXWGFL2Z.js} +89 -1
  61. package/{chunk-TOKPHZ55.js → chunk-EEOOBRA7.js} +5 -5
  62. package/{chunk-ZI5SZ3MV.js → chunk-EGHP7KOY.js} +20 -20
  63. package/{chunk-OXA5GWHU.js → chunk-F6Z6ZCUV.js} +2 -2
  64. package/{chunk-X2KRQP7V.js → chunk-FJSNBZXR.js} +1 -1
  65. package/{chunk-3VFYQH3I.js → chunk-FPBJM2BW.js} +17 -39
  66. package/{chunk-KRRE4A7D.js → chunk-G7IUT2V3.js} +3 -2
  67. package/{chunk-LXTC53TN.js → chunk-GAYNXB6T.js} +184 -153
  68. package/{chunk-45LZIYXB.js → chunk-HBRDSQ3M.js} +1 -1
  69. package/{chunk-GRXSJR2Z.js → chunk-HF7BLF3F.js} +21 -21
  70. package/{chunk-T5N6NHAT.js → chunk-HHFGE2WF.js} +3 -3
  71. package/{chunk-IX2BXN2K.js → chunk-HSSBDZLD.js} +3 -3
  72. package/{chunk-TINJKQSO.js → chunk-HXB4VDGK.js} +20 -20
  73. package/{chunk-MWHOH4RJ.js → chunk-HYLRQDEE.js} +4 -4
  74. package/{chunk-L5I543VB.js → chunk-JQZRSXS5.js} +23 -23
  75. package/{chunk-T2BEPTAG.js → chunk-L32W3PRP.js} +47 -17
  76. package/{chunk-LA7JYAKF.js → chunk-LYD6C7OU.js} +3 -3
  77. package/{chunk-PHOSZT3E.js → chunk-M3OZRQNH.js} +1 -1
  78. package/{chunk-M3Y4IBIR.js → chunk-M4SFKP5L.js} +4 -4
  79. package/{chunk-7Z3WUZ4Q.js → chunk-MJI3UAXN.js} +52 -28
  80. package/{chunk-YOT437BH.js → chunk-MNEZUL5S.js} +137 -118
  81. package/{chunk-GOLPOTG5.js → chunk-MZG5CETE.js} +3 -3
  82. package/{chunk-KJAAPGBE.js → chunk-OBIC6EG7.js} +6 -6
  83. package/{chunk-CLCXHIBS.js → chunk-OJ45MEEI.js} +1 -1
  84. package/{chunk-AXYH4734.js → chunk-OOJNQK6V.js} +13 -13
  85. package/{chunk-2SKTCNWO.js → chunk-OTKSESZR.js} +2 -2
  86. package/{chunk-XIEYGCN6.js → chunk-OWKNSIXL.js} +149 -48
  87. package/{chunk-6XIE5ZGI.js → chunk-PDCV7P5W.js} +1 -1
  88. package/{chunk-HOCHUZQ7.js → chunk-QJTZ76CP.js} +24 -6
  89. package/{chunk-YQETUZ5V.js → chunk-QRGDJA4B.js} +11 -11
  90. package/{chunk-ULAQPRHX.js → chunk-QYB23WUH.js} +1 -1
  91. package/{chunk-CSW7IPVD.js → chunk-R6Z5S5GA.js} +11 -11
  92. package/{chunk-MK2Q7ZJD.js → chunk-R7XWZDOH.js} +58 -24
  93. package/{chunk-GUVXQSFZ.js → chunk-RBPUNSG5.js} +1 -1
  94. package/{chunk-GOQ6ZVTN.js → chunk-RG2DGNL6.js} +3 -3
  95. package/{chunk-F5AY2UZL.js → chunk-RRDRQOEC.js} +515 -9
  96. package/{chunk-6EDAMVG6.js → chunk-RTHFJZ6M.js} +10 -10
  97. package/{chunk-WJP4TH6U.js → chunk-S6FDXXZV.js} +1 -1
  98. package/{chunk-LJSNEV7M.js → chunk-SRCCSTIM.js} +7 -7
  99. package/{chunk-KMRKZNGT.js → chunk-TCZ2VJZQ.js} +13 -12
  100. package/{chunk-AK5O76CC.js → chunk-TI2EPRHE.js} +2 -2
  101. package/{chunk-5LQDHFBN.js → chunk-TQEKUOTI.js} +14 -11
  102. package/{chunk-SRG5CNLC.js → chunk-TSPMLCWI.js} +6 -6
  103. package/{chunk-YGILMZ7N.js → chunk-TUSTONB3.js} +1 -1
  104. package/{chunk-YPPKC6FL.js → chunk-U2HBB7RS.js} +17 -17
  105. package/{chunk-HVUDBOQG.js → chunk-VMJVAJ6W.js} +9 -6
  106. package/{chunk-CQVGR3MX.js → chunk-VQ5N5GSV.js} +8 -8
  107. package/{chunk-ABGULE7H.js → chunk-WCFFRBL5.js} +12 -12
  108. package/{chunk-NAOO4PVX.js → chunk-WFDNADFX.js} +16 -16
  109. package/chunk-WFGNWWJI.js +326 -0
  110. package/{chunk-FIYSMXHY.js → chunk-WWTSEBDF.js} +1 -1
  111. package/{chunk-JHF6VLVL.js → chunk-X3E6EHJW.js} +32 -31
  112. package/{chunk-E2BESSAW.js → chunk-X4O7FJF5.js} +2 -0
  113. package/{chunk-C2B7M567.js → chunk-XAG3FWBE.js} +15 -4
  114. package/{chunk-4OKTPFNX.js → chunk-XFXFPUO7.js} +105 -37
  115. package/{chunk-HYKGIXNO.js → chunk-XSW4EXQV.js} +85 -21
  116. package/{chunk-ZADGPNTV.js → chunk-XTJKU3Z4.js} +29 -29
  117. package/{chunk-T43K75CK.js → chunk-YKY4OVOX.js} +15 -15
  118. package/{chunk-ZYA2YDB6.js → chunk-YVFH2MFB.js} +16 -16
  119. package/{chunk-L42CBKBZ.js → chunk-ZEVQHCLM.js} +3 -3
  120. package/{chunk-5RKUPJYL.js → chunk-ZH3KXFHS.js} +11 -3
  121. package/chunk-ZOHO6MOF.js +376 -0
  122. package/{chunk-PXKF5CV4.js → chunk-ZXF6D3I6.js} +10 -8
  123. package/{cliAgentConfigHelpers-QVSQYTKC.js → cliAgentConfigHelpers-BTRHMPW2.js} +14 -14
  124. package/{cliEnvHelpers-D6HMC46Z.js → cliEnvHelpers-CNMP3RDX.js} +2 -2
  125. package/{cliExecutor-4MAX3PZL.js → cliExecutor-K6FDZTQ2.js} +3 -1
  126. package/{cliLocalAgentRecordReader-SPKAJYME.js → cliLocalAgentRecordReader-H3HYQRRR.js} +48 -47
  127. package/{commandRegistry-TKR6OWXP.js → commandRegistry-FVYPE2IN.js} +93 -93
  128. package/{contentThunks-BQWRPCTM.js → contentThunks-GNFPG32S.js} +36 -35
  129. package/{cooldownCommands-FZYQOWI5.js → cooldownCommands-YB5H5BBK.js} +3 -3
  130. package/{createAgentAutomationAction-GFI6SJZV.js → createAgentAutomationAction-PB4QIFQ4.js} +36 -35
  131. package/{createDialogAction-MMBIHFFU.js → createDialogAction-EVTOPY7A.js} +37 -37
  132. package/{createPageAction-EEYUE5FB.js → createPageAction-2UYF2IDZ.js} +39 -38
  133. package/{db-CS4ZJQKV.js → db-M7FU2GNK.js} +9 -6
  134. package/{dbSlice-X4Z4E4QU.js → dbSlice-XRUZOGSU.js} +13 -13
  135. package/{deleteFile-QOOP2UK7.js → deleteFile-6URDHYRB.js} +9 -9
  136. package/{dialogCommands-OXBQ73DD.js → dialogCommands-6SZD4TYP.js} +58 -57
  137. package/{dialogNotifyCommand-VWS5G4OO.js → dialogNotifyCommand-SHGPCU22.js} +17 -17
  138. package/{dialogSlice-KGYIABDY.js → dialogSlice-5EQ2A6LY.js} +34 -33
  139. package/{dialogUsageCommand-FEWCN7IA.js → dialogUsageCommand-W2WCSGKF.js} +6 -6
  140. package/{docCreateCommands-LS32VKY3.js → docCreateCommands-25E6PGN3.js} +53 -51
  141. package/{docDeleteCommands-JTYR5RPH.js → docDeleteCommands-F7ZVGEHW.js} +55 -53
  142. package/{docReadCommands-E5LTVKWN.js → docReadCommands-JY2E5XEN.js} +53 -51
  143. package/{docStore-TVS2FNER.js → docStore-OKKIKLT3.js} +15 -15
  144. package/{docUpdateCommands-I3J3JDZ2.js → docUpdateCommands-OZ4CUSIQ.js} +53 -51
  145. package/{fetchMessages-Q3INLN5F.js → fetchMessages-TQEUZD7H.js} +3 -3
  146. package/{getPricing-VNGFM4PN.js → getPricing-LF5C4XSI.js} +6 -6
  147. package/{handleSendMessageAction-SSON36TJ.js → handleSendMessageAction-LNT7SZND.js} +68 -67
  148. package/{hostCredentialCreate-WTW4THJF.js → hostCredentialCreate-XUU2CSHI.js} +107 -106
  149. package/index.js +54 -16
  150. package/keys-RWF7UCB4.js +1 -1
  151. package/{localDialogRead-V36DX2Q2.js → localDialogRead-CCOCVGAP.js} +2 -2
  152. package/{localRuntimeAdapter-MI2JGXSF.js → localRuntimeAdapter-IBSTMSX7.js} +114 -113
  153. package/{machineCommands-3LROJZDK.js → machineCommands-HSQHDHOT.js} +135 -119
  154. package/{machineWsRunDispatch-BUUJRUUB.js → machineWsRunDispatch-L6H7J66T.js} +105 -104
  155. package/{memberThunks-CFEPHAND.js → memberThunks-7Y3OYSJQ.js} +17 -17
  156. package/{memoryCommands-JQMEJO7J.js → memoryCommands-BC6REPQB.js} +6 -6
  157. package/{overlay-THLKYIWY.js → overlay-BBQZXGYI.js} +5 -3
  158. package/package.json +1 -1
  159. package/{projectArchive-3X54XFVN.js → projectArchive-FQO654Z3.js} +44 -43
  160. package/{providerPresetApply-FO36N5TX.js → providerPresetApply-WHAMP2D5.js} +9 -9
  161. package/{providerRegistry-U2BSFE6K.js → providerRegistry-ZI2KORJ7.js} +9 -9
  162. package/{read-KA3L2V7O.js → read-TYMBGEXO.js} +9 -9
  163. package/{readDocTool-AMAZAPAW.js → readDocTool-SKQVHBLO.js} +1 -1
  164. package/{readlineWorkspace-Z3YUH4SX.js → readlineWorkspace-7U272DSA.js} +4398 -4165
  165. package/{removeDialogAgentAction-JQOJSUM7.js → removeDialogAgentAction-F5QE2O2B.js} +19 -19
  166. package/{runAgentClientLoop-4FCFLMDJ.js → runAgentClientLoop-AF4JQIJ7.js} +72 -71
  167. package/{runtimeDoctorCommands-CXOCVDPU.js → runtimeDoctorCommands-RRKPBGVO.js} +16 -16
  168. package/{secretCommands-GGUAWAE7.js → secretCommands-KZWBZIYS.js} +2 -2
  169. package/{setDialogExtraReferencesAction-YXQTGXIN.js → setDialogExtraReferencesAction-72L27ERM.js} +15 -15
  170. package/{setPrimaryDialogAgentAction-YNLB66WE.js → setPrimaryDialogAgentAction-GJJDUSGJ.js} +19 -19
  171. package/{settingThunks-E6N7RSSS.js → settingThunks-ZRGWVGZD.js} +18 -18
  172. package/{skillDiscovery-B5V23AXP.js → skillDiscovery-BHHPCUHZ.js} +3 -3
  173. package/{spaceCommands-DB5DKC2J.js → spaceCommands-5VNWMDBE.js} +55 -53
  174. package/{store-JRVN62NM.js → store-Z53ICFL3.js} +3 -1
  175. package/{streamAgentChatTurn-FCBGMD4D.js → streamAgentChatTurn-YSPEFY4K.js} +97 -95
  176. package/{switchDialogAgentAction-LAHLUECU.js → switchDialogAgentAction-IIJBPND3.js} +16 -16
  177. package/{tableCommands-VNSXHAMG.js → tableCommands-FTAOCBTX.js} +12 -12
  178. package/{tools-6JD36D6K.js → tools-M35PTIFB.js} +61 -60
  179. package/tuiRestart-2IL37YIB.js +41 -0
  180. package/{tuiSummaryLlmCaller-UHZIPGAX.js → tuiSummaryLlmCaller-W2QN4VAC.js} +21 -21
  181. package/{updateCommands-KZ54HCU5.js → updateCommands-CPATDG6J.js} +8 -6
  182. package/{updateDialogTitleAction-RV3EUEN3.js → updateDialogTitleAction-IMIRJRQQ.js} +36 -35
  183. package/{usageCommand-KFVV6UL3.js → usageCommand-2BF74MKF.js} +2 -2
  184. package/{usageRebuildCommand-HHFSNK46.js → usageRebuildCommand-UHB55BQM.js} +3 -3
  185. package/{windowsSelfUpdate-KERHIAB4.js → windowsSelfUpdate-ZFD6J5HF.js} +2 -2
  186. package/chunk-2WZXXAQD.js +0 -57
  187. package/chunk-BJF2MHJ3.js +0 -118
  188. package/chunk-KEPOVMF4.js +0 -91
  189. package/chunk-PMDVQBGA.js +0 -100
  190. package/chunk-WACI5I6V.js +0 -147
  191. package/{accountResolver-EK2S4PWF.js → accountResolver-QETKNC7T.js} +4 -4
  192. package/{chunk-AGP3YSEC.js → chunk-4N6G2CKP.js} +3 -3
  193. package/{chunk-VXL2FZTP.js → chunk-HXER7YJF.js} +3 -3
  194. package/{chunk-BLVSFYQ3.js → chunk-LISC7BD4.js} +3 -3
  195. package/{chunk-SSGTV4FC.js → chunk-USGHJSGO.js} +5 -5
  196. package/{chunk-IC2I373Q.js → chunk-VS276URX.js} +3 -3
  197. package/{chunk-AETZ7AD6.js → chunk-W6RFEDN4.js} +3 -3
  198. package/{offlineMarxistsAgentCommand-AGA2X5E4.js → offlineMarxistsAgentCommand-XVXUE6G5.js} +5 -5
  199. package/{workloadLifecycle-O2I3NZ2Q.js → workloadLifecycle-HFJIN5IZ.js} +8 -8
@@ -2,8 +2,11 @@ import {
2
2
  findPotentialSecrets
3
3
  } from "./chunk-6QDYSCPW.js";
4
4
  import {
5
- parsePositiveFiniteNumberOrFallback
6
- } from "./chunk-Y5GCAMGP.js";
5
+ applyMemoryInterpreterMutation,
6
+ deriveStateResident,
7
+ resolvePureVNextRuntime,
8
+ touchMemoryItemsInDb
9
+ } from "./chunk-ZOHO6MOF.js";
7
10
  import {
8
11
  getReadableCliDb
9
12
  } from "./chunk-YFLVRVYK.js";
@@ -21,6 +24,7 @@ import {
21
24
  isLiveAgentRunObservation,
22
25
  isMachineBoundLocalhostCustomProvider,
23
26
  isSubtaskRun,
27
+ normalizeCliRunImages,
24
28
  parseAgentRunArgs,
25
29
  parseAgentRunEvent,
26
30
  readFlagValue,
@@ -31,15 +35,7 @@ import {
31
35
  resolveServerUrl,
32
36
  validateInstaboxWorkspaceSelection,
33
37
  writeUsage
34
- } from "./chunk-FKEZOMIF.js";
35
- import {
36
- clearCredentialAvailability,
37
- readEffectiveCredentialEntry
38
- } from "./chunk-FIYSMXHY.js";
39
- import {
40
- readDbRecord,
41
- resolveAgentRecordFromHybridStore
42
- } from "./chunk-5LQDHFBN.js";
38
+ } from "./chunk-DLXMMTGM.js";
43
39
  import {
44
40
  boxGlyphs,
45
41
  displayWidth,
@@ -47,26 +43,22 @@ import {
47
43
  stripAnsi,
48
44
  tokenizeAnsiLine,
49
45
  visibleWidth
50
- } from "./chunk-HYKGIXNO.js";
46
+ } from "./chunk-XSW4EXQV.js";
51
47
  import {
52
- deriveStateResident,
53
- resolvePureVNextRuntime,
54
- touchMemoryItemsInDb
55
- } from "./chunk-PMDVQBGA.js";
48
+ clearCredentialAvailability,
49
+ readEffectiveCredentialEntry
50
+ } from "./chunk-WWTSEBDF.js";
51
+ import {
52
+ CliProviderQuotaError
53
+ } from "./chunk-R7XWZDOH.js";
54
+ import {
55
+ resolveMachineId
56
+ } from "./chunk-S73EPYNC.js";
56
57
  import {
57
- _appendEntityBatch,
58
- _appendEvidenceBatch,
59
- _appendRelationBatch,
60
- _appendRetiredStateBatch,
61
- _appendStateBatch,
62
- getMemoryEntityVNext,
63
- getMemoryEvidenceVNext,
64
58
  getMemoryEvidenceVNextStrict,
65
- getMemoryStateVNext,
66
- listMemoryStatesForEntityVNext,
67
59
  loadMemoryVNextCatalog,
68
60
  putMemoryEvidenceVNext
69
- } from "./chunk-XI2BWJM5.js";
61
+ } from "./chunk-324FWHUA.js";
70
62
  import {
71
63
  rankMemoryCandidates,
72
64
  recallMemoryVNextLocal
@@ -74,8 +66,9 @@ import {
74
66
  import {
75
67
  DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET,
76
68
  EXPLICIT_REMEMBER_PREFIX_REGEX,
77
- buildMemoryOverlay
78
- } from "./chunk-EUCFKKDM.js";
69
+ buildMemoryOverlay,
70
+ emptyMemoryInjectionObservation
71
+ } from "./chunk-4I2MXV5Q.js";
79
72
  import {
80
73
  buildLegacyMemoryEvidence,
81
74
  resolveLegacyMemoryPrincipal
@@ -83,38 +76,27 @@ import {
83
76
  import {
84
77
  isBuiltinNoloAgentRef,
85
78
  resolveLocalUserId
86
- } from "./chunk-T5N6NHAT.js";
87
- import {
88
- CliProviderQuotaError
89
- } from "./chunk-MK2Q7ZJD.js";
90
- import {
91
- resolveMachineId
92
- } from "./chunk-S73EPYNC.js";
79
+ } from "./chunk-HHFGE2WF.js";
93
80
  import {
94
81
  extractGoogleValidationLink
95
82
  } from "./chunk-BMQ2MJUK.js";
96
83
  import {
97
84
  resolveCliLocalRuntimeKeyCapability
98
- } from "./chunk-LXTC53TN.js";
99
- import {
100
- isTransientFetchError
101
- } from "./chunk-KFHREHUQ.js";
85
+ } from "./chunk-GAYNXB6T.js";
102
86
  import {
103
87
  parseUiCard,
104
88
  uiCardFallback
105
- } from "./chunk-GRXSJR2Z.js";
89
+ } from "./chunk-HF7BLF3F.js";
106
90
  import {
107
91
  isGatewayHttpStatus
108
92
  } from "./chunk-NF64D32W.js";
109
93
  import {
110
94
  buildMemorySubjectsForAgent,
111
- resolveAgentMemoryPolicy
112
- } from "./chunk-SW6OD4KE.js";
113
- import {
114
95
  chooseMemoryOwners,
115
96
  loadMemoryCandidatesFromDb,
116
- loadOwnerItemsFromDb
117
- } from "./chunk-BJF2MHJ3.js";
97
+ loadOwnerItemsFromDb,
98
+ resolveAgentMemoryPolicy
99
+ } from "./chunk-4QYJPWHH.js";
118
100
  import {
119
101
  API_REPORTED_COST_MULTIPLIER,
120
102
  estimateMessagesTokens,
@@ -124,7 +106,25 @@ import {
124
106
  resolveAgentContextWindow,
125
107
  resolveOccupancy,
126
108
  resolveOccupancyWindow
127
- } from "./chunk-PVAWNHP5.js";
109
+ } from "./chunk-7BCG67EI.js";
110
+ import {
111
+ parsePositiveFiniteNumberOrFallback
112
+ } from "./chunk-Y5GCAMGP.js";
113
+ import {
114
+ readDbRecord,
115
+ resolveAgentRecordFromHybridStore
116
+ } from "./chunk-TQEKUOTI.js";
117
+ import {
118
+ isTransientFetchError
119
+ } from "./chunk-DXWGFL2Z.js";
120
+ import {
121
+ isCliAuthorityBrokerProtocolError,
122
+ isCliAuthorityBrokerTimeoutError,
123
+ isCliAuthorityBrokerUnavailableError
124
+ } from "./chunk-5ZMIIR23.js";
125
+ import {
126
+ getDefaultCliLocalRuntimeDb
127
+ } from "./chunk-N5Z2V73W.js";
128
128
  import {
129
129
  awaitLocalWriterChild,
130
130
  createRunActivityTracker,
@@ -134,6 +134,7 @@ import {
134
134
  popSingleQueueMessage,
135
135
  readRunRecord,
136
136
  recordRunResultHeaderMeta,
137
+ recordRunStartup,
137
138
  registerLocalForegroundWriter,
138
139
  reportRunProcessIdentity,
139
140
  resolveResultServerMeta,
@@ -141,8 +142,9 @@ import {
141
142
  resolveRunsDir,
142
143
  serverOriginForDialog,
143
144
  settleRunTerminalAuthoritatively,
144
- spawnLocalBackgroundRun
145
- } from "./chunk-XIEYGCN6.js";
145
+ spawnLocalBackgroundRun,
146
+ transitionRunToTerminal
147
+ } from "./chunk-OWKNSIXL.js";
146
148
  import {
147
149
  formatAgentListCard,
148
150
  formatFinishedRunCard,
@@ -153,30 +155,26 @@ import {
153
155
  formatStopRunCard,
154
156
  getAgentRunStatusIcon,
155
157
  isAgentRunTerminalStatus
156
- } from "./chunk-AXYH4734.js";
157
- import {
158
- isCliAuthorityBrokerProtocolError,
159
- isCliAuthorityBrokerTimeoutError,
160
- isCliAuthorityBrokerUnavailableError
161
- } from "./chunk-5ZMIIR23.js";
162
- import {
163
- getDefaultCliLocalRuntimeDb
164
- } from "./chunk-N5Z2V73W.js";
158
+ } from "./chunk-OOJNQK6V.js";
165
159
  import {
166
160
  isLocalCliAgentKey
167
161
  } from "./chunk-BR3GT6MR.js";
168
162
  import {
169
163
  buildSkillDiscoveryContextLayer
170
- } from "./chunk-CKT6QUE2.js";
164
+ } from "./chunk-5YMA6DDZ.js";
171
165
  import {
172
166
  LOCAL_AGENT_CONFIG_MISSING_CODE,
173
167
  LOCAL_TURN_ABORTED_CODE,
174
168
  markCliUserBatchPhase,
175
- readActionGate
176
- } from "./chunk-CVERLOJM.js";
169
+ readActionGate,
170
+ readAgentsMdLayerFromDisk
171
+ } from "./chunk-3QIYD3VM.js";
177
172
  import {
178
173
  resolveAgentRuntimeConfigFromRecord
179
- } from "./chunk-C2B7M567.js";
174
+ } from "./chunk-XAG3FWBE.js";
175
+ import {
176
+ resolveAgentImageInputSupport
177
+ } from "./chunk-DUUDXSLX.js";
180
178
  import {
181
179
  createThinkParserState,
182
180
  flushThinkParser,
@@ -188,18 +186,18 @@ import {
188
186
  isQuotaExhaustedText,
189
187
  resolveAvailabilityAction,
190
188
  resolveCredentialKeyWithFallback
191
- } from "./chunk-HOCHUZQ7.js";
189
+ } from "./chunk-QJTZ76CP.js";
192
190
  import {
193
191
  ATTACHMENT_PART_TYPE,
194
192
  ATTACHMENT_PART_VERSION,
195
193
  describeAttachmentForModel,
196
194
  normalizeAttachmentPart
197
- } from "./chunk-YQETUZ5V.js";
195
+ } from "./chunk-QRGDJA4B.js";
198
196
  import {
199
197
  findCodexOAuthPinnedContextWindow,
200
198
  normalizeUsage,
201
199
  readCacheReadInputTokensOrNull
202
- } from "./chunk-T2BEPTAG.js";
200
+ } from "./chunk-L32W3PRP.js";
203
201
  import {
204
202
  isOAuthApiKeyRef
205
203
  } from "./chunk-UKZX3NHN.js";
@@ -209,7 +207,7 @@ import {
209
207
  import {
210
208
  normalizeRuntimeToolPolicyOverride,
211
209
  resolveEffectiveRuntimeToolPolicy
212
- } from "./chunk-SSGTV4FC.js";
210
+ } from "./chunk-USGHJSGO.js";
213
211
  import {
214
212
  compactWhitespace
215
213
  } from "./chunk-DWLEOOGR.js";
@@ -218,18 +216,12 @@ import {
218
216
  isQuotaExhaustedError
219
217
  } from "./chunk-EWQ3HGNZ.js";
220
218
  import {
221
- isAntigravityOAuthAgent
222
- } from "./chunk-VPAZ6BEN.js";
223
- import {
224
- resolveClientVersion
225
- } from "./chunk-6EDAMVG6.js";
226
- import {
227
- toErrorMessage
228
- } from "./chunk-HNMXYYJR.js";
219
+ estimateTokenCount
220
+ } from "./chunk-PSCNXBYA.js";
229
221
  import {
230
222
  parseExternalSkillMarkdown,
231
223
  parseSkillDocProtocol
232
- } from "./chunk-AETZ7AD6.js";
224
+ } from "./chunk-W6RFEDN4.js";
233
225
  import {
234
226
  BUILTIN_NOLO_AGENT_KEY,
235
227
  BUILTIN_NOLO_AGENT_NAME,
@@ -240,32 +232,25 @@ import {
240
232
  parsePublicAgentId
241
233
  } from "./chunk-M2EJHDJP.js";
242
234
  import {
243
- findModelConfig
244
- } from "./chunk-KYH7XW3K.js";
245
- import {
246
- CLIENT_VERSION_TOO_OLD_CODE,
247
- NOLO_CLIENT_VERSION_HEADER,
248
- buildClientVersionUpgradeMessage
249
- } from "./chunk-OBSEKCVK.js";
250
- import {
251
- asTrimmedLowercaseString
252
- } from "./chunk-QSJ3HFEF.js";
235
+ ulid
236
+ } from "./chunk-OJKUU3LP.js";
253
237
  import {
254
- buildAgentsMdLayer,
255
- buildAgentsMdLayerHeader,
256
238
  buildMemoryOverlayLayer,
257
239
  buildMemoryUseGuidanceLayer,
258
240
  partitionScopedBlocks,
259
241
  renderTurnContextBlocksWithScope
260
- } from "./chunk-JWXITTQB.js";
242
+ } from "./chunk-42OKN2LI.js";
261
243
  import {
262
244
  exitCliFromWatchdog,
263
245
  getLogger,
264
246
  normalizeError
265
- } from "./chunk-YGMBIXCF.js";
247
+ } from "./chunk-6XRPBZRS.js";
266
248
  import {
267
- resolveAuthToken
268
- } from "./chunk-WACI5I6V.js";
249
+ RuntimeProtocolMismatchError,
250
+ RuntimeVersionMismatchError,
251
+ resolveAuthToken,
252
+ validateAgentRunProtocol
253
+ } from "./chunk-BIDSIRTS.js";
269
254
  import {
270
255
  readPipeText,
271
256
  spawnProcess
@@ -276,19 +261,36 @@ import {
276
261
  t,
277
262
  toolLabel,
278
263
  toolLabelVariants
279
- } from "./chunk-OB6DVWPF.js";
264
+ } from "./chunk-262R3XNN.js";
280
265
  import {
281
- ulid
282
- } from "./chunk-OJKUU3LP.js";
266
+ isAntigravityOAuthAgent
267
+ } from "./chunk-7JGMNKKG.js";
268
+ import {
269
+ resolveClientVersion
270
+ } from "./chunk-RTHFJZ6M.js";
271
+ import {
272
+ toErrorMessage
273
+ } from "./chunk-HNMXYYJR.js";
283
274
  import {
284
275
  asTrimmedString
285
276
  } from "./chunk-3EUW3WEO.js";
277
+ import {
278
+ findModelConfig
279
+ } from "./chunk-CD3RU7XL.js";
286
280
  import {
287
281
  asOptionalTrimmedString
288
282
  } from "./chunk-G3SUCT4W.js";
283
+ import {
284
+ CLIENT_VERSION_TOO_OLD_CODE,
285
+ NOLO_CLIENT_VERSION_HEADER,
286
+ buildClientVersionUpgradeMessage
287
+ } from "./chunk-OBSEKCVK.js";
288
+ import {
289
+ asTrimmedLowercaseString
290
+ } from "./chunk-QSJ3HFEF.js";
289
291
 
290
292
  // packages/cli/agentRunCommand.ts
291
- import { createHash as createHash2 } from "node:crypto";
293
+ import { createHash as createHash3 } from "node:crypto";
292
294
 
293
295
  // packages/cli/agentRunLocalWorkspace.ts
294
296
  import { createHash } from "node:crypto";
@@ -423,10 +425,10 @@ async function captureLocalRunBase(cwd, options = {}) {
423
425
  return head;
424
426
  };
425
427
  try {
426
- return await Promise.race([work(), new Promise((resolve5) => {
427
- onAbort = () => resolve5(null);
428
+ return await Promise.race([work(), new Promise((resolve4) => {
429
+ onAbort = () => resolve4(null);
428
430
  controller.signal.addEventListener("abort", onAbort, { once: true });
429
- if (controller.signal.aborted) resolve5(null);
431
+ if (controller.signal.aborted) resolve4(null);
430
432
  })]);
431
433
  } catch {
432
434
  return null;
@@ -602,10 +604,10 @@ async function captureBoundedWorkspace(cwd, options = {}) {
602
604
  const pending = work().finally(() => {
603
605
  activeCommandWorkspaceSamples--;
604
606
  });
605
- return await Promise.race([pending, new Promise((resolve5) => {
606
- onAbort = () => resolve5(null);
607
+ return await Promise.race([pending, new Promise((resolve4) => {
608
+ onAbort = () => resolve4(null);
607
609
  controller.signal.addEventListener("abort", onAbort, { once: true });
608
- if (controller.signal.aborted) resolve5(null);
610
+ if (controller.signal.aborted) resolve4(null);
609
611
  })]);
610
612
  } catch {
611
613
  return null;
@@ -8415,7 +8417,7 @@ function normalizeListLine(line) {
8415
8417
  }
8416
8418
  return line;
8417
8419
  }
8418
- var TOOL_TREE_HEADER_RE = /^•\s+(.+?)\s+\((\d+)\) · (.*?) ✓$/;
8420
+ var TOOL_TREE_HEADER_RE = /^(?:▸|•)\s+(.+?)\s+\((\d+)\) · (.*?) ✓$/;
8419
8421
  var TOOL_SINGLE_RE = /^▸\s+(.+?)(?:\s+·\s+(.*?))?(?:\s{2}(✓|✗|!)(?:\s+(.*))?)$/;
8420
8422
  function plainToolLine(line) {
8421
8423
  return stripAnsi(line);
@@ -8461,23 +8463,40 @@ function statusColorSeq(marker, brightness) {
8461
8463
  if (marker === "\u2717") return colorSeq("danger", brightness);
8462
8464
  return colorSeq("warning", brightness);
8463
8465
  }
8466
+ function styleToolDetailSegments(detail, muted, chrome) {
8467
+ const metaMatch = detail.match(/^(.*?)(\s+·\s+(?:\d+\s+(?:lines?|bytes?\s+written|replacements?|matches?)(?:\s+·\s+truncated)?|truncated))$/);
8468
+ if (!metaMatch) {
8469
+ return `${muted}${detail}${STYLE.reset}`;
8470
+ }
8471
+ return `${muted}${metaMatch[1]}${STYLE.reset}${chrome}${STYLE.dim}${metaMatch[2]}${STYLE.reset}`;
8472
+ }
8464
8473
  function styleTuiToolLine(line, brightness) {
8465
8474
  const plain = plainToolLine(line);
8466
8475
  const chrome = colorSeq("chrome", brightness);
8467
8476
  const muted = colorSeq("muted", brightness);
8477
+ const info = colorSeq("info", brightness);
8478
+ const danger = colorSeq("danger", brightness);
8468
8479
  const header = toolTreeHeaderMatch(plain);
8469
8480
  if (header) {
8470
- return `${chrome}\u2022${STYLE.reset} ${STYLE.bold}${muted}${header[1]}${STYLE.reset} ${chrome}${STYLE.dim}(${header[2]})${STYLE.reset} ${chrome}\xB7 ${header[3]}${STYLE.reset} ${statusColorSeq("\u2713", brightness)}\u2713${STYLE.reset}`;
8481
+ const glyph = plain.startsWith("\u2022") ? "\u2022" : "\u25B8";
8482
+ return `${chrome}${glyph}${STYLE.reset} ${STYLE.bold}${info}${header[1]}${STYLE.reset} ${chrome}${STYLE.dim}(${header[2]})${STYLE.reset} ${chrome}\xB7${STYLE.reset} ${muted}${header[3]}${STYLE.reset} ${statusColorSeq("\u2713", brightness)}\u2713${STYLE.reset}`;
8471
8483
  }
8472
8484
  const single = plain.match(TOOL_SINGLE_RE);
8473
8485
  if (single) {
8474
8486
  const [, label, detail, marker, statusDetail] = single;
8475
- let rendered = `${chrome}\u25B8${STYLE.reset} ${STYLE.bold}${muted}${label}${STYLE.reset}`;
8476
- if (detail) rendered += ` ${chrome}\xB7 ${detail}${STYLE.reset}`;
8487
+ const isError = marker === "\u2717";
8488
+ const labelColor = isError ? danger : info;
8489
+ let rendered = `${chrome}\u25B8${STYLE.reset} ${STYLE.bold}${labelColor}${label}${STYLE.reset}`;
8490
+ if (detail) {
8491
+ rendered += ` ${chrome}\xB7${STYLE.reset} ${styleToolDetailSegments(detail, muted, chrome)}`;
8492
+ }
8477
8493
  rendered += ` ${statusColorSeq(marker, brightness)}${marker}${STYLE.reset}`;
8478
8494
  if (statusDetail) {
8479
- const metaSeq = marker === "\u2713" ? chrome : statusColorSeq(marker, brightness);
8480
- rendered += ` ${metaSeq}${STYLE.dim}${statusDetail}${STYLE.reset}`;
8495
+ if (isError) {
8496
+ rendered += ` ${danger}${statusDetail}${STYLE.reset}`;
8497
+ } else {
8498
+ rendered += ` ${chrome}${STYLE.dim}${statusDetail}${STYLE.reset}`;
8499
+ }
8481
8500
  }
8482
8501
  return rendered;
8483
8502
  }
@@ -9008,6 +9027,9 @@ function formatAssistantTextForCli(text) {
9008
9027
  return text.replace(/\u003cthink\u003e[\s\S]*?\u003c\/think\u003e\s*/gi, "").replace(/\n{3,}/g, "\n\n").trim();
9009
9028
  }
9010
9029
 
9030
+ // packages/cli/client/toolOutput.ts
9031
+ import { createHash as createHash2 } from "node:crypto";
9032
+
9011
9033
  // packages/cli/tui/tuiLayout.ts
9012
9034
  var DEFAULT_TERMINAL_ROWS = 24;
9013
9035
  var DEFAULT_TERMINAL_COLUMNS = 80;
@@ -9039,19 +9061,231 @@ function resolveHistoryViewportHeight(terminalRows, composerRows, foregroundRese
9039
9061
  return Math.max(0, rows - composer - reserved);
9040
9062
  }
9041
9063
 
9042
- // packages/cli/tui/redactSecrets.ts
9064
+ // packages/core/redactSecrets.ts
9043
9065
  var REDACTED = "\u27E8redacted\u27E9";
9044
9066
  function redactSecrets(text) {
9045
- return text.replace(/\b(?:sk|pk)-[A-Za-z0-9_-]{10,}/g, REDACTED).replace(/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{12,}/gi, `$1${REDACTED}`).replace(
9046
- /\b((?:api[_-]?key|apikey|access[_-]?token|auth[_-]?token|token|secret|password|passwd|credential)s?\s*[=:]\s*["']?)[^\s"',;]{8,}/gi,
9067
+ return text.replace(/\b(?:sk|pk)-[A-Za-z0-9_-]{10,}/g, REDACTED).replace(
9068
+ /\b(Authorization:\s*Basic\s+)[A-Za-z0-9._~+/=-]{8,}/gi,
9047
9069
  `$1${REDACTED}`
9070
+ ).replace(/\b(Bearer\s+)[A-Za-z0-9._~+/=-]{12,}/gi, `$1${REDACTED}`).replace(
9071
+ /(^|\s)((?:--[a-z0-9-]*(?:token|key|secret|password|credential)[a-z0-9-]*)(?:[^\S\r\n]*=[^\S\r\n]*|[^\S\r\n]+))(?:"(?:\\[^\r\n]|[^"\\\r\n]){8,}(?:"|(?=[\r\n]|$))|'(?:\\[^\r\n]|[^'\\\r\n]){8,}(?:'|(?=[\r\n]|$))|[^\s"']{8,})/gi,
9072
+ `$1$2${REDACTED}`
9048
9073
  ).replace(
9049
- /\b((?:--[a-z-]*(?:token|key|secret|password|credential)[a-z-]*)\s+)[^\s"']{8,}/gi,
9074
+ /(^|[^\w-])((?:[A-Z0-9]+_)*(?:API[_-]?KEY|APIKEY|ACCESS[_-]?TOKEN|AUTH[_-]?TOKEN|TOKEN|SECRET|PASSWORD|PASSWD|CREDENTIALS?|KEY)\s*[=:]\s*)(?:"(?:\\[^\r\n]|[^"\\\r\n]){8,}(?:"|(?=[\r\n]|$))|'(?:\\[^\r\n]|[^'\\\r\n]){8,}(?:'|(?=[\r\n]|$))|[^\s"',;]{8,})/g,
9075
+ `$1$2${REDACTED}`
9076
+ ).replace(
9077
+ /\b((?:api[_-]?key|apikey|access[_-]?token|auth[_-]?token|token|secret|password|passwd|credential)s?\s*[=:]\s*)(?:"(?:\\[^\r\n]|[^"\\\r\n]){8,}(?:"|(?=[\r\n]|$))|'(?:\\[^\r\n]|[^'\\\r\n]){8,}(?:'|(?=[\r\n]|$))|[^\s"',;]{8,})/gi,
9050
9078
  `$1${REDACTED}`
9051
9079
  );
9052
9080
  }
9053
9081
 
9054
- // packages/cli/tui/shellCommandGist.ts
9082
+ // packages/cli/tui/redactSecrets.ts
9083
+ var NORMAL_GIST_SECRET_PATTERNS = [
9084
+ /\bbearer\s+[A-Za-z0-9._~+/=-]{8,}/i,
9085
+ /\bsk-(?:ant-)?(?:api)?[0-9a-zA-Z-]{10,}/,
9086
+ /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{10,}/,
9087
+ /\bxox[baprs]-[A-Za-z0-9-]{10,}/
9088
+ ];
9089
+ function withholdIfSecretLike(gist) {
9090
+ if (!gist) return "";
9091
+ if (findPotentialSecrets(gist).length > 0) return "";
9092
+ if (NORMAL_GIST_SECRET_PATTERNS.some((pattern) => pattern.test(gist))) return "";
9093
+ return gist;
9094
+ }
9095
+
9096
+ // packages/core/shellCommandGist.ts
9097
+ function shellWords(text, validationOnly = false) {
9098
+ const words2 = [];
9099
+ let word = "", started = false;
9100
+ let quote;
9101
+ for (let i = 0; i < text.length; i++) {
9102
+ const ch = text[i];
9103
+ if (ch === "\\" && quote !== "'") {
9104
+ const next = text[++i];
9105
+ if (next === void 0) return null;
9106
+ word += next;
9107
+ started = true;
9108
+ continue;
9109
+ }
9110
+ if (ch === "$" && quote !== "'" || ch === "`" && quote !== "'") return null;
9111
+ if (quote) {
9112
+ if (ch === quote) quote = void 0;
9113
+ else word += ch;
9114
+ continue;
9115
+ }
9116
+ if (ch === "'" || ch === '"') {
9117
+ quote = ch;
9118
+ started = true;
9119
+ continue;
9120
+ }
9121
+ if (validationOnly && (ch === "|" || ch === "~")) {
9122
+ word += ch;
9123
+ started = true;
9124
+ continue;
9125
+ }
9126
+ if (/[<> &|;(){}*?\[\]#~]/.test(ch) && !/\s/.test(ch)) return null;
9127
+ if (/\s/.test(ch)) {
9128
+ if (started) words2.push(word);
9129
+ word = "";
9130
+ started = false;
9131
+ } else {
9132
+ word += ch;
9133
+ started = true;
9134
+ }
9135
+ }
9136
+ if (quote) return null;
9137
+ if (started) words2.push(word);
9138
+ return words2;
9139
+ }
9140
+ function isSafeGitTarget(token) {
9141
+ if (!token || token.startsWith("-")) return false;
9142
+ if (/:\/\/|@/.test(token)) return false;
9143
+ return true;
9144
+ }
9145
+ function clipShortText(text, maxLen = 24) {
9146
+ const oneLine = text.replace(/\s+/g, " ").trim();
9147
+ if (!oneLine) return "";
9148
+ return oneLine.length <= maxLen ? oneLine : `${oneLine.slice(0, maxLen - 1)}\u2026`;
9149
+ }
9150
+ function parseGit(rest) {
9151
+ const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
9152
+ if (!tokens2) return null;
9153
+ let i = 0, context;
9154
+ while (tokens2[i]?.startsWith("-")) {
9155
+ const option = tokens2[i++];
9156
+ if (["-C", "-c", "--git-dir", "--work-tree"].includes(option)) {
9157
+ const value = tokens2[i++];
9158
+ if (!value || value.startsWith("-")) return null;
9159
+ if (option === "-C") context = value;
9160
+ } else if (!/^(--git-dir|--work-tree)=.+/.test(option) && !["--no-pager", "--no-optional-locks", "--literal-pathspecs"].includes(option)) return null;
9161
+ }
9162
+ const sub = tokens2[i++];
9163
+ const args = tokens2.slice(i);
9164
+ const result = (action, object, readOnly) => ({ action, object, context, readOnly });
9165
+ if (sub === "worktree") {
9166
+ const operation = args.shift();
9167
+ const operands = [];
9168
+ let end = false;
9169
+ for (let j = 0; j < args.length; j++) {
9170
+ const token = args[j];
9171
+ if (!end && token === "--") {
9172
+ end = true;
9173
+ continue;
9174
+ }
9175
+ if (!end && token.startsWith("-")) {
9176
+ if (operation === "add" && ["-b", "-B", "--reason"].includes(token)) {
9177
+ if (!args[++j] || args[j].startsWith("-")) return null;
9178
+ } else if (!(operation === "add" && ["--detach", "--checkout", "--no-checkout", "--lock"].includes(token)) && !(operation === "list" && ["--porcelain", "-v", "--verbose", "-z"].includes(token)) && !(operation === "remove" && ["-f", "--force"].includes(token))) return null;
9179
+ } else operands.push(token);
9180
+ }
9181
+ if (operation === "list" && !operands.length) return result("\u5217\u51FA\u5DE5\u4F5C\u533A", void 0, true);
9182
+ if (operation === "add" && operands.length >= 1 && operands.length <= 2) return result("\u521B\u5EFA\u5DE5\u4F5C\u533A", operands[0], false);
9183
+ if (operation === "remove" && operands.length === 1) return result("\u79FB\u9664\u5DE5\u4F5C\u533A", operands[0], false);
9184
+ return null;
9185
+ }
9186
+ if (sub === "branch") {
9187
+ let mode = "create", end = false;
9188
+ const operands = [];
9189
+ for (const token of args) {
9190
+ if (!end && token === "--") {
9191
+ end = true;
9192
+ continue;
9193
+ }
9194
+ if (!end && token.startsWith("-")) {
9195
+ if (["-d", "-D", "--delete"].includes(token) && mode === "create") mode = "delete";
9196
+ else if (["--list", "-a", "--all", "-r", "--remotes", "-v", "-vv", "--show-current"].includes(token) && mode === "create") mode = "list";
9197
+ else return null;
9198
+ } else operands.push(token);
9199
+ }
9200
+ if (mode === "delete" && operands.length === 1) return result("\u5220\u9664\u5206\u652F", operands[0], false);
9201
+ if (mode === "list" || !args.length) return result("\u5217\u51FA\u5206\u652F", void 0, true);
9202
+ if (mode === "create" && operands.length >= 1 && operands.length <= 2) return result("\u521B\u5EFA\u5206\u652F", operands[0], false);
9203
+ return null;
9204
+ }
9205
+ if (sub === "checkout" && args.some((t2) => t2 === "." || t2 === "--" || t2.includes("/"))) return null;
9206
+ const nonFlagArgs = (list) => {
9207
+ const out = [];
9208
+ for (let j = 0; j < list.length; j++) {
9209
+ const tok = list[j];
9210
+ if (tok === "--") {
9211
+ out.push(...list.slice(j + 1));
9212
+ break;
9213
+ }
9214
+ if (tok.startsWith("-")) {
9215
+ if (["-m", "-F", "-b", "-B", "-n", "--max-count", "--format", "--pretty", "--since", "--until", "--author", "-U"].includes(tok)) j++;
9216
+ continue;
9217
+ }
9218
+ out.push(tok);
9219
+ }
9220
+ return out;
9221
+ };
9222
+ switch (sub) {
9223
+ case "status":
9224
+ return result("\u67E5\u72B6\u6001", void 0, true);
9225
+ case "log":
9226
+ return result("\u67E5\u5386\u53F2", void 0, true);
9227
+ case "rev-list":
9228
+ return result("\u7EDF\u8BA1\u63D0\u4EA4", void 0, true);
9229
+ case "merge-base":
9230
+ return result("\u67E5\u5171\u540C\u7956\u5148", void 0, true);
9231
+ case "rev-parse":
9232
+ return result("\u67E5\u4ED3\u5E93\u4FE1\u606F", void 0, true);
9233
+ case "show": {
9234
+ const target = nonFlagArgs(args)[0];
9235
+ return result("\u770B\u63D0\u4EA4", isSafeGitTarget(target) ? clipShortText(target, 20) : void 0, true);
9236
+ }
9237
+ case "diff": {
9238
+ const target = nonFlagArgs(args).find(isSafeGitTarget);
9239
+ return result("\u770B\u5DEE\u5F02", target ? baseName(target) ?? clipShortText(target, 20) : void 0, true);
9240
+ }
9241
+ case "tag": {
9242
+ const hasMutating = args.some((t2) => ["-d", "--delete", "-a", "-s", "-f", "--force"].includes(t2)) || nonFlagArgs(args).length > 0;
9243
+ return hasMutating ? result("\u7BA1\u6807\u7B7E", void 0, false) : result("\u67E5\u6807\u7B7E", void 0, true);
9244
+ }
9245
+ case "add": {
9246
+ if (args.some((t2) => t2 === "-A" || t2 === "--all" || t2 === ".")) return result("\u6682\u5B58\u5168\u90E8\u4FEE\u6539", void 0, false);
9247
+ const files = nonFlagArgs(args).filter(isSafeGitTarget);
9248
+ if (files.length === 1) return result("\u6682\u5B58", baseName(files[0]) ?? files[0], false);
9249
+ if (files.length > 1) return result("\u6682\u5B58", `${files.length} \u9879`, false);
9250
+ return result("\u6682\u5B58\u4FEE\u6539", void 0, false);
9251
+ }
9252
+ case "commit":
9253
+ return result("\u63D0\u4EA4", void 0, false);
9254
+ case "merge": {
9255
+ const branch = nonFlagArgs(args).find(isSafeGitTarget);
9256
+ return result("\u5408\u5E76", branch ? clipShortText(branch, 28) : void 0, false);
9257
+ }
9258
+ case "checkout":
9259
+ case "switch": {
9260
+ const branch = nonFlagArgs(args).find(isSafeGitTarget);
9261
+ return result("\u5207\u6362\u5206\u652F", branch ? clipShortText(branch, 28) : void 0, false);
9262
+ }
9263
+ case "push": {
9264
+ const parts = nonFlagArgs(args).filter(isSafeGitTarget);
9265
+ const target = parts.length >= 2 ? `${parts[0]}/${parts[1]}` : parts[0];
9266
+ return result("\u63A8\u9001", target ? clipShortText(target, 28) : void 0, false);
9267
+ }
9268
+ case "pull": {
9269
+ const parts = nonFlagArgs(args).filter(isSafeGitTarget);
9270
+ const target = parts.length >= 2 ? `${parts[0]}/${parts[1]}` : parts[0];
9271
+ return result("\u62C9\u53D6", target ? clipShortText(target, 28) : void 0, false);
9272
+ }
9273
+ case "fetch": {
9274
+ const remote = nonFlagArgs(args).find(isSafeGitTarget);
9275
+ return result("\u83B7\u53D6\u8FDC\u7AEF", remote ? clipShortText(remote, 24) : void 0, true);
9276
+ }
9277
+ case "stash": {
9278
+ const op = nonFlagArgs(args)[0];
9279
+ return op === "list" ? result("\u67E5\u8D2E\u85CF", void 0, true) : result("\u6682\u5B58", void 0, false);
9280
+ }
9281
+ case "reset":
9282
+ return result("\u91CD\u7F6E", void 0, false);
9283
+ case "restore":
9284
+ return result("\u6062\u590D\u6587\u4EF6", void 0, false);
9285
+ default:
9286
+ return null;
9287
+ }
9288
+ }
9055
9289
  function baseName(path2) {
9056
9290
  const cleaned = path2.replace(/^['"]|['"]$/g, "").replace(/\/+$/, "");
9057
9291
  if (!cleaned || cleaned === "." || cleaned === "..") return void 0;
@@ -9113,9 +9347,14 @@ function splitSegments(command) {
9113
9347
  return { segments, hasFallback };
9114
9348
  }
9115
9349
  function stripEnvAssignments(segment) {
9116
- let rest = segment;
9117
- while (/^[A-Za-z_][A-Za-z0-9_]*=\S*\s+/.test(rest)) {
9118
- rest = rest.replace(/^[A-Za-z_][A-Za-z0-9_]*=\S*\s+/, "");
9350
+ let rest = segment.trimStart();
9351
+ if (/^export\s+[A-Za-z_][A-Za-z0-9_]*=/.test(rest)) {
9352
+ rest = rest.replace(/^export\s+/, "");
9353
+ }
9354
+ while (/^[A-Za-z_][A-Za-z0-9_]*=(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\S*)\s*/.test(rest)) {
9355
+ const next = rest.replace(/^[A-Za-z_][A-Za-z0-9_]*=(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\S*)\s*/, "");
9356
+ if (next === rest) break;
9357
+ rest = next;
9119
9358
  }
9120
9359
  return rest;
9121
9360
  }
@@ -9123,182 +9362,399 @@ function firstVerbToken(segment) {
9123
9362
  let rest = stripEnvAssignments(segment).trim();
9124
9363
  const wrappers = /* @__PURE__ */ new Set(["sudo", "env", "command", "time", "nohup", "exec"]);
9125
9364
  let guard = 0;
9126
- while (guard++ < 5) {
9365
+ while (guard++ < 6) {
9127
9366
  const before = rest;
9128
9367
  rest = stripEnvAssignments(rest).trim();
9129
9368
  const m = rest.match(/^(\S+)\s*(.*)$/s);
9130
9369
  if (!m) return { verb: "", rest: "" };
9131
9370
  const [, word, restAfter] = m;
9132
- if (wrappers.has(word) && restAfter.trim()) {
9371
+ const base = word.replace(/^.*\//, "");
9372
+ if (wrappers.has(base) && restAfter.trim()) {
9133
9373
  rest = restAfter.trim();
9134
9374
  continue;
9135
9375
  }
9376
+ if (base === "timeout" && restAfter.trim()) {
9377
+ const tokens2 = shellWords(restAfter.trim());
9378
+ if (!tokens2 || tokens2.length < 2) return { verb: "timeout", rest: restAfter.trim() };
9379
+ let idx = 0;
9380
+ while (idx < tokens2.length && tokens2[idx].startsWith("-")) {
9381
+ const opt = tokens2[idx++];
9382
+ if (["-k", "-s", "--kill-after", "--signal"].includes(opt)) idx++;
9383
+ }
9384
+ if (idx < tokens2.length && /^\d+(?:\.\d+)?[smhd]?$/i.test(tokens2[idx])) idx++;
9385
+ if (idx < tokens2.length) {
9386
+ const inner = tokens2.slice(idx).map((q) => /\s/.test(q) ? JSON.stringify(q) : q).join(" ");
9387
+ rest = inner;
9388
+ continue;
9389
+ }
9390
+ }
9136
9391
  if (before !== rest && !rest) return { verb: "", rest: "" };
9137
- return { verb: word.replace(/^.*\//, ""), rest: restAfter.trim() };
9392
+ return { verb: base, rest: restAfter.trim() };
9138
9393
  }
9139
9394
  return { verb: "", rest };
9140
9395
  }
9396
+ function extractSafeSearchTarget(rest) {
9397
+ const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
9398
+ if (!tokens2) return void 0;
9399
+ const valuedOpts = /* @__PURE__ */ new Set(["-e", "-f", "-g", "--glob", "-t", "--type", "-T", "--type-not", "-A", "-B", "-C", "-m", "--max-count", "--max-filesize", "--color", "--sort"]);
9400
+ let hasExtendedRegex = false;
9401
+ let pattern;
9402
+ for (let i = 0; i < tokens2.length; i++) {
9403
+ const tok = tokens2[i];
9404
+ if (tok === "--") {
9405
+ pattern = tokens2[i + 1];
9406
+ break;
9407
+ }
9408
+ if (tok.startsWith("-")) {
9409
+ if (tok === "-E" || tok === "-P" || tok === "--extended-regexp") hasExtendedRegex = true;
9410
+ if (valuedOpts.has(tok)) {
9411
+ if (tok === "-e" && !pattern && tokens2[i + 1]) pattern = tokens2[i + 1];
9412
+ i++;
9413
+ }
9414
+ continue;
9415
+ }
9416
+ pattern = tok;
9417
+ break;
9418
+ }
9419
+ if (!pattern || hasExtendedRegex || /[|[\]^$()*+?\\]/.test(pattern)) return void 0;
9420
+ return clipShortText(pattern, 22);
9421
+ }
9422
+ function parseSed(rest) {
9423
+ const rawTokens = shellWords(rest.split(/\s+\|\s+/)[0]);
9424
+ if (!rawTokens) return null;
9425
+ let quiet = false;
9426
+ let inPlace = false;
9427
+ const scripts = [];
9428
+ const positional = [];
9429
+ for (let i = 0; i < rawTokens.length; i++) {
9430
+ const tok = rawTokens[i];
9431
+ if (tok === "--") {
9432
+ positional.push(...rawTokens.slice(i + 1));
9433
+ break;
9434
+ }
9435
+ if (tok.startsWith("-") && tok.length > 1) {
9436
+ if (tok === "--quiet" || tok === "--silent") {
9437
+ quiet = true;
9438
+ continue;
9439
+ }
9440
+ if (tok === "--in-place" || tok.startsWith("--in-place=")) {
9441
+ inPlace = true;
9442
+ continue;
9443
+ }
9444
+ if (tok === "--regexp-extended") continue;
9445
+ if (tok.startsWith("--expression=")) {
9446
+ scripts.push(tok.slice("--expression=".length));
9447
+ continue;
9448
+ }
9449
+ if (tok === "--expression") {
9450
+ if (rawTokens[i + 1] === void 0) return null;
9451
+ scripts.push(rawTokens[++i]);
9452
+ continue;
9453
+ }
9454
+ if (tok.startsWith("--")) return null;
9455
+ for (let c = 1; c < tok.length; c++) {
9456
+ const flag = tok[c];
9457
+ if (flag === "n") {
9458
+ quiet = true;
9459
+ continue;
9460
+ }
9461
+ if (flag === "r" || flag === "E") continue;
9462
+ if (flag === "i") {
9463
+ inPlace = true;
9464
+ if (c === tok.length - 1 && rawTokens[i + 1] === "") i++;
9465
+ break;
9466
+ }
9467
+ if (flag === "e") {
9468
+ if (c + 1 < tok.length) {
9469
+ scripts.push(tok.slice(c + 1));
9470
+ } else {
9471
+ if (rawTokens[i + 1] === void 0) return null;
9472
+ scripts.push(rawTokens[++i]);
9473
+ }
9474
+ break;
9475
+ }
9476
+ return null;
9477
+ }
9478
+ continue;
9479
+ }
9480
+ positional.push(tok);
9481
+ }
9482
+ const isSedScript = (tok) => /^(?:\d+|\$)(?:,\s*(?:\d+|\$))?[pdq=!]?$/.test(tok) || /^s[|/#]/.test(tok) || /^\/.*\/[pd=!]?$/.test(tok) || /^\d+[ew]/.test(tok);
9483
+ for (const tok of positional) {
9484
+ if (isSedScript(tok)) scripts.push(tok);
9485
+ }
9486
+ const files = positional.filter((t2) => !isSedScript(t2));
9487
+ if (scripts.length === 0 && files.length >= 2) {
9488
+ scripts.push(files.shift());
9489
+ }
9490
+ const fileToken = files[files.length - 1];
9491
+ const target = fileToken ? baseName(fileToken) : void 0;
9492
+ if (inPlace) {
9493
+ const isSafeSub = (part) => {
9494
+ if (part.length < 4 || part[0] !== "s") return false;
9495
+ const delim = part[1];
9496
+ if (delim !== "|" && delim !== "/" && delim !== "#") return false;
9497
+ let delimsSeen = 1;
9498
+ let idx = 2;
9499
+ for (; idx < part.length && delimsSeen < 3; idx++) {
9500
+ const ch = part[idx];
9501
+ if (ch === "\\" && idx + 1 < part.length) {
9502
+ idx++;
9503
+ continue;
9504
+ }
9505
+ if (ch === delim) delimsSeen++;
9506
+ }
9507
+ if (delimsSeen !== 3) return false;
9508
+ return /^[gipI]*$/.test(part.slice(idx));
9509
+ };
9510
+ const allSafe = scripts.every((s) => {
9511
+ const parts = s.split(";").map((p) => p.trim()).filter(Boolean);
9512
+ return parts.length > 0 && parts.every(isSafeSub);
9513
+ });
9514
+ if (!allSafe) return null;
9515
+ const replaceCount = (rest.match(/s[|/#][^|/#]*[|/#][^|/#]*[|/#]/g) ?? []).length;
9516
+ return {
9517
+ verb: "\u7F16\u8F91",
9518
+ target,
9519
+ count: replaceCount > 1 ? replaceCount : void 0,
9520
+ unit: "\u5904\u66FF\u6362",
9521
+ readOnly: false
9522
+ };
9523
+ }
9524
+ if (quiet) {
9525
+ const isStrictReadOnlyPrint = (s) => /^(?:\d+|\$)(?:\s*,\s*(?:\d+|\$))?\s*p$/.test(s.trim());
9526
+ if (scripts.length === 0 || !scripts.every(isStrictReadOnlyPrint)) {
9527
+ return null;
9528
+ }
9529
+ return { verb: "\u67E5\u770B", target, readOnly: true };
9530
+ }
9531
+ return { verb: "\u5904\u7406\u6587\u672C", target, readOnly: false };
9532
+ }
9533
+ function parseNolo(rest) {
9534
+ const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
9535
+ if (!tokens2 || tokens2.length === 0) return null;
9536
+ const sub = tokens2[0];
9537
+ const action = tokens2[1];
9538
+ const nonFlag = tokens2.slice(2).filter((t2) => !t2.startsWith("-"));
9539
+ if (sub === "browser" || sub === "chrome") {
9540
+ const map = {
9541
+ status: ["\u67E5\u6D4F\u89C8\u5668\u72B6\u6001", true],
9542
+ "list-tabs": ["\u5217\u6D4F\u89C8\u5668\u6807\u7B7E", true],
9543
+ "read-page": ["\u6D4F\u89C8\u5668\u8BFB\u9875\u9762", true],
9544
+ "read-network": ["\u67E5\u6D4F\u89C8\u5668\u8BF7\u6C42", true],
9545
+ screenshot: ["\u6D4F\u89C8\u5668\u622A\u56FE", true],
9546
+ "open-tab": ["\u6D4F\u89C8\u5668\u5F00\u6807\u7B7E", false],
9547
+ click: ["\u6D4F\u89C8\u5668\u70B9\u51FB", false],
9548
+ type: ["\u6D4F\u89C8\u5668\u8F93\u5165", false],
9549
+ press: ["\u6D4F\u89C8\u5668\u6309\u952E", false]
9550
+ };
9551
+ if (action && map[action]) return { verb: map[action][0], readOnly: map[action][1] };
9552
+ return { verb: "\u6D4F\u89C8\u5668\u64CD\u4F5C", readOnly: false };
9553
+ }
9554
+ if (sub === "agent") {
9555
+ if (action === "list" || action === "providers" || action === "models") return { verb: action === "list" ? "\u5217\u667A\u80FD\u4F53" : "\u5217\u6A21\u578B\u901A\u9053", readOnly: true };
9556
+ if (action === "read") return { verb: "\u8BFB\u667A\u80FD\u4F53", target: nonFlag[0] ? clipShortText(nonFlag[0], 24) : void 0, readOnly: true };
9557
+ if (action === "create") return { verb: "\u521B\u5EFA\u667A\u80FD\u4F53", target: nonFlag[0] ? clipShortText(nonFlag[0], 24) : void 0, readOnly: false };
9558
+ if (action === "delete") return { verb: "\u5220\u9664\u667A\u80FD\u4F53", target: nonFlag[0] ? clipShortText(nonFlag[0], 24) : void 0, readOnly: false };
9559
+ return { verb: "\u7BA1\u7406\u667A\u80FD\u4F53", readOnly: false };
9560
+ }
9561
+ if (sub === "dialog") {
9562
+ if (action === "list") return { verb: "\u5217\u5BF9\u8BDD", readOnly: true };
9563
+ if (action === "read") return { verb: "\u8BFB\u5BF9\u8BDD", target: nonFlag[0] ? clipShortText(nonFlag[0], 20) : void 0, readOnly: true };
9564
+ if (action === "status") return { verb: "\u67E5\u5BF9\u8BDD\u72B6\u6001", readOnly: true };
9565
+ if (action === "search") return { verb: "\u641C\u5BF9\u8BDD", readOnly: true };
9566
+ return { verb: "\u7BA1\u5BF9\u8BDD", readOnly: false };
9567
+ }
9568
+ if (sub === "secret") {
9569
+ if (action === "list") return { verb: "\u5217\u51ED\u636E", readOnly: true };
9570
+ if (action === "run") return { verb: "\u5E26\u51ED\u636E\u6267\u884C", readOnly: false };
9571
+ return { verb: "\u7BA1\u51ED\u636E", readOnly: false };
9572
+ }
9573
+ if (sub === "ci") return { verb: "\u67E5 CI \u72B6\u6001", readOnly: true };
9574
+ return null;
9575
+ }
9141
9576
  function classifySegment(segment) {
9142
9577
  const { verb, rest } = firstVerbToken(segment);
9143
9578
  if (!verb) return null;
9144
9579
  switch (verb) {
9145
9580
  case "cd":
9146
- return { verb: "\u8FDB\u5165\u76EE\u5F55", target: baseName(rest) };
9581
+ return { verb: "\u8FDB\u5165\u76EE\u5F55", target: baseName(rest), readOnly: true };
9147
9582
  case "mkdir":
9148
- return { verb: "\u5EFA\u76EE\u5F55", target: baseName(rest.replace(/^-\S+\s+/, "")) };
9583
+ return { verb: "\u5EFA\u76EE\u5F55", target: baseName(rest.replace(/^-\S+\s+/, "")), readOnly: false };
9149
9584
  case "cp":
9150
- return { verb: "\u590D\u5236", target: baseName(rest.split(/\s+/).pop() ?? "") };
9585
+ return { verb: "\u590D\u5236", target: baseName(rest.split(/\s+/).pop() ?? ""), readOnly: false };
9151
9586
  case "mv":
9152
- return { verb: "\u79FB\u52A8", target: baseName(rest.split(/\s+/).pop() ?? "") };
9587
+ return { verb: "\u79FB\u52A8", target: baseName(rest.split(/\s+/).pop() ?? ""), readOnly: false };
9153
9588
  case "rm":
9154
- return { verb: "\u5220\u9664", target: baseName(rest.split(/\s+/).pop() ?? "") };
9589
+ return { verb: "\u5220\u9664", target: baseName(rest.split(/\s+/).pop() ?? ""), readOnly: false };
9155
9590
  case "touch":
9156
- return { verb: "\u521B\u5EFA\u6587\u4EF6", target: baseName(rest) };
9157
- case "cat":
9158
- return { verb: "\u8BFB\u53D6", target: baseName(rest.split(/\s+/)[0] ?? "") };
9159
- case "ls":
9160
- return { verb: "\u5217\u51FA\u76EE\u5F55" };
9591
+ return { verb: "\u521B\u5EFA\u6587\u4EF6", target: baseName(rest), readOnly: false };
9592
+ case "cat": {
9593
+ const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
9594
+ const file = tokens2?.find((t2) => !t2.startsWith("-"));
9595
+ return { verb: "\u8BFB\u53D6", target: baseName(file ?? rest.split(/\s+/)[0] ?? ""), readOnly: true };
9596
+ }
9597
+ case "ls": {
9598
+ const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
9599
+ const dir = tokens2?.find((t2) => !t2.startsWith("-"));
9600
+ return { verb: "\u5217\u51FA\u76EE\u5F55", target: dir ? baseName(dir) : void 0, readOnly: true };
9601
+ }
9161
9602
  case "grep":
9162
9603
  case "rg":
9163
- return { verb: "\u641C\u7D22" };
9604
+ return { verb: "\u641C\u7D22", target: extractSafeSearchTarget(rest), readOnly: true };
9164
9605
  case "chmod":
9165
- return { verb: "\u6539\u6743\u9650", target: baseName(rest.split(/\s+/).pop() ?? "") };
9606
+ return { verb: "\u6539\u6743\u9650", target: baseName(rest.split(/\s+/).pop() ?? ""), readOnly: false };
9166
9607
  case "chown":
9167
- return { verb: "\u6539\u5C5E\u4E3B", target: baseName(rest.split(/\s+/).pop() ?? "") };
9608
+ return { verb: "\u6539\u5C5E\u4E3B", target: baseName(rest.split(/\s+/).pop() ?? ""), readOnly: false };
9168
9609
  case "tar":
9169
9610
  case "unzip":
9170
- return { verb: "\u89E3\u538B" };
9611
+ return { verb: "\u89E3\u538B", readOnly: false };
9171
9612
  case "git": {
9172
- const rawTokens = rest.split(/\s+/).filter(Boolean);
9173
- const subIndex = rawTokens.findIndex((t2) => !t2.startsWith("-"));
9174
- const sub = subIndex >= 0 ? rawTokens[subIndex] : "";
9175
- if (sub === "checkout") {
9176
- const args = rawTokens.slice(subIndex + 1);
9177
- const looksLikePath = args.some(
9178
- (t2) => t2 === "." || t2 === "--" || t2.includes("/") || t2.endsWith("*")
9179
- );
9180
- if (looksLikePath) return null;
9181
- }
9182
- const gitVerbs = {
9183
- clone: "\u514B\u9686\u4ED3\u5E93",
9184
- status: "\u67E5\u72B6\u6001",
9185
- add: "\u6682\u5B58\u6539\u52A8",
9186
- commit: "\u63D0\u4EA4",
9187
- push: "\u63A8\u9001",
9188
- pull: "\u62C9\u53D6",
9189
- fetch: "\u6293\u53D6\u8FDC\u7AEF",
9190
- checkout: "\u5207\u6362\u5206\u652F",
9191
- switch: "\u5207\u6362\u5206\u652F",
9192
- merge: "\u5408\u5E76",
9193
- rebase: "\u53D8\u57FA",
9194
- log: "\u67E5\u5386\u53F2",
9195
- diff: "\u770B\u5DEE\u5F02",
9196
- worktree: "\u7BA1\u7406\u5DE5\u4F5C\u533A",
9197
- branch: "\u7BA1\u7406\u5206\u652F",
9198
- stash: "\u6682\u5B58",
9199
- reset: "\u91CD\u7F6E",
9200
- restore: "\u6062\u590D\u6587\u4EF6"
9201
- };
9202
- const mapped = gitVerbs[sub];
9203
- return mapped ? { verb: mapped } : null;
9613
+ const parsed = parseGit(rest);
9614
+ return parsed ? { verb: parsed.action, target: parsed.object, readOnly: parsed.readOnly } : null;
9615
+ }
9616
+ case "sed":
9617
+ return parseSed(rest);
9618
+ case "nolo":
9619
+ return parseNolo(rest);
9620
+ case "gh": {
9621
+ const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
9622
+ if (!tokens2?.length) return null;
9623
+ const sub = tokens2[0];
9624
+ const op = tokens2[1];
9625
+ const isRead = ["view", "list", "status", "checks", "diff"].includes(op ?? "");
9626
+ if (sub === "pr") return { verb: isRead ? "\u67E5 PR" : "\u64CD\u4F5C PR", readOnly: isRead };
9627
+ if (sub === "run") return { verb: isRead ? "\u67E5 CI \u8FD0\u884C" : "\u64CD\u4F5C CI \u8FD0\u884C", readOnly: isRead };
9628
+ if (sub === "issue") return { verb: isRead ? "\u67E5 Issue" : "\u64CD\u4F5C Issue", readOnly: isRead };
9629
+ if (sub === "api") return { verb: "\u8C03 GitHub API", readOnly: false };
9630
+ return null;
9204
9631
  }
9205
- case "sed": {
9206
- const replaceCount = (rest.match(/s[|/#][^|/#]*[|/#][^|/#]*[|/#]/g) ?? []).length;
9207
- const tokens2 = rest.split(/\s+/).filter((t2) => t2 && !t2.startsWith("-"));
9208
- const fileToken = [...tokens2].reverse().find((t2) => !/[|/#]/.test(t2));
9209
- return {
9210
- verb: "\u7F16\u8F91",
9211
- target: baseName(fileToken ?? ""),
9212
- count: replaceCount > 1 ? replaceCount : void 0,
9213
- unit: "\u5904\u66FF\u6362"
9214
- };
9632
+ case "ps":
9633
+ return { verb: "\u67E5\u8FDB\u7A0B", readOnly: true };
9634
+ case "sha256sum": {
9635
+ const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
9636
+ const file = tokens2?.find((t2) => !t2.startsWith("-"));
9637
+ return { verb: "\u7B97\u6821\u9A8C\u548C", target: file ? baseName(file) : void 0, readOnly: true };
9215
9638
  }
9216
9639
  case "dnf":
9217
9640
  case "yum": {
9218
9641
  const sub = rest.split(/\s+/)[0] ?? "";
9219
- if (sub === "install") return { verb: "\u88C5\u8F6F\u4EF6\u5305" };
9220
- if (sub === "remove" || sub === "erase") return { verb: "\u5378\u8F7D\u8F6F\u4EF6\u5305" };
9221
- if (sub === "update" || sub === "upgrade") return { verb: "\u66F4\u65B0\u7CFB\u7EDF" };
9222
- if (sub === "search") return { verb: "\u641C\u7D22\u8F6F\u4EF6\u5305" };
9223
- if (sub === "list") return { verb: "\u5217\u51FA\u8F6F\u4EF6\u5305" };
9224
- if (sub === "history") return { verb: "\u67E5\u5B89\u88C5\u5386\u53F2" };
9642
+ if (sub === "install") return { verb: "\u88C5\u8F6F\u4EF6\u5305", readOnly: false };
9643
+ if (sub === "remove" || sub === "erase") return { verb: "\u5378\u8F7D\u8F6F\u4EF6\u5305", readOnly: false };
9644
+ if (sub === "update" || sub === "upgrade") return { verb: "\u66F4\u65B0\u7CFB\u7EDF", readOnly: false };
9645
+ if (sub === "search") return { verb: "\u641C\u7D22\u8F6F\u4EF6\u5305", readOnly: true };
9646
+ if (sub === "list") return { verb: "\u5217\u51FA\u8F6F\u4EF6\u5305", readOnly: true };
9647
+ if (sub === "history") return { verb: "\u67E5\u5B89\u88C5\u5386\u53F2", readOnly: true };
9225
9648
  return null;
9226
9649
  }
9227
9650
  case "rpm":
9228
9651
  case "pacman":
9229
9652
  case "apt":
9230
9653
  case "apt-get":
9231
- return { verb: "\u7BA1\u8F6F\u4EF6\u5305" };
9654
+ return { verb: "\u7BA1\u8F6F\u4EF6\u5305", readOnly: false };
9232
9655
  case "systemctl":
9233
9656
  case "journalctl": {
9234
9657
  const tokens2 = rest.split(/\s+/).filter((t2) => t2 && !t2.startsWith("-"));
9235
9658
  const sub = tokens2[0] ?? "";
9236
- if (verb === "journalctl") return { verb: "\u67E5\u65E5\u5FD7" };
9659
+ if (verb === "journalctl") return { verb: "\u67E5\u65E5\u5FD7", readOnly: true };
9237
9660
  const sysVerbs = {
9238
- start: "\u542F\u52A8\u670D\u52A1",
9239
- stop: "\u505C\u6B62\u670D\u52A1",
9240
- restart: "\u91CD\u542F\u670D\u52A1",
9241
- status: "\u67E5\u670D\u52A1\u72B6\u6001",
9242
- enable: "\u542F\u7528\u670D\u52A1",
9243
- disable: "\u505C\u7528\u670D\u52A1",
9244
- "daemon-reload": "\u91CD\u8F7D\u670D\u52A1\u914D\u7F6E",
9245
- "list-units": "\u5217\u670D\u52A1",
9246
- "list-unit-files": "\u5217\u670D\u52A1",
9247
- is: "\u67E5\u670D\u52A1\u72B6\u6001",
9248
- cat: "\u770B\u670D\u52A1\u5B9A\u4E49"
9661
+ start: ["\u542F\u52A8\u670D\u52A1", false],
9662
+ stop: ["\u505C\u6B62\u670D\u52A1", false],
9663
+ restart: ["\u91CD\u542F\u670D\u52A1", false],
9664
+ status: ["\u67E5\u670D\u52A1\u72B6\u6001", true],
9665
+ enable: ["\u542F\u7528\u670D\u52A1", false],
9666
+ disable: ["\u505C\u7528\u670D\u52A1", false],
9667
+ "daemon-reload": ["\u91CD\u8F7D\u670D\u52A1\u914D\u7F6E", false],
9668
+ "list-units": ["\u5217\u670D\u52A1", true],
9669
+ "list-unit-files": ["\u5217\u670D\u52A1", true],
9670
+ is: ["\u67E5\u670D\u52A1\u72B6\u6001", true],
9671
+ cat: ["\u770B\u670D\u52A1\u5B9A\u4E49", true]
9249
9672
  };
9250
9673
  const mapped = sysVerbs[sub];
9251
- return mapped ? { verb: mapped } : null;
9674
+ return mapped ? { verb: mapped[0], readOnly: mapped[1] } : null;
9252
9675
  }
9253
9676
  case "awk":
9254
- return { verb: "\u5904\u7406\u6587\u672C" };
9677
+ return { verb: "\u5904\u7406\u6587\u672C", readOnly: true };
9255
9678
  case "find": {
9256
9679
  if (/(?:^|\s)(?:-delete|-exec|-execdir|-ok|-okdir)(?:\s|$)/.test(rest)) return null;
9257
- return { verb: "\u67E5\u627E\u6587\u4EF6" };
9680
+ return { verb: "\u67E5\u627E\u6587\u4EF6", readOnly: true };
9258
9681
  }
9259
9682
  case "curl":
9260
9683
  case "wget":
9261
- return { verb: "\u4E0B\u8F7D" };
9684
+ return { verb: "\u4E0B\u8F7D", readOnly: false };
9262
9685
  case "bun":
9263
9686
  case "npm":
9264
9687
  case "pnpm":
9265
9688
  case "yarn": {
9266
- const tokens2 = rest.split(/\s+/).filter(Boolean);
9689
+ const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]) ?? rest.split(/\s+/).filter(Boolean);
9267
9690
  const sub = tokens2[0] ?? "";
9268
9691
  if (sub === "test") {
9269
9692
  const target = tokens2.slice(1).find((t2) => !t2.startsWith("-"));
9270
- return { verb: "\u8DD1\u6D4B\u8BD5", target: target ? baseName(target) : void 0 };
9693
+ return { verb: "\u8DD1\u6D4B\u8BD5", target: target ? baseName(target) : void 0, readOnly: false };
9271
9694
  }
9272
- if (sub === "install" || sub === "i" || sub === "add") return { verb: "\u88C5\u4F9D\u8D56" };
9695
+ if (sub === "install" || sub === "i" || sub === "add") return { verb: "\u88C5\u4F9D\u8D56", readOnly: false };
9273
9696
  if (sub === "run") {
9274
9697
  const script = tokens2[1];
9275
- return { verb: "\u8DD1\u811A\u672C", target: script };
9698
+ return { verb: "\u8DD1\u811A\u672C", target: script, readOnly: false };
9276
9699
  }
9277
- if (sub === "build") return { verb: "\u6784\u5EFA" };
9700
+ if (sub === "build") return { verb: "\u6784\u5EFA", readOnly: false };
9278
9701
  if (sub === "x" || sub === "exec") {
9279
- return { verb: "\u6267\u884C", target: tokens2[1] };
9702
+ return { verb: "\u6267\u884C", target: tokens2[1], readOnly: false };
9703
+ }
9704
+ if (verb === "bun" && (sub === "-e" || sub === "-p" || sub === "--inline-heredoc" || tokens2.includes("--inline-heredoc"))) {
9705
+ return { verb: "\u6267\u884C\u5185\u8054\u811A\u672C (Bun)", readOnly: false };
9706
+ }
9707
+ const scriptFile = tokens2.find((t2) => !t2.startsWith("-") && (/\.(?:ts|tsx|js|mjs|mts|cjs)$/i.test(t2) || t2.includes("/")));
9708
+ if (scriptFile) {
9709
+ return { verb: "\u8FD0\u884C\u811A\u672C", target: baseName(scriptFile), readOnly: false };
9280
9710
  }
9281
9711
  return null;
9282
9712
  }
9283
- case "node":
9284
9713
  case "python":
9285
- case "python3":
9714
+ case "python3": {
9715
+ const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]) ?? [];
9716
+ if (tokens2.includes("--inline-heredoc") || /(?:^|\s)-[A-Za-z]*c(?:\s|$)/.test(rest)) {
9717
+ return { verb: "\u6267\u884C\u5185\u8054\u811A\u672C (Python)", readOnly: false };
9718
+ }
9719
+ const script = rest.split(/\s+/).find((t2) => t2 && !t2.startsWith("-"));
9720
+ return { verb: "\u6267\u884C\u811A\u672C", target: baseName(script ?? ""), readOnly: false };
9721
+ }
9722
+ case "node": {
9723
+ if (/(?:^|\s)-[A-Za-z]*e(?:\s|$)/.test(rest)) return null;
9724
+ const script = rest.split(/\s+/).find((t2) => t2 && !t2.startsWith("-"));
9725
+ return { verb: "\u6267\u884C\u811A\u672C", target: baseName(script ?? ""), readOnly: false };
9726
+ }
9286
9727
  case "bash":
9287
9728
  case "sh":
9288
9729
  case "zsh": {
9289
9730
  if (/(?:^|\s)-[A-Za-z]*[ce](?:\s|$)/.test(rest)) return null;
9290
9731
  const script = rest.split(/\s+/).find((t2) => t2 && !t2.startsWith("-"));
9291
- return { verb: "\u6267\u884C\u811A\u672C", target: baseName(script ?? "") };
9732
+ return { verb: "\u6267\u884C\u811A\u672C", target: baseName(script ?? ""), readOnly: false };
9292
9733
  }
9293
9734
  case "echo":
9294
9735
  case "printf":
9295
- return { verb: "\u8F93\u51FA" };
9736
+ return { verb: "\u8F93\u51FA", readOnly: true };
9296
9737
  case "head":
9297
9738
  case "tail":
9298
9739
  case "wc":
9299
9740
  case "sort":
9300
- case "uniq":
9301
- return { verb: "\u67E5\u770B\u8F93\u51FA" };
9741
+ case "uniq": {
9742
+ const tokens2 = shellWords(rest.split(/\s+\|\s+/)[0]);
9743
+ let file;
9744
+ if (tokens2) {
9745
+ for (let i = 0; i < tokens2.length; i++) {
9746
+ const tok = tokens2[i];
9747
+ if (tok === "-n" || tok === "-c") {
9748
+ i++;
9749
+ continue;
9750
+ }
9751
+ if (tok.startsWith("-")) continue;
9752
+ file = tok;
9753
+ break;
9754
+ }
9755
+ }
9756
+ return file ? { verb: "\u67E5\u770B", target: baseName(file), readOnly: true } : { verb: "\u67E5\u770B\u8F93\u51FA", readOnly: true };
9757
+ }
9302
9758
  default:
9303
9759
  return null;
9304
9760
  }
@@ -9401,13 +9857,77 @@ function hasNonFilterPipeline(command) {
9401
9857
  }
9402
9858
  return false;
9403
9859
  }
9860
+ function collapseSafeHeredocs(command) {
9861
+ const lines = command.split(/\r?\n/);
9862
+ const out = [];
9863
+ for (let i = 0; i < lines.length; i++) {
9864
+ const line = lines[i];
9865
+ const trimmed = line.trim();
9866
+ if (!trimmed) continue;
9867
+ const hd = trimmed.match(/^(.*?)\s*<<-?\s*'([A-Za-z0-9_]+)'\s*$/);
9868
+ if (hd) {
9869
+ const head = hd[1].trim();
9870
+ const tag = hd[2];
9871
+ let end = -1;
9872
+ for (let j = i + 1; j < lines.length; j++) {
9873
+ if (lines[j].trim() === tag) {
9874
+ end = j;
9875
+ break;
9876
+ }
9877
+ }
9878
+ if (end === -1) return null;
9879
+ out.push(`${head} --inline-heredoc`);
9880
+ i = end;
9881
+ continue;
9882
+ }
9883
+ out.push(trimmed);
9884
+ }
9885
+ return out.join("\n");
9886
+ }
9887
+ function normalizeTopLevelNewlines(command) {
9888
+ let out = "";
9889
+ let quote = null;
9890
+ for (let i = 0; i < command.length; i++) {
9891
+ const ch = command[i];
9892
+ const next = command[i + 1];
9893
+ if (quote) {
9894
+ if (ch === "\\" && next && quote === '"') {
9895
+ out += ch + next;
9896
+ i++;
9897
+ continue;
9898
+ }
9899
+ if (ch === quote) quote = null;
9900
+ out += ch === "\n" ? " " : ch;
9901
+ continue;
9902
+ }
9903
+ if (ch === '"' || ch === "'") {
9904
+ quote = ch;
9905
+ out += ch;
9906
+ continue;
9907
+ }
9908
+ if (ch === "\\" && next) {
9909
+ out += ch + next;
9910
+ i++;
9911
+ continue;
9912
+ }
9913
+ if (ch === "\n") {
9914
+ if (!out.endsWith("&& ") && out.trim().length > 0) out += " && ";
9915
+ continue;
9916
+ }
9917
+ out += ch;
9918
+ }
9919
+ return out.replace(/(?:\s*&&\s*)+$/, "").trim();
9920
+ }
9404
9921
  function summarizeShellCommand(command) {
9405
- const normalized = command.split(/\r?\n/).map((line) => line.replace(/\s+/g, " ").trim()).filter(Boolean).join(" && ");
9922
+ const collapsed = collapseSafeHeredocs(command);
9923
+ if (collapsed === null) return null;
9924
+ const normalized = normalizeTopLevelNewlines(collapsed);
9406
9925
  if (!normalized) return null;
9407
9926
  if (hasNonFilterPipeline(normalized)) return null;
9408
9927
  const { segments, hasFallback } = splitSegments(normalized);
9409
9928
  if (segments.length === 0) return null;
9410
9929
  if (hasFallback) return null;
9930
+ if (segments.some((segment) => !shellWords(segment, true))) return null;
9411
9931
  const actions = [];
9412
9932
  for (const segment of segments) {
9413
9933
  const action = classifySegment(segment);
@@ -9416,24 +9936,67 @@ function summarizeShellCommand(command) {
9416
9936
  }
9417
9937
  const summary = summarizeActions(actions);
9418
9938
  if (!summary) return null;
9419
- return { summary, foldedSegments: segments.length };
9939
+ const readOnly = actions.every((a) => a.readOnly === true);
9940
+ const single = segments.length === 1 ? firstVerbToken(segments[0]) : void 0;
9941
+ const git = single?.verb === "git" ? parseGit(single.rest) : null;
9942
+ const singleAction = segments.length === 1 && !actions[0]?.count ? { action: actions[0].verb, ...actions[0].target ? { object: actions[0].target } : {} } : {};
9943
+ return { summary, foldedSegments: segments.length, readOnly, ...singleAction, ...git ?? {} };
9944
+ }
9945
+
9946
+ // packages/core/toolActivityPresentation.ts
9947
+ var families = {
9948
+ readFile: ["read", "\u8BFB\u53D6", ["path"], true],
9949
+ read_file: ["read", "\u8BFB\u53D6", ["path"], true],
9950
+ readWorkspaceFile: ["read", "\u8BFB\u53D6", ["path"], true],
9951
+ writeFile: ["write", "\u5199\u5165", ["path"], false],
9952
+ editFile: ["edit", "\u4FEE\u6539", ["path"], false],
9953
+ globFiles: ["find", "\u67E5\u627E\u6587\u4EF6", ["pattern", "path"], true],
9954
+ search: ["search", "\u641C\u7D22", ["query", "pattern"], true],
9955
+ grep: ["search", "\u641C\u7D22", ["pattern", "query"], true],
9956
+ loadSkill: ["skill", "\u52A0\u8F7D\u6280\u80FD", ["name", "slug"], true]
9957
+ };
9958
+ var shellTools = /* @__PURE__ */ new Set(["execShell", "exec_shell", "runCommand", "launchProcess"]);
9959
+ function projectToolActivity(input, translate) {
9960
+ const text = (...keys) => {
9961
+ for (const key of keys) {
9962
+ const value = input.args?.[key];
9963
+ if (typeof value === "string" && value.length) return value;
9964
+ }
9965
+ return void 0;
9966
+ };
9967
+ let action = input.toolName, object, summary, readOnly = false;
9968
+ let confidence = "raw-fallback";
9969
+ let context = text("cwd");
9970
+ if (shellTools.has(input.toolName)) {
9971
+ object = text("command", "cmd");
9972
+ const gist = object ? summarizeShellCommand(object) : null;
9973
+ action = gist?.action ?? gist?.summary ?? "\u547D\u4EE4";
9974
+ if (gist) {
9975
+ object = gist.object;
9976
+ context = context ?? gist.context;
9977
+ summary = gist.summary;
9978
+ readOnly = gist.readOnly === true;
9979
+ confidence = "recognized";
9980
+ }
9981
+ if (!gist || gist.action) action = translate?.(gist?.action ? `toolActivity.shell.${gist.action}` : "toolActivity.shell", action) ?? action;
9982
+ } else {
9983
+ const family = families[input.toolName];
9984
+ if (family) {
9985
+ action = translate?.(`toolActivity.${family[0]}`, family[1]) ?? family[1];
9986
+ object = text(...family[2]);
9987
+ readOnly = family[3];
9988
+ confidence = "recognized";
9989
+ } else object = text("path", "query", "command", "url", "name");
9990
+ }
9991
+ return { key: input.key, action, object, context, ...summary ? { summary } : {}, readOnly, confidence, state: input.state, attention: input.attention, standalone: input.mode !== "ordinary" || input.attention.length > 0 || ["failed", "cancelled", "repairing"].includes(input.state), scopeKey: input.scopeKey, batchKey: input.batchKey, evidenceKey: input.evidenceKey };
9992
+ }
9993
+ function canCoalesceToolActivities(previous, next) {
9994
+ return !previous.standalone && !next.standalone && previous.attention.length === 0 && next.attention.length === 0 && !!previous.scopeKey && previous.scopeKey === next.scopeKey && !!previous.batchKey && previous.batchKey === next.batchKey;
9420
9995
  }
9421
9996
 
9422
9997
  // packages/cli/tui/askTextSanitize.ts
9423
9998
  var ASK_SECRET_PLACEHOLDER = "\u27E8redacted\u27E9";
9424
9999
  var C0_C1_CONTROL_REGEX = /[\x00-\x1f\x7f-\x9f]/g;
9425
- var NORMAL_GIST_SECRET_PATTERNS = [
9426
- /\bbearer\s+[A-Za-z0-9._~+/=-]{8,}/i,
9427
- /\bsk-(?:ant-)?(?:api)?[0-9a-zA-Z-]{10,}/,
9428
- /\b(?:ghp|gho|ghu|ghs|ghr)_[A-Za-z0-9]{10,}/,
9429
- /\bxox[baprs]-[A-Za-z0-9-]{10,}/
9430
- ];
9431
- function withholdIfSecretLike(gist) {
9432
- if (!gist) return "";
9433
- if (findPotentialSecrets(gist).length > 0) return "";
9434
- if (NORMAL_GIST_SECRET_PATTERNS.some((pattern) => pattern.test(gist))) return "";
9435
- return gist;
9436
- }
9437
10000
  function toText(value) {
9438
10001
  return typeof value === "string" ? value : String(value ?? "");
9439
10002
  }
@@ -9777,14 +10340,6 @@ function formatSearchItemQuery(query, path2, customHomedir) {
9777
10340
  if (!text) return "search";
9778
10341
  return text.length > 80 ? `${text.slice(0, 79)}\u2026` : text;
9779
10342
  }
9780
- function formatRunItemCommand(command, exitCode, timedOut) {
9781
- let text = compactWhitespace(command || "");
9782
- if (!text) text = "command";
9783
- text = text.length > 80 ? `${text.slice(0, 79)}\u2026` : text;
9784
- if (timedOut) return `${text} (timed out)`;
9785
- if (typeof exitCode === "number" && exitCode !== 0) return `${text} (exit ${exitCode})`;
9786
- return text;
9787
- }
9788
10343
  function formatFetchItemUrl(url) {
9789
10344
  const text = (url || "").trim();
9790
10345
  if (!text) return "webpage";
@@ -10485,19 +11040,16 @@ function formatNormalToolLine(event, pending, colorEnabled, opts) {
10485
11040
  const label = toolLabel(toolName);
10486
11041
  const cols = typeof process !== "undefined" && typeof process.stdout?.columns === "number" && process.stdout.columns > 0 ? process.stdout.columns : 80;
10487
11042
  const totalBudget = Math.max(1, resolveHistoryLayoutGeometry(cols).contentWidth - displayWidth("\u25C8 "));
10488
- if (readActionGate(event.metadata?.actionGate)) {
10489
- const actionText = t("toolNeedsAction");
10490
- const prefix = `\u25B8 ${label} ! `;
10491
- const maxActionWidth = Math.max(0, totalBudget - displayWidth(prefix));
10492
- const fittedAction = maxActionWidth > 0 && displayWidth(actionText) > maxActionWidth ? truncateByDisplayWidth(actionText, maxActionWidth) : maxActionWidth > 0 ? actionText : "";
10493
- return formatToolTraceLine(fitNormalLine(`\u25B8 ${label}`, `! ${fittedAction}`, totalBudget), colorEnabled, "error");
11043
+ if (readActionGate(event.metadata?.actionGate) || event.metadata?.permissionRequest) {
11044
+ const gist2 = opts?.tuiTrees ? normalToolGist(event) : "";
11045
+ const title = gist2 ? `${label} \xB7 ${gist2}` : label;
11046
+ return formatToolTraceLine(fitNormalLine(`\u25B8 ${title}`, `! ${t("toolNeedsAction")}`, totalBudget), colorEnabled, "error");
10494
11047
  }
10495
11048
  if (event.type === "tool-error" || event.metadata?.timedOut || isFailedToolResult(event)) {
10496
11049
  const reason = event.metadata?.timedOut ? t("toolTimedOut") : toolFailureReason(event) || t("toolFailed");
10497
- const prefix = `\u25B8 ${label} \u2717 `;
10498
- const maxReasonWidth = Math.max(0, totalBudget - displayWidth(prefix));
10499
- const fittedReason = maxReasonWidth > 0 && displayWidth(reason) > maxReasonWidth ? truncateByDisplayWidth(reason, maxReasonWidth) : maxReasonWidth > 0 ? reason : "";
10500
- return formatToolTraceLine(fitNormalLine(`\u25B8 ${label}`, `\u2717 ${fittedReason}`, totalBudget), colorEnabled, "error");
11050
+ const gist2 = opts?.tuiTrees ? normalToolGist(event) : "";
11051
+ const title = gist2 ? `${label} \xB7 ${gist2}` : label;
11052
+ return formatToolTraceLine(fitNormalLine(`\u25B8 ${title}`, `\u2717 ${reason}`, totalBudget), colorEnabled, "error");
10501
11053
  }
10502
11054
  const resultSummary = normalResultSummary(event);
10503
11055
  const gist = [normalToolGist(event), resultSummary].filter(Boolean).join(" \xB7 ");
@@ -10608,11 +11160,17 @@ var TUI_TREE_TOOLS = {
10608
11160
  Search: ["exa_search"],
10609
11161
  Fetch: ["fetchWebpage"]
10610
11162
  };
11163
+ function toolDetails(event, line) {
11164
+ const command = event.metadata?.command;
11165
+ return isRunToolName(event.toolName) && typeof command === "string" ? `${line}${safeApprovalMultilineText(command)}
11166
+ ` : line;
11167
+ }
10611
11168
  function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts = {}) {
10612
11169
  const pending = /* @__PURE__ */ new Map();
11170
+ let scope = 0;
10613
11171
  let tree = null;
10614
11172
  const treeKind = (name) => Object.keys(TUI_TREE_TOOLS).find((kind) => TUI_TREE_TOOLS[kind].includes(name)) ?? null;
10615
- const treeLine = (kind, items, fallback) => {
11173
+ const treeLine = (kind, items, fallback, details) => {
10616
11174
  const label = kind === "Run" ? toolLabel("execShell") : kind === "Read" ? toolLabel("readFile") : kind === "Fetch" ? toolLabel("fetchWebpage") : toolLabel("exa_search");
10617
11175
  const header = `${label} (${items.length}) \xB7 `;
10618
11176
  const columns = resolveHistoryLayoutGeometry(process.stdout.columns).contentWidth - displayWidth("\u25C8 ");
@@ -10628,6 +11186,7 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
10628
11186
  kind,
10629
11187
  summary,
10630
11188
  fallback,
11189
+ details,
10631
11190
  previousRow: tree?.lastRow
10632
11191
  };
10633
11192
  if (tree) tree.lastRow = `\u25B8 ${summary}`;
@@ -10635,8 +11194,9 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
10635
11194
  `;
10636
11195
  };
10637
11196
  const formatTreeEvent = (event, call) => {
11197
+ if (event.type === "tool-error") tree = null;
10638
11198
  if (!opts.tuiTrees || event.type !== "tool-result") return null;
10639
- if (isFailedToolResult(event) || event.metadata?.failed || event.metadata?.timedOut || readActionGate(event.metadata?.actionGate)) {
11199
+ if (isFailedToolResult(event) || event.metadata?.failed || event.metadata?.timedOut || readActionGate(event.metadata?.actionGate) || event.metadata?.permissionRequest) {
10640
11200
  tree = null;
10641
11201
  return null;
10642
11202
  }
@@ -10646,24 +11206,40 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
10646
11206
  tree = null;
10647
11207
  return null;
10648
11208
  }
11209
+ const activity = projectToolActivity({
11210
+ key: event.toolCallId,
11211
+ toolName: name,
11212
+ args: event.metadata,
11213
+ state: "success",
11214
+ attention: [],
11215
+ mode: "ordinary",
11216
+ // Formatter lifecycle/reset is the real assistant-output boundary;
11217
+ // round comes from the execution stream, never from adjacent rows.
11218
+ scopeKey: `assistant:${scope}`,
11219
+ batchKey: Number.isInteger(event.round) && event.round >= 0 ? `round:${event.round}` : void 0,
11220
+ evidenceKey: event.toolCallId
11221
+ });
10649
11222
  let item = "";
10650
11223
  const m = event.metadata ?? {};
10651
11224
  if (kind === "Run") {
10652
- const command = typeof m.command === "string" ? m.command : "";
10653
- item = command ? formatRunItemCommand(command, typeof m.exitCode === "number" ? m.exitCode : void 0, Boolean(m.timedOut)) : "command";
11225
+ item = activity.summary ?? (activity.confidence === "raw-fallback" ? clipCompactText(redactSecrets(activity.object ?? ""), 56, "\u2026") : [activity.action, activity.object].filter(Boolean).join(" "));
10654
11226
  }
10655
11227
  if (kind === "Read") item = formatReadItemPath(typeof m.path === "string" ? m.path : typeof m.filePath === "string" ? m.filePath : "file", m);
10656
11228
  if (kind === "Search") item = formatSearchItemQuery(typeof m.query === "string" ? m.query : typeof m.pattern === "string" ? m.pattern : "search", typeof m.path === "string" ? m.path : void 0);
10657
11229
  if (kind === "Fetch") item = formatFetchItemUrl(typeof m.url === "string" ? m.url : "webpage");
10658
- item = withholdIfSecretLike(item) || toolLabel(name);
10659
- if (tree?.kind !== kind) tree = { kind, items: [] };
11230
+ item = safeAskText(item) || toolLabel(name);
11231
+ if (tree?.kind !== kind || !canCoalesceToolActivities(tree.activity, activity)) tree = { kind, items: [], activity };
10660
11232
  tree.items.push(item);
10661
11233
  if (tree.items.length < 2) {
10662
- const line = formatNormalToolLine(event, call, colorEnabled, opts);
10663
- tree.lastRow = stripAnsi(line).trimEnd();
10664
- return line;
11234
+ const line2 = formatNormalToolLine(event, call, colorEnabled, opts);
11235
+ tree.lastRow = stripAnsi(line2).trimEnd();
11236
+ const rawCommand = typeof m.command === "string" ? m.command : "";
11237
+ const runIdentity = kind === "Run" && activity.readOnly && rawCommand ? createHash2("sha256").update(rawCommand).digest("hex").slice(0, 16) : void 0;
11238
+ return `${TUI_TREE_MARKER}${JSON.stringify({ kind, summary: stripAnsi(line2).trimEnd().replace(/^▸ /, ""), fallback: line2, details: toolDetails(event, line2), appendOnly: true, ...runIdentity ? { readOnly: true, runIdentity } : {} })}${TUI_TREE_END}
11239
+ `;
10665
11240
  }
10666
- return treeLine(kind, tree.items, formatNormalToolLine(event, call, colorEnabled, opts));
11241
+ const line = formatNormalToolLine(event, call, colorEnabled, opts);
11242
+ return treeLine(kind, tree.items, line, toolDetails(event, line));
10667
11243
  };
10668
11244
  const format = (event) => {
10669
11245
  if (event.type === "tool-call") {
@@ -10677,10 +11253,16 @@ function createToolEventFormatter(colorEnabled = resolveCliColorEnabled(), opts
10677
11253
  pending.delete(event.toolCallId);
10678
11254
  const treeOutput = formatTreeEvent(event, call);
10679
11255
  if (treeOutput !== null) return treeOutput;
10680
- return formatNormalToolLine(event, call, colorEnabled, opts);
11256
+ const line = formatNormalToolLine(event, call, colorEnabled, opts);
11257
+ if (opts.tuiTrees && line && isRunToolName(event.toolName)) {
11258
+ return `${TUI_TREE_MARKER}${JSON.stringify({ kind: "Run", summary: "", fallback: line, details: toolDetails(event, line), appendOnly: true })}${TUI_TREE_END}
11259
+ `;
11260
+ }
11261
+ return line;
10681
11262
  };
10682
11263
  format.reset = () => {
10683
11264
  tree = null;
11265
+ scope++;
10684
11266
  };
10685
11267
  format.consume = (event) => {
10686
11268
  if (event.type === "tool-call") {
@@ -10928,10 +11510,6 @@ function shouldPromoteTuiNarration(text) {
10928
11510
  if (text.length >= TUI_PROGRESS_BUFFER_LIMIT) return true;
10929
11511
  return /(^|\n)\s*(?:#{1,3}\s|```|[-*+]\s|\d+[.)]\s)/.test(text);
10930
11512
  }
10931
- function narrationActivityLabel(text) {
10932
- const oneLine = stripAnsi(text).replace(/[`*_#>]/g, "").replace(/\s+/g, " ").trim();
10933
- return truncateThinkingHint(oneLine, 60);
10934
- }
10935
11513
  function createCliTurnOutput(params) {
10936
11514
  const { options } = params;
10937
11515
  const workingLabel = params.workingLabel ?? `${options.agentName} -> working`;
@@ -10944,12 +11522,7 @@ function createCliTurnOutput(params) {
10944
11522
  const assistantLabelManaged = options.output.assistantLabelManaged === true;
10945
11523
  const showThinking = !assistantLabelManaged && options.showThinking !== false;
10946
11524
  const hidesRoutineTuiToolDetail = (event) => {
10947
- if (!assistantLabelManaged || event.toolName !== "editFile") return false;
10948
- if (event.type === "tool-error") return false;
10949
- if (readActionGate(event.metadata?.actionGate)) return false;
10950
- if (event.metadata?.timedOut || event.metadata?.failed || event.metadata?.error) return false;
10951
- if (typeof event.metadata?.exitCode === "number" && event.metadata.exitCode !== 0) return false;
10952
- return true;
11525
+ return false;
10953
11526
  };
10954
11527
  let streamedAssistantText = false;
10955
11528
  let everStreamedAnyText = false;
@@ -11023,11 +11596,6 @@ function createCliTurnOutput(params) {
11023
11596
  streamedAssistantText = true;
11024
11597
  options.activityReporter?.(null);
11025
11598
  };
11026
- const dropPendingTuiProgress = () => {
11027
- pendingTuiNarration = "";
11028
- tuiNarrationPromoted = false;
11029
- options.activityReporter?.(null);
11030
- };
11031
11599
  const writeVisibleAssistantChunk = (chunk) => {
11032
11600
  if (!chunk) return;
11033
11601
  if (!assistantLabelManaged) formatToolEvent.reset?.();
@@ -11046,6 +11614,7 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
11046
11614
  }
11047
11615
  printedAssistantLabel = true;
11048
11616
  }
11617
+ if (assistantLabelManaged) options.activityReporter?.(t("generatingReply"));
11049
11618
  everStreamedAnyText = true;
11050
11619
  if (assistantLabelManaged) {
11051
11620
  if (tuiNarrationPromoted) {
@@ -11057,8 +11626,7 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
11057
11626
  if (shouldPromoteTuiNarration(pendingTuiNarration)) {
11058
11627
  flushPendingTuiNarration();
11059
11628
  } else {
11060
- const label = narrationActivityLabel(pendingTuiNarration);
11061
- if (label) options.activityReporter?.(label);
11629
+ options.activityReporter?.(t("generatingReply"));
11062
11630
  }
11063
11631
  return;
11064
11632
  }
@@ -11079,7 +11647,7 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
11079
11647
  }
11080
11648
  if (event.type === "tool-call") {
11081
11649
  if (assistantLabelManaged && pendingTuiNarration) {
11082
- dropPendingTuiProgress();
11650
+ flushPendingTuiNarration();
11083
11651
  }
11084
11652
  renderWriter.flush();
11085
11653
  if (!hidesRoutineTuiToolDetail(event)) {
@@ -11120,12 +11688,7 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
11120
11688
  /**
11121
11689
  * Terminal cleanup for abort/error paths that never reach `finish()`.
11122
11690
  *
11123
- * A user abort discards the transient TUI progress buffer: the user stopped
11124
- * on purpose and the dock already showed that text as activity. A genuine
11125
- * failure must not swallow prose that never got the chance to be *proven*
11126
- * durable (only a following tool call proves "progress"), so it promotes the
11127
- * pending buffer and flushes what was already promoted — otherwise a short
11128
- * final answer followed by a transport error disappears from the transcript.
11691
+ * Preserve original prose on both abort and transport failure.
11129
11692
  */
11130
11693
  cancel(cleanup) {
11131
11694
  if (assistantLabelManaged && cleanup?.preservePendingNarration) {
@@ -11135,7 +11698,8 @@ ${options.agentName}${IDENTITY_LABEL_SEPARATOR}`);
11135
11698
  options.output.write("\n");
11136
11699
  }
11137
11700
  }
11138
- dropPendingTuiProgress();
11701
+ flushPendingTuiNarration();
11702
+ renderWriter.flush();
11139
11703
  },
11140
11704
  pushText(chunk) {
11141
11705
  writeVisibleAssistantChunk(chunk);
@@ -11714,7 +12278,7 @@ function isBalanceExhaustedError(error) {
11714
12278
 
11715
12279
  // packages/cli/client/agentRun.ts
11716
12280
  async function loadRunLocalAgentTurn() {
11717
- const { runLocalAgentTurn } = await import("./agentRuntimeLocal-GOX2DIY7.js");
12281
+ const { runLocalAgentTurn } = await import("./agentRuntimeLocal-HOXKWCYO.js");
11718
12282
  return runLocalAgentTurn;
11719
12283
  }
11720
12284
  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();
@@ -12509,6 +13073,10 @@ function describeLocalRunFailure(message, rawError) {
12509
13073
  }
12510
13074
  if (isMissingBatchReceiptFailure(message)) {
12511
13075
  return `[nolo] ${describeMissingBatchReceipt()}.
13076
+ `;
13077
+ }
13078
+ if (/\bimage_model_unsupported\b/.test(message)) {
13079
+ return `[nolo] ${message}. ${NO_FALLBACK} Check the selected model's image capability or use a model known to support images.
12512
13080
  `;
12513
13081
  }
12514
13082
  const cls = classifyLocalRunError(message);
@@ -12858,6 +13426,17 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
12858
13426
  options.modelOverride
12859
13427
  ) : resolvedBaseAdapter;
12860
13428
  if (adapter2) adapter2 = applyEphemeralIfRequested(options, adapter2);
13429
+ if (adapter2 && options.imageUrls?.length) {
13430
+ const imageAdapter = adapter2;
13431
+ adapter2 = { ...imageAdapter, loadAgentConfig: async (agentRef) => {
13432
+ const config = await imageAdapter.loadAgentConfig(agentRef);
13433
+ if (!config) return config;
13434
+ if (!resolveAgentImageInputSupport({ ...config, hasVision: config.hasVision ?? false })) {
13435
+ throw new Error("image_model_unsupported: child model image capability is unsupported or unknown");
13436
+ }
13437
+ return config;
13438
+ } };
13439
+ }
12861
13440
  return adapter2;
12862
13441
  })();
12863
13442
  if (!baseAdapter) {
@@ -12946,6 +13525,9 @@ async function executeLocalAgentTurnForCliWithAdapter(options, settings, resolve
12946
13525
  try {
12947
13526
  const saved = await commandAdapter.saveTurn({
12948
13527
  ...input,
13528
+ // Receipt-backed user rows are excluded below to avoid duplicate persistence.
13529
+ // Keep their explicit identities for post-sync native memory capture.
13530
+ ...{ cliCaptureUserMessageIds: input.messages.filter((message) => message.role === "user").map((message) => message.cliMessageId).filter((id) => typeof id === "string") },
12949
13531
  messages: input.messages.filter((message) => {
12950
13532
  const cliMessageId = message.cliMessageId;
12951
13533
  if (!cliMessageId) return true;
@@ -13576,249 +14158,6 @@ function buildHostEnvironmentLayer(options) {
13576
14158
  return layer;
13577
14159
  }
13578
14160
 
13579
- // packages/agent-runtime/agentsMd.ts
13580
- import { existsSync as existsSync2, readFileSync as readFileSync3 } from "node:fs";
13581
- import { resolve as resolve3 } from "node:path";
13582
- var AGENTS_MD_MAX_BYTES = 8192;
13583
- var AGENTS_MD_MARKER_RESERVE_BYTES = 512;
13584
- var AGENTS_MD_CANDIDATES = ["AGENTS.md", "CLAUDE.md"];
13585
- function truncateAgentsMdContent(content, maxBytes = AGENTS_MD_MAX_BYTES) {
13586
- const buf = Buffer.from(content, "utf8");
13587
- if (buf.byteLength <= maxBytes) {
13588
- return content;
13589
- }
13590
- let boundary = Math.min(maxBytes, buf.byteLength);
13591
- while (boundary > 0 && boundary < buf.byteLength && (buf[boundary] & 192) === 128) {
13592
- boundary--;
13593
- }
13594
- const boundarySlice = buf.subarray(0, boundary).toString("utf8");
13595
- const slice = buf.subarray(0, maxBytes);
13596
- const lastNewline = slice.lastIndexOf(10);
13597
- if (lastNewline > 0) {
13598
- const lineCandidate = slice.subarray(0, lastNewline).toString("utf8");
13599
- const lineBytes = Buffer.byteLength(lineCandidate, "utf8");
13600
- const boundaryBytes = Buffer.byteLength(boundarySlice, "utf8");
13601
- if (lineCandidate.trim().length > 0 && lineBytes * 2 >= boundaryBytes) {
13602
- return lineCandidate.replace(/\r$/, "");
13603
- }
13604
- }
13605
- return boundarySlice.replace(/\r$/, "");
13606
- }
13607
- var AGENTS_MD_SUMMARY_MAX_BYTES = 3072;
13608
- var AGENTS_MD_SUMMARY_ITEM_MAX_CHARS = 120;
13609
- var AGENTS_MD_SUMMARY_PRIORITY_KEYWORDS = [
13610
- "review",
13611
- "\u8BC4\u5BA1",
13612
- "commit",
13613
- "\u63D0\u4EA4",
13614
- "worktree",
13615
- "\u6D4B\u8BD5",
13616
- "typecheck",
13617
- "\u7C7B\u578B\u68C0\u67E5",
13618
- "push",
13619
- "\u53D1\u5E03",
13620
- "\u6587\u6863\u843D\u4F4D",
13621
- "\u5220\u9664",
13622
- "\u6D3E\u53D1"
13623
- ];
13624
- var AGENTS_MD_SUMMARY_POINTER_INSTRUCTION = "\u7528 readFile \u8BFB\u5168\u6587\uFF1A%REL%\uFF08cwd\uFF09/ %PATH%\n\u4EC5\u7D22\u5F15\uFF1A\u63D0\u4EA4/\u8BC4\u5BA1\u95E8\u7981\u3001worktree \u9694\u79BB\u3001\u6D4B\u8BD5/typecheck\u3001\u6587\u6863\u843D\u4F4D\u3001\u5220\u9664\u3001push/\u53D1\u5E03\u524D\uFF0C**\u5FC5\u987B\u5148 readFile \u8BFB\u5168\u6587\u518D\u6267\u884C**\u3002\n\u8DEF\u5F84\uFF1A%REL% \u76F8\u5BF9 cwd\uFF1Bmachine:<id>/\u6C99\u76D2\u6267\u884C\u9762 cwd \u7531\u5176\u51B3\u5B9A\uFF0C\u8BFB\u4E0D\u5230\u8BA9\u5BBF\u4E3B\u6CE8\u5165\u6216\u7528\u7EDD\u5BF9\u8DEF\u5F84\u3002";
13625
- var AGENTS_MD_SUMMARY_DELETE_REFERENCE = "- \u5220\u9664/\u4E0D\u53EF\u9006\u64CD\u4F5C\uFF1A\u9075\u5B88\u7CFB\u7EDF\u63D0\u793A\u7684\u5220\u9664\u7EA2\u7EBF\uFF08\u5148\u5448\u73B0\u5B8C\u6574\u5F85\u5220\u6E05\u5355\u5E76\u83B7\u7528\u6237\u660E\u786E\u786E\u8BA4\uFF0C\u7981\u6B62\u5148\u5220\u540E\u62A5\u3001\u7981\u6B62\u6A21\u7CCA\u5B9A\u4F4D\uFF09\uFF0C\u4ED3\u5E93\u82E5\u6709\u9644\u52A0\u5220\u9664\u89C4\u5219\u89C1\u5B8C\u6574\u6587\u4EF6\u3002";
13626
- var clipToChars = (text, maxChars) => text.length <= maxChars ? text : `${text.slice(0, maxChars).trimEnd()}\u2026`;
13627
- var parseAgentsMdItem = (body) => {
13628
- const bold = /^\*\*(.+?)\*\*/.exec(body);
13629
- if (bold) {
13630
- return {
13631
- label: bold[1].trim().replace(/[::]$/, ""),
13632
- rest: body.slice(bold[0].length).replace(/^[::\s]+/, "")
13633
- };
13634
- }
13635
- const firstClause = body.split(/[::]/)[0];
13636
- return {
13637
- label: clipToChars(firstClause.trim(), 40),
13638
- rest: body.slice(firstClause.length).replace(/^[::\s]+/, "")
13639
- };
13640
- };
13641
- var AGENTS_MD_COMMAND_TOKEN_PREFIX = /^(bunx?|npx|node|npm|pnpm|yarn|git|gh|tsc|deno)\b\s/;
13642
- var extractAgentsMdCommandTokens = (body) => {
13643
- const tokens2 = [];
13644
- const seen = /* @__PURE__ */ new Set();
13645
- for (const match of body.matchAll(/`([^`\n]+)`/g)) {
13646
- const raw = match[1];
13647
- if (!AGENTS_MD_COMMAND_TOKEN_PREFIX.test(raw)) continue;
13648
- if (seen.has(raw)) continue;
13649
- seen.add(raw);
13650
- tokens2.push(raw);
13651
- }
13652
- return tokens2;
13653
- };
13654
- var buildAgentsMdItemGist = (firstSentence, bulletBody) => {
13655
- const max = AGENTS_MD_SUMMARY_ITEM_MAX_CHARS;
13656
- const clipped = clipToChars(firstSentence, max);
13657
- const missing = extractAgentsMdCommandTokens(bulletBody).filter(
13658
- (token) => !clipped.includes(token)
13659
- );
13660
- if (missing.length === 0) return clipped;
13661
- let tail = "";
13662
- for (const token of missing) {
13663
- const candidate = tail ? `${tail} \`${token}\`` : `\`${token}\``;
13664
- if (candidate.length > max) continue;
13665
- tail = candidate;
13666
- }
13667
- if (!tail) return clipped;
13668
- const room = max - tail.length - 2;
13669
- const head = room > 0 ? clipToChars(firstSentence, room) : "";
13670
- return head ? `${head} ${tail}` : tail;
13671
- };
13672
- var priorityOf = (label) => {
13673
- const lowered = label.toLowerCase();
13674
- for (let i = 0; i < AGENTS_MD_SUMMARY_PRIORITY_KEYWORDS.length; i += 1) {
13675
- if (lowered.includes(AGENTS_MD_SUMMARY_PRIORITY_KEYWORDS[i].toLowerCase())) {
13676
- return i;
13677
- }
13678
- }
13679
- return -1;
13680
- };
13681
- var collectAgentsMdSummaryItems = (content) => {
13682
- const items = [];
13683
- const seen = /* @__PURE__ */ new Set();
13684
- let section = null;
13685
- for (const rawLine of content.split(/\r?\n/)) {
13686
- const line = rawLine.trim();
13687
- if (!line) continue;
13688
- const heading = /^#{2,3}\s+(.+)$/.exec(line);
13689
- if (heading) {
13690
- section = heading[1].trim();
13691
- continue;
13692
- }
13693
- if (line.startsWith("#") || line.startsWith("<") || line.startsWith("<!--")) {
13694
- continue;
13695
- }
13696
- const bullet = /^[-*]\s+(.+)$/.exec(line);
13697
- if (!bullet) continue;
13698
- const { label, rest } = parseAgentsMdItem(bullet[1]);
13699
- if (!label || seen.has(label)) continue;
13700
- seen.add(label);
13701
- const firstSentence = rest.split("\u3002")[0].trim();
13702
- items.push({
13703
- section,
13704
- label,
13705
- gist: buildAgentsMdItemGist(firstSentence, bullet[1]),
13706
- priority: priorityOf(label)
13707
- });
13708
- }
13709
- return items;
13710
- };
13711
- function buildAgentsMdSummaryBody(content, filePath, options = {}) {
13712
- const budgetBytes = options.budgetBytes ?? AGENTS_MD_SUMMARY_MAX_BYTES;
13713
- const items = collectAgentsMdSummaryItems(content);
13714
- if (items.length === 0) return null;
13715
- const relativePath2 = options.fileName ?? "AGENTS.md";
13716
- const pointer = AGENTS_MD_SUMMARY_POINTER_INSTRUCTION.replaceAll(
13717
- "%REL%",
13718
- relativePath2
13719
- ).replaceAll("%PATH%", filePath);
13720
- const head = `${pointer}
13721
- ${AGENTS_MD_SUMMARY_DELETE_REFERENCE}
13722
- `;
13723
- if (Buffer.byteLength(head, "utf8") > budgetBytes) return null;
13724
- const candidates = [
13725
- ...items.filter((item) => item.priority >= 0).sort((a, b) => a.priority - b.priority),
13726
- ...items.filter((item) => item.priority < 0)
13727
- ];
13728
- const noteBlock = `
13729
- \u2026\uFF08\u7D22\u5F15\u5DF2\u622A\u65AD\uFF0C\u5176\u4F59\u951A\u70B9\u89C1\u5B8C\u6574\u6587\u4EF6\uFF09`;
13730
- const noteBytes = Buffer.byteLength(noteBlock, "utf8");
13731
- let used = Buffer.byteLength(head, "utf8");
13732
- const admitted = [];
13733
- const seenSections = /* @__PURE__ */ new Set();
13734
- let truncated = false;
13735
- for (const item of candidates) {
13736
- const line = item.gist ? `- ${item.label}\uFF1A${item.gist}` : `- ${item.label}`;
13737
- const headingCost = item.section && !seenSections.has(item.section) ? Buffer.byteLength(`
13738
- ## ${item.section}`, "utf8") : 0;
13739
- const cost = headingCost + Buffer.byteLength(`
13740
- ${line}`, "utf8");
13741
- if (used + cost + noteBytes > budgetBytes) {
13742
- truncated = true;
13743
- continue;
13744
- }
13745
- used += cost;
13746
- if (item.section) seenSections.add(item.section);
13747
- admitted.push(item);
13748
- }
13749
- const groupOrder = [];
13750
- for (const item of admitted) {
13751
- if (!groupOrder.includes(item.section)) groupOrder.push(item.section);
13752
- }
13753
- const frozen = [];
13754
- for (const section of groupOrder) {
13755
- for (const item of admitted) {
13756
- if (item.section !== section) continue;
13757
- frozen.push({
13758
- section,
13759
- line: item.gist ? `- ${item.label}\uFF1A${item.gist}` : `- ${item.label}`
13760
- });
13761
- }
13762
- }
13763
- if (admitted.length === 0) return null;
13764
- return `${head}${renderSummarySections(frozen)}${truncated ? noteBlock : ""}`;
13765
- }
13766
- var renderSummarySections = (entries) => {
13767
- let rendered = "";
13768
- let currentSection = null;
13769
- for (const entry of entries) {
13770
- if (entry.section && entry.section !== currentSection) {
13771
- rendered += `
13772
- ## ${entry.section}`;
13773
- currentSection = entry.section;
13774
- }
13775
- rendered += `
13776
- ${entry.line}`;
13777
- }
13778
- return rendered;
13779
- };
13780
- function readAgentsMdLayerFromDisk(cwd) {
13781
- for (const name of AGENTS_MD_CANDIDATES) {
13782
- const filePath = resolve3(cwd, name);
13783
- if (!existsSync2(filePath)) continue;
13784
- try {
13785
- const raw = readFileSync3(filePath, "utf8");
13786
- const content = raw.trim();
13787
- if (!content) continue;
13788
- const totalBytes = Buffer.byteLength(raw, "utf8");
13789
- const trimmedBytes = Buffer.byteLength(content, "utf8");
13790
- const headerBytes = Buffer.byteLength(buildAgentsMdLayerHeader(name), "utf8");
13791
- if (headerBytes + trimmedBytes <= AGENTS_MD_MAX_BYTES) {
13792
- return buildAgentsMdLayer(content, name);
13793
- }
13794
- const summaryBody = buildAgentsMdSummaryBody(content, filePath, {
13795
- // 正文预算 = 摘要上限 − 块头部:buildAgentsMdLayer 会再拼一次头部,
13796
- // 因此「头部 + 正文」才等于最终注入字节,不得超过摘要上限。
13797
- budgetBytes: AGENTS_MD_SUMMARY_MAX_BYTES - headerBytes,
13798
- fileName: name
13799
- });
13800
- if (summaryBody) return buildAgentsMdLayer(summaryBody, name);
13801
- const buildMarker = (omitted2, withPath) => {
13802
- const pathPart = withPath ? `\u5B8C\u6574\u6587\u4EF6\uFF1A${filePath}` : `\u5B8C\u6574\u6587\u4EF6\uFF1A\u5DE5\u4F5C\u533A\u6839\u76EE\u5F55\u7684 ${name}`;
13803
- return `<!-- AGENTS.md truncated: \u539F\u6587\u4EF6 ${totalBytes} \u5B57\u8282\uFF0C\u6CE8\u5165\u9884\u7B97 ${AGENTS_MD_MAX_BYTES} \u5B57\u8282\uFF0C\u5DF2\u7701\u7565 ${omitted2} \u5B57\u8282\uFF08\u4E0A\u6587\u53EF\u80FD\u7F3A\u5C11\u6587\u4EF6\u672B\u5C3E\u7684 commit/review \u95E8\u7981\u7EC6\u5219\uFF0C\u63D0\u4EA4/\u8BC4\u5BA1\u524D\u8BF7\u8BFB\u5B8C\u6574\u6587\u4EF6\uFF09\u3002${pathPart} -->`;
13804
- };
13805
- const bodyBudget = AGENTS_MD_MAX_BYTES - AGENTS_MD_MARKER_RESERVE_BYTES - 2 - headerBytes;
13806
- const body = truncateAgentsMdContent(content, bodyBudget);
13807
- const bodyBytes = Buffer.byteLength(body, "utf8");
13808
- const omitted = Math.max(0, totalBytes - bodyBytes);
13809
- let marker = buildMarker(omitted, true);
13810
- if (Buffer.byteLength(marker, "utf8") > AGENTS_MD_MARKER_RESERVE_BYTES) {
13811
- marker = buildMarker(omitted, false);
13812
- }
13813
- return buildAgentsMdLayer(`${body}
13814
-
13815
- ${marker}`, name);
13816
- } catch {
13817
- }
13818
- }
13819
- return null;
13820
- }
13821
-
13822
14161
  // packages/ai/token/cacheRunSummary.ts
13823
14162
  var finiteCount = (value) => typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : void 0;
13824
14163
  var isUsageObject = (usage) => Boolean(usage) && typeof usage === "object";
@@ -13920,17 +14259,17 @@ function runDoDCommands(commands, cwd, deps = {}) {
13920
14259
  }
13921
14260
 
13922
14261
  // packages/cli/agentRunPrompts.ts
13923
- import { existsSync as existsSync3, readFileSync as readFileSync4, readdirSync, statSync as statSync2 } from "node:fs";
13924
- import { dirname, extname, isAbsolute as isAbsolute2, join as join2, relative as relativePath, resolve as resolve4, sep } from "node:path";
14262
+ import { existsSync as existsSync2, readFileSync as readFileSync3, readdirSync, statSync as statSync2 } from "node:fs";
14263
+ import { dirname, extname, isAbsolute as isAbsolute2, join as join2, relative as relativePath, resolve as resolve3, sep } from "node:path";
13925
14264
  function workflowRefToCandidatePath(cwd, ref) {
13926
14265
  const normalized = ref.trim();
13927
14266
  if (!normalized) return "";
13928
14267
  if (normalized.endsWith(".md") || normalized.includes("/") || normalized.includes("\\")) {
13929
- const directPath = resolve4(cwd, normalized);
13930
- if (existsSync3(directPath)) return directPath;
14268
+ const directPath = resolve3(cwd, normalized);
14269
+ if (existsSync2(directPath)) return directPath;
13931
14270
  }
13932
14271
  const fileName = normalized.replace(/[^a-zA-Z0-9一-鿿]+/g, "-").replace(/^-+|-+$/g, "");
13933
- return resolve4(cwd, "docs", "workflows", `${fileName}.md`);
14272
+ return resolve3(cwd, "docs", "workflows", `${fileName}.md`);
13934
14273
  }
13935
14274
  var SKILL_SEARCH_DIRS = [
13936
14275
  ".agents/skills"
@@ -13939,22 +14278,22 @@ function skillRefToCandidatePath(cwd, ref) {
13939
14278
  const normalized = ref.trim();
13940
14279
  if (!normalized) return "";
13941
14280
  if (normalized.endsWith(".md") || normalized.includes("/") || normalized.includes("\\")) {
13942
- const directPath = resolve4(cwd, normalized);
13943
- if (existsSync3(directPath)) return directPath;
14281
+ const directPath = resolve3(cwd, normalized);
14282
+ if (existsSync2(directPath)) return directPath;
13944
14283
  }
13945
14284
  const fileName = normalized.replace(/[^a-zA-Z0-9一-鿿]+/g, "-").replace(/^-+|-+$/g, "");
13946
14285
  for (const dir of SKILL_SEARCH_DIRS) {
13947
- const skillMdPath = resolve4(cwd, dir, fileName, "SKILL.md");
13948
- if (existsSync3(skillMdPath)) return skillMdPath;
14286
+ const skillMdPath = resolve3(cwd, dir, fileName, "SKILL.md");
14287
+ if (existsSync2(skillMdPath)) return skillMdPath;
13949
14288
  }
13950
- return resolve4(cwd, ".agents", "skills", fileName, "SKILL.md");
14289
+ return resolve3(cwd, ".agents", "skills", fileName, "SKILL.md");
13951
14290
  }
13952
14291
  async function resolveWorkflowReference(ref, cwd = process.cwd()) {
13953
14292
  const path2 = workflowRefToCandidatePath(cwd, ref);
13954
- if (!path2 || !existsSync3(path2)) {
14293
+ if (!path2 || !existsSync2(path2)) {
13955
14294
  throw new Error(`Workflow reference not found: ${ref}`);
13956
14295
  }
13957
- const markdown = readFileSync4(path2, "utf8");
14296
+ const markdown = readFileSync3(path2, "utf8");
13958
14297
  const parsed = parseSkillDocProtocol(markdown);
13959
14298
  return {
13960
14299
  ref,
@@ -13964,15 +14303,15 @@ async function resolveWorkflowReference(ref, cwd = process.cwd()) {
13964
14303
  }
13965
14304
  function inlineRelativeRefs(body, skillDir) {
13966
14305
  const refPattern = /\[([^\]]+)\]\((\.\/[^)]+|[^)]+\/[^)]+)\)/g;
13967
- const normalizedSkillDir = resolve4(skillDir) + sep;
14306
+ const normalizedSkillDir = resolve3(skillDir) + sep;
13968
14307
  return body.replace(refPattern, (match, label, relPath) => {
13969
14308
  const cleaned = relPath.trim();
13970
14309
  if (!cleaned.startsWith("./") && !cleaned.startsWith("../")) return match;
13971
- const absPath = resolve4(skillDir, cleaned);
14310
+ const absPath = resolve3(skillDir, cleaned);
13972
14311
  const relative = relativePath(normalizedSkillDir, absPath);
13973
14312
  if (relative.startsWith("..") || isAbsolute2(relative)) return match;
13974
- if (!existsSync3(absPath) || !absPath.endsWith(".md")) return match;
13975
- const refContent = readFileSync4(absPath, "utf8");
14313
+ if (!existsSync2(absPath) || !absPath.endsWith(".md")) return match;
14314
+ const refContent = readFileSync3(absPath, "utf8");
13976
14315
  return `
13977
14316
 
13978
14317
  ### ${label}
@@ -13984,7 +14323,7 @@ ${refContent}
13984
14323
  }
13985
14324
  function listSkillScripts(skillDir) {
13986
14325
  const scriptsDir = join2(skillDir, "scripts");
13987
- if (!existsSync3(scriptsDir) || !statSync2(scriptsDir).isDirectory()) return null;
14326
+ if (!existsSync2(scriptsDir) || !statSync2(scriptsDir).isDirectory()) return null;
13988
14327
  const entries = readdirSync(scriptsDir).filter((e) => !e.startsWith("."));
13989
14328
  if (entries.length === 0) return null;
13990
14329
  return [
@@ -14011,10 +14350,10 @@ async function resolveSkillReference(ref, options = {}) {
14011
14350
  } else {
14012
14351
  const cwd = options.cwd ?? process.cwd();
14013
14352
  const path2 = skillRefToCandidatePath(cwd, ref);
14014
- if (!path2 || !existsSync3(path2)) {
14353
+ if (!path2 || !existsSync2(path2)) {
14015
14354
  throw new Error(`Skill reference not found: ${ref}`);
14016
14355
  }
14017
- markdown = readFileSync4(path2, "utf8");
14356
+ markdown = readFileSync3(path2, "utf8");
14018
14357
  filePath = path2;
14019
14358
  skillDir = dirname(path2);
14020
14359
  }
@@ -14118,9 +14457,9 @@ function prependSubjectDialogMarker(message, subjectDialogKey) {
14118
14457
  }
14119
14458
  function normalizeCliImageInput(input) {
14120
14459
  if (/^(https?:|data:|file:)/i.test(input)) return input;
14121
- const absolutePath = resolve4(input);
14122
- if (!existsSync3(absolutePath)) return input;
14123
- const base64 = readFileSync4(absolutePath).toString("base64");
14460
+ const absolutePath = resolve3(input);
14461
+ if (!existsSync2(absolutePath)) return input;
14462
+ const base64 = readFileSync3(absolutePath).toString("base64");
14124
14463
  return `data:${imageMimeTypeForPath(absolutePath)};base64,${base64}`;
14125
14464
  }
14126
14465
  function imageMimeTypeForPath(path2) {
@@ -14185,6 +14524,73 @@ var createDetachedThrottle = (input) => {
14185
14524
  };
14186
14525
  };
14187
14526
 
14527
+ // packages/ai/memory/vnext/recallBudget.ts
14528
+ var DEFAULT_DEEP_MEMORY_TOKENS = DEFAULT_MEMORY_OVERLAY_TOKEN_BUDGET;
14529
+ var resolveMemoryBudget = (value) => {
14530
+ const budget = value ?? DEFAULT_DEEP_MEMORY_TOKENS;
14531
+ if (!Number.isSafeInteger(budget) || budget < 512) {
14532
+ throw new Error("memory budget must be a safe integer >= 512 estimated tokens");
14533
+ }
14534
+ return budget;
14535
+ };
14536
+ var clipMemoryText = (text, maxTokens) => {
14537
+ if (estimateTokenCount(text) <= maxTokens) return text;
14538
+ const suffix = "\u2026[truncated]";
14539
+ if (estimateTokenCount(suffix) > maxTokens) return "";
14540
+ let lo = 0;
14541
+ let hi = text.length;
14542
+ while (lo < hi) {
14543
+ const mid = Math.ceil((lo + hi) / 2);
14544
+ if (estimateTokenCount(text.slice(0, mid) + suffix) <= maxTokens) lo = mid;
14545
+ else hi = mid - 1;
14546
+ }
14547
+ if (lo && /[\uD800-\uDBFF]/.test(text[lo - 1])) lo--;
14548
+ return text.slice(0, lo) + suffix;
14549
+ };
14550
+ var DESCRIPTIVE_FIELDS = /* @__PURE__ */ new Set(["text", "name", "facet", "subtype", "value", "aliases"]);
14551
+ var compactMemoryRow = (row, fieldTokens = 128) => Object.fromEntries(Object.entries(row).map(([key, value]) => [
14552
+ key,
14553
+ DESCRIPTIVE_FIELDS.has(key) && estimateTokenCount(typeof value === "string" ? value : JSON.stringify(value) ?? "") > fieldTokens ? clipMemoryText(typeof value === "string" ? value : JSON.stringify(value) ?? "", fieldTokens) : value
14554
+ ]));
14555
+ var memoryMessageTokens = (messages) => messages.reduce((sum, message) => sum + estimateTokenCount(message.content) + 8, 0);
14556
+ var buildBudgetedMemoryInput = (input) => {
14557
+ const maxTokens = resolveMemoryBudget(input.maxTokens);
14558
+ const query = clipMemoryText(input.query, Math.floor(maxTokens / 4));
14559
+ const rows = [];
14560
+ const messages = () => [
14561
+ { role: "system", content: input.system + "\nThis is a budgeted subset. Omitted candidates are unknown, not absent. Select only supplied exact ids; never infer nonexistence from omissions." },
14562
+ { role: "user", content: `Query:
14563
+ ${query}
14564
+
14565
+ Memory catalog:
14566
+ ${JSON.stringify({ candidates: rows })}` }
14567
+ ];
14568
+ if (memoryMessageTokens(messages()) > maxTokens) {
14569
+ throw new Error("memory budget cannot fit instructions and query");
14570
+ }
14571
+ let clipped = false;
14572
+ for (const original of input.rows) {
14573
+ const row = compactMemoryRow(original);
14574
+ rows.push(row);
14575
+ if (memoryMessageTokens(messages()) > maxTokens) rows.pop();
14576
+ else if (JSON.stringify(row) !== JSON.stringify(original)) clipped = true;
14577
+ }
14578
+ const result = messages();
14579
+ return {
14580
+ messages: result,
14581
+ rows,
14582
+ budget: {
14583
+ maxTokens,
14584
+ usedTokens: memoryMessageTokens(result),
14585
+ truncated: clipped || rows.length !== input.rows.length || query !== input.query,
14586
+ queryTruncated: query !== input.query,
14587
+ offeredCandidates: rows.length,
14588
+ totalCandidates: input.rows.length,
14589
+ omittedCandidates: input.rows.length - rows.length
14590
+ }
14591
+ };
14592
+ };
14593
+
14188
14594
  // packages/ai/memory/vnext/recall.ts
14189
14595
  var MAX_RECALL_REFS = 6;
14190
14596
  var stripFence = (raw) => {
@@ -14214,76 +14620,84 @@ var parseSelection = (raw) => {
14214
14620
  reason: obj.reason
14215
14621
  };
14216
14622
  };
14217
- var catalogText = (entities, states) => JSON.stringify(
14218
- {
14219
- entities: entities.map((entity) => ({
14220
- id: entity.id,
14221
- type: entity.type,
14222
- name: entity.name,
14223
- ...entity.subtype ? { subtype: entity.subtype } : {},
14224
- ...entity.aliases?.length ? { aliases: entity.aliases } : {}
14225
- })),
14226
- states: states.map((state2) => ({
14227
- id: state2.id,
14228
- entityId: state2.entityId,
14229
- facet: state2.facet,
14230
- text: state2.text,
14231
- // Retired (superseded) States stay listed as recoverable history; the
14232
- // boolean — not the retiredAt timestamp — enters the prompt so no
14233
- // timestamps reach LLM text.
14234
- ...state2.retiredAt ? { retired: true } : {}
14235
- }))
14236
- },
14237
- null,
14238
- 2
14239
- );
14240
14623
  var createMemoryVNextRecall = (input) => async (query) => {
14241
14624
  const startedAt = performance.now();
14625
+ const maxTokens = resolveMemoryBudget(input.maxInputTokens);
14242
14626
  const { entities, states } = await loadMemoryVNextCatalog(input.db, input.ownerId);
14243
- if (entities.length === 0 && states.length === 0) {
14627
+ if (!query.trim() || entities.length === 0 && states.length === 0) {
14244
14628
  return {
14245
14629
  query,
14246
14630
  refs: [],
14247
14631
  entities: [],
14248
14632
  states: [],
14249
- reason: "memory catalog is empty",
14633
+ reason: query.trim() ? "memory catalog is empty" : "query is empty",
14250
14634
  trace: {
14251
14635
  candidateEntities: 0,
14252
14636
  candidateStates: 0,
14253
14637
  selectedRefs: 0,
14638
+ budget: {
14639
+ maxTokens,
14640
+ usedTokens: 0,
14641
+ truncated: false,
14642
+ offeredCandidates: 0,
14643
+ totalCandidates: entities.length + states.length,
14644
+ omittedCandidates: entities.length + states.length
14645
+ },
14254
14646
  elapsedMs: Math.round((performance.now() - startedAt) * 10) / 10
14255
14647
  }
14256
14648
  };
14257
14649
  }
14258
- const result = await input.provider.complete(
14259
- [
14260
- {
14261
- role: "system",
14262
- content: [
14263
- "Select the smallest useful set of long-lived memory entrances for the user query.",
14264
- 'Return ONLY JSON: {"refs":["exact-id"],"reason":"short explanation"}.',
14265
- `Select at most ${MAX_RECALL_REFS} exact ids from the supplied catalog.`,
14266
- "Prefer State ids when current durable understanding answers the query.",
14267
- "Select an Entity id when it is a useful navigation anchor and no single State is enough.",
14268
- "Do not select unrelated memories merely because they are personal or interesting.",
14269
- "Historical-detail questions may select the relevant current State/Entity as an entrance; deeper evidence is handled by inspect, not here."
14270
- ].join("\n")
14271
- },
14272
- {
14273
- role: "user",
14274
- content: `Query:
14275
- ${query}
14276
-
14277
- Memory catalog:
14278
- ${catalogText(entities, states)}`
14279
- }
14650
+ const hits = recallMemoryVNextLocal({ query, entities, states, limit: states.length });
14651
+ const priority = new Set(hits.flatMap(({ state: state2 }) => [state2.id, state2.entityId]));
14652
+ const rankedStates = [
14653
+ ...hits.map(({ state: state2 }) => state2),
14654
+ ...states.filter((state2) => !priority.has(state2.id)).sort((a, b) => a.id.localeCompare(b.id))
14655
+ ];
14656
+ const rankedEntities = [...entities].sort((a, b) => Number(priority.has(b.id)) - Number(priority.has(a.id)) || a.id.localeCompare(b.id));
14657
+ const stateRows = rankedStates.map((state2) => ({
14658
+ kind: "state",
14659
+ id: state2.id,
14660
+ entityId: state2.entityId,
14661
+ facet: state2.facet,
14662
+ text: state2.text,
14663
+ ...state2.retiredAt ? { retired: true } : {}
14664
+ }));
14665
+ const entityRows = rankedEntities.map((entity) => ({
14666
+ kind: "entity",
14667
+ id: entity.id,
14668
+ type: entity.type,
14669
+ name: entity.name,
14670
+ ...entity.subtype ? { subtype: entity.subtype } : {},
14671
+ ...entity.aliases?.length ? { aliases: entity.aliases } : {}
14672
+ }));
14673
+ const request = buildBudgetedMemoryInput({
14674
+ query,
14675
+ maxTokens: input.maxInputTokens,
14676
+ rows: [
14677
+ ...stateRows.filter((row) => priority.has(row.id)),
14678
+ ...entityRows.filter((row) => priority.has(row.id)),
14679
+ ...stateRows.filter((row) => !priority.has(row.id)),
14680
+ ...entityRows.filter((row) => !priority.has(row.id))
14280
14681
  ],
14682
+ system: [
14683
+ "Select the smallest useful set of long-lived memory entrances for the user query.",
14684
+ 'Return ONLY JSON: {"refs":["exact-id"],"reason":"short explanation"}.',
14685
+ `Select at most ${MAX_RECALL_REFS} exact ids from the supplied catalog.`,
14686
+ "Prefer current State ids; retired States are history entrances, not current facts.",
14687
+ "Select an Entity when it is a useful navigation anchor.",
14688
+ "Do not select unrelated memories merely because they are personal or interesting.",
14689
+ "Historical questions may select a relevant entrance; deeper evidence is handled by inspect."
14690
+ ].join("\n")
14691
+ });
14692
+ const result = await input.provider.complete(
14693
+ request.messages,
14281
14694
  input.timeoutMs ? { timeoutMs: input.timeoutMs } : void 0
14282
14695
  );
14283
14696
  const selected = parseSelection(result.content);
14284
14697
  const entityById = new Map(entities.map((entity) => [entity.id, entity]));
14285
14698
  const stateById = new Map(states.map((state2) => [state2.id, state2]));
14286
- const validRefs = selected.refs.filter((ref) => entityById.has(ref) || stateById.has(ref));
14699
+ const offered = new Set(request.rows.map((row) => row.id));
14700
+ const validRefs = selected.refs.filter((ref) => offered.has(ref) && (entityById.has(ref) || stateById.has(ref)));
14287
14701
  return {
14288
14702
  query,
14289
14703
  refs: validRefs,
@@ -14300,6 +14714,7 @@ ${catalogText(entities, states)}`
14300
14714
  candidateEntities: entities.length,
14301
14715
  candidateStates: states.length,
14302
14716
  selectedRefs: validRefs.length,
14717
+ budget: request.budget,
14303
14718
  elapsedMs: Math.round((performance.now() - startedAt) * 10) / 10
14304
14719
  }
14305
14720
  };
@@ -14455,254 +14870,6 @@ var runMemoryVNextShadowRead = async (input) => {
14455
14870
  };
14456
14871
  var isMemoryVNextShadowReadEnabled = (env = typeof process !== "undefined" ? process.env : {}) => env.NOLO_MEMORY_VNEXT_SHADOW_READ === "1" || env.NOLO_MEMORY_VNEXT_SHADOW_READ === "true";
14457
14872
 
14458
- // packages/ai/memory/vnext/applyMutation.ts
14459
- async function validateMutation(db, ownerId, mutation) {
14460
- const pending = {
14461
- evidenceIds: /* @__PURE__ */ new Set(),
14462
- entityIds: /* @__PURE__ */ new Set(),
14463
- stateIds: /* @__PURE__ */ new Set(),
14464
- relationIds: /* @__PURE__ */ new Set()
14465
- };
14466
- for (const ev of mutation.evidence ?? []) {
14467
- if (!ev.id || typeof ev.id !== "string") {
14468
- throw new Error("evidence id must be a non-empty string");
14469
- }
14470
- if (pending.evidenceIds.has(ev.id)) {
14471
- throw new Error(`duplicate evidence id in mutation: ${ev.id}`);
14472
- }
14473
- pending.evidenceIds.add(ev.id);
14474
- }
14475
- for (const ent of mutation.entities ?? []) {
14476
- if (!ent.id || typeof ent.id !== "string") {
14477
- throw new Error("entity id must be a non-empty string");
14478
- }
14479
- if (pending.entityIds.has(ent.id)) {
14480
- throw new Error(`duplicate entity id in mutation: ${ent.id}`);
14481
- }
14482
- pending.entityIds.add(ent.id);
14483
- }
14484
- for (const st of mutation.states ?? []) {
14485
- if (!st.id || typeof st.id !== "string") {
14486
- throw new Error("state id must be a non-empty string");
14487
- }
14488
- if (pending.stateIds.has(st.id)) {
14489
- throw new Error(`duplicate state id in mutation: ${st.id}`);
14490
- }
14491
- pending.stateIds.add(st.id);
14492
- }
14493
- for (const rel of mutation.relations ?? []) {
14494
- if (!rel.id || typeof rel.id !== "string") {
14495
- throw new Error("relation id must be a non-empty string");
14496
- }
14497
- if (pending.relationIds.has(rel.id)) {
14498
- throw new Error(`duplicate relation id in mutation: ${rel.id}`);
14499
- }
14500
- pending.relationIds.add(rel.id);
14501
- }
14502
- const supersededIds = /* @__PURE__ */ new Set();
14503
- for (const sid of mutation.supersededStateIds ?? []) {
14504
- if (supersededIds.has(sid)) {
14505
- throw new Error(`duplicate supersededStateId in mutation: ${sid}`);
14506
- }
14507
- supersededIds.add(sid);
14508
- }
14509
- for (const ev of mutation.evidence ?? []) {
14510
- if (ev.ownerId !== ownerId) {
14511
- throw new Error(
14512
- `evidence ${ev.id} has ownerId ${ev.ownerId}, expected ${ownerId}`
14513
- );
14514
- }
14515
- }
14516
- for (const ent of mutation.entities ?? []) {
14517
- if (ent.ownerId !== ownerId) {
14518
- throw new Error(
14519
- `entity ${ent.id} has ownerId ${ent.ownerId}, expected ${ownerId}`
14520
- );
14521
- }
14522
- }
14523
- for (const st of mutation.states ?? []) {
14524
- if (st.ownerId !== ownerId) {
14525
- throw new Error(
14526
- `state ${st.id} has ownerId ${st.ownerId}, expected ${ownerId}`
14527
- );
14528
- }
14529
- }
14530
- for (const rel of mutation.relations ?? []) {
14531
- if (rel.ownerId !== ownerId) {
14532
- throw new Error(
14533
- `relation ${rel.id} has ownerId ${rel.ownerId}, expected ${ownerId}`
14534
- );
14535
- }
14536
- }
14537
- for (const st of mutation.states ?? []) {
14538
- if (supersededIds.has(st.id)) {
14539
- throw new Error(
14540
- `state ${st.id} appears in both states and supersededStateIds; a record cannot be created and retired in the same mutation`
14541
- );
14542
- }
14543
- }
14544
- const facetSlots = /* @__PURE__ */ new Set();
14545
- for (const st of mutation.states ?? []) {
14546
- const slot = `${st.entityId} ${st.facet}`;
14547
- if (facetSlots.has(slot)) {
14548
- throw new Error(
14549
- `mutation writes parallel current states for entity ${st.entityId} facet ${st.facet}`
14550
- );
14551
- }
14552
- facetSlots.add(slot);
14553
- }
14554
- for (const ev of mutation.evidence ?? []) {
14555
- const existing = await getMemoryEvidenceVNext(db, ownerId, ev.id);
14556
- if (existing) {
14557
- throw new Error(
14558
- `evidence ${ev.id} already exists (owner ${ownerId}); use a unique id`
14559
- );
14560
- }
14561
- }
14562
- for (const ent of mutation.entities ?? []) {
14563
- const existing = await getMemoryEntityVNext(db, ownerId, ent.id);
14564
- if (existing) {
14565
- throw new Error(
14566
- `entity ${ent.id} already exists (owner ${ownerId}); use a unique id`
14567
- );
14568
- }
14569
- }
14570
- for (const st of mutation.states ?? []) {
14571
- if (!pending.entityIds.has(st.entityId)) {
14572
- const entity = await getMemoryEntityVNext(db, ownerId, st.entityId);
14573
- if (!entity) {
14574
- throw new Error(
14575
- `memory state ${st.id} references missing entity ${st.entityId} (owner ${ownerId})`
14576
- );
14577
- }
14578
- }
14579
- for (const evidenceId of st.evidenceIds) {
14580
- if (!pending.evidenceIds.has(evidenceId)) {
14581
- const ev = await getMemoryEvidenceVNext(db, ownerId, evidenceId);
14582
- if (!ev) {
14583
- throw new Error(
14584
- `memory state ${st.id} references missing evidence ${evidenceId} (owner ${ownerId})`
14585
- );
14586
- }
14587
- }
14588
- }
14589
- const existing = await getMemoryStateVNext(db, ownerId, st.id);
14590
- if (existing) {
14591
- if (existing.retiredAt) {
14592
- throw new Error(
14593
- `cannot update retired memory state ${st.id} (owner ${ownerId})`
14594
- );
14595
- }
14596
- if (existing.entityId !== st.entityId || existing.facet !== st.facet) {
14597
- throw new Error(
14598
- `state ${st.id} already exists with different entity/facet (${existing.entityId}/${existing.facet} vs ${st.entityId}/${st.facet}); use supersede instead`
14599
- );
14600
- }
14601
- }
14602
- if (!existing) {
14603
- const existingStates = await listMemoryStatesForEntityVNext(db, ownerId, st.entityId);
14604
- for (const es of existingStates) {
14605
- if (es.facet === st.facet && !es.retiredAt) {
14606
- if (!supersededIds.has(es.id)) {
14607
- throw new Error(
14608
- `entity ${st.entityId} facet ${st.facet} already has current state ${es.id}; supersede it or use a different facet`
14609
- );
14610
- }
14611
- }
14612
- }
14613
- }
14614
- }
14615
- for (const sid of mutation.supersededStateIds ?? []) {
14616
- const existing = await getMemoryStateVNext(db, ownerId, sid);
14617
- if (!existing) {
14618
- throw new Error(
14619
- `cannot supersede missing memory state: ${sid} (owner ${ownerId})`
14620
- );
14621
- }
14622
- if (existing.retiredAt) {
14623
- throw new Error(
14624
- `cannot supersede already retired memory state: ${sid} (owner ${ownerId})`
14625
- );
14626
- }
14627
- const replacement = (mutation.states ?? []).find(
14628
- (st) => st.entityId === existing.entityId && st.facet === existing.facet
14629
- );
14630
- if (!replacement) {
14631
- throw new Error(
14632
- `superseded state ${sid} (entity ${existing.entityId} facet ${existing.facet}) has no replacement in this mutation`
14633
- );
14634
- }
14635
- }
14636
- for (const rel of mutation.relations ?? []) {
14637
- for (const [side, ref] of [
14638
- ["from", rel.from],
14639
- ["to", rel.to]
14640
- ]) {
14641
- if (pending.entityIds.has(ref) || pending.stateIds.has(ref) || pending.evidenceIds.has(ref)) {
14642
- continue;
14643
- }
14644
- const resolved = await getMemoryEntityVNext(db, ownerId, ref) ?? await getMemoryStateVNext(db, ownerId, ref) ?? await getMemoryEvidenceVNext(db, ownerId, ref);
14645
- if (!resolved) {
14646
- throw new Error(
14647
- `memory relation ${rel.id} references missing ${side} ${ref} (owner ${ownerId})`
14648
- );
14649
- }
14650
- }
14651
- }
14652
- }
14653
- var applyMutationWithoutCoordination = async (db, ownerId, mutation) => {
14654
- await validateMutation(db, ownerId, mutation);
14655
- const batch = db.batch();
14656
- for (const ev of mutation.evidence ?? []) {
14657
- _appendEvidenceBatch(batch, ev);
14658
- }
14659
- for (const ent of mutation.entities ?? []) {
14660
- _appendEntityBatch(batch, ent);
14661
- }
14662
- for (const st of mutation.states ?? []) {
14663
- _appendStateBatch(batch, st);
14664
- }
14665
- for (const sid of mutation.supersededStateIds ?? []) {
14666
- const existing = await getMemoryStateVNext(db, ownerId, sid);
14667
- if (!existing) {
14668
- throw new Error(
14669
- `cannot supersede missing memory state: ${sid} (owner ${ownerId})`
14670
- );
14671
- }
14672
- const replacement = (mutation.states ?? []).find(
14673
- (st) => st.entityId === existing.entityId && st.facet === existing.facet
14674
- );
14675
- const retired = {
14676
- ...existing,
14677
- retiredAt: replacement?.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString()
14678
- };
14679
- _appendRetiredStateBatch(batch, retired);
14680
- }
14681
- for (const rel of mutation.relations ?? []) {
14682
- _appendRelationBatch(batch, rel);
14683
- }
14684
- await batch.write();
14685
- };
14686
- var pendingByDb = /* @__PURE__ */ new WeakMap();
14687
- var applyMemoryInterpreterMutation = async (db, ownerId, mutation) => {
14688
- let owners = pendingByDb.get(db);
14689
- if (!owners) {
14690
- owners = /* @__PURE__ */ new Map();
14691
- pendingByDb.set(db, owners);
14692
- }
14693
- const previous = owners.get(ownerId) ?? Promise.resolve();
14694
- const operation = previous.then(() => applyMutationWithoutCoordination(db, ownerId, mutation));
14695
- const settled = operation.then(() => {
14696
- }, () => {
14697
- });
14698
- owners.set(ownerId, settled);
14699
- try {
14700
- await operation;
14701
- } finally {
14702
- if (owners.get(ownerId) === settled) owners.delete(ownerId);
14703
- }
14704
- };
14705
-
14706
14873
  // packages/ai/memory/vnext/legacyMigrationApply.ts
14707
14874
  var isSameLegacyMemoryEvidence = (left, right) => left.id === right.id && left.ownerId === right.ownerId && left.text === right.text && left.sourceRef === right.sourceRef && left.confidence === right.confidence && left.createdAt === right.createdAt;
14708
14875
  var applyLegacyMemoryEvidence = async (db, item) => {
@@ -15389,6 +15556,10 @@ var resolveMemoryVNextM4Selection = async (input) => {
15389
15556
  const renderItems = [...recalledStates, ...uncoveredLegacy];
15390
15557
  return {
15391
15558
  renderItems,
15559
+ sources: new Map([
15560
+ ...recalledStates.map((item) => [item, "vnext"]),
15561
+ ...uncoveredLegacy.map((item) => [item, "legacy-uncovered"])
15562
+ ]),
15392
15563
  recalledStateCount: recalledStates.length,
15393
15564
  uncoveredLegacyCount: uncoveredLegacy.length,
15394
15565
  coveredSuppressedCount
@@ -15516,6 +15687,10 @@ var resolveMemoryRuntime = async (input) => {
15516
15687
  let outcome = "error";
15517
15688
  let errorKind = "runtime_error";
15518
15689
  let fallbackKind = "none";
15690
+ let injection = emptyMemoryInjectionObservation();
15691
+ const injectionEmit = (observation) => {
15692
+ injection = observation;
15693
+ };
15519
15694
  const finish = (result) => {
15520
15695
  outcome = fallbackKind === "none" ? result.promptBlock ? "result" : "empty" : "fallback";
15521
15696
  errorKind = fallbackKind;
@@ -15539,7 +15714,8 @@ var resolveMemoryRuntime = async (input) => {
15539
15714
  db: input.db,
15540
15715
  owners,
15541
15716
  userInput: input.userInput,
15542
- maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET
15717
+ maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET,
15718
+ injectionEmit
15543
15719
  });
15544
15720
  } catch (error) {
15545
15721
  pureFailed = true;
@@ -15668,8 +15844,8 @@ var resolveMemoryRuntime = async (input) => {
15668
15844
  );
15669
15845
  const selected = [...residentItems, ...ranked];
15670
15846
  const legacyLatencyMs = Math.round((performance.now() - legacyStartedAt) * 10) / 10;
15671
- const renderOverlay = (items) => items.length === 0 ? null : buildMemoryOverlay(items, { maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET });
15672
- let promptBlock = renderOverlay(selected);
15847
+ const renderOverlay = (items, sources) => buildMemoryOverlay(items, { maxTokens: MEMORY_OVERLAY_TOKEN_BUDGET, sources, injectionEmit });
15848
+ let promptBlock = configuredPrimary ? null : renderOverlay(selected);
15673
15849
  const primaryRead = configuredPrimary;
15674
15850
  let allCoveredByVNext = false;
15675
15851
  if (primaryRead) {
@@ -15698,7 +15874,7 @@ var resolveMemoryRuntime = async (input) => {
15698
15874
  );
15699
15875
  })
15700
15876
  ]).finally(() => clearTimeout(timer));
15701
- promptBlock = renderOverlay(m4.renderItems);
15877
+ promptBlock = renderOverlay(m4.renderItems, m4.sources);
15702
15878
  allCoveredByVNext = m4.uncoveredLegacyCount === 0 && m4.recalledStateCount > 0;
15703
15879
  const source = m4.recalledStateCount > 0 ? m4.uncoveredLegacyCount === 0 ? "vnext" : "hybrid" : m4.uncoveredLegacyCount > 0 ? "legacy_fallback" : "none";
15704
15880
  emitPrimary({
@@ -15712,6 +15888,7 @@ var resolveMemoryRuntime = async (input) => {
15712
15888
  ...source === "legacy_fallback" ? { fallbackReason: "no_vnext_context" } : {}
15713
15889
  });
15714
15890
  } catch (error) {
15891
+ promptBlock = renderOverlay(selected);
15715
15892
  fallbackKind = error === timeoutMarker ? "timeout" : "runtime_error";
15716
15893
  emitPrimary({
15717
15894
  ...base,
@@ -15767,6 +15944,7 @@ var resolveMemoryRuntime = async (input) => {
15767
15944
  return finish({ selectedItems: selected, promptBlock });
15768
15945
  } finally {
15769
15946
  const observation = {
15947
+ ...injection,
15770
15948
  event: "memory_runtime_result",
15771
15949
  configuredPure,
15772
15950
  configuredPrimary,
@@ -15967,6 +16145,35 @@ async function resolveAgentBoundMachineIdFromRecord(args) {
15967
16145
  return resolveBoundMachineId(record) || void 0;
15968
16146
  }
15969
16147
  async function runAgentRunCommand(args, deps) {
16148
+ const env = deps.env ?? process.env;
16149
+ const runId = env.NOLO_AGENT_RUN_ID;
16150
+ const controlDeps = { env, homedir: deps.homedir, fs: deps.fs, now: deps.now };
16151
+ const failStartup = async (error) => {
16152
+ if (!runId || readRunRecord(runId, controlDeps)?.status !== "running") return;
16153
+ const result = await settleRunTerminalAuthoritatively(runId, {
16154
+ status: "failed",
16155
+ exitCode: 1,
16156
+ failureReason: error instanceof RuntimeProtocolMismatchError ? "runtime_protocol_mismatch" : error instanceof RuntimeVersionMismatchError ? "runtime_version_mismatch" : "startup_failed",
16157
+ note: error ? toErrorMessage(error) : "Child initialization returned without terminal result"
16158
+ }, controlDeps, (id, update, d) => transitionRunToTerminal(id, update, d));
16159
+ if (result.kind === "contended") throw new Error(`Startup settlement lock busy: ${runId}`);
16160
+ };
16161
+ try {
16162
+ if (runId) {
16163
+ if (!readRunRecord(runId, controlDeps)) throw new Error("[local-writer-resource] missing child binding");
16164
+ await recordRunStartup(runId, "initializing", controlDeps);
16165
+ validateAgentRunProtocol(env.NOLO_AGENT_RUN_PROTOCOL);
16166
+ await recordRunStartup(runId, "protocol_validated", controlDeps);
16167
+ }
16168
+ const code = await runAgentRunCommandImpl(args, deps);
16169
+ if (runId) await failStartup();
16170
+ return code;
16171
+ } catch (error) {
16172
+ await failStartup(error);
16173
+ throw error;
16174
+ }
16175
+ }
16176
+ async function runAgentRunCommandImpl(args, deps) {
15970
16177
  const env = deps.env ?? process.env;
15971
16178
  const output = deps.output ?? {
15972
16179
  write: (chunk) => process.stdout.write(chunk),
@@ -15989,10 +16196,17 @@ async function runAgentRunCommand(args, deps) {
15989
16196
  return 1;
15990
16197
  }
15991
16198
  const rawRunner = deps.runner ?? runAgentTurn;
16199
+ let modelPhaseRecorded = false;
15992
16200
  const watchdogAbort = new AbortController();
15993
16201
  let activeRunner;
15994
16202
  const runner = (options) => {
15995
- activeRunner = Promise.resolve().then(() => rawRunner({ ...options, abortSignal: watchdogAbort.signal })).then((result) => {
16203
+ activeRunner = Promise.resolve().then(async () => {
16204
+ if (env.NOLO_AGENT_RUN_ID && !modelPhaseRecorded) {
16205
+ await recordRunStartup(env.NOLO_AGENT_RUN_ID, "model", { env, homedir: deps.homedir, fs: deps.fs, now: deps.now });
16206
+ modelPhaseRecorded = true;
16207
+ }
16208
+ return rawRunner({ ...options, abortSignal: watchdogAbort.signal });
16209
+ }).then((result) => {
15996
16210
  watchdogAbort.signal.throwIfAborted();
15997
16211
  return result;
15998
16212
  });
@@ -16005,8 +16219,8 @@ async function runAgentRunCommand(args, deps) {
16005
16219
  try {
16006
16220
  return await Promise.race([
16007
16221
  activeRunner.then(() => true, () => true),
16008
- new Promise((resolve5) => {
16009
- timer = setTimeout(() => resolve5(false), 100);
16222
+ new Promise((resolve4) => {
16223
+ timer = setTimeout(() => resolve4(false), 100);
16010
16224
  })
16011
16225
  ]);
16012
16226
  } finally {
@@ -16425,6 +16639,7 @@ async function runAgentRunCommand(args, deps) {
16425
16639
  );
16426
16640
  const shellApprovalChild = process.connected && typeof process.send === "function" ? createShellApprovalChild(process) : void 0;
16427
16641
  try {
16642
+ const imageUrls = await normalizeCliRunImages(parsed.imageUrls, normalizeCliImageInput);
16428
16643
  const buildRunOptions = (targetAgentKey, turnMessage = effectiveMessage) => ({
16429
16644
  ...shellApprovalChild ? { execShellApproval: targetAgentKey === agentKey ? shellApprovalChild.authority : {
16430
16645
  request: async () => {
@@ -16444,7 +16659,7 @@ async function runAgentRunCommand(args, deps) {
16444
16659
  responseViewport: "unknown",
16445
16660
  serverUrl: resolveServerUrl(env),
16446
16661
  message: formatTurnMessage(turnMessage),
16447
- imageUrls: parsed.imageUrls.map(normalizeCliImageInput),
16662
+ imageUrls,
16448
16663
  scriptDir: deps.scriptDir,
16449
16664
  env: runEnv,
16450
16665
  output,
@@ -16674,7 +16889,7 @@ async function runAgentRunCommand(args, deps) {
16674
16889
  acceptance.checks.observations = dodResults.map((check, index) => ({
16675
16890
  // Command lines/output can contain credentials. Persist only a digest
16676
16891
  // here; the pre-existing registry is the execution evidence reference.
16677
- commandFingerprint: `sha256:${createHash2("sha256").update(check.command).digest("hex")}`,
16892
+ commandFingerprint: `sha256:${createHash3("sha256").update(check.command).digest("hex")}`,
16678
16893
  cwd: childRecordForDoD?.cwd || process.cwd(),
16679
16894
  exitCode: check.exitCode,
16680
16895
  evidence: `${childRunId}.json#/dodResults/${index}`,
@@ -16744,6 +16959,16 @@ async function runAgentRunCommand(args, deps) {
16744
16959
  }
16745
16960
 
16746
16961
  export {
16962
+ resolveAgentModelIdentity,
16963
+ resolveAgentContextWindow2 as resolveAgentContextWindow,
16964
+ platformCreditsFromUsage,
16965
+ formatCreditsChip,
16966
+ resolveAuthorityTurnCount,
16967
+ computeBaselineContextTokens,
16968
+ preserveContextUsageWithoutReceipt,
16969
+ resolveContextUsage,
16970
+ renderTokenStatus,
16971
+ redactSecrets,
16747
16972
  resolveCliColorEnabled,
16748
16973
  dimCliText,
16749
16974
  THEME_PALETTES,
@@ -16769,21 +16994,10 @@ export {
16769
16994
  formatAssistantDisplay,
16770
16995
  resolveHistoryLayoutGeometry,
16771
16996
  resolveHistoryViewportHeight,
16772
- redactSecrets,
16773
16997
  safeAskText,
16774
16998
  safeApprovalMultilineText,
16775
16999
  TUI_TREE_MARKER,
16776
17000
  TUI_TREE_TOOLS,
16777
- resolveAgentModelIdentity,
16778
- resolveAgentContextWindow2 as resolveAgentContextWindow,
16779
- platformCreditsFromUsage,
16780
- formatCreditsChip,
16781
- formatTokenCount,
16782
- resolveAuthorityTurnCount,
16783
- computeBaselineContextTokens,
16784
- preserveContextUsageWithoutReceipt,
16785
- resolveContextUsage,
16786
- renderTokenStatus,
16787
17001
  createIdleHeapReleaser,
16788
17002
  COLLAPSED_PASTE_PLACEHOLDER_RE,
16789
17003
  shouldCollapsePaste,
@@ -16795,7 +17009,6 @@ export {
16795
17009
  releaseCollapsedPasteReferences,
16796
17010
  expandRangeToCollapsedPasteChips,
16797
17011
  findCollapsedPasteSpanAt,
16798
- readAgentsMdLayerFromDisk,
16799
17012
  emitTerminalProgramStatus,
16800
17013
  contextRefusalDiagnostics,
16801
17014
  describeContextRefusal,