nolo-cli 0.226.0-alpha.1 → 0.227.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/{_executeModel-UE2NJPZD.js → _executeModel-JKQGZ3HU.js} +60 -60
  2. package/accountResolver-EK2S4PWF.js +1 -1
  3. package/action-CK64LS6S.js +3 -3
  4. package/{addContentAction-EQXMFNPR.js → addContentAction-CARFID6E.js} +11 -11
  5. package/{addDialogAgentAction-RSDZDASD.js → addDialogAgentAction-APLZLFW5.js} +10 -10
  6. package/{agentDeleteCommand-SOI25WK7.js → agentDeleteCommand-NVR2V2HH.js} +86 -87
  7. package/{agentEmailCommands-UGWQQNKM.js → agentEmailCommands-UCVOWD3S.js} +86 -87
  8. package/{agentFavoriteCommands-2LKGKSUD.js → agentFavoriteCommands-4PDOP3GW.js} +3 -3
  9. package/{agentGrantCommands-QQV4N4JW.js → agentGrantCommands-FLCEXLUH.js} +4 -4
  10. package/{agentListCommands-YBNOQ5T3.js → agentListCommands-C65UESYM.js} +70 -57
  11. package/{agentMachineCommands-M6IKO7XE.js → agentMachineCommands-V3DGEJU4.js} +43 -43
  12. package/{agentProviderCommands-7BSJH7TO.js → agentProviderCommands-7QBFRFRK.js} +4 -4
  13. package/{agentPullCommand-XN6ZPBUW.js → agentPullCommand-E6JBGBVG.js} +3 -3
  14. package/{agentRecordCommands-3HL7Z4X6.js → agentRecordCommands-6RCJS2EY.js} +83 -84
  15. package/{agentRunCommand-C64A6MPL.js → agentRunCommand-P3GRKXKS.js} +86 -86
  16. package/{agentRunControl-DFEEOFC7.js → agentRunControl-SNZZ5XP4.js} +10 -10
  17. package/{agentRuntimeLocal-GSTYFEX4.js → agentRuntimeLocal-GOX2DIY7.js} +38 -38
  18. package/{agentSlice-7PTNWEED.js → agentSlice-N7H2FRJA.js} +15 -15
  19. package/{appDeleteCommands-L7HL4AWF.js → appDeleteCommands-LZDN26FU.js} +47 -47
  20. package/{appDeployCommands-SGSUNFZR.js → appDeployCommands-6IO6TTZH.js} +47 -47
  21. package/{appDeployStatusCommands-AAA3XD54.js → appDeployStatusCommands-FG3LX24J.js} +47 -47
  22. package/{appGetCommands-LN72GAOA.js → appGetCommands-NAKVDVD4.js} +47 -47
  23. package/{appListCommands-IJQQ3VND.js → appListCommands-KL56RN73.js} +47 -47
  24. package/{authCommand-7JXW54U4.js → authCommand-AUN5MXV2.js} +20 -20
  25. package/{authCommands-YDNAIDEY.js → authCommands-D2IPS6ES.js} +7 -7
  26. package/{builtinSkillRegistry-PXH7EGQB.js → builtinSkillRegistry-UQGLKRYP.js} +5 -5
  27. package/{chromeOpsCommands-YKX2QX3A.js → chromeOpsCommands-UJWN5HWH.js} +5 -5
  28. package/{chunk-3QFLXA24.js → chunk-2G3YSVO6.js} +1 -1
  29. package/{chunk-TUIWP2LF.js → chunk-2SKTCNWO.js} +2 -2
  30. package/{chunk-KNIIRXHF.js → chunk-3HTP4WZQ.js} +2 -2
  31. package/{chunk-2TIQO6TC.js → chunk-3VFYQH3I.js} +21 -170
  32. package/{chunk-AZQZ5XPM.js → chunk-4OKTPFNX.js} +27 -27
  33. package/{chunk-UYOICCYG.js → chunk-5HL4KC4A.js} +9 -9
  34. package/{chunk-2VA6TU4I.js → chunk-5LQDHFBN.js} +14 -14
  35. package/{chunk-QLFCTYRH.js → chunk-5RKRXQ2H.js} +2 -2
  36. package/{chunk-PDCV7P5W.js → chunk-6XIE5ZGI.js} +1 -1
  37. package/{chunk-HYHIAM6T.js → chunk-7Z3WUZ4Q.js} +27 -24
  38. package/{chunk-X4OVEYPX.js → chunk-ABGULE7H.js} +13 -13
  39. package/{chunk-VQUWV3YR.js → chunk-AXYH4734.js} +12 -12
  40. package/{chunk-UEKXWO7A.js → chunk-C2B7M567.js} +4 -4
  41. package/{chunk-2ZKFCIJJ.js → chunk-CLCXHIBS.js} +1 -1
  42. package/{chunk-GBZ4YKEO.js → chunk-CQVGR3MX.js} +2 -2
  43. package/{chunk-KC4SCKXO.js → chunk-CVERLOJM.js} +51 -52
  44. package/{chunk-KN3HEZIQ.js → chunk-EVGU5P4U.js} +1 -1
  45. package/{chunk-QZI44GWV.js → chunk-F5AY2UZL.js} +145 -4
  46. package/{chunk-JIADJPUV.js → chunk-FKEZOMIF.js} +426 -2459
  47. package/{chunk-PVZY6P3S.js → chunk-G6HJUMST.js} +2 -2
  48. package/{chunk-TD6QCQ5G.js → chunk-GOLPOTG5.js} +3 -3
  49. package/{chunk-GVGOEMNV.js → chunk-GOQ6ZVTN.js} +1 -1
  50. package/{chunk-5NC6A2RZ.js → chunk-GRXSJR2Z.js} +19 -19
  51. package/{chunk-GGKNJ42M.js → chunk-GUVXQSFZ.js} +2 -2
  52. package/{chunk-UKS7D2NL.js → chunk-HYKGIXNO.js} +9 -9
  53. package/{chunk-GS4OTYCH.js → chunk-IAJJYHIB.js} +5 -5
  54. package/{chunk-SOF4OWDM.js → chunk-IC2I373Q.js} +3 -5
  55. package/{chunk-UJKTI5PG.js → chunk-ILHQ2AXT.js} +0 -1
  56. package/{chunk-VV7TXWOC.js → chunk-IX2BXN2K.js} +3 -3
  57. package/{chunk-FS3RA7D2.js → chunk-JHF6VLVL.js} +29 -29
  58. package/{chunk-DISQCYPE.js → chunk-KJAAPGBE.js} +1 -1
  59. package/{chunk-N5PQJKCY.js → chunk-KMRKZNGT.js} +5 -5
  60. package/{chunk-GNHMRBYZ.js → chunk-KRRE4A7D.js} +3 -3
  61. package/{chunk-6J4TTPS2.js → chunk-L42CBKBZ.js} +4 -4
  62. package/{chunk-4PMZVBDU.js → chunk-LA7JYAKF.js} +3 -3
  63. package/{chunk-X7YC2OHB.js → chunk-LXTC53TN.js} +84 -72
  64. package/{chunk-67BE44IS.js → chunk-M3Y4IBIR.js} +4 -4
  65. package/{chunk-GIABSSWQ.js → chunk-MWHOH4RJ.js} +1 -1
  66. package/{chunk-3KNEE64G.js → chunk-NAOO4PVX.js} +16 -16
  67. package/{chunk-MOMR7NMG.js → chunk-NO3VBWTL.js} +1 -1
  68. package/{chunk-YDBMZ7FV.js → chunk-OXA5GWHU.js} +2 -2
  69. package/{chunk-FTQWYWUI.js → chunk-PHOSZT3E.js} +1 -1
  70. package/{chunk-C4WTX5TU.js → chunk-PLPLH2XZ.js} +1 -1
  71. package/{chunk-HJAO2NAL.js → chunk-PVAWNHP5.js} +52 -52
  72. package/{chunk-652XYZGP.js → chunk-PXKF5CV4.js} +9 -4
  73. package/{chunk-ZH6MUQEO.js → chunk-RU6DULV4.js} +1 -1
  74. package/{chunk-JVRQ6YVK.js → chunk-S6K5F3KP.js} +1 -1
  75. package/{chunk-AVHRSJUH.js → chunk-SFTTXGPM.js} +10 -10
  76. package/{chunk-4HFTBHBF.js → chunk-SRG5CNLC.js} +4 -4
  77. package/{chunk-ZZ4M2I3R.js → chunk-SW6OD4KE.js} +6 -6
  78. package/{chunk-TXGQ4O5S.js → chunk-T43K75CK.js} +13 -13
  79. package/{chunk-KZU52OJ5.js → chunk-T5N6NHAT.js} +6 -6
  80. package/{chunk-CVS5IMJ5.js → chunk-TINJKQSO.js} +11 -11
  81. package/{chunk-JM5C4EUA.js → chunk-TOKPHZ55.js} +1 -1
  82. package/{chunk-GSAS72AN.js → chunk-UAPNPNSG.js} +892 -625
  83. package/{chunk-BGGHA5DV.js → chunk-UCFPVYP7.js} +1 -1
  84. package/{chunk-SOG7OEXX.js → chunk-ULAQPRHX.js} +1 -1
  85. package/{chunk-SBVTHMEG.js → chunk-UN7HIYMH.js} +1 -1
  86. package/{chunk-GOAPXKQU.js → chunk-UVUVQVZ6.js} +4 -4
  87. package/{chunk-VTW7VKZX.js → chunk-VIHDJ3FK.js} +5 -5
  88. package/{chunk-EWPDMS4N.js → chunk-VPAZ6BEN.js} +1 -1
  89. package/{chunk-XN23AUVU.js → chunk-VZW34YUL.js} +3 -3
  90. package/{chunk-D726I5AZ.js → chunk-WJP4TH6U.js} +1 -1
  91. package/{chunk-EOWLBDY6.js → chunk-X2KRQP7V.js} +1 -1
  92. package/{chunk-F7DU25CE.js → chunk-XIEYGCN6.js} +4 -10
  93. package/{chunk-KOXKKHFE.js → chunk-XZODOEKU.js} +1 -1
  94. package/{chunk-QVBXJNZ2.js → chunk-YGILMZ7N.js} +1 -1
  95. package/{chunk-C4VAR65S.js → chunk-YOT437BH.js} +5 -5
  96. package/{chunk-VFBVA3U2.js → chunk-YPPKC6FL.js} +2 -2
  97. package/{chunk-LM2PS3YS.js → chunk-YQETUZ5V.js} +5 -5
  98. package/{chunk-OWH2BLNU.js → chunk-ZADGPNTV.js} +24 -24
  99. package/{chunk-BRW24CTE.js → chunk-ZI5SZ3MV.js} +11 -11
  100. package/{chunk-EVPIBQ5I.js → chunk-ZYA2YDB6.js} +18 -18
  101. package/{cliAgentConfigHelpers-KICKKNYQ.js → cliAgentConfigHelpers-QVSQYTKC.js} +10 -10
  102. package/{cliEnvHelpers-VPSJ4XWC.js → cliEnvHelpers-D6HMC46Z.js} +2 -2
  103. package/{cliLocalAgentRecordReader-6FXGFBI3.js → cliLocalAgentRecordReader-SPKAJYME.js} +45 -45
  104. package/{commandRegistry-XSMTI5PG.js → commandRegistry-TKR6OWXP.js} +91 -91
  105. package/{contentThunks-S4NNC7R2.js → contentThunks-BQWRPCTM.js} +29 -29
  106. package/{createAgentAutomationAction-TH7ZEACJ.js → createAgentAutomationAction-GFI6SJZV.js} +32 -32
  107. package/{createDialogAction-SYZAYIIQ.js → createDialogAction-MMBIHFFU.js} +30 -30
  108. package/{createPageAction-7Y4U6TXO.js → createPageAction-EEYUE5FB.js} +32 -32
  109. package/{dbSlice-ZJPDIFER.js → dbSlice-X4Z4E4QU.js} +10 -10
  110. package/{deleteFile-Q3YDB4ML.js → deleteFile-QOOP2UK7.js} +5 -5
  111. package/{dialogCommands-V5IYEOQP.js → dialogCommands-OXBQ73DD.js} +48 -48
  112. package/{dialogNotifyCommand-77B57PL6.js → dialogNotifyCommand-VWS5G4OO.js} +13 -13
  113. package/{dialogSlice-O3RHDAWK.js → dialogSlice-KGYIABDY.js} +27 -27
  114. package/{dialogUsageCommand-HTVPR2CX.js → dialogUsageCommand-FEWCN7IA.js} +6 -6
  115. package/{docCreateCommands-36WS33BK.js → docCreateCommands-LS32VKY3.js} +47 -47
  116. package/{docDeleteCommands-C4CS4XLF.js → docDeleteCommands-JTYR5RPH.js} +48 -48
  117. package/{docReadCommands-QZMSFMPN.js → docReadCommands-E5LTVKWN.js} +47 -47
  118. package/{docStore-PYNEODAH.js → docStore-TVS2FNER.js} +12 -12
  119. package/{docUpdateCommands-BYI64HVV.js → docUpdateCommands-I3J3JDZ2.js} +47 -47
  120. package/{fetchMessages-TQEUZD7H.js → fetchMessages-Q3INLN5F.js} +2 -2
  121. package/getPricing-VNGFM4PN.js +2 -2
  122. package/{handleSendMessageAction-Z43FP2E2.js → handleSendMessageAction-SSON36TJ.js} +54 -54
  123. package/{hostCredentialCreate-Y7YIGKP4.js → hostCredentialCreate-WTW4THJF.js} +83 -84
  124. package/index.js +12 -12
  125. package/{localDialogRead-SVTPA5GY.js → localDialogRead-V36DX2Q2.js} +1 -1
  126. package/{localRuntimeAdapter-ZLJONQZS.js → localRuntimeAdapter-MI2JGXSF.js} +83 -84
  127. package/{machineCommands-4ZLMRIA3.js → machineCommands-3LROJZDK.js} +86 -87
  128. package/{machineWsRunDispatch-L7Z3ULDF.js → machineWsRunDispatch-BUUJRUUB.js} +82 -83
  129. package/{memberThunks-JRYNONYV.js → memberThunks-CFEPHAND.js} +14 -14
  130. package/{memoryCommands-5WC3T66U.js → memoryCommands-JQMEJO7J.js} +3 -3
  131. package/package.json +1 -1
  132. package/{projectArchive-JBX6HNK6.js → projectArchive-3X54XFVN.js} +32 -32
  133. package/{providerPresetApply-J3WMRPD2.js → providerPresetApply-FO36N5TX.js} +5 -5
  134. package/{providerRegistry-KJGB5XWS.js → providerRegistry-U2BSFE6K.js} +5 -5
  135. package/{read-Q7GOHGNP.js → read-KA3L2V7O.js} +6 -6
  136. package/{readDocTool-Z5OQ6422.js → readDocTool-AMAZAPAW.js} +1 -1
  137. package/{readlineWorkspace-WFPIAAAT.js → readlineWorkspace-Z3YUH4SX.js} +599 -1264
  138. package/{removeDialogAgentAction-U3F2MNAY.js → removeDialogAgentAction-JQOJSUM7.js} +12 -12
  139. package/{runAgentClientLoop-STI5TKDJ.js → runAgentClientLoop-4FCFLMDJ.js} +63 -59
  140. package/{runtimeDoctorCommands-UXKXYBW6.js → runtimeDoctorCommands-CXOCVDPU.js} +5 -5
  141. package/{secretCommands-LJXOOYA7.js → secretCommands-GGUAWAE7.js} +3 -3
  142. package/{setDialogExtraReferencesAction-G3WSJ7EM.js → setDialogExtraReferencesAction-YXQTGXIN.js} +11 -11
  143. package/{setPrimaryDialogAgentAction-6FHAHZBB.js → setPrimaryDialogAgentAction-YNLB66WE.js} +12 -12
  144. package/{settingThunks-AXTBX3Q5.js → settingThunks-E6N7RSSS.js} +16 -16
  145. package/{spaceCommands-GUKMDRWN.js → spaceCommands-DB5DKC2J.js} +43 -43
  146. package/{streamAgentChatTurn-A2WL5OOF.js → streamAgentChatTurn-FCBGMD4D.js} +84 -123
  147. package/{switchDialogAgentAction-UOFIAGPL.js → switchDialogAgentAction-LAHLUECU.js} +10 -10
  148. package/{tools-6NU5E6BN.js → tools-6JD36D6K.js} +49 -49
  149. package/{tuiSummaryLlmCaller-7WLUKNP2.js → tuiSummaryLlmCaller-UHZIPGAX.js} +14 -14
  150. package/{updateCommands-RJVCRSBP.js → updateCommands-KZ54HCU5.js} +6 -6
  151. package/{updateDialogTitleAction-VMKU2Y67.js → updateDialogTitleAction-RV3EUEN3.js} +32 -32
  152. package/{usageCommand-YPJ2ZI2F.js → usageCommand-KFVV6UL3.js} +1 -1
  153. package/{usageRebuildCommand-FERQO74C.js → usageRebuildCommand-HHFSNK46.js} +2 -2
  154. package/{chunk-4NA3YTBC.js → chunk-6EDAMVG6.js} +6 -6
  155. package/{chunk-W6RFEDN4.js → chunk-AETZ7AD6.js} +3 -3
  156. package/{chunk-2VUZSVAS.js → chunk-CSW7IPVD.js} +9 -9
  157. package/{chunk-KEN3N2TN.js → chunk-HVUDBOQG.js} +7 -7
  158. package/{chunk-SNBZZPYH.js → chunk-OQHIVPG4.js} +3 -3
  159. package/{chunk-47ITIXO7.js → chunk-SSGTV4FC.js} +3 -3
  160. package/{chunk-IZIN2UNJ.js → chunk-T2BEPTAG.js} +6 -6
  161. package/{chunk-HXER7YJF.js → chunk-VXL2FZTP.js} +3 -3
  162. package/{chunk-2THCNKE4.js → chunk-WACI5I6V.js} +3 -3
  163. package/{cooldownCommands-X7P5M2V5.js → cooldownCommands-FZYQOWI5.js} +1 -1
  164. package/{offlineMarxistsAgentCommand-4IC3Y4C6.js → offlineMarxistsAgentCommand-AGA2X5E4.js} +6 -6
  165. package/{tableCommands-HITDSLHS.js → tableCommands-VNSXHAMG.js} +9 -9
@@ -4,26 +4,26 @@ import {
4
4
  } from "./chunk-PPJYZRSQ.js";
5
5
  import {
6
6
  resolveAuthGuidanceState
7
- } from "./chunk-3QFLXA24.js";
7
+ } from "./chunk-2G3YSVO6.js";
8
8
  import {
9
9
  isHiddenFromDialogList,
10
10
  loadLocalRunChildDialogIds,
11
11
  normalizeDialogRecord,
12
12
  readDialogSnapshot,
13
13
  sortDialogs
14
- } from "./chunk-AZQZ5XPM.js";
14
+ } from "./chunk-4OKTPFNX.js";
15
15
  import {
16
16
  listFavoriteAgentIdsAcrossServers,
17
17
  listLocalCachedAgents,
18
18
  listRemoteAgents,
19
19
  listRemoteAgentsAcrossServers,
20
20
  normalizeListedAgent
21
- } from "./chunk-XN23AUVU.js";
21
+ } from "./chunk-VZW34YUL.js";
22
22
  import "./chunk-ID4G2MAR.js";
23
23
  import {
24
24
  listUserRecordsFromServers,
25
25
  readLiveDbRecordAfterTombstoneMerge
26
- } from "./chunk-FTQWYWUI.js";
26
+ } from "./chunk-PHOSZT3E.js";
27
27
  import {
28
28
  COLLAPSED_PASTE_PLACEHOLDER_RE,
29
29
  OWNER_OAUTH_UNAVAILABLE_HINT,
@@ -60,6 +60,7 @@ import {
60
60
  polishBreathInsertsBlankBetween,
61
61
  preserveContextUsageWithoutReceipt,
62
62
  readAgentsMdLayerFromDisk,
63
+ redactSecrets,
63
64
  releaseCollapsedPaste,
64
65
  releaseCollapsedPasteReferences,
65
66
  renderSurfaceLine,
@@ -79,6 +80,8 @@ import {
79
80
  resolveTuiBrightnessSignal,
80
81
  resolveTuiThemeMode,
81
82
  runAgentTurn,
83
+ safeApprovalMultilineText,
84
+ safeAskText,
82
85
  setActiveBrightness,
83
86
  setActiveThemeMode,
84
87
  setActiveThemeName,
@@ -89,51 +92,42 @@ import {
89
92
  themeText,
90
93
  tuiRenderThemeFingerprint,
91
94
  userSurfaceBackgroundSequence
92
- } from "./chunk-GSAS72AN.js";
95
+ } from "./chunk-UAPNPNSG.js";
96
+ import "./chunk-6QDYSCPW.js";
93
97
  import "./chunk-Y5GCAMGP.js";
94
98
  import {
95
99
  refreshSubscriptionQuotas
96
- } from "./chunk-QVBXJNZ2.js";
100
+ } from "./chunk-YGILMZ7N.js";
97
101
  import {
98
102
  getReadableCliDb
99
103
  } from "./chunk-YFLVRVYK.js";
100
104
  import {
101
105
  RUN_WAKE_CHANNEL_ENV,
102
- admitHostTaskWorkspace,
103
106
  buildCliNoticeText,
104
107
  buildNoticeTasksFromRuns,
105
108
  clearCliLocalRuntimePreparedAgentCache,
106
- collectHostTaskWorkspace,
107
109
  createCliLocalRuntimeAdapter,
108
110
  createHostApprovalCardQueue,
109
- createHostTaskController,
110
111
  createOriginShellGrant,
111
112
  formatApprovalRemaining,
112
113
  getOrCreateSharedStore,
113
- hostTaskEventsRoot,
114
114
  matchContextualFragment,
115
115
  mergeNoticeGroup,
116
- readHostTask,
117
116
  readTimestamp,
118
- redactSecrets,
119
117
  registerHostApprovalRenderer,
120
118
  renderCliNotice,
121
119
  renderNoticeElements,
122
120
  resolveNoticeTitle,
123
- safeApprovalMultilineText,
124
- safeAskText,
125
- sameTaskScope,
126
121
  setTurnNoticeMeta
127
- } from "./chunk-JIADJPUV.js";
122
+ } from "./chunk-FKEZOMIF.js";
128
123
  import "./chunk-2YGBI2XB.js";
129
- import "./chunk-6QDYSCPW.js";
130
124
  import "./chunk-VP3BINY7.js";
131
125
  import "./chunk-FIYSMXHY.js";
132
126
  import {
133
127
  deleteDbRecord,
134
128
  queryUserRecords,
135
129
  readDbRecord
136
- } from "./chunk-2VA6TU4I.js";
130
+ } from "./chunk-5LQDHFBN.js";
137
131
  import "./chunk-WOAZVUSN.js";
138
132
  import {
139
133
  runAnthropicOAuthLogin,
@@ -142,10 +136,10 @@ import {
142
136
  runXaiOAuthDeviceCode,
143
137
  runXaiOAuthLogin,
144
138
  syncCredentialToServer
145
- } from "./chunk-3KNEE64G.js";
139
+ } from "./chunk-NAOO4PVX.js";
146
140
  import {
147
141
  runCloudflareOAuthLogin
148
- } from "./chunk-ZH6MUQEO.js";
142
+ } from "./chunk-RU6DULV4.js";
149
143
  import {
150
144
  ANSI_ESCAPE_REGEX,
151
145
  anthropicGrantRemainingMs,
@@ -170,7 +164,7 @@ import {
170
164
  wrapTextToLines,
171
165
  wrapTranscriptLine,
172
166
  wrapTranscriptLineWithLayout
173
- } from "./chunk-UKS7D2NL.js";
167
+ } from "./chunk-HYKGIXNO.js";
174
168
  import "./chunk-LKZPX6YH.js";
175
169
  import {
176
170
  createAccountSessionCore,
@@ -179,7 +173,7 @@ import {
179
173
  parseStoredTokenEntries,
180
174
  parseUserToken,
181
175
  saveTokenLogin
182
- } from "./chunk-TXGQ4O5S.js";
176
+ } from "./chunk-T43K75CK.js";
183
177
  import "./chunk-PMDVQBGA.js";
184
178
  import "./chunk-VIWDGTDA.js";
185
179
  import "./chunk-XI2BWJM5.js";
@@ -197,19 +191,19 @@ import {
197
191
  resolveDialogNotifyRoot,
198
192
  writeAck,
199
193
  writeLease
200
- } from "./chunk-67BE44IS.js";
194
+ } from "./chunk-M3Y4IBIR.js";
201
195
  import "./chunk-HGDKT2D6.js";
202
196
  import "./chunk-UAIHKQIA.js";
203
197
  import {
204
198
  resolveLocalUserId
205
- } from "./chunk-KZU52OJ5.js";
199
+ } from "./chunk-T5N6NHAT.js";
206
200
  import {
207
201
  defaultPromptReader,
208
202
  setSecret
209
- } from "./chunk-D726I5AZ.js";
203
+ } from "./chunk-WJP4TH6U.js";
210
204
  import {
211
205
  createTuiSummaryLlmCaller
212
- } from "./chunk-4HFTBHBF.js";
206
+ } from "./chunk-SRG5CNLC.js";
213
207
  import "./chunk-M3JEW6N6.js";
214
208
  import "./chunk-MK2Q7ZJD.js";
215
209
  import "./chunk-S73EPYNC.js";
@@ -221,32 +215,32 @@ import {
221
215
  } from "./chunk-PRJ473FK.js";
222
216
  import "./chunk-BMQ2MJUK.js";
223
217
  import "./chunk-ATNTHIZI.js";
224
- import "./chunk-652XYZGP.js";
218
+ import "./chunk-PXKF5CV4.js";
225
219
  import "./chunk-JEXVIMYZ.js";
226
220
  import {
227
221
  prepareTools
228
- } from "./chunk-TUIWP2LF.js";
222
+ } from "./chunk-2SKTCNWO.js";
229
223
  import "./chunk-HS7MLR74.js";
230
- import "./chunk-X7YC2OHB.js";
224
+ import "./chunk-LXTC53TN.js";
231
225
  import "./chunk-KFHREHUQ.js";
232
- import "./chunk-QZI44GWV.js";
233
- import "./chunk-5NC6A2RZ.js";
226
+ import "./chunk-F5AY2UZL.js";
227
+ import "./chunk-GRXSJR2Z.js";
234
228
  import "./chunk-NF64D32W.js";
235
229
  import "./chunk-3L2WKC3W.js";
236
- import "./chunk-GGKNJ42M.js";
230
+ import "./chunk-GUVXQSFZ.js";
237
231
  import "./chunk-FJ23FZXF.js";
238
232
  import "./chunk-AGIM7IMJ.js";
239
233
  import "./chunk-63W5N6P3.js";
240
234
  import "./chunk-VF4K2QE6.js";
241
- import "./chunk-4PMZVBDU.js";
242
- import "./chunk-KOXKKHFE.js";
235
+ import "./chunk-LA7JYAKF.js";
236
+ import "./chunk-XZODOEKU.js";
243
237
  import "./chunk-4JVNURX4.js";
244
- import "./chunk-GIABSSWQ.js";
245
- import "./chunk-BGGHA5DV.js";
238
+ import "./chunk-MWHOH4RJ.js";
239
+ import "./chunk-UCFPVYP7.js";
246
240
  import "./chunk-AK5O76CC.js";
247
- import "./chunk-ZZ4M2I3R.js";
241
+ import "./chunk-SW6OD4KE.js";
248
242
  import "./chunk-BJF2MHJ3.js";
249
- import "./chunk-CVS5IMJ5.js";
243
+ import "./chunk-TINJKQSO.js";
250
244
  import {
251
245
  createChatQueueRuntime,
252
246
  createTurnRequest,
@@ -254,7 +248,7 @@ import {
254
248
  historyTokensBeforeLatestAssistant,
255
249
  initialChatQueueState,
256
250
  normalizeRunCompletionShape
257
- } from "./chunk-HJAO2NAL.js";
251
+ } from "./chunk-PVAWNHP5.js";
258
252
  import "./chunk-TZXPT53C.js";
259
253
  import "./chunk-BUDVRYES.js";
260
254
  import "./chunk-KEPOVMF4.js";
@@ -262,11 +256,11 @@ import {
262
256
  BUILTIN_DIALOG_LLM_FALLBACK_MODEL,
263
257
  BUILTIN_SUMMARY_LLM_CONFIG
264
258
  } from "./chunk-523DITKR.js";
265
- import "./chunk-X4OVEYPX.js";
266
- import "./chunk-MOMR7NMG.js";
259
+ import "./chunk-ABGULE7H.js";
260
+ import "./chunk-NO3VBWTL.js";
267
261
  import "./chunk-BYXBJQAS.js";
268
262
  import "./chunk-QYPE3TS3.js";
269
- import "./chunk-GVGOEMNV.js";
263
+ import "./chunk-GOQ6ZVTN.js";
270
264
  import {
271
265
  getActiveDialogAgentId
272
266
  } from "./chunk-5RGU3J7P.js";
@@ -275,12 +269,33 @@ import "./chunk-YNIYE47Z.js";
275
269
  import "./chunk-S2NTVGA2.js";
276
270
  import "./chunk-5FUN7EG4.js";
277
271
  import "./chunk-VREDDN25.js";
278
- import "./chunk-HXER7YJF.js";
279
- import "./chunk-PVZY6P3S.js";
272
+ import "./chunk-VXL2FZTP.js";
273
+ import "./chunk-G6HJUMST.js";
280
274
  import "./chunk-UAD2WT54.js";
281
- import "./chunk-AVHRSJUH.js";
275
+ import "./chunk-SFTTXGPM.js";
282
276
  import "./chunk-3PVYUPXK.js";
283
- import "./chunk-C4WTX5TU.js";
277
+ import "./chunk-PLPLH2XZ.js";
278
+ import {
279
+ TAIL_LINES_MAX,
280
+ backfillRunRecordParentDialog,
281
+ checkStaleRun,
282
+ isRunRecordClaimed,
283
+ listRunRecords,
284
+ readRunRecord,
285
+ runAgentStopCommand
286
+ } from "./chunk-XIEYGCN6.js";
287
+ import "./chunk-UN7HIYMH.js";
288
+ import {
289
+ clipText,
290
+ formatDuration,
291
+ formatRunAge,
292
+ isAgentNameFallback,
293
+ isAgentRunTerminalStatus,
294
+ normalizeRunTitle,
295
+ resolveRunLabel,
296
+ shortAgentKey,
297
+ shortRunId
298
+ } from "./chunk-AXYH4734.js";
284
299
  import "./chunk-GBWGPTA7.js";
285
300
  import "./chunk-P2ZLUIW2.js";
286
301
  import "./chunk-ZYKJBRZ3.js";
@@ -288,23 +303,31 @@ import "./chunk-5ZMIIR23.js";
288
303
  import "./chunk-CVMMWN6P.js";
289
304
  import "./chunk-N5Z2V73W.js";
290
305
  import "./chunk-GLKOYSRU.js";
291
- import "./chunk-QLFCTYRH.js";
292
- import "./chunk-2VUZSVAS.js";
306
+ import "./chunk-5RKRXQ2H.js";
307
+ import "./chunk-CSW7IPVD.js";
293
308
  import "./chunk-UEILX4EV.js";
294
309
  import "./chunk-7Z6EW7AH.js";
295
310
  import "./chunk-AGP3YSEC.js";
296
311
  import "./chunk-QQ56R7KS.js";
297
312
  import "./chunk-PXYBUFDB.js";
298
313
  import "./chunk-BV3FLP2L.js";
299
- import "./chunk-N5PQJKCY.js";
300
- import "./chunk-2ZKFCIJJ.js";
314
+ import "./chunk-KMRKZNGT.js";
315
+ import "./chunk-CLCXHIBS.js";
301
316
  import {
302
317
  CURRENT_OPERATOR_USER_ID,
303
318
  NOLO_DEFAULT_AGENT_KEY,
304
319
  resolveCliAgentKeyInput
305
320
  } from "./chunk-BR3GT6MR.js";
306
- import "./chunk-GOAPXKQU.js";
307
- import "./chunk-JVRQ6YVK.js";
321
+ import "./chunk-UVUVQVZ6.js";
322
+ import "./chunk-S6K5F3KP.js";
323
+ import "./chunk-LJSNEV7M.js";
324
+ import "./chunk-VIDPVFP3.js";
325
+ import "./chunk-4JH2UMJR.js";
326
+ import {
327
+ buildSkillDiscoveryContextBlock,
328
+ buildSkillDiscoveryContextLayer,
329
+ discoverSkills
330
+ } from "./chunk-CKT6QUE2.js";
308
331
  import {
309
332
  buildLoadSkillExecutor,
310
333
  buildLocalWorkspaceOpenAiTools,
@@ -318,19 +341,19 @@ import {
318
341
  runTaskStop,
319
342
  saveCliPendingUserMessages,
320
343
  scrubSecrets
321
- } from "./chunk-KC4SCKXO.js";
344
+ } from "./chunk-CVERLOJM.js";
322
345
  import "./chunk-ZNFJWEN4.js";
323
- import "./chunk-VFBVA3U2.js";
346
+ import "./chunk-YPPKC6FL.js";
324
347
  import "./chunk-CHOZJMJS.js";
325
348
  import "./chunk-PWTNI4N7.js";
326
349
  import "./chunk-AL3TYDIF.js";
327
- import "./chunk-VV7TXWOC.js";
350
+ import "./chunk-IX2BXN2K.js";
328
351
  import "./chunk-HNUWUO75.js";
329
352
  import "./chunk-LKA64WH4.js";
330
- import "./chunk-UEKXWO7A.js";
353
+ import "./chunk-C2B7M567.js";
331
354
  import "./chunk-2WZXXAQD.js";
332
- import "./chunk-KNIIRXHF.js";
333
- import "./chunk-SOG7OEXX.js";
355
+ import "./chunk-3HTP4WZQ.js";
356
+ import "./chunk-ULAQPRHX.js";
334
357
  import "./chunk-56GBUMO5.js";
335
358
  import {
336
359
  CREDENTIAL_HYGIENE_RULE,
@@ -346,21 +369,21 @@ import {
346
369
  buildRuntimeGuidanceBlocks,
347
370
  resolveResponseGuidelines,
348
371
  resolveToolGuidedSections
349
- } from "./chunk-2TIQO6TC.js";
350
- import "./chunk-C4VAR65S.js";
372
+ } from "./chunk-3VFYQH3I.js";
373
+ import "./chunk-YOT437BH.js";
351
374
  import {
352
375
  formatQuotaSummary
353
376
  } from "./chunk-HOCHUZQ7.js";
354
- import "./chunk-SOF4OWDM.js";
355
- import "./chunk-JM5C4EUA.js";
377
+ import "./chunk-IC2I373Q.js";
378
+ import "./chunk-TOKPHZ55.js";
356
379
  import "./chunk-E2BESSAW.js";
357
380
  import "./chunk-TLE77UJ5.js";
358
- import "./chunk-EOWLBDY6.js";
359
- import "./chunk-DISQCYPE.js";
381
+ import "./chunk-X2KRQP7V.js";
382
+ import "./chunk-KJAAPGBE.js";
360
383
  import "./chunk-2MBTWINN.js";
361
384
  import {
362
385
  extractReferenceKeysFromMessage
363
- } from "./chunk-LM2PS3YS.js";
386
+ } from "./chunk-YQETUZ5V.js";
364
387
  import "./chunk-5ZUL4CUO.js";
365
388
  import {
366
389
  COMPACTION_SUMMARY_SYSTEM_PROMPT,
@@ -377,59 +400,75 @@ import {
377
400
  planCompression,
378
401
  runSummaryWithContract,
379
402
  serializeMessageContent
380
- } from "./chunk-IZIN2UNJ.js";
403
+ } from "./chunk-T2BEPTAG.js";
381
404
  import "./chunk-H57T64RA.js";
382
405
  import "./chunk-UKZX3NHN.js";
383
406
  import {
384
407
  clipCompactText
385
408
  } from "./chunk-5MMAK75Q.js";
386
- import "./chunk-47ITIXO7.js";
409
+ import "./chunk-SSGTV4FC.js";
387
410
  import "./chunk-KX6YBIHG.js";
388
- import "./chunk-SNBZZPYH.js";
411
+ import "./chunk-OQHIVPG4.js";
389
412
  import {
390
413
  compactWhitespace
391
414
  } from "./chunk-DWLEOOGR.js";
415
+ import {
416
+ formatToolOverflowMarker,
417
+ getProcessRegistry
418
+ } from "./chunk-HVUDBOQG.js";
419
+ import {
420
+ isQuotaExhaustedError
421
+ } from "./chunk-EWQ3HGNZ.js";
422
+ import {
423
+ estimateTokenCount
424
+ } from "./chunk-PSCNXBYA.js";
392
425
  import "./chunk-OW765XBU.js";
393
426
  import {
394
427
  isAbortError
395
428
  } from "./chunk-7DPNBQSV.js";
396
429
  import "./chunk-62HXNQVV.js";
397
- import "./chunk-EWPDMS4N.js";
430
+ import "./chunk-VPAZ6BEN.js";
431
+ import {
432
+ resolvePlatformAuthToken
433
+ } from "./chunk-6EDAMVG6.js";
434
+ import "./chunk-45LZIYXB.js";
435
+ import {
436
+ toErrorMessage
437
+ } from "./chunk-HNMXYYJR.js";
398
438
  import {
399
439
  WORKTREE_ISOLATION_PRELUDE,
400
440
  expandEnabledPacks,
401
441
  listBuiltinSkills
402
- } from "./chunk-GNHMRBYZ.js";
442
+ } from "./chunk-KRRE4A7D.js";
403
443
  import {
404
444
  canonicalizeToolNames
405
445
  } from "./chunk-6OVNSQHN.js";
406
446
  import {
407
447
  parseExternalSkillMarkdown
408
- } from "./chunk-W6RFEDN4.js";
409
- import "./chunk-KN3HEZIQ.js";
448
+ } from "./chunk-AETZ7AD6.js";
449
+ import "./chunk-EVGU5P4U.js";
410
450
  import {
411
451
  BUILTIN_NOLO_AGENT_KEY,
412
452
  BUILTIN_NOLO_AGENT_MODEL,
413
453
  BUILTIN_NOLO_AGENT_NAME,
414
454
  builtinAgentCatalogEntryById,
415
455
  parseBuiltinPlatformAgentId
416
- } from "./chunk-UJKTI5PG.js";
456
+ } from "./chunk-ILHQ2AXT.js";
417
457
  import {
418
458
  extractCustomId,
419
459
  parsePublicAgentId
420
460
  } from "./chunk-M2EJHDJP.js";
421
- import "./chunk-SYTHYBMI.js";
422
- import "./chunk-OJKUU3LP.js";
423
- import "./chunk-YZMNK53S.js";
424
- import "./chunk-I42VC5KR.js";
425
- import "./chunk-LJSNEV7M.js";
426
- import "./chunk-VIDPVFP3.js";
427
- import "./chunk-4JH2UMJR.js";
461
+ import "./chunk-KYH7XW3K.js";
462
+ import "./chunk-JRTNUU5Z.js";
428
463
  import {
429
- buildSkillDiscoveryContextBlock,
430
- buildSkillDiscoveryContextLayer,
431
- discoverSkills
432
- } from "./chunk-CKT6QUE2.js";
464
+ isRecord
465
+ } from "./chunk-KUG52IAP.js";
466
+ import {
467
+ PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL
468
+ } from "./chunk-OBSEKCVK.js";
469
+ import {
470
+ asTrimmedLowercaseString
471
+ } from "./chunk-QSJ3HFEF.js";
433
472
  import {
434
473
  buildMemoryOverlayLayer,
435
474
  buildMemoryUseGuidanceLayer,
@@ -450,7 +489,21 @@ import {
450
489
  getCliInstallChannel,
451
490
  probeCliUpdate,
452
491
  runSelfUpdateDetailed
453
- } from "./chunk-UYOICCYG.js";
492
+ } from "./chunk-5HL4KC4A.js";
493
+ import {
494
+ parseUserIdFromAuthToken,
495
+ resolveAuthToken,
496
+ resolveServerCandidates,
497
+ resolveServerUrl
498
+ } from "./chunk-WACI5I6V.js";
499
+ import {
500
+ DEFAULT_NOLO_SERVER_URL
501
+ } from "./chunk-OLZBQWZU.js";
502
+ import "./chunk-LCBAMY2M.js";
503
+ import "./chunk-4SN6J65J.js";
504
+ import {
505
+ normalizeServerOrigin
506
+ } from "./chunk-CF7PE763.js";
454
507
  import {
455
508
  PERMISSION_GRANT_KINDS,
456
509
  getAgentSelectionAuditPath,
@@ -479,80 +532,20 @@ import {
479
532
  toolLabel
480
533
  } from "./chunk-OB6DVWPF.js";
481
534
  import {
482
- TAIL_LINES_MAX,
483
- backfillRunRecordParentDialog,
484
- checkStaleRun,
485
- isRunRecordClaimed,
486
- listRunRecords,
487
- readRunRecord,
488
- resolveRunsDir,
489
- runAgentStopCommand
490
- } from "./chunk-F7DU25CE.js";
491
- import "./chunk-SBVTHMEG.js";
492
- import {
493
- clipText,
494
- formatDuration,
495
- formatRunAge,
496
- isAgentNameFallback,
497
- isAgentRunTerminalStatus,
498
- normalizeRunTitle,
499
- resolveRunLabel,
500
- shortAgentKey,
501
- shortRunId
502
- } from "./chunk-VQUWV3YR.js";
503
- import {
504
- formatToolOverflowMarker,
505
- getProcessRegistry
506
- } from "./chunk-KEN3N2TN.js";
507
- import {
508
- isQuotaExhaustedError
509
- } from "./chunk-EWQ3HGNZ.js";
510
- import {
511
- estimateTokenCount
512
- } from "./chunk-PSCNXBYA.js";
513
- import {
514
- resolvePlatformAuthToken
515
- } from "./chunk-4NA3YTBC.js";
516
- import "./chunk-45LZIYXB.js";
517
- import {
518
- toErrorMessage
519
- } from "./chunk-HNMXYYJR.js";
535
+ createOAuthTokenStore,
536
+ isTokenExpired
537
+ } from "./chunk-G7Y4GXTY.js";
538
+ import "./chunk-6UBGXX2W.js";
539
+ import "./chunk-SYTHYBMI.js";
540
+ import "./chunk-OJKUU3LP.js";
541
+ import "./chunk-YZMNK53S.js";
542
+ import "./chunk-I42VC5KR.js";
520
543
  import "./chunk-3EUW3WEO.js";
521
- import "./chunk-KYH7XW3K.js";
522
- import "./chunk-JRTNUU5Z.js";
523
- import {
524
- isRecord
525
- } from "./chunk-KUG52IAP.js";
526
- import {
527
- PLATFORM_HOSTED_DEEPSEEK_FLASH_MODEL
528
- } from "./chunk-OBSEKCVK.js";
529
- import {
530
- asTrimmedLowercaseString
531
- } from "./chunk-QSJ3HFEF.js";
532
544
  import "./chunk-U6VC4MU4.js";
533
545
  import "./chunk-WWC7I6TA.js";
534
- import {
535
- parseUserIdFromAuthToken,
536
- resolveAuthToken,
537
- resolveServerCandidates,
538
- resolveServerUrl
539
- } from "./chunk-2THCNKE4.js";
540
- import {
541
- DEFAULT_NOLO_SERVER_URL
542
- } from "./chunk-OLZBQWZU.js";
543
- import "./chunk-LCBAMY2M.js";
544
546
  import {
545
547
  asOptionalTrimmedString
546
548
  } from "./chunk-G3SUCT4W.js";
547
- import "./chunk-4SN6J65J.js";
548
- import {
549
- normalizeServerOrigin
550
- } from "./chunk-CF7PE763.js";
551
- import {
552
- createOAuthTokenStore,
553
- isTokenExpired
554
- } from "./chunk-G7Y4GXTY.js";
555
- import "./chunk-6UBGXX2W.js";
556
549
  import "./chunk-U67V476Y.js";
557
550
 
558
551
  // packages/cli/tui/runWakeDiagnostics.ts
@@ -566,882 +559,75 @@ function queueWakeFields(status) {
566
559
  }
567
560
  function traceChildRunWake(stage, event, currentDialogId, fields = {}) {
568
561
  if (typeof event === "string" || event.kind !== "child-run-completed") return;
569
- for (const run of event.runs) traceRunWake(stage, {
570
- runId: run.runId,
571
- status: run.status,
572
- parentDialogId: run.parentDialogId ?? null,
573
- currentDialogId,
574
- ...fields
575
- });
576
- }
577
- function traceRunWake(stage, fields) {
578
- try {
579
- getDiagnostics()?.logger.child({ component: "run-terminal-wake", fields }).debug(stage);
580
- } catch {
581
- }
582
- }
583
-
584
- // packages/cli/tui/runWakeDelivery.ts
585
- function createRunWakeHandler(deps) {
586
- const handler = (event) => {
587
- if (deps.isDone()) {
588
- traceChildRunWake("delivery-done", event, deps.getDialogId());
589
- return false;
590
- }
591
- const busy = deps.isBusy();
592
- const paused = deps.fixedInput.isPaused();
593
- const turnInjectionInbox = deps.getInbox();
594
- const fixedInput = deps.fixedInput;
595
- const trace = (stage, extra = {}) => traceChildRunWake(stage, event, deps.getDialogId(), { busy, paused, inboxPresent: !!turnInjectionInbox, ...queueWakeFields(deps.getQueueStatus()), ...extra });
596
- if (busy || paused) {
597
- if (typeof event !== "string" && event.kind === "auto-review-continuation") {
598
- const status = deps.enqueue(event);
599
- trace("delivery-queue", { ...queueWakeFields(status), inboxPushResult: null });
600
- return true;
601
- }
602
- const text = typeof event === "string" ? event : event.text;
603
- const injected = !!turnInjectionInbox && turnInjectionInbox.push({ text, fallback: event });
604
- trace("delivery-inbox-attempt", { inboxPushResult: injected });
605
- if (injected) {
606
- const displayText = typeof event === "string" ? event : event.kind === "user" ? event.text : event.displayText ?? event.text;
607
- if (displayText) deps.printLine(displayText);
608
- } else {
609
- const status = deps.enqueue(event);
610
- trace("delivery-queue", queueWakeFields(status));
611
- }
612
- if (fixedInput.active && !fixedInput.isPaused()) {
613
- deps.repaint();
614
- }
615
- return true;
616
- }
617
- trace("delivery-idle-turn");
618
- if (typeof event !== "string" && event.kind === "child-run-completed") {
619
- deps.enqueue(event);
620
- void deps.drainQueue().catch(deps.onError);
621
- } else {
622
- void deps.runIdle(event).catch(deps.onError);
623
- }
624
- return true;
625
- };
626
- return Object.assign(handler, {
627
- async resumeAfterInputPause() {
628
- if (deps.isDone() || deps.isBusy() || deps.fixedInput.isPaused()) return;
629
- await deps.drainQueue();
630
- }
631
- });
632
- }
633
- function deliverChildCompletion(event, receive, reconcile) {
634
- const accepted = receive?.(event) ?? false;
635
- if (accepted) {
636
- try {
637
- reconcile();
638
- } catch {
639
- traceChildRunWake("reconcile-after-admission-failed", event, null);
640
- }
641
- }
642
- return accepted;
643
- }
644
-
645
- // packages/cli/tui/autoReviewContinuationWake.ts
646
- import { createHash as createHash3 } from "node:crypto";
647
-
648
- // packages/cli/client/autoReviewContinuation.ts
649
- var present = (v) => typeof v === "string" && v.trim().length > 0;
650
- var MAX_CONSUMED_EVENT_KEYS = 256;
651
- var DEFAULT_NO_PROGRESS_LIMIT = 2;
652
- var ROUND_CONSUMING = /* @__PURE__ */ new Set([
653
- "continue-author",
654
- "request-review",
655
- "decide-review",
656
- "commit",
657
- "local-merge",
658
- "done"
659
- ]);
660
- function validAutoReviewFingerprint(fingerprint2) {
661
- if (!fingerprint2 || typeof fingerprint2 !== "object") return false;
662
- if (!present(fingerprint2.taskInstanceId)) return false;
663
- if (!["implementation", "wait-user", "wait-review", "decision", "fix", "commit", "merge", "done", "blocked"].includes(fingerprint2.stage)) return false;
664
- if (!["unknown", "pending", "accepted", "waived"].includes(fingerprint2.acceptance)) return false;
665
- return true;
666
- }
667
- function progressSignature(fingerprint2, evidence) {
668
- return JSON.stringify([
669
- fingerprint2.acceptance,
670
- evidence.implementation ?? null,
671
- evidence.revision ?? null,
672
- evidence.reviewRun ?? null,
673
- evidence.reviewDecision?.verdict ?? null,
674
- evidence.reviewDecision?.hasCriticalOrHigh ?? null,
675
- evidence.commit?.commitId ?? null,
676
- evidence.commit?.revision ?? null,
677
- evidence.localMerge?.mergeCommitId ?? null,
678
- evidence.localMerge?.sourceCommitId ?? null
679
- ]);
680
- }
681
- function decideAutoReviewAction(fingerprint2, evidence) {
682
- if (!evidence.implementation) {
683
- return { action: { kind: "blocked", reason: "implementation_evidence_missing" } };
684
- }
685
- if (evidence.implementation !== "complete") {
686
- return { action: { kind: "continue-author" }, reason: "implementation_not_complete" };
687
- }
688
- if (fingerprint2.acceptance === "pending") return { action: { kind: "wait-user", reason: "acceptance_pending" } };
689
- if (fingerprint2.acceptance === "unknown") return { action: { kind: "wait-user", reason: "acceptance_unknown" } };
690
- const revision = evidence.revision ?? fingerprint2.revision;
691
- const decision = evidence.reviewDecision;
692
- if (!decision) {
693
- if (evidence.reviewRun === "running") return { action: { kind: "wait-user", reason: "review_running" } };
694
- if (evidence.reviewRun === "finished") return { action: { kind: "decide-review" } };
695
- if (evidence.reviewRun === "none") {
696
- if (!present(revision)) return { action: { kind: "blocked", reason: "revision_missing" } };
697
- return { action: { kind: "request-review" } };
698
- }
699
- return { action: { kind: "blocked", reason: "review_status_missing" } };
700
- }
701
- if (decision.revision && revision && decision.revision !== revision) {
702
- return { action: { kind: "request-review" }, reason: "review_stale" };
703
- }
704
- if (decision.hasCriticalOrHigh === true) return { action: { kind: "wait-user", reason: "review_high_findings" } };
705
- if (decision.verdict === "BLOCK") return { action: { kind: "continue-author" }, reason: "review_blocked_fix" };
706
- if (decision.verdict === "WARNING" && decision.hasCriticalOrHigh !== false) {
707
- return { action: { kind: "wait-user", reason: "review_warning_high" } };
708
- }
709
- if (decision.verdict === "APPROVE" && decision.hasCriticalOrHigh === void 0) {
710
- return { action: { kind: "wait-user", reason: "review_findings_unknown" } };
711
- }
712
- const commit = evidence.commit;
713
- const commitUsable = !!commit && present(commit.commitId) && (!commit.revision || !revision || commit.revision === revision);
714
- if (!commitUsable) return { action: { kind: "commit" } };
715
- const merge = evidence.localMerge;
716
- const mergeUsable = !!merge && present(merge.mergeCommitId) && (!merge.sourceCommitId || merge.sourceCommitId === commit.commitId);
717
- if (!mergeUsable) return { action: { kind: "local-merge" } };
718
- return { action: { kind: "done" } };
719
- }
720
- function reconcileAutoReviewContinuation(input) {
721
- const budget = input.budget;
722
- const fingerprint2 = input.fingerprint;
723
- const evidence = input.evidence ?? {};
724
- const eventKey = input.trigger?.eventKey ?? "";
725
- const authorization = input.authorization ?? "unknown";
726
- const noProgressLimit = budget.noProgressLimit > 0 ? budget.noProgressLimit : DEFAULT_NO_PROGRESS_LIMIT;
727
- if (budget.corrupt) {
728
- return { action: { kind: "blocked", reason: "budget_corrupt" }, budget, roundConsumed: false };
729
- }
730
- if (!present(eventKey)) {
731
- return { action: { kind: "blocked", reason: "invalid_event_key" }, budget, roundConsumed: false };
732
- }
733
- if (budget.consumedEventKeys.includes(eventKey)) {
734
- return { action: { kind: "duplicate" }, budget, roundConsumed: false };
735
- }
736
- const withEvent = (next) => {
737
- const keys = [...next.consumedEventKeys, eventKey];
738
- return { ...next, consumedEventKeys: keys.length > MAX_CONSUMED_EVENT_KEYS ? keys.slice(keys.length - MAX_CONSUMED_EVENT_KEYS) : keys };
739
- };
740
- const finish = (action2, patch, roundConsumed2, reason) => {
741
- const next = withEvent({ ...budget, ...patch, rounds: budget.rounds + (roundConsumed2 ? 1 : 0) });
742
- return { action: action2, budget: next, reason, roundConsumed: roundConsumed2 };
743
- };
744
- if (!validAutoReviewFingerprint(fingerprint2)) {
745
- return finish({ kind: "blocked", reason: "invalid_fingerprint" }, {}, false, "invalid_fingerprint");
746
- }
747
- if (input.scope?.taskInstanceId && fingerprint2.taskInstanceId !== input.scope.taskInstanceId) {
748
- return finish({ kind: "blocked", reason: "scope_mismatch" }, {}, false, "scope_mismatch");
749
- }
750
- if (authorization !== "active") {
751
- const reason = authorization === "paused" ? "authorization_paused" : authorization === "revoked" ? "authorization_revoked" : "authorization_unknown";
752
- return finish({ kind: "stopped", reason }, {}, false, reason);
753
- }
754
- if (evidence.aborted) return finish({ kind: "stopped", reason: "aborted" }, {}, false, "aborted");
755
- if (budget.rounds >= budget.maxRounds) {
756
- return finish({ kind: "blocked", reason: "budget_exhausted" }, {}, false, "budget_exhausted");
757
- }
758
- const decision = decideAutoReviewAction(fingerprint2, evidence);
759
- const signature = progressSignature(fingerprint2, evidence);
760
- const isWait = decision.action.kind === "wait-user";
761
- let consecutiveNoProgress = budget.consecutiveNoProgress;
762
- let lastSignature = budget.lastSignature;
763
- let lastAction = budget.lastAction;
764
- let blocked;
765
- if (!isWait) {
766
- consecutiveNoProgress = signature === lastSignature ? consecutiveNoProgress + 1 : 0;
767
- if (consecutiveNoProgress >= noProgressLimit) blocked = { kind: "blocked", reason: "no_progress" };
768
- lastSignature = signature;
769
- lastAction = decision.action.kind;
770
- }
771
- const action = blocked ?? decision.action;
772
- const roundConsumed = !blocked && ROUND_CONSUMING.has(action.kind);
773
- return finish(action, { consecutiveNoProgress, lastSignature, lastAction }, roundConsumed, blocked ? "no_progress" : decision.reason);
774
- }
775
-
776
- // packages/cli/tui/autoReviewContinuationWake.ts
777
- import { lstatSync as lstatSync2, readdirSync as readdirSync2, readFileSync as readFileSync3, realpathSync } from "node:fs";
778
- import { join as join3, resolve as resolve2 } from "node:path";
779
-
780
- // packages/cli/client/autoReviewContinuationStore.ts
781
- import { createHash, randomUUID } from "node:crypto";
782
- import { appendFileSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
783
- import { homedir } from "node:os";
784
- import { join } from "node:path";
785
- var AUTO_REVIEW_CONTINUATION_MAX_ROUNDS = 8;
786
- var DEFAULT_LEASE_MS = 5 * 60 * 1e3;
787
- var SELF_ABANDON_LEASES = 3;
788
- function autoReviewContinuationRoot(env) {
789
- return join(env.NOLO_HOME || join(homedir(), ".nolo"), "auto-review-continuation");
790
- }
791
- function autoReviewContinuationTaskDir(env, scope) {
792
- const key = createHash("sha256").update(JSON.stringify(scope)).digest("hex");
793
- return join(autoReviewContinuationRoot(env), key);
794
- }
795
- function slotsDir(env, scope) {
796
- return join(autoReviewContinuationTaskDir(env, scope), "slots");
797
- }
798
- function freshBudget(maxRounds) {
799
- return {
800
- rounds: 0,
801
- maxRounds: maxRounds ?? AUTO_REVIEW_CONTINUATION_MAX_ROUNDS,
802
- consecutiveNoProgress: 0,
803
- noProgressLimit: 2,
804
- consumedEventKeys: []
805
- };
806
- }
807
- function validBudget(value) {
808
- if (!value || typeof value !== "object") return false;
809
- const b = value;
810
- if (!Number.isSafeInteger(b.rounds) || b.rounds < 0) return false;
811
- if (!Number.isSafeInteger(b.maxRounds) || b.maxRounds <= 0) return false;
812
- if (!Number.isSafeInteger(b.consecutiveNoProgress) || b.consecutiveNoProgress < 0) return false;
813
- if (!Number.isSafeInteger(b.noProgressLimit) || b.noProgressLimit <= 0) return false;
814
- if (!Array.isArray(b.consumedEventKeys) || b.consumedEventKeys.some((k) => typeof k !== "string")) return false;
815
- return true;
816
- }
817
- function describeError(error) {
818
- if (error instanceof Error) return `${error.name}: ${error.message}`;
819
- return String(error);
820
- }
821
- function procStartToken(pid) {
822
- try {
823
- const stat3 = readFileSync(`/proc/${pid}/stat`, "utf8");
824
- const close = stat3.lastIndexOf(")");
825
- const fields = stat3.slice(close + 2).split(" ");
826
- return fields[19] ?? "";
827
- } catch {
828
- return "";
829
- }
830
- }
831
- function ownerAlive(record) {
832
- if (!record.pid) return false;
833
- if (record.pid === process.pid) return true;
834
- const token = procStartToken(record.pid);
835
- if (token) return !record.procStart || token === record.procStart;
836
- try {
837
- process.kill(record.pid, 0);
838
- return true;
839
- } catch (error) {
840
- return error.code === "EPERM";
841
- }
842
- }
843
- function readSlots(env, scope) {
844
- const dir = slotsDir(env, scope);
845
- let names;
846
- try {
847
- names = readdirSync(dir);
848
- } catch {
849
- return { records: [], corrupt: false };
850
- }
851
- const records = [];
852
- let corrupt = false;
853
- for (const name of names.filter((n) => n.endsWith(".json")).sort()) {
854
- let record;
855
- try {
856
- record = JSON.parse(readFileSync(join(dir, name), "utf8"));
857
- } catch {
858
- corrupt = true;
859
- continue;
860
- }
861
- if (!record || typeof record !== "object" || !Number.isSafeInteger(record.seq) || typeof record.owner !== "string" || typeof record.eventKey !== "string" || !["claim", "commit", "release"].includes(record.kind)) {
862
- corrupt = true;
863
- continue;
864
- }
865
- records.push(record);
866
- }
867
- records.sort((a, b) => a.seq - b.seq);
868
- return { records, corrupt };
869
- }
870
- function nextSeq(records) {
871
- return records.reduce((max, r) => Math.max(max, r.seq), -1) + 1;
872
- }
873
- function createSlot(env, scope, record) {
874
- const dir = slotsDir(env, scope);
875
- mkdirSync(dir, { recursive: true, mode: 448 });
876
- const path3 = join(dir, `${String(record.seq).padStart(12, "0")}.json`);
877
- try {
878
- writeFileSync(path3, JSON.stringify(record), { flag: "wx", mode: 384 });
879
- return { ok: true };
880
- } catch (error) {
881
- if (error.code === "EEXIST") return { ok: false, reason: "conflict" };
882
- throw error;
883
- }
884
- }
885
- function claimEntries(records) {
886
- const entries = /* @__PURE__ */ new Map();
887
- for (const record of records) {
888
- if (record.kind === "claim") {
889
- if (typeof record.supersedesSeq === "number") {
890
- const prior = entries.get(record.supersedesSeq);
891
- if (prior) prior.superseded = true;
892
- }
893
- entries.set(record.seq, { record, closed: false, superseded: false });
894
- } else if (typeof record.claimSeq === "number") {
895
- const entry = entries.get(record.claimSeq);
896
- if (entry) entry.closed = true;
897
- }
898
- }
899
- return entries;
900
- }
901
- function activeClaim(records) {
902
- let active;
903
- for (const entry of claimEntries(records).values()) {
904
- if (entry.closed || entry.superseded) continue;
905
- if (!active || entry.record.seq > active.record.seq) active = entry;
906
- }
907
- return active;
908
- }
909
- function readBudgetState(env, scope, options = {}) {
910
- const { records, corrupt } = readSlots(env, scope);
911
- if (corrupt) return { version: 0, budget: { ...freshBudget(options.maxRounds), corrupt: true }, corrupt: true };
912
- const superseded = /* @__PURE__ */ new Set();
913
- for (const entry of claimEntries(records).values()) if (entry.superseded) superseded.add(entry.record.seq);
914
- let version = 0;
915
- let budget = freshBudget(options.maxRounds);
916
- let stateCorrupt = false;
917
- for (const record of records) {
918
- if (record.kind !== "commit") continue;
919
- if (!validBudget(record.budget)) {
920
- stateCorrupt = true;
921
- continue;
922
- }
923
- if (typeof record.claimSeq === "number" && superseded.has(record.claimSeq)) continue;
924
- version = record.seq;
925
- budget = record.budget;
926
- }
927
- return { version, budget, corrupt: stateCorrupt };
928
- }
929
- function readAutoReviewContinuationState(env, scope, options = {}) {
930
- return readBudgetState(env, scope, options);
931
- }
932
- function claimAutoReviewContinuation(scope, eventKey, env, options = {}) {
933
- let { records, corrupt } = readSlots(env, scope);
934
- if (corrupt) return { ok: false, reason: "busy" };
935
- const state = readBudgetState(env, scope, options);
936
- if (state.budget.consumedEventKeys.includes(eventKey)) return { ok: false, reason: "duplicate-event" };
937
- const active = activeClaim(records);
938
- if (active) {
939
- const abandonedSelf = active.record.pid === process.pid && !state.budget.consumedEventKeys.includes(active.record.eventKey) && (options.now ? options.now() : Date.now()) - active.record.at > active.record.leaseMs * SELF_ABANDON_LEASES;
940
- if (ownerAlive(active.record) && !abandonedSelf) {
941
- return { ok: false, reason: "busy" };
942
- }
943
- if (abandonedSelf) {
944
- const released = releaseClaimSlot(env, scope, active.record, options);
945
- if (!released.ok) {
946
- return { ok: false, reason: "blocked", detail: `abandoned_claim_not_releasable: ${released.detail ?? "unknown"}` };
947
- }
948
- records = readSlots(env, scope).records;
949
- }
950
- }
951
- const owner = options.owner ?? randomUUID();
952
- const pid = options.ownerPid ?? process.pid;
953
- const record = {
954
- seq: nextSeq(records),
955
- kind: "claim",
956
- owner,
957
- eventKey,
958
- at: options.now ? options.now() : Date.now(),
959
- pid,
960
- procStart: options.ownerProcStart ?? procStartToken(pid),
961
- leaseMs: options.leaseMs ?? DEFAULT_LEASE_MS,
962
- ...active ? { supersedesSeq: active.record.seq } : {}
963
- };
964
- const created = createSlot(env, scope, record);
965
- if (!created.ok) return { ok: false, reason: "busy" };
966
- return { ok: true, claim: { eventKey, owner, at: record.at, leaseMs: record.leaseMs, seq: record.seq } };
967
- }
968
- function releaseClaimSlot(env, scope, claim, options = {}) {
969
- const { records } = readSlots(env, scope);
970
- const record = {
971
- seq: nextSeq(records),
972
- kind: "release",
973
- owner: claim.owner,
974
- eventKey: claim.eventKey,
975
- at: options.now ? options.now() : Date.now(),
976
- pid: process.pid,
977
- procStart: procStartToken(process.pid),
978
- leaseMs: claim.leaseMs,
979
- claimSeq: claim.seq
980
- };
981
- try {
982
- const created = createSlot(env, scope, record);
983
- return created.ok ? { ok: true } : { ok: false, detail: "sequence_conflict" };
984
- } catch (error) {
985
- return { ok: false, detail: describeError(error) };
986
- }
987
- }
988
- function commitAutoReviewContinuation(scope, claim, budget, env, meta) {
989
- const { records, corrupt } = readSlots(env, scope);
990
- if (corrupt) return { ok: false, reason: "budget_corrupt" };
991
- const entry = claimEntries(records).get(claim.seq);
992
- if (!entry || entry.closed || entry.superseded || entry.record.owner !== claim.owner || entry.record.eventKey !== claim.eventKey) {
993
- return { ok: false, reason: "superseded" };
994
- }
995
- const state = readBudgetState(env, scope);
996
- if (state.corrupt) return { ok: false, reason: "budget_corrupt" };
997
- if (typeof meta?.expectedVersion === "number" && state.version !== meta.expectedVersion) {
998
- return { ok: false, reason: "version_conflict" };
999
- }
1000
- const record = {
1001
- // Fixed target: the slot right after our claim. Any writer that took it
1002
- // first wins, and our commit fails instead of overwriting the newer state.
1003
- seq: claim.seq + 1,
1004
- kind: "commit",
1005
- owner: claim.owner,
1006
- eventKey: claim.eventKey,
1007
- at: Date.now(),
1008
- pid: process.pid,
1009
- procStart: procStartToken(process.pid),
1010
- leaseMs: claim.leaseMs,
1011
- claimSeq: claim.seq,
1012
- budget
1013
- };
1014
- const created = createSlot(env, scope, record);
1015
- if (!created.ok) return { ok: false, reason: "conflict" };
1016
- try {
1017
- appendFileSync(join(autoReviewContinuationTaskDir(env, scope), "audit.log"), `${JSON.stringify({ at: (/* @__PURE__ */ new Date()).toISOString(), eventKey: claim.eventKey, action: meta?.action, rounds: budget.rounds })}
1018
- `, { mode: 384 });
1019
- } catch {
1020
- }
1021
- return { ok: true };
1022
- }
1023
- function runAutoReviewContinuation(input, env, options = {}) {
1024
- const before = readAutoReviewContinuationState(env, input.scope, options);
1025
- if (before.corrupt) {
1026
- return { status: "blocked", action: { kind: "blocked", reason: "budget_corrupt" }, budget: before.budget, reason: "budget_corrupt", roundConsumed: false, effect: false };
1027
- }
1028
- let claim;
1029
- let committed = false;
1030
- let failure;
1031
- let releaseDetail;
1032
- try {
1033
- const claimed = claimAutoReviewContinuation(input.scope, input.trigger.eventKey, env, options);
1034
- if (!claimed.ok) {
1035
- if (claimed.reason === "blocked") {
1036
- failure = { status: "blocked", reason: "claim_blocked", diagnosis: claimed.detail };
1037
- } else {
1038
- return {
1039
- status: claimed.reason === "duplicate-event" ? "duplicate-event" : "busy",
1040
- action: claimed.reason === "duplicate-event" ? { kind: "duplicate" } : void 0,
1041
- budget: before.budget,
1042
- reason: claimed.reason,
1043
- roundConsumed: false,
1044
- effect: false,
1045
- ...claimed.detail ? { diagnosis: claimed.detail } : {}
1046
- };
1047
- }
1048
- } else {
1049
- claim = claimed.claim;
1050
- const state = readAutoReviewContinuationState(env, input.scope, options);
1051
- if (state.corrupt) {
1052
- failure = { status: "blocked", reason: "budget_corrupt" };
1053
- } else {
1054
- const result = reconcileAutoReviewContinuation({
1055
- scope: input.scope,
1056
- trigger: input.trigger,
1057
- fingerprint: input.fingerprint,
1058
- budget: state.budget,
1059
- authorization: input.authorization,
1060
- evidence: input.evidence
1061
- });
1062
- const commitResult = commitAutoReviewContinuation(input.scope, claim, result.budget, env, {
1063
- action: result.action.kind,
1064
- expectedVersion: state.version
1065
- });
1066
- if (!commitResult.ok) {
1067
- failure = {
1068
- status: commitResult.reason === "superseded" ? "superseded" : "failed",
1069
- reason: commitResult.reason ?? "commit_failed"
1070
- };
1071
- } else {
1072
- committed = true;
1073
- if (result.action.kind === "duplicate") {
1074
- return { status: "duplicate-event", action: result.action, budget: result.budget, reason: result.reason, roundConsumed: false, effect: false };
1075
- }
1076
- return { status: "acted", action: result.action, budget: result.budget, reason: result.reason, roundConsumed: result.roundConsumed, effect: result.roundConsumed };
1077
- }
1078
- }
1079
- }
1080
- } catch (error) {
1081
- failure = { status: "failed", reason: "store_error", diagnosis: describeError(error) };
1082
- } finally {
1083
- if (claim && !committed) {
1084
- try {
1085
- const released = releaseClaimSlot(env, input.scope, {
1086
- seq: claim.seq,
1087
- kind: "claim",
1088
- owner: claim.owner,
1089
- eventKey: claim.eventKey,
1090
- at: claim.at,
1091
- pid: process.pid,
1092
- procStart: procStartToken(process.pid),
1093
- leaseMs: claim.leaseMs
1094
- }, options);
1095
- if (!released.ok) releaseDetail = `release_failed: ${released.detail ?? "unknown"}`;
1096
- } catch (error) {
1097
- releaseDetail = `release_failed: ${describeError(error)}`;
1098
- }
1099
- }
1100
- }
1101
- const diagnosis = [failure?.diagnosis, releaseDetail].filter(Boolean).join("; ") || void 0;
1102
- return {
1103
- status: failure?.status ?? "failed",
1104
- action: void 0,
1105
- budget: before.budget,
1106
- reason: failure?.reason ?? "commit_failed",
1107
- roundConsumed: false,
1108
- effect: false,
1109
- ...diagnosis ? { diagnosis } : {}
1110
- };
1111
- }
1112
-
1113
- // packages/cli/tui/autoReviewControl.ts
1114
- import { mkdirSync as mkdirSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, renameSync, lstatSync } from "node:fs";
1115
- import { join as join2, dirname } from "node:path";
1116
- import { EventEmitter } from "node:events";
1117
- import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
1118
- import { resolve } from "node:path";
1119
-
1120
- // packages/cli/tui/learnPrompt.ts
1121
- var TUI_LEARN_DEVELOPER_REVIEW_PROMPT = `\u5BA1\u67E5\u5F53\u524D\u5BF9\u8BDD\u4E2D\u5DF2\u53EF\u89C1\u7684\u5BF9\u8BDD\u4E0E\u5DE5\u4F5C\uFF0C\u53EA\u5BFB\u627E\u5BF9\u7CFB\u7EDF\u53EF\u590D\u7528\u7684\u6539\u8FDB\u3002\u8986\u76D6\u6B64\u5904\u5B9E\u9645\u53EF\u89C1\u7684\u5185\u5BB9\uFF0C\u5305\u62EC\u672A\u5B8C\u6210\u3001\u5931\u8D25\u6216\u88AB\u4E2D\u65AD\u7684\u5DE5\u4F5C\uFF1B\u4E0D\u8981\u81C6\u6D4B\u4F60\u770B\u4E0D\u5230\u7684\u5386\u53F2\u3002
1122
-
1123
- \u805A\u7126\u4E24\u4E2A\u5C42\u9762\uFF1A
1124
-
1125
- 1. \u5DE5\u5177
1126
- - \u662F\u5426\u6709\u5DE5\u5177\u4E0D\u5FC5\u8981\u3001\u88AB\u53CD\u590D\u8C03\u7528\u3001\u96BE\u4EE5\u4F7F\u7528\u6216\u7F3A\u5931\uFF1F
1127
- - \u662F\u5426\u6709\u5DE5\u5177\u63CF\u8FF0\u3001schema \u6216\u7ED3\u679C\u7ED3\u6784\u9020\u6210\u8FC7\u56F0\u60D1\u6216\u6D6A\u8D39\uFF1F
1128
- - \u662F\u5426\u5B58\u5728\u4E00\u9879\u5177\u4F53\u7684\u5DE5\u5177\u6539\u52A8\uFF0C\u80FD\u6539\u8FDB\u591A\u4E2A\u672A\u6765\u4EFB\u52A1\uFF1F
1129
-
1130
- 2. \u63D0\u793A\u8BCD / \u6307\u4EE4
1131
- - \u662F\u5426\u6709\u7CFB\u7EDF\u3001\u5F00\u53D1\u8005\u3001\u9879\u76EE\u6216\u5DE5\u5177\u6307\u4EE4\u9020\u6210\u8FC7\u56F0\u60D1\u3001\u51B2\u7A81\u3001\u91CD\u590D\u6216\u4E0D\u5FC5\u8981\u7684\u5DE5\u4F5C\uFF1F
1132
- - \u662F\u5426\u7F3A\u5C11\u4E00\u6761\u91CD\u8981\u7684\u53EF\u590D\u7528\u6307\u4EE4\uFF1F
1133
- - \u662F\u5426\u5B58\u5728\u4E00\u9879\u5177\u4F53\u7684\u63D0\u793A\u8BCD/\u6307\u4EE4\u6539\u52A8\uFF0C\u80FD\u6539\u8FDB\u591A\u4E2A\u672A\u6765\u4EFB\u52A1\uFF1F
1134
-
1135
- \u89C4\u5219\uFF1A
1136
- - \u4E0D\u8981\u4E3A\u4E86\u4EA7\u51FA\u53CD\u9988\u800C\u7F16\u9020\u53D1\u73B0\u3002"\u65E0" \u662F\u4E00\u4E2A\u597D\u7ED3\u679C\u3002
1137
- - \u6BCF\u6761\u53D1\u73B0\u5FC5\u987B\u5F15\u7528\u5177\u4F53\u53EF\u89C1\u7684\u8BC1\u636E\uFF1A\u7528\u6237\u7684\u7EA0\u6B63\u3001\u5931\u8D25\u7684\u8C03\u7528\u3001\u91CD\u590D\u7684\u5DE5\u4F5C\u3002\u6CA1\u6709\u8BC1\u636E\u5C31\u6CA1\u6709\u53D1\u73B0\u3002\u628A\u89C2\u5BDF\u5230\u7684\u4E8B\u5B9E\u4E0E\u5047\u8BBE\u5206\u5F00\uFF0C\u4E0D\u8981\u628A\u76F8\u5173\u6027\u5F53\u6210\u6839\u56E0\u3002
1138
- - \u4F18\u5148\u5220\u9664\u3001\u5408\u5E76\u6216\u6F84\u6E05\u65E2\u6709\u6307\u4EE4\uFF0C\u800C\u4E0D\u662F\u65B0\u589E\u4E00\u6761\uFF1B\u4E0D\u8981\u628A\u4E00\u6B21\u6027\u9519\u8BEF\u6CDB\u5316\u6210\u5168\u5C40\u89C4\u5219\u3002
1139
- - \u5BF9\u4E8E\u63D0\u793A\u8BCD\u7C7B\u53D1\u73B0\uFF0C\u7ED9\u51FA\u53EF\u89C1\u7684\u539F\u6587\u63AA\u8F9E\u6216\u53EF\u9A8C\u8BC1\u7684\u4F4D\u7F6E\uFF0C\u52A0\u4E0A\u6700\u5C0F\u7684\u66FF\u6362\u6587\u672C\u3002\u5982\u679C\u5B9A\u4F4D\u4E0D\u5230\uFF0C\u5C31\u8BF4\u660E\u4F4D\u7F6E\u672A\u77E5\uFF0C\u4E0D\u8981\u731C\u6D4B\u6765\u6E90\u3002
1140
- - \u4F18\u5148\u8DE8\u4EFB\u52A1\u53EF\u590D\u7528\u3001\u6295\u5165\u4EA7\u51FA\u6BD4\u9AD8\u3001\u8D1F\u9762\u526F\u4F5C\u7528\u5C0F\u7684\u6539\u8FDB\uFF0C\u76EE\u6807\u662F\u66F4\u901A\u7528\u3001\u66F4\u5FEB\u3001\u66F4\u7701\u94B1\u3001\u66F4\u51C6\u786E\uFF1B\u53EA\u6362\u63AA\u8F9E\u3001\u6CA1\u6709\u5B9E\u8D28\u884C\u4E3A\u6536\u76CA\u7684\u6539\u5199\u4E0D\u7B97\u6539\u8FDB\u3002
1141
- - \u4F18\u5148\u6709\u4EE3\u7801\u4FDD\u969C\u3001\u7ED3\u6784\u5316\u5951\u7EA6\u6216\u7ED3\u6784\u5316\u7ED3\u679C\uFF0C\u6216\u6709\u660E\u786E\u89E6\u53D1\u6761\u4EF6\u3001\u52A8\u4F5C\u4E0E\u505C\u6B62\u6761\u4EF6\u7684\u6539\u52A8\u3002
1142
- - \u6BCF\u6761\u53D1\u73B0\u6309\uFF1A\u8BC1\u636E\uFF1B\u5EFA\u8BAE\u6539\u52A8\uFF1B\u6536\u76CA\u673A\u5236\uFF1B\u6210\u672C\u6216\u526F\u4F5C\u7528\uFF1B\u672A\u77E5\u70B9\u3002\u8BC1\u636E\u4E0D\u8DB3\u6216\u6536\u76CA\u4E0E\u98CE\u9669\u4E0D\u660E\u7684\uFF0C\u4E0D\u8981\u65AD\u8A00\u6536\u76CA\uFF0C\u4E5F\u4E0D\u8981\u58F0\u79F0\u96F6\u526F\u4F5C\u7528\u3002
1143
- - \u53EF\u80FD\u524A\u5F31\u6743\u9650\u3001\u5B89\u5168\u3001\u8D44\u6E90\u4FDD\u62A4\u6216\u6B63\u786E\u6027\u7684\u6539\u52A8\uFF0C\u5217\u4E3A"\u5F85\u9A8C\u8BC1"\u6216"\u4E0D\u63A8\u8350"\uFF0C\u4E0D\u4F5C\u4E3A\u76F4\u63A5\u5B9E\u65BD\u5EFA\u8BAE\uFF1B\u4E5F\u4E0D\u8981\u628A\u9A8C\u8BC1\u6362\u6210\u5C11\u8C03\u5DE5\u5177\u3002
1144
- - \u672C\u6B21\u5BA1\u67E5\u4E0D\u5F97\u4FEE\u6539\u4EE3\u7801\u3001\u63D0\u793A\u8BCD\u3001\u5DE5\u5177\u3001\u8BB0\u5FC6\u6216\u914D\u7F6E\u3002\u4EC5\u5BA1\u67E5\u3002
1145
- - \u4FDD\u6301\u7B80\u6D01\u3002
1146
-
1147
- \u4E25\u683C\u6309\u4EE5\u4E0B\u5C0F\u8282\u8FD4\u56DE\uFF1A
1148
- \u5DE5\u5177\u53D1\u73B0
1149
- - \u65E0 \u6216\uFF1A\u53D1\u73B0\uFF1B\u8BC1\u636E\uFF1B\u5EFA\u8BAE\u6539\u52A8\uFF1B\u6536\u76CA\u673A\u5236\uFF1B\u6210\u672C/\u526F\u4F5C\u7528\uFF1B\u672A\u77E5\u70B9
1150
-
1151
- \u63D0\u793A\u8BCD\u53D1\u73B0
1152
- - \u65E0 \u6216\uFF1A\u53D1\u73B0\uFF1B\u8BC1\u636E\uFF1B\u5EFA\u8BAE\u6539\u52A8\uFF1B\u6536\u76CA\u673A\u5236\uFF1B\u6210\u672C/\u526F\u4F5C\u7528\uFF1B\u672A\u77E5\u70B9
1153
-
1154
- \u503C\u5F97\u6539\u52A8\u5417\uFF1F
1155
- - \u662F/\u5426
1156
- - \u7F6E\u4FE1\u5EA6\uFF1A\u4F4E/\u4E2D/\u9AD8
1157
- - \u4E00\u53E5\u8BDD\u7406\u7531
1158
- - \u6536\u76CA\u4E0E\u98CE\u9669\uFF1A\u6700\u4E3B\u8981\u6536\u76CA\uFF08\u66F4\u5FEB/\u66F4\u7701/\u66F4\u51C6\uFF09\u4E0E\u6700\u5927\u98CE\u9669\u6216\u672A\u77E5`;
1159
- var TUI_LEARN_PLAIN_REVIEW_PROMPT = `\u8BF7\u4EE5\u666E\u901A\u7528\u6237\u7684\u89D2\u5EA6\uFF0C\u56DE\u987E\u8FD9\u6B21\u5BF9\u8BDD\u91CC\u4F60\u5B9E\u9645\u770B\u5230\u7684\u5185\u5BB9\uFF0C\u627E\u51FA\u54EA\u4E9B\u5730\u65B9\u8BA9\u4EBA\u4E0D\u987A\u624B\u3001\u8D39\u65F6\u95F4\uFF0C\u6216\u8005\u6CA1\u6709\u62FF\u5230\u60F3\u8981\u7684\u7ED3\u679C\u3002
1160
-
1161
- \u89C4\u5219\uFF1A
1162
- - \u53EA\u4F9D\u636E\u8FD9\u6B21\u5BF9\u8BDD\u91CC\u770B\u5F97\u89C1\u7684\u5185\u5BB9\u6765\u8BF4\u8BDD\uFF1A\u54EA\u4E00\u6B65\u5361\u4F4F\u4E86\u3001\u91CD\u590D\u505A\u4E86\u4EC0\u4E48\u3001\u54EA\u6761\u4FE1\u606F\u6CA1\u770B\u61C2\u3002\u6CA1\u6709\u8BC1\u636E\u5C31\u4E0D\u8981\u63D0\uFF1B"\u6CA1\u53D1\u73B0\u9700\u8981\u6539\u7684\u5730\u65B9" \u4E5F\u662F\u597D\u7ED3\u679C\u3002
1163
- - \u7528\u65E5\u5E38\u8BDD\u8BF4\u6E05\u695A\u95EE\u9898\u51FA\u5728\u4EC0\u4E48\u5730\u65B9\u3001\u9020\u6210\u4E86\u4EC0\u4E48\u5F71\u54CD\uFF0C\u518D\u7ED9\u51FA\u4E00\u4E2A\u5177\u4F53\u3001\u80FD\u91CD\u590D\u4F7F\u7528\u7684\u6539\u8FDB\u5EFA\u8BAE\u3002
1164
- - \u4E0D\u8981\u4F7F\u7528\u884C\u8BDD\u3001\u6587\u4EF6\u540D\u6216\u5185\u90E8\u672F\u8BED\u6765\u89E3\u91CA\u95EE\u9898\uFF1B\u5982\u679C\u5FC5\u987B\u63D0\u5230\u67D0\u4E2A\u6280\u672F\u540D\u8BCD\uFF0C\u5C31\u987A\u5E26\u7528\u4E00\u53E5\u767D\u8BDD\u8BF4\u660E\u5B83\u662F\u4EC0\u4E48\u3002
1165
- - \u8FD9\u6B21\u53EA\u662F\u590D\u76D8\uFF1A\u4E0D\u8981\u4FEE\u6539\u4EE3\u7801\u3001\u914D\u7F6E\u3001\u8BB0\u5FC6\u6216\u8BBE\u7F6E\uFF0C\u4E5F\u4E0D\u8981\u66FF\u4EBA\u505A\u51B3\u5B9A\u3002\u9700\u8981\u6539\u52A8\u7684\u5730\u65B9\u53EA\u5199\u6210\u5EFA\u8BAE\uFF0C\u7B49\u4EBA\u786E\u8BA4\u540E\u518D\u505A\u3002
1166
- - \u4FDD\u6301\u7B80\u6D01\u3002
1167
-
1168
- \u4E25\u683C\u6309\u4EE5\u4E0B\u7ED3\u6784\u8FD4\u56DE\uFF1A
1169
- \u505A\u5F97\u987A\u7684\u5730\u65B9
1170
- - \u4E00\u53E5\u8BDD\u5373\u53EF\uFF1B\u6CA1\u6709\u5C31\u5199"\u65E0"
1171
-
1172
- \u4E0D\u987A\u624B\u7684\u5730\u65B9
1173
- - \u6BCF\u6761\u5199\u6E05\u695A\uFF1A\u54EA\u91CC\u5361\u4F4F \u2192 \u5F71\u54CD\u4E86\u4EC0\u4E48 \u2192 \u5EFA\u8BAE\u600E\u4E48\u6539
1174
- - \u6CA1\u6709\u5C31\u5199"\u65E0"
1175
-
1176
- \u6700\u503C\u5F97\u6539\u7684\u4E00\u70B9
1177
- - \u4E00\u53E5\u8BDD
1178
- - \u7F6E\u4FE1\u5EA6\uFF1A\u4F4E/\u4E2D/\u9AD8`;
1179
- function resolveTuiLearnOperatorUserId(env = {}) {
1180
- const token = resolvePlatformAuthToken(env);
1181
- if (!token) return null;
1182
- const userId = parseUserIdFromAuthToken(token);
1183
- return userId ? userId : null;
1184
- }
1185
- function selectTuiLearnReviewPrompt(operatorUserId) {
1186
- return operatorUserId === CURRENT_OPERATOR_USER_ID ? TUI_LEARN_DEVELOPER_REVIEW_PROMPT : TUI_LEARN_PLAIN_REVIEW_PROMPT;
1187
- }
1188
- function resolveTuiLearnReviewPrompt(startupEnv = {}, liveEnv) {
1189
- return selectTuiLearnReviewPrompt(
1190
- resolveTuiLearnOperatorUserId(resolveTuiIdentityEnv(startupEnv, liveEnv))
1191
- );
1192
- }
1193
- function resolveTuiIdentityEnv(startupEnv, liveEnv) {
1194
- const merged = { ...startupEnv ?? {} };
1195
- for (const [key, value] of Object.entries(liveEnv ?? {})) {
1196
- if (value !== void 0) merged[key] = value;
1197
- }
1198
- return merged;
1199
- }
1200
-
1201
- // packages/cli/tui/autoReviewControl.ts
1202
- var AUTO_REVIEW_SCOPE = "\u4EC5\u5F53\u524D\u4EFB\u52A1\uFF1A\u72EC\u7ACB review\u3001\u4FEE\u590D\u3001commit\u3001\u672C\u5730 alpha merge\uFF1B\u4E0D\u6388\u6743 push\u3001main/production merge\u3001release\u3001\u56DE\u6EDA\u6216\u5220\u9664\u3002";
1203
- var acceptanceEvents = new EventEmitter();
1204
- function onAutoReviewAcceptance(listener) {
1205
- acceptanceEvents.on("accepted", listener);
1206
- return () => {
1207
- acceptanceEvents.off("accepted", listener);
1208
- };
1209
- }
1210
- function bindingPath(userId, dialogId, workspace, env) {
1211
- return join2(hostTaskEventsRoot(env), "current-bindings", createHash2("sha256").update(JSON.stringify([userId, dialogId, resolve(workspace)])).digest("hex") + ".json");
1212
- }
1213
- function restoreCurrentAutoReviewTask(userId, dialogId, workspace, env) {
1214
- try {
1215
- const path3 = bindingPath(userId, dialogId, workspace, env);
1216
- if (lstatSync(path3).isSymbolicLink()) return void 0;
1217
- const stored = JSON.parse(readFileSync2(path3, "utf8"));
1218
- const ref = stored.reference;
1219
- if (stored.userId !== userId || ref.dialogId !== dialogId || resolve(ref.workspace) !== resolve(workspace) || !ref.taskInstanceId) return void 0;
1220
- const task = readHostTask(hostTaskEventsRoot(env), ref);
1221
- if (task.authorization === "unknown" || task.taskStart?.userId !== userId) return void 0;
1222
- return task.authorization === "active" || task.authorization === "paused" ? ref : void 0;
1223
- } catch {
1224
- return void 0;
1225
- }
1226
- }
1227
- function currentAutoReviewTask(state, env) {
1228
- const userId = resolveTuiLearnOperatorUserId(env);
1229
- if (!userId || !state.dialogId) return void 0;
1230
- const restored = restoreCurrentAutoReviewTask(userId, state.dialogId, state.cwd, env);
1231
- if (!restored) {
1232
- try {
1233
- lstatSync(bindingPath(userId, state.dialogId, state.cwd, env));
1234
- return void 0;
1235
- } catch (error) {
1236
- if (error.code !== "ENOENT") return void 0;
1237
- }
1238
- }
1239
- const reference = restored ?? referenceFor(userId, state.dialogId, state.cwd);
1240
- let resolution;
1241
- try {
1242
- resolution = readHostTask(hostTaskEventsRoot(env), reference);
1243
- } catch {
1244
- return void 0;
1245
- }
1246
- if (resolution.authorization !== "active" && resolution.authorization !== "paused") return void 0;
1247
- return reference;
1248
- }
1249
- function referenceFor(userId, dialogId, workspace) {
1250
- const id = createHash2("sha256").update(JSON.stringify([userId, dialogId, resolve(workspace), "local-alpha-v1"])).digest("hex");
1251
- return { taskId: `tui-local-alpha-v1-${id}`, workspace: resolve(workspace), dialogId };
1252
- }
1253
- function applyAutoReviewControl(line, state, env) {
1254
- const parts = line.trim().split(/\s+/);
1255
- const command = parts[1] ?? "status";
1256
- const fail = (output) => ({ state, output });
1257
- if (parts.length > 2 || !["status", "on", "pause", "resume", "off", "accept", "waive"].includes(command)) {
1258
- return fail("\u7528\u6CD5\uFF1A/auto-review status|on|pause|resume|off|accept|waive");
1259
- }
1260
- const userId = resolveTuiLearnOperatorUserId(env);
1261
- if (!userId) return fail("auto-review\uFF1A\u5F53\u524D\u767B\u5F55\u8EAB\u4EFD\u672A\u77E5\uFF0C\u672A\u5199\u5165\u4EFB\u4F55\u6388\u6743\u3002");
1262
- if (state.dialogOwnerId && state.dialogOwnerId !== userId) return fail("auto-review\uFF1A\u5F53\u524D dialog \u4E0D\u5C5E\u4E8E\u5F53\u524D\u767B\u5F55\u7528\u6237\uFF0C\u672A\u5199\u5165\u6388\u6743\u3002");
1263
- if (!state.dialogId) return fail("auto-review\uFF1A\u5F53\u524D\u5C1A\u65E0 dialog\uFF0C\u8BF7\u5148\u5EFA\u7ACB\u5BF9\u8BDD\uFF1B\u672A\u521B\u5EFA\u6388\u6743\u3002");
1264
- let persisted;
1265
- try {
1266
- const path3 = bindingPath(userId, state.dialogId, state.cwd, env);
1267
- if (lstatSync(path3).isSymbolicLink()) return fail("auto-review\uFF1Acurrent binding \u4E0D\u5B89\u5168\u3002");
1268
- const binding = JSON.parse(readFileSync2(path3, "utf8"));
1269
- if (binding.userId !== userId || binding.reference.dialogId !== state.dialogId || resolve(binding.reference.workspace) !== resolve(state.cwd)) return fail("auto-review\uFF1Acurrent binding \u4F5C\u7528\u57DF\u4E0D\u7B26\u3002");
1270
- persisted = binding.reference;
1271
- } catch (error) {
1272
- if (error.code !== "ENOENT") return fail("auto-review\uFF1Acurrent binding \u4E0D\u53EF\u7528\u3002");
1273
- }
1274
- const reference = persisted ?? referenceFor(userId, state.dialogId, state.cwd);
1275
- const root = hostTaskEventsRoot(env);
1276
- const current = readHostTask(root, reference);
1277
- const nextState = { ...state, autoReviewTask: { userId, reference } };
1278
- const describe = (auth, acceptance) => `auto-review\uFF1A${auth}\uFF1B\u9A8C\u6536\uFF1A${acceptance}\u3002${AUTO_REVIEW_SCOPE}`;
1279
- if (command === "status") {
1280
- if (current.authorization === "unknown") return fail("auto-review\uFF1A\u672A\u5F00\u542F\uFF08\u65E0\u53EF\u4FE1\u5F53\u524D\u4EFB\u52A1\u8BB0\u5F55\uFF09\u3002");
1281
- return { state, output: describe(current.authorization, current.contract.acceptance) };
1282
- }
1283
- if (current.authorization === "unknown" && (command !== "on" || current.reason !== "missing")) return fail("auto-review\uFF1A\u65E0\u53EF\u4FE1\u5F53\u524D\u4EFB\u52A1\u8BB0\u5F55\uFF1B\u53EA\u6709 /auto-review on \u53EF\u4EE5\u521B\u5EFA\u4EFB\u52A1\u6388\u6743\u3002");
1284
- if (command === "on" && current.authorization !== "unknown") return { state: nextState, output: `auto-review\uFF1A\u4EFB\u52A1\u8BB0\u5F55\u5DF2\u5B58\u5728\uFF0C\u72B6\u6001 ${current.authorization}\uFF1B\u6062\u590D\u8BF7\u663E\u5F0F\u4F7F\u7528 resume\u3002${AUTO_REVIEW_SCOPE}` };
1285
- if (command === "resume" && current.authorization === "revoked") return fail("auto-review\uFF1A\u5F53\u524D\u4EFB\u52A1\u6388\u6743\u5DF2\u64A4\u9500\uFF0C\u4E0D\u80FD resume\uFF1B\u8BF7\u5728\u65B0\u7684 dialog \u5F00\u542F\u65B0\u4EFB\u52A1\u3002");
1286
- const controller = createHostTaskController(root, { kind: "user-control", actorId: userId, sourceId: `tui-control-${randomUUID2()}` });
562
+ for (const run of event.runs) traceRunWake(stage, {
563
+ runId: run.runId,
564
+ status: run.status,
565
+ parentDialogId: run.parentDialogId ?? null,
566
+ currentDialogId,
567
+ ...fields
568
+ });
569
+ }
570
+ function traceRunWake(stage, fields) {
1287
571
  try {
1288
- if (command === "on") {
1289
- const workspace = admitHostTaskWorkspace(reference, env);
1290
- if (workspace.status !== "ready") return fail(`auto-review\uFF1Ablocked\uFF1B${workspace.reason ?? "\u5DE5\u4F5C\u533A\u5F52\u5C5E\u672A\u77E5"}\uFF1B\u672A\u521B\u5EFA\u6388\u6743\u3002`);
1291
- }
1292
- const sequence = current.authorization === "unknown" ? 0 : current.sequence;
1293
- const change = command === "on" ? { type: "admitted", role: "owner" } : command === "accept" || command === "waive" ? { type: "acceptance", value: command === "accept" ? "accepted" : "waived" } : { type: "authorization", value: command === "pause" ? "paused" : command === "off" ? "revoked" : "active" };
1294
- const next = controller.append(reference, sequence, change);
1295
- if ((command === "accept" || command === "waive") && next.authorization !== "unknown") {
1296
- queueMicrotask(() => acceptanceEvents.emit("accepted", reference, next.sequence));
1297
- }
1298
- return { state: nextState, output: describe(next.authorization, next.authorization === "unknown" ? "unknown" : next.contract.acceptance) };
572
+ getDiagnostics()?.logger.child({ component: "run-terminal-wake", fields }).debug(stage);
1299
573
  } catch {
1300
- return fail("auto-review\uFF1A\u4E8B\u4EF6\u4FDD\u5B58\u5931\u8D25\u6216 sequence \u51B2\u7A81\uFF0C\u672A\u5BA3\u544A\u64CD\u4F5C\u6210\u529F\uFF1B\u8BF7\u7528 status \u68C0\u67E5\u3002");
1301
574
  }
1302
575
  }
1303
576
 
1304
- // packages/cli/tui/autoReviewContinuationWake.ts
1305
- var hostEvents = /* @__PURE__ */ new WeakSet();
1306
- function isHostAutoReviewContinuationEvent(event) {
1307
- return hostEvents.has(event);
1308
- }
1309
- function reviewState(scope, revision, env) {
1310
- const directory = join3(resolveRunsDir(env), "host-review-dispatch");
1311
- try {
1312
- lstatSync2(directory);
1313
- } catch (error) {
1314
- return error.code === "ENOENT" ? "none" : "unknown";
1315
- }
1316
- try {
1317
- if (lstatSync2(directory).isSymbolicLink() || realpathSync(directory) !== resolve2(directory)) return "unknown";
1318
- let finished = false;
1319
- for (const name of readdirSync2(directory).filter((n) => n.endsWith(".json") && !n.startsWith("author-") && !n.startsWith("plan-"))) {
1320
- const path3 = join3(directory, name);
1321
- if (lstatSync2(path3).isSymbolicLink() || !lstatSync2(path3).isFile()) return "unknown";
1322
- const intent = JSON.parse(readFileSync3(path3, "utf8"));
1323
- if (!intent.scope || !sameTaskScope(intent.scope, scope) || intent.scope.taskInstanceId !== scope.taskInstanceId || intent.revision !== revision) continue;
1324
- if (!/^[A-Za-z0-9._-]{1,128}$/.test(intent.dispatchId) || !/^[A-Za-z0-9._-]{1,128}$/.test(intent.reviewerRunId)) return "unknown";
1325
- const bound = join3(directory, `dispatch-${intent.dispatchId}.bound`);
1326
- if (lstatSync2(bound).isSymbolicLink() || readFileSync3(bound, "utf8") !== intent.reviewerRunId) return "unknown";
1327
- const consumedPath = join3(directory, `dispatch-${intent.dispatchId}.consumed`);
1328
- if (lstatSync2(consumedPath).isSymbolicLink()) return "unknown";
1329
- const consumed = JSON.parse(readFileSync3(consumedPath, "utf8"));
1330
- const { reviewerRunId: _run, resultSha256: _digest, ...context } = intent;
1331
- if (JSON.stringify(context) !== JSON.stringify(consumed)) return "unknown";
1332
- const run = readRunRecord(intent.reviewerRunId, { env });
1333
- if (!run || run.runId !== intent.reviewerRunId) return "unknown";
1334
- if (!isAgentRunTerminalStatus(run.status)) return "running";
1335
- finished = true;
1336
- }
1337
- return finished ? "finished" : "none";
1338
- } catch {
1339
- return "unknown";
1340
- }
1341
- }
1342
- function createAutoReviewContinuationWake(host) {
1343
- return (trigger, aborted = false, expectedScope) => {
1344
- const scope = currentAutoReviewTask(host.getState(), host.env);
1345
- if (expectedScope && JSON.stringify(scope) !== JSON.stringify(expectedScope)) return { kind: "stopped", reason: "task_scope_changed" };
1346
- if (!scope) return { kind: "stopped", reason: "no_active_task" };
1347
- const task = readHostTask(hostTaskEventsRoot(host.env), scope);
1348
- if (task.authorization === "unknown") return { kind: "stopped", reason: "authorization_unknown" };
1349
- const c = task.contract;
1350
- if (aborted || task.authorization !== "active") return { kind: "stopped", reason: aborted ? "aborted" : `authorization_${task.authorization}` };
1351
- if (!aborted && task.authorization === "active" && (c.acceptance === "pending" || c.acceptance === "unknown")) {
1352
- return { kind: "wait-user", reason: "acceptance_pending" };
1353
- }
1354
- const dispatch = reviewState(scope, c.revision, host.env);
1355
- if (dispatch === "unknown") return { kind: "blocked", reason: "review_dispatch_unknown" };
1356
- const evidence = {
1357
- implementation: c.implementation,
1358
- revision: c.revision,
1359
- reviewRun: dispatch,
1360
- reviewDecision: dispatch === "finished" ? c.review : void 0,
1361
- commit: c.commit,
1362
- localMerge: c.localMerge,
1363
- aborted
1364
- };
1365
- const fingerprint2 = {
1366
- taskInstanceId: scope.taskInstanceId ?? scope.taskId,
1367
- stage: "implementation",
1368
- revision: c.revision,
1369
- acceptance: c.acceptance
1370
- };
1371
- const proposed = decideAutoReviewAction(fingerprint2, evidence).action.kind;
1372
- const oneShot = ["request-review", "decide-review", "commit", "local-merge"].includes(proposed);
1373
- const eventTrigger = oneShot ? { ...trigger, eventKey: `effect:${createHash3("sha256").update(JSON.stringify([scope, proposed, fingerprint2, evidence])).digest("hex")}` } : trigger;
1374
- const result = runAutoReviewContinuation({
1375
- scope,
1376
- trigger: eventTrigger,
1377
- authorization: task.authorization,
1378
- evidence,
1379
- fingerprint: {
1380
- taskInstanceId: scope.taskInstanceId ?? scope.taskId,
1381
- stage: "implementation",
1382
- revision: c.revision,
1383
- acceptance: c.acceptance
1384
- }
1385
- }, host.env);
1386
- const action = result.action;
1387
- if (result.status !== "acted" || !action) return action;
1388
- if (["continue-author", "request-review", "decide-review", "commit", "local-merge"].includes(action.kind)) {
1389
- const event = {
1390
- kind: "auto-review-continuation",
1391
- scope,
1392
- eventKey: trigger.eventKey,
1393
- action: action.kind,
1394
- displayText: "",
1395
- text: `[host auto-review continuation] task=${scope.taskId}; action=${action.kind}. Continue the existing authorized task using host evidence. This is not a user submission or new authorization. For request-review, use listAgents to select an independent eligible reviewer then the existing typed review request; obey fee authorization and never automatically select a platform-paid agent. Do not request already-granted authorization again; do not push or merge main/production.`
1396
- };
1397
- hostEvents.add(event);
1398
- host.wake(event);
577
+ // packages/cli/tui/runWakeDelivery.ts
578
+ function createRunWakeHandler(deps) {
579
+ const handler = (event) => {
580
+ if (deps.isDone()) {
581
+ traceChildRunWake("delivery-done", event, deps.getDialogId());
582
+ return false;
583
+ }
584
+ const busy = deps.isBusy();
585
+ const paused = deps.fixedInput.isPaused();
586
+ const turnInjectionInbox = deps.getInbox();
587
+ const fixedInput = deps.fixedInput;
588
+ const trace = (stage, extra = {}) => traceChildRunWake(stage, event, deps.getDialogId(), { busy, paused, inboxPresent: !!turnInjectionInbox, ...queueWakeFields(deps.getQueueStatus()), ...extra });
589
+ if (busy || paused) {
590
+ const text = typeof event === "string" ? event : event.text;
591
+ const injected = !!turnInjectionInbox && turnInjectionInbox.push({ text, fallback: event });
592
+ trace("delivery-inbox-attempt", { inboxPushResult: injected });
593
+ if (injected) {
594
+ const displayText = typeof event === "string" ? event : event.kind === "user" ? event.text : event.displayText ?? event.text;
595
+ if (displayText) deps.printLine(displayText);
596
+ } else {
597
+ const status = deps.enqueue(event);
598
+ trace("delivery-queue", queueWakeFields(status));
599
+ }
600
+ if (fixedInput.active && !fixedInput.isPaused()) {
601
+ deps.repaint();
602
+ }
603
+ return true;
604
+ }
605
+ trace("delivery-idle-turn");
606
+ if (typeof event !== "string" && event.kind === "child-run-completed") {
607
+ deps.enqueue(event);
608
+ void deps.drainQueue().catch(deps.onError);
609
+ } else {
610
+ void deps.runIdle(event).catch(deps.onError);
1399
611
  }
1400
- return action;
612
+ return true;
1401
613
  };
614
+ return Object.assign(handler, {
615
+ async resumeAfterInputPause() {
616
+ if (deps.isDone() || deps.isBusy() || deps.fixedInput.isPaused()) return;
617
+ await deps.drainQueue();
618
+ }
619
+ });
1402
620
  }
1403
- var queueHosts = /* @__PURE__ */ new WeakMap();
1404
- async function runAutoReviewDrainedTurn(binding, run) {
1405
- const host = queueHosts.get(binding);
1406
- const scope = host?.getScope();
1407
- const context = host?.getContext();
1408
- const key = host?.nextEventKey();
1409
- const outcome = await run();
1410
- const current = host?.getScope();
1411
- const after = host?.getContext();
1412
- if (host && current && context && after && key && outcome.ok && !outcome.aborted && context.dialogId === after.dialogId && context.workspace === after.workspace && (!scope || JSON.stringify(scope) === JSON.stringify(current))) {
1413
- queueMicrotask(() => host.reconcile({ kind: "turn-terminal", eventKey: key }, false, current));
1414
- }
1415
- return outcome;
1416
- }
1417
- function bindAutoReviewTurnEnd(binding, host) {
1418
- queueHosts.set(binding, host);
1419
- let startedScope;
1420
- let eventKey;
1421
- let startedContext;
1422
- const start = binding.notifyTurnStart.bind(binding);
1423
- const end = binding.notifyTurnEnd.bind(binding);
1424
- binding.notifyTurnStart = () => {
1425
- startedContext = host.getContext();
1426
- startedScope = host.getScope();
1427
- eventKey = host.nextEventKey();
1428
- start();
1429
- };
1430
- binding.notifyTurnEnd = async (outcome) => {
1431
- const current = host.getScope();
1432
- const context = host.getContext();
1433
- const sameContext = startedContext && startedContext.dialogId === context.dialogId && startedContext.workspace === context.workspace;
1434
- const scope = sameContext && current && current.dialogId === context.dialogId && current.workspace === context.workspace && (!startedScope || JSON.stringify(startedScope) === JSON.stringify(current)) ? current : void 0;
1435
- const key = eventKey;
1436
- startedContext = void 0;
1437
- startedScope = void 0;
1438
- eventKey = void 0;
1439
- await end(outcome);
1440
- if (scope && key && outcome.ok && !outcome.aborted) {
1441
- queueMicrotask(() => host.reconcile({ kind: "turn-terminal", eventKey: key }, false, scope));
621
+ function deliverChildCompletion(event, receive, reconcile) {
622
+ const accepted = receive?.(event) ?? false;
623
+ if (accepted) {
624
+ try {
625
+ reconcile();
626
+ } catch {
627
+ traceChildRunWake("reconcile-after-admission-failed", event, null);
1442
628
  }
1443
- };
1444
- return binding;
629
+ }
630
+ return accepted;
1445
631
  }
1446
632
 
1447
633
  // packages/cli/tui/shellApprovalSession.ts
@@ -2108,6 +1294,12 @@ function layoutImageRows(images, contentWidth, graphicsEnabled, bodyEnd) {
2108
1294
  const rows = [];
2109
1295
  for (const image of images) {
2110
1296
  if (graphicsEnabled && hasUsableSize(image)) {
1297
+ rows.push({
1298
+ rendered: truncateAnsi(`${PLACEHOLDER_PREFIX}${sanitizeImageLabel(image.label)}`, width),
1299
+ sourceStart: bodyEnd,
1300
+ sourceEnd: bodyEnd,
1301
+ prefixWidth: 0
1302
+ });
2111
1303
  const fit = fitImageToCells(
2112
1304
  { width: image.width, height: image.height },
2113
1305
  { maxColumns: width }
@@ -2472,14 +1664,14 @@ function appendLocalTurn(history, command, output) {
2472
1664
  trimHistoryToBudget(history);
2473
1665
  resetStreamingTurnCache();
2474
1666
  }
2475
- var TOOL_SUCCESS_LINE_RE = /^(▸ .*?)(?: ×(\d+))?( ✓)$/;
1667
+ var TOOL_SUCCESS_LINE_RE = /^(▸ .*?)(?: ×(\d+))?( ✓(?:\s+\d+(?:\.\d+)?(?:ms|s))?)$/;
2476
1668
  function readTreePayload(chunk) {
2477
1669
  return JSON.parse(chunk.slice(TUI_TREE_MARKER.length).replace(/\u0002\n?$/, ""));
2478
1670
  }
2479
1671
  function applyTreeRewrite(text, chunk) {
2480
1672
  if (!chunk.startsWith(TUI_TREE_MARKER)) return null;
2481
1673
  const payload = readTreePayload(chunk);
2482
- const tree = `\u2022 ${payload.summary}`;
1674
+ const tree = `\u25B8 ${payload.summary}`;
2483
1675
  const hadTrailingNewline = text.endsWith("\n");
2484
1676
  const body = hadTrailingNewline ? text.slice(0, -1) : text;
2485
1677
  const bodyLines = body.split("\n");
@@ -2487,8 +1679,11 @@ function applyTreeRewrite(text, chunk) {
2487
1679
  const tail = plainLines.at(-1) ?? "";
2488
1680
  const labels = TUI_TREE_TOOLS[payload.kind].map(toolLabel);
2489
1681
  const flatLabel = tail.match(/^▸ (.+?)(?: · .*?)?(?: ×\d+)? ✓(?: (?:\d+(?:\.\d+)?(?:ms|s)|×\d+))*$/)?.[1];
2490
- const summaryLabel = tail.match(/^• (.+?) \(\d+\) · .* ✓$/)?.[1];
2491
- if (!labels.includes(flatLabel ?? "") && summaryLabel !== labels[0]) return null;
1682
+ const summaryLabel = tail.match(/^▸ (.+?) \(\d+\) · .* ✓$/)?.[1];
1683
+ if (payload.previousRow !== void 0) {
1684
+ const withoutFoldCount = (row) => row.replace(/ ×\d+(?= ✓|$)/g, "");
1685
+ if (withoutFoldCount(tail) !== withoutFoldCount(payload.previousRow)) return null;
1686
+ } else if (!labels.includes(flatLabel ?? "") && summaryLabel !== labels[0]) return null;
2492
1687
  const prefix = bodyLines.length < 2 ? "" : `${bodyLines.slice(0, -1).join("\n")}
2493
1688
  `;
2494
1689
  return `${prefix}${tree}
@@ -2496,18 +1691,20 @@ function applyTreeRewrite(text, chunk) {
2496
1691
  }
2497
1692
  function foldToolSuccessLine(text, chunk) {
2498
1693
  const plain = stripAnsi(chunk).replace(/\n+$/, "");
2499
- if (!plain || plain.includes("\n") || !TOOL_SUCCESS_LINE_RE.test(plain)) return null;
1694
+ if (!plain || plain.includes("\n")) return null;
1695
+ const chunkMatch = TOOL_SUCCESS_LINE_RE.exec(plain);
1696
+ if (!chunkMatch) return null;
2500
1697
  const hadTrailingNewline = text.endsWith("\n");
2501
1698
  const body = hadTrailingNewline ? text.slice(0, -1) : text;
2502
1699
  const newlineAt = body.lastIndexOf("\n");
2503
1700
  const tail = newlineAt === -1 ? body : body.slice(newlineAt + 1);
2504
1701
  const match = TOOL_SUCCESS_LINE_RE.exec(stripAnsi(tail));
2505
- if (!match || `${match[1]}${match[3]}` !== plain) return null;
1702
+ if (!match || match[1] !== chunkMatch[1]) return null;
2506
1703
  const count = (match[2] ? Number(match[2]) : 1) + 1;
2507
1704
  const anchor = tail.lastIndexOf(" ");
2508
1705
  if (anchor < 0) return null;
2509
1706
  const head = tail.slice(0, anchor).replace(/\s×\d+$/, "");
2510
- const merged = `${head} \xD7${count}${tail.slice(anchor)}`;
1707
+ const merged = `${head} \xD7${count}${chunkMatch[3]}`;
2511
1708
  const prefix = newlineAt === -1 ? "" : body.slice(0, newlineAt + 1);
2512
1709
  return `${prefix}${merged}${hadTrailingNewline ? "\n" : ""}`;
2513
1710
  }
@@ -2524,7 +1721,7 @@ function applyOutputChunkToCurrentTurn(history, chunk, kind = "assistant") {
2524
1721
  const treeContent = rewrittenTree;
2525
1722
  history.currentContent = treeContent;
2526
1723
  const lastBlock = history.currentBlocks.at(-1);
2527
- const treeBlock = `\u2022 ${readTreePayload(chunk).summary}
1724
+ const treeBlock = `\u25B8 ${readTreePayload(chunk).summary}
2528
1725
  `;
2529
1726
  if (lastBlock?.kind === "tool") lastBlock.content = applyTreeRewrite(lastBlock.content, chunk) ?? `${lastBlock.content}${treeBlock}`;
2530
1727
  else history.currentBlocks.push({ kind: "tool", content: treeBlock });
@@ -2567,7 +1764,11 @@ function styleAssistantTurn(content, colorEnabled) {
2567
1764
  }
2568
1765
  return line.startsWith("[nolo]") && colorEnabled ? themeText(line, "chrome", true) : line;
2569
1766
  });
2570
- return styledLines.join("\n");
1767
+ return styledLines.flatMap((line, index) => {
1768
+ const current = stripAnsi(line);
1769
+ const previous = stripAnsi(styledLines[index - 1] ?? "");
1770
+ return /^▸ /.test(current) && /^▸ /.test(previous) ? ["", line] : [line];
1771
+ }).join("\n");
2571
1772
  }
2572
1773
  function fillUserBubbleRow(row, surfaceSeq, contentWidth) {
2573
1774
  const visible = visibleWidth(row);
@@ -2578,15 +1779,43 @@ function fillUserBubbleRow(row, surfaceSeq, contentWidth) {
2578
1779
  }
2579
1780
  return renderSurfaceLine({ text: row, surface: surfaceSeq, padTo: contentWidth });
2580
1781
  }
1782
+ function gutterForRole(role, colorEnabled) {
1783
+ if (role === "user") {
1784
+ const accentSeq = colorEnabled ? themeColorSequence("accent") : "";
1785
+ const prefix = colorEnabled ? `${accentSeq}\x1B[1m\u2503 \x1B[0m` : "\u2503 ";
1786
+ const surfaceSeq = colorEnabled ? userSurfaceBackgroundSequence() : "";
1787
+ return { prefix, prefixWidth: 3, surfaceSeq };
1788
+ }
1789
+ if (role === "local") {
1790
+ const dimSeq = colorEnabled ? "\x1B[2m" : "";
1791
+ const resetSeq = colorEnabled ? "\x1B[0m" : "";
1792
+ return { prefix: `${dimSeq} ${resetSeq}`, prefixWidth: 2, surfaceSeq: "" };
1793
+ }
1794
+ return { prefix: "", prefixWidth: 0, surfaceSeq: "" };
1795
+ }
2581
1796
  function layoutTurnRows(role, content, contentWidth, colorEnabled, command, options) {
2582
1797
  const textRows = layoutTextRows(role, content, contentWidth, colorEnabled, command);
2583
1798
  const images = options?.images;
2584
1799
  if (!images || images.length === 0) return textRows;
2585
1800
  const bodyEnd = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n").length;
2586
- return [
2587
- ...textRows,
2588
- ...layoutImageRows(images, contentWidth, options?.graphicsEnabled === true, bodyEnd)
2589
- ];
1801
+ const gutter = gutterForRole(role, colorEnabled);
1802
+ const imageContentWidth = Math.max(1, contentWidth - gutter.prefixWidth);
1803
+ const rawImageRows = layoutImageRows(images, imageContentWidth, options?.graphicsEnabled === true, bodyEnd);
1804
+ const imageRows = rawImageRows.map((r) => {
1805
+ let rendered = r.rendered;
1806
+ if (gutter.prefixWidth > 0) {
1807
+ const styled = `${gutter.prefix}${rendered}`;
1808
+ rendered = gutter.surfaceSeq ? fillUserBubbleRow(styled, gutter.surfaceSeq, contentWidth) : styled;
1809
+ }
1810
+ return {
1811
+ rendered,
1812
+ sourceStart: r.sourceStart,
1813
+ sourceEnd: r.sourceEnd,
1814
+ prefixWidth: gutter.prefixWidth,
1815
+ image: r.image
1816
+ };
1817
+ });
1818
+ return [...textRows, ...imageRows];
2590
1819
  }
2591
1820
  function layoutTextRows(role, content, contentWidth, colorEnabled, command) {
2592
1821
  content = content.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
@@ -2705,10 +1934,11 @@ function layoutTextRows(role, content, contentWidth, colorEnabled, command) {
2705
1934
  const prefixCharCount = anchorPrefix.length;
2706
1935
  const rawLineLen = rawLine.length;
2707
1936
  const sourceMapping = buildSourceMapping(rawLine, styledLine, prefixCharCount);
1937
+ const listMarker = stripAnsi(styledLine).replace(/^◈ /, "").match(/^(\s*(?:\d+[.)]|[•*+-])\s+)/)?.[1];
2708
1938
  const lineRows = wrapTranscriptLineWithLayout(
2709
1939
  styledLine,
2710
1940
  contentWidth,
2711
- "",
1941
+ listMarker ? " ".repeat(prefixWidth + displayWidth(listMarker)) : "",
2712
1942
  rawOffset,
2713
1943
  prefixWidth,
2714
1944
  prefixCharCount,
@@ -2993,7 +2223,10 @@ function renderTailTurnBlock(role, content, contentWidth, colorEnabled) {
2993
2223
  });
2994
2224
  const lines = [];
2995
2225
  for (const logicalLine of styledLines) {
2996
- lines.push(...wrapTranscriptLine(logicalLine, contentWidth));
2226
+ const plain = stripAnsi(logicalLine);
2227
+ const anchor = plain.startsWith("\u25C8 ") ? 2 : 0;
2228
+ const marker = plain.replace(/^◈ /, "").match(/^(\s*(?:\d+[.)]|[•*+-])\s+)/)?.[1] ?? "";
2229
+ lines.push(...wrapTranscriptLine(logicalLine, contentWidth, marker ? " ".repeat(anchor + displayWidth(marker)) : ""));
2997
2230
  }
2998
2231
  return lines;
2999
2232
  }
@@ -3263,7 +2496,8 @@ function buildLayoutRowWindow(history, contentWidth, fromRow, toRowExclusive) {
3263
2496
  var renderCacheMissCount = 0;
3264
2497
  function collectVisibleImageRows(layoutRows, turnIndex, turnStart, winStart, winEnd, out) {
3265
2498
  for (let k = 0; k < layoutRows.length; k++) {
3266
- const info = layoutRows[k].image;
2499
+ const row = layoutRows[k];
2500
+ const info = row.image;
3267
2501
  if (!info || !info.graphics || info.index !== 0) continue;
3268
2502
  const start = turnStart + k;
3269
2503
  if (start < winStart || start + info.rows > winEnd) continue;
@@ -3273,7 +2507,7 @@ function collectVisibleImageRows(layoutRows, turnIndex, turnStart, winStart, win
3273
2507
  occurrence: `${turnIndex}:${info.key}:${info.index}`,
3274
2508
  key: info.key,
3275
2509
  row: start - winStart,
3276
- column: 0,
2510
+ column: row.prefixWidth,
3277
2511
  columns: info.columns,
3278
2512
  rows: info.rows
3279
2513
  });
@@ -3877,9 +3111,9 @@ function createRawKeyReader(input) {
3877
3111
  };
3878
3112
  const resolveWaiter = (value) => {
3879
3113
  if (!waiter) return;
3880
- const resolve6 = waiter;
3114
+ const resolve5 = waiter;
3881
3115
  waiter = null;
3882
- resolve6(value);
3116
+ resolve5(value);
3883
3117
  };
3884
3118
  const tryDeliver = () => {
3885
3119
  if (!waiter) return;
@@ -3936,12 +3170,12 @@ function createRawKeyReader(input) {
3936
3170
  input.on("close", onClose);
3937
3171
  input.on("end", onClose);
3938
3172
  input.resume?.();
3939
- const reader = () => new Promise((resolve6) => {
3173
+ const reader = () => new Promise((resolve5) => {
3940
3174
  if (closed) {
3941
- resolve6(drainClosed());
3175
+ resolve5(drainClosed());
3942
3176
  return;
3943
3177
  }
3944
- waiter = resolve6;
3178
+ waiter = resolve5;
3945
3179
  tryDeliver();
3946
3180
  });
3947
3181
  reader.dispose = () => {
@@ -3971,8 +3205,8 @@ async function runSelectDialog(args) {
3971
3205
  const input = args.input ?? process.stdin;
3972
3206
  const readKey = args.readKey ?? createRawKeyReader(input);
3973
3207
  let cancelRead;
3974
- const cancelled = new Promise((resolve6) => {
3975
- cancelRead = () => resolve6(STREAM_CLOSED);
3208
+ const cancelled = new Promise((resolve5) => {
3209
+ cancelRead = () => resolve5(STREAM_CLOSED);
3976
3210
  });
3977
3211
  args.signal?.addEventListener("abort", cancelRead, { once: true });
3978
3212
  if (args.signal?.aborted) cancelRead();
@@ -4378,12 +3612,12 @@ function createInlineHostApprovalPrompt(args) {
4378
3612
  finishing.finish(decision);
4379
3613
  }
4380
3614
  };
4381
- const presentOne = (card) => new Promise((resolve6) => {
3615
+ const presentOne = (card) => new Promise((resolve5) => {
4382
3616
  if (disposed) {
4383
- resolve6("deny");
3617
+ resolve5("deny");
4384
3618
  return;
4385
3619
  }
4386
- active = { card, finish: resolve6 };
3620
+ active = { card, finish: resolve5 };
4387
3621
  try {
4388
3622
  const lines = renderHostApprovalCardLines(card, { now: now(), columns: columns() });
4389
3623
  args.write(`${lines.join("\n")}
@@ -5771,7 +5005,8 @@ function createActivityIndicator(deps) {
5771
5005
  const getAgentRuns = () => runDock.getRuns();
5772
5006
  const getActivityLines = (colorEnabled = resolveCliColorEnabled(), layout) => {
5773
5007
  const lines = [];
5774
- const baseView = getView();
5008
+ const rawView = getView();
5009
+ const baseView = rawView ? { ...rawView, label: rawView.label.replace(/^.+? -> (working locally)(?=\s|$)/, "$1") } : null;
5775
5010
  if (baseView && stopping) {
5776
5011
  lines.push(
5777
5012
  colorEnabled ? themeText(baseView.frame, "accent") + " " + themeText(baseView.label, "muted") : `${baseView.frame} ${baseView.label}`
@@ -6716,10 +5951,10 @@ function createRunCompletionWatcher(deps) {
6716
5951
  }
6717
5952
 
6718
5953
  // packages/cli/tui/pasteImage.ts
6719
- import { readFileSync as readFileSync4, statSync as statSync2 } from "node:fs";
5954
+ import { readFileSync, statSync as statSync2 } from "node:fs";
6720
5955
  import { readFile, stat } from "node:fs/promises";
6721
- import { homedir as homedir3 } from "node:os";
6722
- import { isAbsolute, resolve as resolve4 } from "node:path";
5956
+ import { homedir as homedir2 } from "node:os";
5957
+ import { isAbsolute, resolve as resolve2 } from "node:path";
6723
5958
 
6724
5959
  // packages/cli/tui/compressImage.ts
6725
5960
  var MAX_IMAGE_DIMENSION = 1568;
@@ -6918,9 +6153,9 @@ async function compressImage(input, mime, options = {}) {
6918
6153
  }
6919
6154
 
6920
6155
  // packages/cli/tui/sessionInput.ts
6921
- import { readdirSync as readdirSync3, statSync } from "node:fs";
6922
- import { homedir as homedir2 } from "node:os";
6923
- import { resolve as resolve3 } from "node:path";
6156
+ import { readdirSync, statSync } from "node:fs";
6157
+ import { homedir } from "node:os";
6158
+ import { resolve } from "node:path";
6924
6159
  var PASTE_TOKEN_PREFIX = "\0PASTE\0";
6925
6160
  function applyTuiInputKey(buffer, sequence, key = {}, cursorPos, options) {
6926
6161
  const seq = sequence ?? "";
@@ -7296,15 +6531,15 @@ function completeCdPathCandidates(prefix, cwd) {
7296
6531
  const baseName = lastSlash >= 0 ? prefix.slice(lastSlash + 1) : prefix;
7297
6532
  let dirPath;
7298
6533
  if (head === "~" || head === "~/" || head === "~\\") {
7299
- dirPath = homedir2();
6534
+ dirPath = homedir();
7300
6535
  } else if (head.startsWith("~/") || head.startsWith("~\\")) {
7301
- dirPath = resolve3(homedir2(), head.slice(2));
6536
+ dirPath = resolve(homedir(), head.slice(2));
7302
6537
  } else {
7303
- dirPath = head.startsWith("/") ? head : resolve3(cwd, head);
6538
+ dirPath = head.startsWith("/") ? head : resolve(cwd, head);
7304
6539
  }
7305
6540
  let entries;
7306
6541
  try {
7307
- entries = readdirSync3(dirPath, { withFileTypes: true });
6542
+ entries = readdirSync(dirPath, { withFileTypes: true });
7308
6543
  } catch {
7309
6544
  return [];
7310
6545
  }
@@ -7313,7 +6548,7 @@ function completeCdPathCandidates(prefix, cwd) {
7313
6548
  if (e.isDirectory()) return true;
7314
6549
  if (!e.isSymbolicLink()) return false;
7315
6550
  try {
7316
- return statSync(resolve3(dirPath, e.name)).isDirectory();
6551
+ return statSync(resolve(dirPath, e.name)).isDirectory();
7317
6552
  } catch {
7318
6553
  return false;
7319
6554
  }
@@ -7399,7 +6634,7 @@ function basenameOf(path3) {
7399
6634
  function isWslEnvironment() {
7400
6635
  if (process.env.WSL_DISTRO_NAME) return true;
7401
6636
  try {
7402
- const version = readFileSync4("/proc/version", "utf8");
6637
+ const version = readFileSync("/proc/version", "utf8");
7403
6638
  return /microsoft/i.test(version);
7404
6639
  } catch {
7405
6640
  return false;
@@ -7428,12 +6663,12 @@ function fileUriToPath(rawPath) {
7428
6663
  function resolveImageSource(rawPath, cwd) {
7429
6664
  let candidate = rawPath.trim();
7430
6665
  if (!candidate) return candidate;
7431
- if (candidate === "~") return homedir3();
6666
+ if (candidate === "~") return homedir2();
7432
6667
  if (candidate.startsWith("~/") || candidate.startsWith("~\\")) {
7433
- return homedir3() + candidate.slice(1);
6668
+ return homedir2() + candidate.slice(1);
7434
6669
  }
7435
6670
  if (isAbsolute(candidate)) return candidate;
7436
- return resolve4(cwd, candidate);
6671
+ return resolve2(cwd, candidate);
7437
6672
  }
7438
6673
  function isImagePath(path3) {
7439
6674
  return IMAGE_EXTENSION_SET.has(extnameOf(path3));
@@ -7640,44 +6875,14 @@ function buildAttachedImage(params) {
7640
6875
  ...typeof params.originalSizeBytes === "number" && params.originalSizeBytes > sizeBytes ? { originalSizeBytes: params.originalSizeBytes } : {}
7641
6876
  };
7642
6877
  }
7643
- function describeImageSize(img, options = {}) {
7644
- const isCompressed = typeof img.originalSizeBytes === "number" && img.originalSizeBytes > img.sizeBytes;
7645
- const core = isCompressed ? `${formatBytes(img.sizeBytes)} (\u5DF2\u538B\u7F29 ${formatBytes(img.originalSizeBytes)} \u2192 ${formatBytes(img.sizeBytes)})` : formatBytes(img.sizeBytes);
7646
- return options.prefix ? `Size: ${core}` : core;
7647
- }
7648
6878
  function formatBytes(bytes) {
7649
6879
  if (bytes < 1024) return `${bytes} B`;
7650
6880
  if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
7651
6881
  return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
7652
6882
  }
7653
- function summarizeAttachment(img) {
7654
- const colorEnabled = resolveCliColorEnabled();
7655
- const sizeText = describeImageSize(img, { prefix: true });
7656
- const titleRaw = "\u{1F4F7} [Attached Image]";
7657
- const nameRaw = `Name: ${img.filename}`;
7658
- const boxWidth = Math.max(40, titleRaw.length + 4, nameRaw.length + 4, sizeText.length + 4);
7659
- const g = boxGlyphs(resolveBoxCharset());
7660
- const border = g.tl + g.h.repeat(boxWidth - 2) + g.tr;
7661
- const bottom = g.bl + g.h.repeat(boxWidth - 2) + g.br;
7662
- const padLine = (content) => {
7663
- const padded = content.padEnd(boxWidth - 4, " ");
7664
- return `${g.v} ${padded} ${g.v}`;
7665
- };
7666
- const title = padLine(titleRaw);
7667
- const name = padLine(nameRaw);
7668
- const size = padLine(sizeText);
7669
- const text = [
7670
- border,
7671
- title,
7672
- name,
7673
- size,
7674
- bottom
7675
- ].join("\n");
7676
- return themeText(text, "chrome", colorEnabled);
7677
- }
7678
6883
  function formatComposerAttachmentLine(images) {
7679
6884
  if (images.length === 0) return null;
7680
- const head = images.slice(0, 2).map((img) => `\u{1F4CE} ${img.filename} (${formatBytes(img.sizeBytes)})`);
6885
+ const head = images.slice(0, 2).map((img, index) => `\u{1F4CE} ${index + 1} \xB7 ${sanitizeImageLabel(img.filename)} (${formatBytes(img.sizeBytes)})`);
7681
6886
  const extra = images.length - head.length;
7682
6887
  return extra > 0 ? `${head.join(", ")} +${extra}` : head.join(", ");
7683
6888
  }
@@ -7710,12 +6915,12 @@ function mergeAttachedImages(existing, incoming) {
7710
6915
  return out;
7711
6916
  }
7712
6917
  async function readImagePaths(paths, options = {}) {
7713
- const resolve6 = options.resolve ?? ((p) => p);
6918
+ const resolve5 = options.resolve ?? ((p) => p);
7714
6919
  const reportedFailures = /* @__PURE__ */ new Set();
7715
6920
  const images = [];
7716
6921
  const failures = [];
7717
6922
  for (const raw of paths) {
7718
- const absolute = resolve6(raw);
6923
+ const absolute = resolve5(raw);
7719
6924
  try {
7720
6925
  const img = await readImageAsDataUrl(absolute, {
7721
6926
  ...options.maxBytes !== void 0 ? { maxBytes: options.maxBytes } : {}
@@ -7736,20 +6941,15 @@ async function readImagePaths(paths, options = {}) {
7736
6941
  async function resolveAttachmentImageUrls({
7737
6942
  actionImagePaths,
7738
6943
  attachedImages,
7739
- onFailure
6944
+ onFailure,
6945
+ onResolved
7740
6946
  }) {
7741
- const pathsToRead = [
7742
- ...actionImagePaths ?? [],
7743
- ...attachedImages.map((img) => img.sourcePath)
7744
- ];
7745
- let imageUrls = [];
7746
- if (pathsToRead.length > 0) {
7747
- const readResult = await readImagePaths(pathsToRead, {
7748
- onFailure
7749
- });
7750
- imageUrls = readResult.images.map((img) => img.dataUrl);
7751
- }
7752
- return { imageUrls };
6947
+ const stagedPaths = new Set(attachedImages.map((image) => image.sourcePath));
6948
+ const paths = [...new Set(actionImagePaths ?? [])].filter((path3) => !stagedPaths.has(path3));
6949
+ const readResult = await readImagePaths(paths, { onFailure });
6950
+ const images = [...readResult.images, ...attachedImages];
6951
+ onResolved?.(images);
6952
+ return { imageUrls: images.map((image) => image.dataUrl) };
7753
6953
  }
7754
6954
  function detectSubmittedImagePaths(text, cwd, opts = {}) {
7755
6955
  const trimmed = text.trim();
@@ -7766,9 +6966,9 @@ function detectSubmittedImagePaths(text, cwd, opts = {}) {
7766
6966
  }
7767
6967
 
7768
6968
  // packages/cli/tui/mediaAttachment.ts
7769
- import { accessSync, constants, mkdirSync as mkdirSync3, statSync as statSync4 } from "node:fs";
6969
+ import { accessSync, constants, mkdirSync, statSync as statSync4 } from "node:fs";
7770
6970
  import { readFile as readFile2, writeFile } from "node:fs/promises";
7771
- import { homedir as homedir4 } from "node:os";
6971
+ import { homedir as homedir3 } from "node:os";
7772
6972
  import path2 from "node:path";
7773
6973
 
7774
6974
  // packages/ai/transcription/mediaPreprocess.ts
@@ -7826,7 +7026,7 @@ async function probeMedia(filePath, opts = {}) {
7826
7026
  const runner = opts.execFileImpl ?? execFile;
7827
7027
  const ffmpegPath = opts.ffmpegPath ?? DEFAULT_FFMPEG_PATH;
7828
7028
  const ffprobePath = ffmpegPath.replace(/ffmpeg$/, "ffprobe");
7829
- return new Promise((resolve6, reject) => {
7029
+ return new Promise((resolve5, reject) => {
7830
7030
  runner(
7831
7031
  ffprobePath,
7832
7032
  [
@@ -7857,7 +7057,7 @@ async function probeMedia(filePath, opts = {}) {
7857
7057
  const hasAudio = /^codec_type=audio$/m.test(text);
7858
7058
  const rateMatch = text.match(/sample_rate=(\d+)/);
7859
7059
  const sampleRate = rateMatch ? parseInt(rateMatch[1], 10) : null;
7860
- resolve6({ durationSec, hasAudio, sampleRate });
7060
+ resolve5({ durationSec, hasAudio, sampleRate });
7861
7061
  }
7862
7062
  );
7863
7063
  });
@@ -7944,7 +7144,7 @@ async function preprocessMedia(inputPath, opts = {}) {
7944
7144
  args.push("-af", filter);
7945
7145
  }
7946
7146
  args.push("-c:a", "libopus", "-b:a", OPUS_BITRATE, outPath);
7947
- await new Promise((resolve6, reject) => {
7147
+ await new Promise((resolve5, reject) => {
7948
7148
  runner(ffmpegPath, args, { encoding: "utf8", maxBuffer: 8 * 1024 * 1024 }, (error, _stdout, stderr) => {
7949
7149
  if (error) {
7950
7150
  reject(
@@ -7954,7 +7154,7 @@ async function preprocessMedia(inputPath, opts = {}) {
7954
7154
  );
7955
7155
  return;
7956
7156
  }
7957
- resolve6();
7157
+ resolve5();
7958
7158
  });
7959
7159
  }).catch((err) => {
7960
7160
  if (ownOutDir) {
@@ -8122,7 +7322,7 @@ function parseTranscribeArgs(argText) {
8122
7322
  return { ok: true, args };
8123
7323
  }
8124
7324
  function transcriptsDir(override) {
8125
- return override ?? path2.join(homedir4(), ".nolo", "transcripts");
7325
+ return override ?? path2.join(homedir3(), ".nolo", "transcripts");
8126
7326
  }
8127
7327
  function pad2(n) {
8128
7328
  return String(n).padStart(2, "0");
@@ -8137,7 +7337,7 @@ function sanitizeBasename(p) {
8137
7337
  }
8138
7338
  async function saveTranscripts(sourcePath, text, srt, dirOverride) {
8139
7339
  const dir = transcriptsDir(dirOverride);
8140
- mkdirSync3(dir, { recursive: true });
7340
+ mkdirSync(dir, { recursive: true });
8141
7341
  const stamp = transcriptStamp();
8142
7342
  const base = sanitizeBasename(sourcePath);
8143
7343
  const txtPath = path2.join(dir, `${base}-${stamp}.txt`);
@@ -8300,11 +7500,11 @@ ${inner}${truncatedNote}
8300
7500
  }
8301
7501
 
8302
7502
  // packages/cli/tui/clipboardImage.ts
8303
- import { createHash as createHash4 } from "node:crypto";
8304
- import { mkdirSync as mkdirSync4 } from "node:fs";
7503
+ import { createHash } from "node:crypto";
7504
+ import { mkdirSync as mkdirSync2 } from "node:fs";
8305
7505
  import { readdir, stat as stat2, unlink, writeFile as writeFile2 } from "node:fs/promises";
8306
7506
  import { tmpdir as tmpdir2 } from "node:os";
8307
- import { join as join4 } from "node:path";
7507
+ import { join } from "node:path";
8308
7508
  var ClipboardImageError = class extends Error {
8309
7509
  code;
8310
7510
  constructor(code, message) {
@@ -8316,7 +7516,7 @@ var ClipboardImageError = class extends Error {
8316
7516
  var DEFAULT_CLIPBOARD_TIMEOUT_MS = 3e4;
8317
7517
  var CLIPBOARD_TEMP_DIR_NAME = "nolo-clipboard";
8318
7518
  function getDefaultClipboardTempDir() {
8319
- return join4(tmpdir2(), CLIPBOARD_TEMP_DIR_NAME);
7519
+ return join(tmpdir2(), CLIPBOARD_TEMP_DIR_NAME);
8320
7520
  }
8321
7521
  var CLIPBOARD_SWEEP_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
8322
7522
  var CLIPBOARD_SWEEP_FILE_RE = /^clip-[0-9a-f]{8,}\.(png|jpg|jpeg|gif|webp)$/;
@@ -8329,7 +7529,7 @@ async function sweepStaleClipboardFiles(tempDir, opts = {}) {
8329
7529
  for (const name of entries) {
8330
7530
  if (!CLIPBOARD_SWEEP_FILE_RE.test(name)) continue;
8331
7531
  try {
8332
- const fullPath = join4(tempDir, name);
7532
+ const fullPath = join(tempDir, name);
8333
7533
  const stats = await stat2(fullPath);
8334
7534
  if (stats.mtimeMs >= now - maxAgeMs) continue;
8335
7535
  await unlink(fullPath);
@@ -8532,11 +7732,11 @@ async function readClipboardImage(deps = {}) {
8532
7732
  `\u526A\u8D34\u677F\u56FE\u50CF\u8FC7\u5927: ${formatBytes(finalSizeBytes)} (\u4E0A\u9650 ${formatBytes(maxBytes)})`
8533
7733
  );
8534
7734
  }
8535
- const hash = createHash4("sha256").update(finalBuf).digest("hex").slice(0, 12);
7735
+ const hash = createHash("sha256").update(finalBuf).digest("hex").slice(0, 12);
8536
7736
  const ext = mimeToExtension(finalMime);
8537
7737
  const filename = `clip-${hash}.${ext}`;
8538
- mkdirSync4(tempDir, { recursive: true });
8539
- const filePath = join4(tempDir, filename);
7738
+ mkdirSync2(tempDir, { recursive: true });
7739
+ const filePath = join(tempDir, filename);
8540
7740
  await writeFile2(filePath, finalBuf);
8541
7741
  return buildAttachedImage({
8542
7742
  buffer: finalBuf,
@@ -8629,7 +7829,7 @@ function parseStatusOutput(branch, status) {
8629
7829
  return { branch, modified, untracked };
8630
7830
  }
8631
7831
  function execFileUtf8(file, args, cwd) {
8632
- return new Promise((resolve6, reject) => {
7832
+ return new Promise((resolve5, reject) => {
8633
7833
  execFile2(
8634
7834
  file,
8635
7835
  args,
@@ -8639,7 +7839,7 @@ function execFileUtf8(file, args, cwd) {
8639
7839
  reject(err);
8640
7840
  return;
8641
7841
  }
8642
- resolve6(typeof stdout === "string" ? stdout : String(stdout ?? ""));
7842
+ resolve5(typeof stdout === "string" ? stdout : String(stdout ?? ""));
8643
7843
  }
8644
7844
  );
8645
7845
  });
@@ -8721,8 +7921,8 @@ function renderConversationLinks(extracted, t3) {
8721
7921
 
8722
7922
  // packages/cli/tui/sessionDispatch.ts
8723
7923
  import { statSync as statSync5 } from "node:fs";
8724
- import { homedir as homedir5 } from "node:os";
8725
- import { resolve as resolve5 } from "node:path";
7924
+ import { homedir as homedir4 } from "node:os";
7925
+ import { resolve as resolve3 } from "node:path";
8726
7926
 
8727
7927
  // packages/cli/tui/agentPicker.ts
8728
7928
  function toAgentPickerItems(entries) {
@@ -9481,9 +8681,7 @@ function handleTuiInput(input, state, historyTurns, deps) {
9481
8681
  exclude: hints.map((hint) => hint.resolvedPath)
9482
8682
  });
9483
8683
  const previewLines = [
9484
- ...hints.map(
9485
- (hint) => hint.unreadable ? `image path unreadable: ${hint.resolvedPath}` : `found image: ${hint.resolvedPath}`
9486
- ),
8684
+ ...unreadableHints.map((hint) => `image path unreadable: ${hint.resolvedPath}`),
9487
8685
  ...mediaDetected.hints.map(
9488
8686
  (hint) => hint.unreadable ? `media path unreadable: ${hint.resolvedPath}` : t("mediaFoundHint", hint.resolvedPath)
9489
8687
  ),
@@ -9572,8 +8770,8 @@ ${t("cdUsage")}`
9572
8770
  };
9573
8771
  }
9574
8772
  const unquoted = argText.startsWith('"') && argText.endsWith('"') && argText.length >= 2 || argText.startsWith("'") && argText.endsWith("'") && argText.length >= 2 ? argText.slice(1, -1) : argText;
9575
- const expanded = unquoted === "~" ? homedir5() : unquoted.startsWith("~/") || unquoted.startsWith("~\\") ? resolve5(homedir5(), unquoted.slice(2)) : unquoted;
9576
- const target = resolve5(state.cwd, expanded);
8773
+ const expanded = unquoted === "~" ? homedir4() : unquoted.startsWith("~/") || unquoted.startsWith("~\\") ? resolve3(homedir4(), unquoted.slice(2)) : unquoted;
8774
+ const target = resolve3(state.cwd, expanded);
9577
8775
  try {
9578
8776
  if (!statSync5(target).isDirectory()) {
9579
8777
  return { nextState: state, output: t("cdNotDir", target) };
@@ -10112,6 +9310,87 @@ ${t("transcribeUsage")}`
10112
9310
  }
10113
9311
  }
10114
9312
 
9313
+ // packages/cli/tui/learnPrompt.ts
9314
+ var TUI_LEARN_DEVELOPER_REVIEW_PROMPT = `\u5BA1\u67E5\u5F53\u524D\u5BF9\u8BDD\u4E2D\u5DF2\u53EF\u89C1\u7684\u5BF9\u8BDD\u4E0E\u5DE5\u4F5C\uFF0C\u53EA\u5BFB\u627E\u5BF9\u7CFB\u7EDF\u53EF\u590D\u7528\u7684\u6539\u8FDB\u3002\u8986\u76D6\u6B64\u5904\u5B9E\u9645\u53EF\u89C1\u7684\u5185\u5BB9\uFF0C\u5305\u62EC\u672A\u5B8C\u6210\u3001\u5931\u8D25\u6216\u88AB\u4E2D\u65AD\u7684\u5DE5\u4F5C\uFF1B\u4E0D\u8981\u81C6\u6D4B\u4F60\u770B\u4E0D\u5230\u7684\u5386\u53F2\u3002
9315
+
9316
+ \u805A\u7126\u4E24\u4E2A\u5C42\u9762\uFF1A
9317
+
9318
+ 1. \u5DE5\u5177
9319
+ - \u662F\u5426\u6709\u5DE5\u5177\u4E0D\u5FC5\u8981\u3001\u88AB\u53CD\u590D\u8C03\u7528\u3001\u96BE\u4EE5\u4F7F\u7528\u6216\u7F3A\u5931\uFF1F
9320
+ - \u662F\u5426\u6709\u5DE5\u5177\u63CF\u8FF0\u3001schema \u6216\u7ED3\u679C\u7ED3\u6784\u9020\u6210\u8FC7\u56F0\u60D1\u6216\u6D6A\u8D39\uFF1F
9321
+ - \u662F\u5426\u5B58\u5728\u4E00\u9879\u5177\u4F53\u7684\u5DE5\u5177\u6539\u52A8\uFF0C\u80FD\u6539\u8FDB\u591A\u4E2A\u672A\u6765\u4EFB\u52A1\uFF1F
9322
+
9323
+ 2. \u63D0\u793A\u8BCD / \u6307\u4EE4
9324
+ - \u662F\u5426\u6709\u7CFB\u7EDF\u3001\u5F00\u53D1\u8005\u3001\u9879\u76EE\u6216\u5DE5\u5177\u6307\u4EE4\u9020\u6210\u8FC7\u56F0\u60D1\u3001\u51B2\u7A81\u3001\u91CD\u590D\u6216\u4E0D\u5FC5\u8981\u7684\u5DE5\u4F5C\uFF1F
9325
+ - \u662F\u5426\u7F3A\u5C11\u4E00\u6761\u91CD\u8981\u7684\u53EF\u590D\u7528\u6307\u4EE4\uFF1F
9326
+ - \u662F\u5426\u5B58\u5728\u4E00\u9879\u5177\u4F53\u7684\u63D0\u793A\u8BCD/\u6307\u4EE4\u6539\u52A8\uFF0C\u80FD\u6539\u8FDB\u591A\u4E2A\u672A\u6765\u4EFB\u52A1\uFF1F
9327
+
9328
+ \u89C4\u5219\uFF1A
9329
+ - \u4E0D\u8981\u4E3A\u4E86\u4EA7\u51FA\u53CD\u9988\u800C\u7F16\u9020\u53D1\u73B0\u3002"\u65E0" \u662F\u4E00\u4E2A\u597D\u7ED3\u679C\u3002
9330
+ - \u6BCF\u6761\u53D1\u73B0\u5FC5\u987B\u5F15\u7528\u5177\u4F53\u53EF\u89C1\u7684\u8BC1\u636E\uFF1A\u7528\u6237\u7684\u7EA0\u6B63\u3001\u5931\u8D25\u7684\u8C03\u7528\u3001\u91CD\u590D\u7684\u5DE5\u4F5C\u3002\u6CA1\u6709\u8BC1\u636E\u5C31\u6CA1\u6709\u53D1\u73B0\u3002\u628A\u89C2\u5BDF\u5230\u7684\u4E8B\u5B9E\u4E0E\u5047\u8BBE\u5206\u5F00\uFF0C\u4E0D\u8981\u628A\u76F8\u5173\u6027\u5F53\u6210\u6839\u56E0\u3002
9331
+ - \u4F18\u5148\u5220\u9664\u3001\u5408\u5E76\u6216\u6F84\u6E05\u65E2\u6709\u6307\u4EE4\uFF0C\u800C\u4E0D\u662F\u65B0\u589E\u4E00\u6761\uFF1B\u4E0D\u8981\u628A\u4E00\u6B21\u6027\u9519\u8BEF\u6CDB\u5316\u6210\u5168\u5C40\u89C4\u5219\u3002
9332
+ - \u5BF9\u4E8E\u63D0\u793A\u8BCD\u7C7B\u53D1\u73B0\uFF0C\u7ED9\u51FA\u53EF\u89C1\u7684\u539F\u6587\u63AA\u8F9E\u6216\u53EF\u9A8C\u8BC1\u7684\u4F4D\u7F6E\uFF0C\u52A0\u4E0A\u6700\u5C0F\u7684\u66FF\u6362\u6587\u672C\u3002\u5982\u679C\u5B9A\u4F4D\u4E0D\u5230\uFF0C\u5C31\u8BF4\u660E\u4F4D\u7F6E\u672A\u77E5\uFF0C\u4E0D\u8981\u731C\u6D4B\u6765\u6E90\u3002
9333
+ - \u4F18\u5148\u8DE8\u4EFB\u52A1\u53EF\u590D\u7528\u3001\u6295\u5165\u4EA7\u51FA\u6BD4\u9AD8\u3001\u8D1F\u9762\u526F\u4F5C\u7528\u5C0F\u7684\u6539\u8FDB\uFF0C\u76EE\u6807\u662F\u66F4\u901A\u7528\u3001\u66F4\u5FEB\u3001\u66F4\u7701\u94B1\u3001\u66F4\u51C6\u786E\uFF1B\u53EA\u6362\u63AA\u8F9E\u3001\u6CA1\u6709\u5B9E\u8D28\u884C\u4E3A\u6536\u76CA\u7684\u6539\u5199\u4E0D\u7B97\u6539\u8FDB\u3002
9334
+ - \u4F18\u5148\u6709\u4EE3\u7801\u4FDD\u969C\u3001\u7ED3\u6784\u5316\u5951\u7EA6\u6216\u7ED3\u6784\u5316\u7ED3\u679C\uFF0C\u6216\u6709\u660E\u786E\u89E6\u53D1\u6761\u4EF6\u3001\u52A8\u4F5C\u4E0E\u505C\u6B62\u6761\u4EF6\u7684\u6539\u52A8\u3002
9335
+ - \u6BCF\u6761\u53D1\u73B0\u6309\uFF1A\u8BC1\u636E\uFF1B\u5EFA\u8BAE\u6539\u52A8\uFF1B\u6536\u76CA\u673A\u5236\uFF1B\u6210\u672C\u6216\u526F\u4F5C\u7528\uFF1B\u672A\u77E5\u70B9\u3002\u8BC1\u636E\u4E0D\u8DB3\u6216\u6536\u76CA\u4E0E\u98CE\u9669\u4E0D\u660E\u7684\uFF0C\u4E0D\u8981\u65AD\u8A00\u6536\u76CA\uFF0C\u4E5F\u4E0D\u8981\u58F0\u79F0\u96F6\u526F\u4F5C\u7528\u3002
9336
+ - \u53EF\u80FD\u524A\u5F31\u6743\u9650\u3001\u5B89\u5168\u3001\u8D44\u6E90\u4FDD\u62A4\u6216\u6B63\u786E\u6027\u7684\u6539\u52A8\uFF0C\u5217\u4E3A"\u5F85\u9A8C\u8BC1"\u6216"\u4E0D\u63A8\u8350"\uFF0C\u4E0D\u4F5C\u4E3A\u76F4\u63A5\u5B9E\u65BD\u5EFA\u8BAE\uFF1B\u4E5F\u4E0D\u8981\u628A\u9A8C\u8BC1\u6362\u6210\u5C11\u8C03\u5DE5\u5177\u3002
9337
+ - \u672C\u6B21\u5BA1\u67E5\u4E0D\u5F97\u4FEE\u6539\u4EE3\u7801\u3001\u63D0\u793A\u8BCD\u3001\u5DE5\u5177\u3001\u8BB0\u5FC6\u6216\u914D\u7F6E\u3002\u4EC5\u5BA1\u67E5\u3002
9338
+ - \u4FDD\u6301\u7B80\u6D01\u3002
9339
+
9340
+ \u4E25\u683C\u6309\u4EE5\u4E0B\u5C0F\u8282\u8FD4\u56DE\uFF1A
9341
+ \u5DE5\u5177\u53D1\u73B0
9342
+ - \u65E0 \u6216\uFF1A\u53D1\u73B0\uFF1B\u8BC1\u636E\uFF1B\u5EFA\u8BAE\u6539\u52A8\uFF1B\u6536\u76CA\u673A\u5236\uFF1B\u6210\u672C/\u526F\u4F5C\u7528\uFF1B\u672A\u77E5\u70B9
9343
+
9344
+ \u63D0\u793A\u8BCD\u53D1\u73B0
9345
+ - \u65E0 \u6216\uFF1A\u53D1\u73B0\uFF1B\u8BC1\u636E\uFF1B\u5EFA\u8BAE\u6539\u52A8\uFF1B\u6536\u76CA\u673A\u5236\uFF1B\u6210\u672C/\u526F\u4F5C\u7528\uFF1B\u672A\u77E5\u70B9
9346
+
9347
+ \u503C\u5F97\u6539\u52A8\u5417\uFF1F
9348
+ - \u662F/\u5426
9349
+ - \u7F6E\u4FE1\u5EA6\uFF1A\u4F4E/\u4E2D/\u9AD8
9350
+ - \u4E00\u53E5\u8BDD\u7406\u7531
9351
+ - \u6536\u76CA\u4E0E\u98CE\u9669\uFF1A\u6700\u4E3B\u8981\u6536\u76CA\uFF08\u66F4\u5FEB/\u66F4\u7701/\u66F4\u51C6\uFF09\u4E0E\u6700\u5927\u98CE\u9669\u6216\u672A\u77E5`;
9352
+ var TUI_LEARN_PLAIN_REVIEW_PROMPT = `\u8BF7\u4EE5\u666E\u901A\u7528\u6237\u7684\u89D2\u5EA6\uFF0C\u56DE\u987E\u8FD9\u6B21\u5BF9\u8BDD\u91CC\u4F60\u5B9E\u9645\u770B\u5230\u7684\u5185\u5BB9\uFF0C\u627E\u51FA\u54EA\u4E9B\u5730\u65B9\u8BA9\u4EBA\u4E0D\u987A\u624B\u3001\u8D39\u65F6\u95F4\uFF0C\u6216\u8005\u6CA1\u6709\u62FF\u5230\u60F3\u8981\u7684\u7ED3\u679C\u3002
9353
+
9354
+ \u89C4\u5219\uFF1A
9355
+ - \u53EA\u4F9D\u636E\u8FD9\u6B21\u5BF9\u8BDD\u91CC\u770B\u5F97\u89C1\u7684\u5185\u5BB9\u6765\u8BF4\u8BDD\uFF1A\u54EA\u4E00\u6B65\u5361\u4F4F\u4E86\u3001\u91CD\u590D\u505A\u4E86\u4EC0\u4E48\u3001\u54EA\u6761\u4FE1\u606F\u6CA1\u770B\u61C2\u3002\u6CA1\u6709\u8BC1\u636E\u5C31\u4E0D\u8981\u63D0\uFF1B"\u6CA1\u53D1\u73B0\u9700\u8981\u6539\u7684\u5730\u65B9" \u4E5F\u662F\u597D\u7ED3\u679C\u3002
9356
+ - \u7528\u65E5\u5E38\u8BDD\u8BF4\u6E05\u695A\u95EE\u9898\u51FA\u5728\u4EC0\u4E48\u5730\u65B9\u3001\u9020\u6210\u4E86\u4EC0\u4E48\u5F71\u54CD\uFF0C\u518D\u7ED9\u51FA\u4E00\u4E2A\u5177\u4F53\u3001\u80FD\u91CD\u590D\u4F7F\u7528\u7684\u6539\u8FDB\u5EFA\u8BAE\u3002
9357
+ - \u4E0D\u8981\u4F7F\u7528\u884C\u8BDD\u3001\u6587\u4EF6\u540D\u6216\u5185\u90E8\u672F\u8BED\u6765\u89E3\u91CA\u95EE\u9898\uFF1B\u5982\u679C\u5FC5\u987B\u63D0\u5230\u67D0\u4E2A\u6280\u672F\u540D\u8BCD\uFF0C\u5C31\u987A\u5E26\u7528\u4E00\u53E5\u767D\u8BDD\u8BF4\u660E\u5B83\u662F\u4EC0\u4E48\u3002
9358
+ - \u8FD9\u6B21\u53EA\u662F\u590D\u76D8\uFF1A\u4E0D\u8981\u4FEE\u6539\u4EE3\u7801\u3001\u914D\u7F6E\u3001\u8BB0\u5FC6\u6216\u8BBE\u7F6E\uFF0C\u4E5F\u4E0D\u8981\u66FF\u4EBA\u505A\u51B3\u5B9A\u3002\u9700\u8981\u6539\u52A8\u7684\u5730\u65B9\u53EA\u5199\u6210\u5EFA\u8BAE\uFF0C\u7B49\u4EBA\u786E\u8BA4\u540E\u518D\u505A\u3002
9359
+ - \u4FDD\u6301\u7B80\u6D01\u3002
9360
+
9361
+ \u4E25\u683C\u6309\u4EE5\u4E0B\u7ED3\u6784\u8FD4\u56DE\uFF1A
9362
+ \u505A\u5F97\u987A\u7684\u5730\u65B9
9363
+ - \u4E00\u53E5\u8BDD\u5373\u53EF\uFF1B\u6CA1\u6709\u5C31\u5199"\u65E0"
9364
+
9365
+ \u4E0D\u987A\u624B\u7684\u5730\u65B9
9366
+ - \u6BCF\u6761\u5199\u6E05\u695A\uFF1A\u54EA\u91CC\u5361\u4F4F \u2192 \u5F71\u54CD\u4E86\u4EC0\u4E48 \u2192 \u5EFA\u8BAE\u600E\u4E48\u6539
9367
+ - \u6CA1\u6709\u5C31\u5199"\u65E0"
9368
+
9369
+ \u6700\u503C\u5F97\u6539\u7684\u4E00\u70B9
9370
+ - \u4E00\u53E5\u8BDD
9371
+ - \u7F6E\u4FE1\u5EA6\uFF1A\u4F4E/\u4E2D/\u9AD8`;
9372
+ function resolveTuiLearnOperatorUserId(env = {}) {
9373
+ const token = resolvePlatformAuthToken(env);
9374
+ if (!token) return null;
9375
+ const userId = parseUserIdFromAuthToken(token);
9376
+ return userId ? userId : null;
9377
+ }
9378
+ function selectTuiLearnReviewPrompt(operatorUserId) {
9379
+ return operatorUserId === CURRENT_OPERATOR_USER_ID ? TUI_LEARN_DEVELOPER_REVIEW_PROMPT : TUI_LEARN_PLAIN_REVIEW_PROMPT;
9380
+ }
9381
+ function resolveTuiLearnReviewPrompt(startupEnv = {}, liveEnv) {
9382
+ return selectTuiLearnReviewPrompt(
9383
+ resolveTuiLearnOperatorUserId(resolveTuiIdentityEnv(startupEnv, liveEnv))
9384
+ );
9385
+ }
9386
+ function resolveTuiIdentityEnv(startupEnv, liveEnv) {
9387
+ const merged = { ...startupEnv ?? {} };
9388
+ for (const [key, value] of Object.entries(liveEnv ?? {})) {
9389
+ if (value !== void 0) merged[key] = value;
9390
+ }
9391
+ return merged;
9392
+ }
9393
+
10115
9394
  // packages/cli/tui/session.ts
10116
9395
  function applyAgentSwitchState(state, target, messages) {
10117
9396
  return {
@@ -10231,7 +9510,7 @@ async function probeTerminalBackground(args = {}) {
10231
9510
  if (typeof stdin.setRawMode !== "function") return null;
10232
9511
  if (!isTerminal(stdin)) return null;
10233
9512
  const wasRaw = Boolean(stdin.isRaw);
10234
- return await new Promise((resolve6) => {
9513
+ return await new Promise((resolve5) => {
10235
9514
  let buffer = "";
10236
9515
  let settled = false;
10237
9516
  let timer;
@@ -10244,7 +9523,7 @@ async function probeTerminalBackground(args = {}) {
10244
9523
  if (!wasRaw) stdin.setRawMode?.(false);
10245
9524
  } catch {
10246
9525
  }
10247
- resolve6(result);
9526
+ resolve5(result);
10248
9527
  };
10249
9528
  const onData = (chunk) => {
10250
9529
  buffer += chunk.toString("latin1");
@@ -10442,13 +9721,13 @@ function startCiDeployEventStream(args) {
10442
9721
  let controller = null;
10443
9722
  const timers = /* @__PURE__ */ new Set();
10444
9723
  const sleepWaiters = /* @__PURE__ */ new Set();
10445
- const sleepWithRegisteredTimer = (ms) => new Promise((resolve6) => {
9724
+ const sleepWithRegisteredTimer = (ms) => new Promise((resolve5) => {
10446
9725
  let settled = false;
10447
9726
  const wake = () => {
10448
9727
  if (settled) return;
10449
9728
  settled = true;
10450
9729
  sleepWaiters.delete(wake);
10451
- resolve6();
9730
+ resolve5();
10452
9731
  };
10453
9732
  const timer = setTimeout(() => {
10454
9733
  timers.delete(timer);
@@ -10772,12 +10051,12 @@ function prepareChildRunConsumption(event, host) {
10772
10051
  }
10773
10052
 
10774
10053
  // packages/cli/tui/tuiTurnRunner.ts
10775
- import { randomUUID as mintTaskUserMessageId, createHash as hashTaskUserMessage } from "node:crypto";
10054
+ import { randomUUID as mintTaskUserMessageId } from "node:crypto";
10776
10055
 
10777
10056
  // packages/cli/client/turnBillingAudit.ts
10778
- import { appendFileSync as appendFileSync2, mkdirSync as mkdirSync5 } from "node:fs";
10779
- import { homedir as homedir6 } from "node:os";
10780
- import { join as join5 } from "node:path";
10057
+ import { appendFileSync, mkdirSync as mkdirSync3 } from "node:fs";
10058
+ import { homedir as homedir5 } from "node:os";
10059
+ import { join as join2 } from "node:path";
10781
10060
  function projectUsageForAudit(usage) {
10782
10061
  if (!usage || typeof usage !== "object") return null;
10783
10062
  const normalized = normalizeUsage(usage);
@@ -10843,8 +10122,8 @@ function projectTelemetryForAudit(record) {
10843
10122
  return out;
10844
10123
  }
10845
10124
  function resolveTurnBillingAuditLogPath(env = { NOLO_HOME: process.env.NOLO_HOME }) {
10846
- const noloHome = env.NOLO_HOME?.trim() || join5(homedir6(), ".nolo");
10847
- return join5(noloHome, "logs", "turn-billing.jsonl");
10125
+ const noloHome = env.NOLO_HOME?.trim() || join2(homedir5(), ".nolo");
10126
+ return join2(noloHome, "logs", "turn-billing.jsonl");
10848
10127
  }
10849
10128
  function appendTurnBillingAudit(input) {
10850
10129
  try {
@@ -10872,8 +10151,8 @@ function appendTurnBillingAudit(input) {
10872
10151
  calls
10873
10152
  };
10874
10153
  const logPath = resolveTurnBillingAuditLogPath();
10875
- mkdirSync5(join5(logPath, ".."), { recursive: true });
10876
- appendFileSync2(logPath, `${JSON.stringify(row)}
10154
+ mkdirSync3(join2(logPath, ".."), { recursive: true });
10155
+ appendFileSync(logPath, `${JSON.stringify(row)}
10877
10156
  `);
10878
10157
  } catch {
10879
10158
  }
@@ -11487,11 +10766,11 @@ async function runAskChoiceDialog(args) {
11487
10766
  }
11488
10767
  paint();
11489
10768
  while (state.phase === "active") {
11490
- const sequence = await new Promise((resolve6, reject) => {
11491
- const abort = () => resolve6(STREAM_CLOSED);
10769
+ const sequence = await new Promise((resolve5, reject) => {
10770
+ const abort = () => resolve5(STREAM_CLOSED);
11492
10771
  if (request.signal?.aborted) return abort();
11493
10772
  request.signal?.addEventListener("abort", abort, { once: true });
11494
- Promise.resolve(readKey()).then(resolve6, reject).finally(() => request.signal?.removeEventListener("abort", abort));
10773
+ Promise.resolve(readKey()).then(resolve5, reject).finally(() => request.signal?.removeEventListener("abort", abort));
11495
10774
  });
11496
10775
  if (sequence === STREAM_CLOSED) {
11497
10776
  state = askChoiceReducer(state, { type: "CANCEL" });
@@ -12396,12 +11675,12 @@ async function detectTrailingSilenceSuggestion(filePath, durationSec, opts = {})
12396
11675
  "-"
12397
11676
  ];
12398
11677
  try {
12399
- const stderr = await new Promise((resolve6, reject) => {
11678
+ const stderr = await new Promise((resolve5, reject) => {
12400
11679
  runner(
12401
11680
  opts.ffmpegPath ?? resolveFfmpegPath(),
12402
11681
  args,
12403
11682
  { encoding: "utf8", maxBuffer: 16 * 1024 * 1024 },
12404
- (error, _stdout, stderrText) => error ? reject(error) : resolve6(String(stderrText ?? ""))
11683
+ (error, _stdout, stderrText) => error ? reject(error) : resolve5(String(stderrText ?? ""))
12405
11684
  );
12406
11685
  });
12407
11686
  return buildTrailingSilenceSuggestion(
@@ -12510,6 +11789,7 @@ async function prepareQueuedUserRequest(ctx, req) {
12510
11789
  try {
12511
11790
  ({ imageUrls } = await resolveAttachmentImageUrls({
12512
11791
  actionImagePaths: req.imagePaths,
11792
+ onResolved: ctx.onUserImagesPrepared,
12513
11793
  attachedImages: [],
12514
11794
  onFailure: (_path, err) => ctx.output.write(`[nolo] image skipped: ${err.message}
12515
11795
  `)
@@ -13403,13 +12683,7 @@ async function runAgentChat(scriptDir, state, message, env, output, agentRunner
13403
12683
  ...childRunNoticeBlocks
13404
12684
  ]);
13405
12685
  const spawnedRunsMissingParent = [];
13406
- const taskRef = currentAutoReviewTask(state, env);
13407
- const taskWorkspaceEvidence = taskRef ? await collectHostTaskWorkspace(taskRef, env) : void 0;
13408
- const taskEvidenceInput = taskWorkspaceEvidence ? { hostTaskWorkspaceEvidence: taskWorkspaceEvidence } : {};
13409
- if (taskWorkspaceEvidence?.status === "blocked") output.write(`[auto-review] blocked\uFF1A${taskWorkspaceEvidence.reason}
13410
- `);
13411
12686
  const result = await agentRunner({
13412
- ...taskEvidenceInput,
13413
12687
  interactiveHost: true,
13414
12688
  agentName: effectiveAgentName,
13415
12689
  agentKey: effectiveAgentKey,
@@ -13418,13 +12692,10 @@ async function runAgentChat(scriptDir, state, message, env, output, agentRunner
13418
12692
  getProcessCausalDepth: options.getProcessCausalDepth,
13419
12693
  continueDialogId: state.dialogId,
13420
12694
  freshDialog: options.freshDialog,
13421
- hostTaskRef: currentAutoReviewTask(state, env),
13422
12695
  userMessages: options.userMessages,
13423
12696
  ...options.cliBatchId ? { cliBatchId: options.cliBatchId } : {},
13424
- accountTaskUserSource: options.accountTaskUserSource ? {
13425
- ...options.accountTaskUserSource,
13426
- projectedContentSha256: hashTaskUserMessage("sha256").update(effectiveMessage).digest("hex")
13427
- } : void 0,
12697
+ // accountTaskUserSource 已移除:它专为 host task 证据链服务,
12698
+ // 该链路删除后没有任何生产消费者(2026-11-15)。
13428
12699
  ...state.dialogId ? { parentDialogId: state.dialogId } : {},
13429
12700
  // 显式注入 TUI 真实会话身份(createInitialTuiState mint、跨轮稳定),
13430
12701
  // owner-required 契约不再从 parentDialogId/workspaceRoot 派生会话身份。
@@ -13591,14 +12862,14 @@ function waitForActionGate(rl, input, output, gate, spawnRunner) {
13591
12862
  const meta = deriveGateMeta(gate);
13592
12863
  const { commandPayload, isConfirmation, displayCommand } = meta;
13593
12864
  writeGatePrompt(output, meta);
13594
- return new Promise((resolve6) => {
12865
+ return new Promise((resolve5) => {
13595
12866
  let settled = false;
13596
12867
  const finish = (result) => {
13597
12868
  if (settled) return;
13598
12869
  settled = true;
13599
12870
  rl.off("close", onClose);
13600
12871
  rl.off("SIGINT", onSigint);
13601
- resolve6(result);
12872
+ resolve5(result);
13602
12873
  };
13603
12874
  const cancelResult = (reason) => buildGateCancelledResult(gate, reason);
13604
12875
  const failResult = (message) => buildGateFailedResult(gate, message);
@@ -13662,7 +12933,7 @@ function waitForRawActionGate(input, output, gate, spawnRunner, hooks) {
13662
12933
  const meta = deriveGateMeta(gate);
13663
12934
  const { commandPayload, isConfirmation, displayCommand } = meta;
13664
12935
  writeGatePrompt(output, meta);
13665
- return new Promise((resolve6) => {
12936
+ return new Promise((resolve5) => {
13666
12937
  const rawInput = input;
13667
12938
  let settled = false;
13668
12939
  let commandRunning = false;
@@ -13674,7 +12945,7 @@ function waitForRawActionGate(input, output, gate, spawnRunner, hooks) {
13674
12945
  input.off("data", onData);
13675
12946
  input.off?.("end", onEnd);
13676
12947
  input.off?.("close", onEnd);
13677
- resolve6(result);
12948
+ resolve5(result);
13678
12949
  };
13679
12950
  const cancel = (reason) => finish(buildGateCancelledResult(gate, reason));
13680
12951
  const fail = (message) => finish(buildGateFailedResult(gate, message));
@@ -13887,12 +13158,6 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
13887
13158
  });
13888
13159
  };
13889
13160
  let req = createTurnRequest(inputMsg);
13890
- if (req.event.kind === "auto-review-continuation") {
13891
- const scope = currentAutoReviewTask(ctx.state, ctx.effectiveEnv);
13892
- if (!isHostAutoReviewContinuationEvent(req.event) || JSON.stringify(scope) !== JSON.stringify(req.event.scope)) return { ok: false, aborted: true };
13893
- const task = readHostTask(hostTaskEventsRoot(ctx.effectiveEnv), scope);
13894
- if (task.authorization !== "active" || task.contract.acceptance === "pending" || task.contract.acceptance === "unknown") return { ok: false, aborted: true };
13895
- }
13896
13161
  if (req.event.kind === "child-run-completed") {
13897
13162
  traceChildRunWake("turn-consume", req.event, ctx.state.dialogId ?? null, queueWakeFields(ctx.chatQueueBinding?.getStatus?.()));
13898
13163
  const event = prepareChildRunConsumption(req.event, {
@@ -13944,7 +13209,7 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
13944
13209
  if (!approved) return false;
13945
13210
  const commandText = typeof request.command === "string" ? request.command : "";
13946
13211
  if (commandText) {
13947
- const { runApprovedCredentialCommand } = await import("./hostCredentialCreate-Y7YIGKP4.js");
13212
+ const { runApprovedCredentialCommand } = await import("./hostCredentialCreate-WTW4THJF.js");
13948
13213
  const hostResult = await runApprovedCredentialCommand({
13949
13214
  commandText,
13950
13215
  approvalEventId: request.id,
@@ -13966,7 +13231,7 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
13966
13231
  imageUrls: typeof user.content === "string" ? [] : (user.content ?? []).filter((part) => part.type === "image_url").map((part) => part.image_url.url)
13967
13232
  }));
13968
13233
  const batchLast = batchDisplay?.at(-1);
13969
- const transcriptText = batchLast ? batchLast.text : req.event.kind === "auto-review-continuation" ? req.event.displayText : isContextualFragment && (req.event.kind === "child-run-completed" || req.event.kind === "background-task-completed") ? req.event.displayText ?? req.event.text : message;
13234
+ const transcriptText = batchLast ? batchLast.text : isContextualFragment && (req.event.kind === "child-run-completed" || req.event.kind === "background-task-completed") ? req.event.displayText ?? req.event.text : message;
13970
13235
  const noticeTasks = req.event.kind === "child-run-completed" ? buildNoticeTasksFromRuns(req.event.runs, Date.now()) : null;
13971
13236
  if (ctx.history.currentRole !== null && ctx.history.currentContent) {
13972
13237
  finalizeCurrentTurn(ctx.history);
@@ -14152,13 +13417,7 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
14152
13417
  freshDialog,
14153
13418
  userMessages: req.userMessages,
14154
13419
  ...req.cliBatchId ? { cliBatchId: req.cliBatchId } : {},
14155
- ...req.event.kind === "user" ? { accountTaskUserSource: {
14156
- ...req.batchUserSource ?? {
14157
- messageId: req.messageId ?? mintTaskUserMessageId(),
14158
- originalText: message,
14159
- contentSha256: hashTaskUserMessage("sha256").update(message).digest("hex")
14160
- }
14161
- } } : {},
13420
+ // accountTaskUserSource 已移除(host task 证据链下线,无消费者)。
14162
13421
  ...imageUrls.length > 0 ? { imageUrls } : {},
14163
13422
  ...localAttachmentPaths && localAttachmentPaths.length > 0 ? { localAttachmentPaths } : {},
14164
13423
  actionGateHandler: gateHandlerWithStatus,
@@ -14298,12 +13557,6 @@ async function runOneAgentTurn(ctx, inputMsg, imageUrls, actionGateHandler, conf
14298
13557
  }
14299
13558
  }
14300
13559
  );
14301
- if (runResult.hostTaskRef) {
14302
- ctx.state = { ...ctx.state, autoReviewTask: {
14303
- userId: resolveTuiLearnOperatorUserId(ctx.effectiveEnv) ?? "local",
14304
- reference: runResult.hostTaskRef
14305
- } };
14306
- }
14307
13560
  const wasForceStopped = ctx.forcedStopEpoch === myEpoch;
14308
13561
  if (wasForceStopped) {
14309
13562
  emitStatusIfCurrentTurn({ state: "idle" });
@@ -14538,7 +13791,7 @@ function ensureChatQueueBinding(ctx, actionGateHandler, confirmDestructiveAction
14538
13791
  }
14539
13792
  ctx.chatQueueBindingDialogId = boundDialogId;
14540
13793
  const dialogId = () => boundDialogId;
14541
- const run = (req) => runAutoReviewDrainedTurn(ctx.chatQueueBinding, () => runDrainedQueueTurn(ctx, req, actionGateHandler, confirmDestructiveAction));
13794
+ const run = (req) => runDrainedQueueTurn(ctx, req, actionGateHandler, confirmDestructiveAction);
14542
13795
  ctx.chatQueueBinding = createChatQueueTuiBinding(run, {
14543
13796
  savePending: async (requests) => saveCliPendingUserMessages({
14544
13797
  store: await getStore(),
@@ -14618,25 +13871,15 @@ async function runQueuedUserBatch(ctx, requests, actionGateHandler, confirmDestr
14618
13871
  });
14619
13872
  }
14620
13873
  if (!canStart()) return { ok: false, aborted: true };
14621
- const originalText = JSON.stringify(userMessages.map((user) => ({
14622
- ...user,
14623
- content: typeof user.content === "string" ? user.content : user.content.map((part) => part.type === "image_url" ? { type: part.type, sha256: hashTaskUserMessage("sha256").update(part.image_url.url).digest("hex") } : part)
14624
- })));
14625
- const contentSha256 = hashTaskUserMessage("sha256").update(originalText).digest("hex");
14626
- const request = {
14627
- ...requests[0],
14628
- userMessages,
14629
- cliBatchId: batchId,
14630
- batchUserSource: { messageId: `user-batch-${contentSha256}`, originalText, contentSha256 }
14631
- };
14632
- return runAutoReviewDrainedTurn(ctx.chatQueueBinding, () => runTurn(
13874
+ const request = { ...requests[0], userMessages, cliBatchId: batchId };
13875
+ return runTurn(
14633
13876
  ctx,
14634
13877
  request,
14635
13878
  [],
14636
13879
  actionGateHandler,
14637
13880
  confirmDestructiveAction,
14638
13881
  requests.flatMap((request2) => [...request2.imagePaths ?? [], ...request2.mediaPaths ?? []])
14639
- ));
13882
+ );
14640
13883
  }
14641
13884
 
14642
13885
  // packages/cli/tui/tuiUrlOpener.ts
@@ -14834,6 +14077,36 @@ function openVisibleUrlAtScreen(history, contentWidth, scrollTop, screenRow, scr
14834
14077
  return true;
14835
14078
  }
14836
14079
 
14080
+ // packages/cli/tui/tuiImageActions.ts
14081
+ import { stat as stat3 } from "node:fs/promises";
14082
+ import { resolve as resolve4 } from "node:path";
14083
+ var WINDOWS_VIEW_SCRIPT = "$ErrorActionPreference='Stop'; $info = New-Object System.Diagnostics.ProcessStartInfo; $info.FileName = $env:NOLO_IMAGE_VIEW_PATH; $info.UseShellExecute = $true; [System.Diagnostics.Process]::Start($info) | Out-Null";
14084
+ function localImageViewerCommand(platform, path3) {
14085
+ if (platform === "win32") return {
14086
+ argv: ["powershell.exe", "-NoLogo", "-NoProfile", "-NonInteractive", "-Command", WINDOWS_VIEW_SCRIPT],
14087
+ envPatch: { NOLO_IMAGE_VIEW_PATH: path3 }
14088
+ };
14089
+ const command = platform === "darwin" ? "open" : platform === "linux" ? "xdg-open" : void 0;
14090
+ return command ? { argv: [command, path3], envPatch: {} } : void 0;
14091
+ }
14092
+ async function viewLocalImage(sourcePath, env) {
14093
+ if (isRemoteSession(env)) return "\u65E0\u6CD5\u5728\u8FDC\u7A0B\u4F1A\u8BDD\u6253\u5F00\u672C\u673A\u67E5\u770B\u5668\uFF1B\u8BF7\u5728\u6587\u4EF6\u6240\u5728\u673A\u5668\u67E5\u770B\u3002";
14094
+ if (!sourcePath || /[\u0000-\u001f\u007f]/.test(sourcePath)) return "\u65E0\u6CD5\u67E5\u770B\uFF1A\u65E0\u6709\u6548\u672C\u673A\u6587\u4EF6\u8DEF\u5F84\u3002";
14095
+ const path3 = resolve4(sourcePath);
14096
+ try {
14097
+ if (!(await stat3(path3)).isFile()) return "\u65E0\u6CD5\u67E5\u770B\uFF1A\u8DEF\u5F84\u4E0D\u662F\u6587\u4EF6\u3002";
14098
+ const plan = localImageViewerCommand(process.platform, path3);
14099
+ if (!plan || !Bun.which(plan.argv[0], { PATH: env.PATH })) return "\u65E0\u6CD5\u67E5\u770B\uFF1A\u6B64\u73AF\u5883\u6CA1\u6709\u53EF\u7528\u7684\u672C\u673A\u56FE\u7247\u67E5\u770B\u5668\u3002";
14100
+ if (process.platform === "linux" && !env.DISPLAY && !env.WAYLAND_DISPLAY) return "\u65E0\u6CD5\u67E5\u770B\uFF1A\u6CA1\u6709\u684C\u9762\u663E\u793A\u4F1A\u8BDD\u3002";
14101
+ const child = Bun.spawn(plan.argv, { env: { ...env, ...plan.envPatch }, stdin: "ignore", stdout: "ignore", stderr: "pipe" });
14102
+ const error = await new Response(child.stderr).text();
14103
+ const code = await child.exited;
14104
+ return code === 0 ? "\u5DF2\u4EA4\u7ED9\u672C\u673A\u67E5\u770B\u5668\uFF08\u4E0D\u4EE3\u8868\u7A97\u53E3\u5DF2\u663E\u793A\uFF09\u3002" : `\u67E5\u770B\u5668\u542F\u52A8\u5931\u8D25 (${code}): ${sanitizeImageLabel(error).slice(0, 300)}`;
14105
+ } catch (error) {
14106
+ return `\u65E0\u6CD5\u67E5\u770B: ${sanitizeImageLabel(error instanceof Error ? error.message : String(error))}`;
14107
+ }
14108
+ }
14109
+
14837
14110
  // packages/cli/tui/tuiRender.ts
14838
14111
  function createTuiRender(host) {
14839
14112
  const { output, history, selectionState } = host;
@@ -15098,7 +14371,7 @@ function createTerminalGraphicsRuntime(options) {
15098
14371
  }
15099
14372
 
15100
14373
  // packages/cli/tui/tuiImageAttachments.ts
15101
- import { createHash as createHash5 } from "node:crypto";
14374
+ import { createHash as createHash2 } from "node:crypto";
15102
14375
  var IMAGE_CACHE_MAX_BYTES = 32 * 1024 * 1024;
15103
14376
  var IMAGE_CACHE_MAX_COUNT = 64;
15104
14377
  var MAX_DATA_URL_CHARS = Math.ceil(KITTY_MAX_PNG_BYTES / 3) * 4 + 64;
@@ -15152,7 +14425,7 @@ function createImageAttachmentCache(options = {}) {
15152
14425
  textFallbacks.push(label);
15153
14426
  return;
15154
14427
  }
15155
- const fingerprint2 = createHash5("sha256").update(png).digest("hex");
14428
+ const fingerprint2 = createHash2("sha256").update(png).digest("hex");
15156
14429
  let key = contentKeys.get(fingerprint2);
15157
14430
  if (!key || !entries.has(key)) {
15158
14431
  key = `attachment:${encodeURIComponent(turnIdentity)}:${index}:${fingerprint2}`;
@@ -15333,7 +14606,7 @@ function createTuiImageRenderer(options) {
15333
14606
  }
15334
14607
 
15335
14608
  // packages/cli/tui/readlineWorkspace.ts
15336
- import { randomInt, randomUUID as randomUUID3 } from "node:crypto";
14609
+ import { randomInt } from "node:crypto";
15337
14610
 
15338
14611
  // packages/cli/tui/tuiScrollAnimation.ts
15339
14612
  var VELOCITY_WINDOW_MS = 120;
@@ -15742,7 +15015,7 @@ async function compactDialog(options) {
15742
15015
  fetchImpl,
15743
15016
  agentRef: getActiveDialogAgentId(current) ?? void 0,
15744
15017
  loadAdapter: async () => {
15745
- const { createCliLocalRuntimeAdapter: createCliLocalRuntimeAdapter2 } = await import("./localRuntimeAdapter-ZLJONQZS.js");
15018
+ const { createCliLocalRuntimeAdapter: createCliLocalRuntimeAdapter2 } = await import("./localRuntimeAdapter-MI2JGXSF.js");
15746
15019
  return createCliLocalRuntimeAdapter2({ env: { ...options.env ?? {}, AUTH_TOKEN: options.authToken, NOLO_SERVER: options.serverUrl }, fetchImpl });
15747
15020
  }
15748
15021
  }) : void 0);
@@ -16510,16 +15783,6 @@ ${content}`);
16510
15783
  return parts.join("\n\n");
16511
15784
  };
16512
15785
  async function runSubmittedSlashLine(line, host, actionGateHandler, confirmDestructiveAction, directUserSubmission = false) {
16513
- if (line.trim().split(/\s+/)[0] === "/auto-review") {
16514
- if (!directUserSubmission) {
16515
- host.emitCommandOutput("auto-review\uFF1A\u53EA\u63A5\u53D7\u7528\u6237\u76F4\u63A5\u63D0\u4EA4\u7684\u63A7\u5236\u547D\u4EE4\uFF1B\u672A\u4FEE\u6539\u6388\u6743\u3002", line);
16516
- return false;
16517
- }
16518
- const result2 = applyAutoReviewControl(line, host.state, resolveTuiIdentityEnv(host.taskEnv, host.options.env ?? process.env));
16519
- host.state = result2.state;
16520
- host.emitCommandOutput(result2.output, line);
16521
- return false;
16522
- }
16523
15786
  const {
16524
15787
  history,
16525
15788
  pasteStore,
@@ -17267,6 +16530,7 @@ ${messageForModel}` : block;
17267
16530
  }
17268
16531
  const { imageUrls } = await resolveAttachmentImageUrls({
17269
16532
  actionImagePaths: result.action.imagePaths,
16533
+ onResolved: turnCtx.onUserImagesPrepared,
17270
16534
  attachedImages: host.state.attachedImages,
17271
16535
  onFailure: (_path, err) => output.write(`[nolo] image skipped: ${err.message}
17272
16536
  `)
@@ -17576,36 +16840,12 @@ async function runTuiWorkspace(options) {
17576
16840
  });
17577
16841
  const activityReporter = (label) => activityIndicator.report(label);
17578
16842
  let runWakeHandler = null;
17579
- const reconcileAutoReviewWake = createAutoReviewContinuationWake({
17580
- getState: () => state,
17581
- env: options.env ? { ...process.env, ...options.env } : process.env,
17582
- wake: (event) => {
17583
- const expected = currentAutoReviewTask(state, options.env ? { ...process.env, ...options.env } : process.env);
17584
- setImmediate(() => {
17585
- const env = options.env ? { ...process.env, ...options.env } : process.env;
17586
- const current = currentAutoReviewTask(state, env);
17587
- if (!sessionEnded && expected && JSON.stringify(current) === JSON.stringify(expected)) {
17588
- const task = readHostTask(hostTaskEventsRoot(env), expected);
17589
- if (task.authorization === "active") runWakeHandler?.(event);
17590
- }
17591
- });
17592
- }
17593
- });
17594
- const unsubscribeAutoReviewAcceptance = onAutoReviewAcceptance((reference, sequence) => {
17595
- const current = currentAutoReviewTask(state, effectiveEnv);
17596
- if (current?.taskId !== reference.taskId || current.dialogId !== reference.dialogId) return;
17597
- runCompletionWatcher.resumePendingDelivery();
17598
- reconcileAutoReviewWake({ kind: "acceptance", eventKey: `acceptance:${reference.taskId}:${sequence}` });
17599
- });
17600
16843
  const runCompletionWatcher = createRunCompletionWatcher({
17601
16844
  env: options.env ? { ...process.env, ...options.env } : process.env,
17602
16845
  getCurrentDialogId: () => state.dialogId ?? null,
17603
16846
  onWake: (event) => {
17604
- traceChildRunWake("watcher-delivery", event, state.dialogId ?? null, { handlerInstalled: !!runWakeHandler, autoReviewRoute: !!currentAutoReviewTask(state, effectiveEnv) });
16847
+ traceChildRunWake("watcher-delivery", event, state.dialogId ?? null, { handlerInstalled: !!runWakeHandler });
17605
16848
  return deliverChildCompletion(event, runWakeHandler, () => {
17606
- if (typeof event !== "string" && event.kind === "child-run-completed" && currentAutoReviewTask(state, effectiveEnv)) {
17607
- reconcileAutoReviewWake({ kind: "review-terminal", eventKey: `runs:${event.runs.map((r) => `${r.runId}:${r.status}`).sort().join(",")}` });
17608
- }
17609
16849
  });
17610
16850
  }
17611
16851
  });
@@ -17646,6 +16886,9 @@ async function runTuiWorkspace(options) {
17646
16886
  });
17647
16887
  const history = createTurnHistory();
17648
16888
  const imageCache = createImageAttachmentCache();
16889
+ const preparedImages = [];
16890
+ let imageGraphicsSupported = false;
16891
+ let imagePreviewRequested = false;
17649
16892
  let imageRenderer;
17650
16893
  const renderNamespace = randomInt(1, 65536);
17651
16894
  let handleTranscriptScroll = (action) => {
@@ -17906,7 +17149,6 @@ async function runTuiWorkspace(options) {
17906
17149
  ...state,
17907
17150
  attachedImages: mergeAttachedImages(state.attachedImages, [outcome.image])
17908
17151
  };
17909
- emitCommandOutput(summarizeAttachment(outcome.image));
17910
17152
  if (fixedInput.active) fixedInput.repaint(buffer, cursorPos);
17911
17153
  return;
17912
17154
  }
@@ -18057,12 +17299,7 @@ async function runTuiWorkspace(options) {
18057
17299
  return chatQueueBinding;
18058
17300
  },
18059
17301
  set chatQueueBinding(v) {
18060
- chatQueueBinding = v ? bindAutoReviewTurnEnd(v, {
18061
- getScope: () => currentAutoReviewTask(state, effectiveEnv),
18062
- getContext: () => ({ dialogId: state.dialogId, workspace: state.cwd }),
18063
- reconcile: reconcileAutoReviewWake,
18064
- nextEventKey: () => `turn:${randomUUID3()}`
18065
- }) : null;
17302
+ chatQueueBinding = v;
18066
17303
  },
18067
17304
  get turnInjectionInbox() {
18068
17305
  return turnInjectionInbox;
@@ -18070,14 +17307,23 @@ async function runTuiWorkspace(options) {
18070
17307
  set turnInjectionInbox(v) {
18071
17308
  turnInjectionInbox = v;
18072
17309
  },
17310
+ onUserImagesPrepared: (images) => {
17311
+ preparedImages.push(...images);
17312
+ if (preparedImages.length > 64) preparedImages.splice(0, preparedImages.length - 64);
17313
+ },
18073
17314
  onUserTurnFinalized: (turn, imageUrls) => {
18074
- const preview = imageCache.preview(`turn-${turnIdentity++}`, imageUrls.map((dataUrl) => ({
18075
- dataUrl,
18076
- mime: dataUrl.slice(5, dataUrl.indexOf(";")),
18077
- filename: "image",
18078
- sizeBytes: 0,
18079
- sourcePath: ""
18080
- })));
17315
+ const attachments = imageUrls.map((dataUrl, index) => {
17316
+ const prepared = preparedImages.findIndex((image2) => image2.dataUrl === dataUrl);
17317
+ const image = prepared >= 0 ? preparedImages.splice(prepared, 1)[0] : {
17318
+ dataUrl,
17319
+ mime: dataUrl.slice(5, dataUrl.indexOf(";")),
17320
+ filename: "\u540D\u79F0\u672A\u4FDD\u7559",
17321
+ sizeBytes: 0,
17322
+ sourcePath: ""
17323
+ };
17324
+ return { ...image, filename: `${index + 1} \xB7 ${image.filename}` };
17325
+ });
17326
+ const preview = imageCache.preview(`turn-${turnIdentity++}`, attachments);
18081
17327
  turn.images = preview.images;
18082
17328
  for (const fallback of preview.textFallbacks) turn.content += `
18083
17329
  [\u9644\u4EF6] ${fallback}`;
@@ -18204,7 +17450,64 @@ async function runTuiWorkspace(options) {
18204
17450
  spawnRunner,
18205
17451
  installAltScreenRestoreHandlers
18206
17452
  };
17453
+ const manageDraftImages = async (confirmSend) => {
17454
+ while (state.attachedImages.length > 0) {
17455
+ const images = state.attachedImages;
17456
+ const selected = await dialogHost.run((anchor) => {
17457
+ const rawKey = createRawKeyReader(input);
17458
+ const readKey = Object.assign(async () => {
17459
+ const key = await rawKey();
17460
+ return typeof key === "string" && /^[\r\n]+$/.test(key) ? "\r" : key;
17461
+ }, { dispose: () => rawKey.dispose?.() });
17462
+ return runSelectDialog({
17463
+ ...anchor,
17464
+ input,
17465
+ output,
17466
+ readKey,
17467
+ title: confirmSend ? "\u786E\u8BA4\u56FE\u7247\u9644\u4EF6\uFF08\u5C1A\u672A\u53D1\u9001\uFF09" : "\u56FE\u7247\u9644\u4EF6\uFF08\u5C1A\u672A\u53D1\u9001\uFF09",
17468
+ titleLines: [confirmSend ? "\u786E\u8BA4\u56FE\u7247\u9644\u4EF6\uFF08\u5C1A\u672A\u53D1\u9001\uFF09" : "\u56FE\u7247\u9644\u4EF6\uFF08\u5C1A\u672A\u53D1\u9001\uFF09", ...images.map((image2, index) => `${index + 1} \xB7 ${sanitizeImageLabel(image2.filename)} (${image2.sizeBytes} B)`)],
17469
+ footerLines: ["\u79FB\u9664\u4EC5\u53D6\u6D88\u9644\u4EF6\uFF0C\u4E0D\u5220\u9664\u672C\u673A\u6587\u4EF6\u3002Esc \u8FD4\u56DE\u7F16\u8F91\u3002"],
17470
+ items: [
17471
+ { label: confirmSend ? `\u53D1\u9001 ${images.length} \u5F20\u56FE\u7247` : "\u8FD4\u56DE\u7F16\u8F91", action: "done", index: -1 },
17472
+ ...images.flatMap((image2, index) => [
17473
+ { label: `\u67E5\u770B ${index + 1} \xB7 ${sanitizeImageLabel(image2.filename)}`, action: "view", index },
17474
+ { label: `\u79FB\u9664 ${index + 1} \xB7 ${sanitizeImageLabel(image2.filename)}`, action: "remove", index }
17475
+ ])
17476
+ ]
17477
+ });
17478
+ });
17479
+ if (selected.kind !== "selected") return false;
17480
+ if (selected.item.action === "done") return true;
17481
+ const image = images[selected.item.index];
17482
+ if (!image) continue;
17483
+ if (selected.item.action === "remove") {
17484
+ state = { ...state, attachedImages: images.filter((_, index) => index !== selected.item.index) };
17485
+ fixedInput.repaint(buffer, cursorPos);
17486
+ } else {
17487
+ const result = await viewLocalImage(image.sourcePath, effectiveEnv);
17488
+ emitCommandOutput(`[nolo] ${result}`);
17489
+ }
17490
+ }
17491
+ return !confirmSend;
17492
+ };
18207
17493
  const runSubmittedLine = async (line, actionGateHandler, confirmDestructiveAction, directUserSubmission = false) => {
17494
+ if (line.trim() === "/images preview") {
17495
+ if (!imageGraphicsSupported) {
17496
+ emitCommandOutput("[nolo] \u5F53\u524D\u7EC8\u7AEF\u672A\u786E\u8BA4\u652F\u6301\u56FE\u7247\u9884\u89C8\uFF0C\u4FDD\u7559\u56FE\u7247\u540D\u79F0\u6587\u5B57\u3002\u53EF\u7528 /images \u67E5\u770B\u5F85\u53D1\u9001\u9644\u4EF6\u3002");
17497
+ return false;
17498
+ }
17499
+ imagePreviewRequested = !imagePreviewRequested;
17500
+ history.graphicsEnabled = imagePreviewRequested;
17501
+ if (!imagePreviewRequested) imageRenderer?.suspend();
17502
+ emitCommandOutput(`[nolo] \u56FE\u7247\u9884\u89C8${imagePreviewRequested ? "\u5DF2\u5F00\u542F" : "\u5DF2\u5173\u95ED"}\u3002`);
17503
+ renderHistoryToOutput();
17504
+ return false;
17505
+ }
17506
+ if (line.trim() === "/images") {
17507
+ if (state.attachedImages.length === 0) emitCommandOutput("[nolo] \u65E0\u5F85\u53D1\u9001\u56FE\u7247\u3002/images preview \u6309\u9700\u5207\u6362\u6D88\u606F\u56FE\u7247\u9884\u89C8\uFF08\u9700\u7EC8\u7AEF\u80FD\u529B\u786E\u8BA4\uFF09\u3002");
17508
+ await manageDraftImages(false);
17509
+ return false;
17510
+ }
18208
17511
  if (line.trim().split(/\s+/)[0]?.toLowerCase() === "/pending") {
18209
17512
  const [, action, batchId, ...extra] = line.trim().split(/\s+/);
18210
17513
  try {
@@ -18274,7 +17577,7 @@ async function runTuiWorkspace(options) {
18274
17577
  },
18275
17578
  getAttachmentLine: () => {
18276
17579
  const line = formatComposerAttachmentLine(state.attachedImages);
18277
- return line ? dimCliText(line, resolveCliColorEnabled()) : null;
17580
+ return line ? dimCliText(`${line} \xB7 \u5F85\u53D1\u9001 \xB7 /images \u67E5\u770B/\u79FB\u9664`, resolveCliColorEnabled()) : null;
18278
17581
  },
18279
17582
  onInputLinesChange: () => {
18280
17583
  renderHistoryToOutput();
@@ -18404,7 +17707,7 @@ async function runTuiWorkspace(options) {
18404
17707
  onApprove: createSnapshotGuardedApproval("local", () => state.permissionGrants, approveLocalConfirms),
18405
17708
  onApproved: async (approvedGate) => {
18406
17709
  if (approvedGate.kind !== "confirm") return null;
18407
- const { executeApprovedCredentialCreate } = await import("./hostCredentialCreate-Y7YIGKP4.js");
17710
+ const { executeApprovedCredentialCreate } = await import("./hostCredentialCreate-WTW4THJF.js");
18408
17711
  const hostResult = await executeApprovedCredentialCreate({
18409
17712
  gate: approvedGate,
18410
17713
  approvalGateId: approvedGate.id,
@@ -18889,12 +18192,14 @@ ${hint}` : hint;
18889
18192
  if (fixedInput.active) fixedInput.repaint(buffer, cursorPos);
18890
18193
  }
18891
18194
  };
18195
+ let preparingImageSubmission = false;
18892
18196
  const handleInputToken = async (sequence) => {
18893
18197
  if (done) return;
18894
18198
  if (dialogHost.isKeyboardClaimed()) {
18895
18199
  rawActionGateTokenHandler?.(sequence);
18896
18200
  return;
18897
18201
  }
18202
+ if (preparingImageSubmission) return;
18898
18203
  if (hostApprovalPrompt?.handleKey(sequence, {
18899
18204
  draftEmpty: buffer.length === 0,
18900
18205
  busy
@@ -19119,12 +18424,12 @@ ${hint}` : hint;
19119
18424
  return;
19120
18425
  }
19121
18426
  if (result.submit !== void 0) {
19122
- const submittedText = replaceCollapsedPastesWithReferences(
18427
+ let submittedText = replaceCollapsedPastesWithReferences(
19123
18428
  result.submit,
19124
18429
  pasteStore
19125
18430
  );
19126
18431
  const submittedTrimmed = submittedText.trim();
19127
- const startsChatTurn = submittedTrimmed.length > 0 && !submittedTrimmed.startsWith("/") && !submittedTrimmed.startsWith("!");
18432
+ const startsChatTurn = (submittedTrimmed.length > 0 || state.attachedImages.length > 0) && !isLikelySlashCommand(submittedTrimmed) && !submittedTrimmed.startsWith("!");
19128
18433
  if (busyLock) {
19129
18434
  const trimmedText = submittedText.trim();
19130
18435
  const busySlashCommand = trimmedText.split(/\s+/)[0]?.toLowerCase();
@@ -19239,7 +18544,7 @@ ${text}
19239
18544
  if (state.suggestedAuthCommand) {
19240
18545
  state = { ...state, suggestedAuthCommand: void 0 };
19241
18546
  }
19242
- if (!submittedText.trim()) {
18547
+ if (!submittedText.trim() && state.attachedImages.length === 0) {
19243
18548
  const { actionGateHandler, confirmDestructiveAction } = buildInteractiveTurnHandlers();
19244
18549
  const pending = ensureChatQueueBinding(turnCtx, actionGateHandler, confirmDestructiveAction);
19245
18550
  await pending.restorePending();
@@ -19255,6 +18560,36 @@ ${text}
19255
18560
  return;
19256
18561
  }
19257
18562
  }
18563
+ if (startsChatTurn) {
18564
+ preparingImageSubmission = true;
18565
+ try {
18566
+ const detected = detectSubmittedImagePaths(submittedText, state.cwd);
18567
+ if (detected.hints.length > 0) {
18568
+ const read = await readImagePaths(detected.hints.map((hint) => hint.resolvedPath), {
18569
+ onFailure: (_path, error) => emitCommandOutput(`[nolo] \u56FE\u7247\u672A\u6DFB\u52A0: ${sanitizeImageLabel(error.message)}`)
18570
+ });
18571
+ state = { ...state, attachedImages: mergeAttachedImages(state.attachedImages, read.images) };
18572
+ if (read.failures.length > 0) {
18573
+ fixedInput.repaint(buffer, cursorPos);
18574
+ return;
18575
+ }
18576
+ }
18577
+ if (state.attachedImages.length > 0) {
18578
+ if (detected.hints.length > 0) {
18579
+ submittedText = stripImageTokens(submittedText, detected.hints);
18580
+ buffer = stripImageTokens(buffer, detected.hints);
18581
+ cursorPos = buffer.length;
18582
+ }
18583
+ if (!await manageDraftImages(true)) {
18584
+ fixedInput.repaint(buffer, cursorPos);
18585
+ return;
18586
+ }
18587
+ submittedText ||= "\u8BF7\u67E5\u770B\u9644\u4EF6\u56FE\u7247\u3002";
18588
+ }
18589
+ } finally {
18590
+ preparingImageSubmission = false;
18591
+ }
18592
+ }
19258
18593
  if (startsChatTurn && state.attachedImages.length === 0 && chatQueueBinding && (chatQueueBinding.queueLength() > 0 || chatQueueBinding.isRecoveryBlocked())) {
19259
18594
  const images = detectSubmittedImagePaths(submittedText, state.cwd);
19260
18595
  const media = detectSubmittedMediaPaths(images.message, state.cwd);
@@ -19325,7 +18660,8 @@ ${text}
19325
18660
  onForwardInput: (data) => onData(data),
19326
18661
  onCapabilityChanged: (enabled) => {
19327
18662
  if (sessionEnded || done) return;
19328
- history.graphicsEnabled = enabled;
18663
+ imageGraphicsSupported = enabled;
18664
+ history.graphicsEnabled = enabled && imagePreviewRequested;
19329
18665
  if (enabled && !imageRenderer) imageRenderer = createTuiImageRenderer({ output, namespace: renderNamespace, graphicsEnabled: true, getPng: (key) => imageCache.getPng(key) });
19330
18666
  scheduleRender();
19331
18667
  }
@@ -19352,9 +18688,9 @@ ${text}
19352
18688
  fixedInput.repaint(buffer, cursorPos);
19353
18689
  refreshGitStatus();
19354
18690
  refreshCiStatus();
19355
- await new Promise((resolve6) => {
19356
- resolveDone = resolve6;
19357
- if (done) resolve6();
18691
+ await new Promise((resolve5) => {
18692
+ resolveDone = resolve5;
18693
+ if (done) resolve5();
19358
18694
  });
19359
18695
  } finally {
19360
18696
  finish();
@@ -19410,7 +18746,6 @@ ${renderStatusLine(state)}
19410
18746
  } finally {
19411
18747
  const registry = getProcessRegistry();
19412
18748
  unsubscribeProcessTerminal();
19413
- unsubscribeAutoReviewAcceptance();
19414
18749
  const persistentCount = registry.list().filter((p) => p.persist && p.status === "running").length;
19415
18750
  registry.stopAll();
19416
18751
  if (persistentCount > 0) {