@linghun/tui 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/dist/agent-completion-finalizer.js +3 -3
  2. package/dist/background-control-runtime.js +56 -55
  3. package/dist/cache-command-runtime.js +3 -3
  4. package/dist/capability-runtime.js +35 -34
  5. package/dist/{chunk-TJLC3QAS.js → chunk-36ZWUJQS.js} +1 -1
  6. package/dist/{chunk-JDWXC2OQ.js → chunk-3MRYQO7X.js} +4 -4
  7. package/dist/{chunk-2FVEKTKN.js → chunk-3PG7I3LA.js} +4 -4
  8. package/dist/{chunk-J7ZE2JKP.js → chunk-42ZZUF7P.js} +3 -3
  9. package/dist/{chunk-DTK5NBTV.js → chunk-4BFCUJX6.js} +95 -11
  10. package/dist/{chunk-YH6UIHNF.js → chunk-4QWCNMP6.js} +2 -2
  11. package/dist/{chunk-WKMBK5UP.js → chunk-4TO2LDMP.js} +1 -1
  12. package/dist/chunk-4UER2AKI.js +636 -0
  13. package/dist/{chunk-WHFDDZHY.js → chunk-5IFNLTOF.js} +4 -4
  14. package/dist/{chunk-W3KHJNSH.js → chunk-6CHUZ2NF.js} +2 -2
  15. package/dist/{chunk-I3NTAIMF.js → chunk-6DBBXNEG.js} +3 -3
  16. package/dist/{chunk-GDQQNPBP.js → chunk-6GXIGN5W.js} +1 -1
  17. package/dist/{chunk-QLRTQHTR.js → chunk-6JGRNES6.js} +2 -2
  18. package/dist/{chunk-D7TCSOAZ.js → chunk-7BHMBWG2.js} +3 -3
  19. package/dist/{chunk-KO64OFSG.js → chunk-7C6T7RKJ.js} +1 -1
  20. package/dist/{chunk-4WHZ6JKD.js → chunk-7R4YXN7Z.js} +335 -63
  21. package/dist/{chunk-LDABZV5V.js → chunk-7RZE45OT.js} +1 -1
  22. package/dist/{chunk-MLUIOBKL.js → chunk-7ZMDQZ22.js} +4 -4
  23. package/dist/{chunk-X7A22JHP.js → chunk-A4H3UTJZ.js} +1 -1
  24. package/dist/{chunk-LVIM2PA7.js → chunk-AGI6GFFL.js} +3 -3
  25. package/dist/{chunk-D3UTL2QX.js → chunk-ATY7WBIT.js} +1 -1
  26. package/dist/{chunk-ZOSK2UEU.js → chunk-BBK5BA5C.js} +99 -117
  27. package/dist/{chunk-SRZIA6B4.js → chunk-BNC4F63N.js} +1 -1
  28. package/dist/{chunk-WQMSRO4D.js → chunk-CJRJR7TP.js} +5 -5
  29. package/dist/{chunk-OEYW3JE3.js → chunk-DIDRFIIW.js} +2 -2
  30. package/dist/{chunk-AKPXMCVF.js → chunk-EKYXI6C7.js} +11 -7
  31. package/dist/{chunk-GMUCSNUD.js → chunk-FGGY5KNM.js} +7 -7
  32. package/dist/{chunk-APJIC2O5.js → chunk-GTIZNO5O.js} +84 -0
  33. package/dist/{chunk-UOHZQIVL.js → chunk-GXFYUZAM.js} +1 -1
  34. package/dist/{chunk-DDXS2RDZ.js → chunk-HGCTHBUY.js} +1 -1
  35. package/dist/{chunk-QTDGRZMZ.js → chunk-HJOC5WUV.js} +1 -1
  36. package/dist/{chunk-ECFLCY5V.js → chunk-HPIHFENG.js} +2 -2
  37. package/dist/{chunk-SYBNJZEL.js → chunk-HPMBSOQ4.js} +1 -1
  38. package/dist/{chunk-QB4VWH7W.js → chunk-HPQ2IHOW.js} +4 -4
  39. package/dist/{chunk-RVY34HK4.js → chunk-HZ5XNKWS.js} +5 -2
  40. package/dist/{chunk-4K6UB524.js → chunk-IPZZGDUU.js} +1 -1
  41. package/dist/{chunk-JHGWGH2C.js → chunk-J6CYFWSW.js} +89 -7
  42. package/dist/{chunk-6CI6TKLN.js → chunk-JAVRQ3LM.js} +1 -1
  43. package/dist/{chunk-VCSRBS47.js → chunk-JLAJZPOC.js} +1 -1
  44. package/dist/{chunk-THZBFYAH.js → chunk-JY3LI63F.js} +2 -2
  45. package/dist/{chunk-RMLTVKOY.js → chunk-L4YVE3RG.js} +2 -2
  46. package/dist/{chunk-P277M7Z5.js → chunk-LBC75QAB.js} +1 -1
  47. package/dist/{chunk-F6TVBCZV.js → chunk-LWW2IAFC.js} +1 -1
  48. package/dist/{chunk-64MJP6FK.js → chunk-NK4NMYF5.js} +52 -10
  49. package/dist/{chunk-DNQN74CC.js → chunk-NL4M3V5D.js} +33 -0
  50. package/dist/{chunk-OF3K3CU5.js → chunk-O2U4XQVM.js} +2 -2
  51. package/dist/{chunk-LQTVYUT3.js → chunk-OJTMM5CV.js} +2 -2
  52. package/dist/{chunk-HW2TBXVK.js → chunk-OPVRII63.js} +1 -1
  53. package/dist/{chunk-ZZ2CNCXJ.js → chunk-OSFBVVEP.js} +4 -4
  54. package/dist/{chunk-F43AMWLZ.js → chunk-PDTJVJVD.js} +1 -1
  55. package/dist/{chunk-UDQT5CWK.js → chunk-PI6T2AGS.js} +1 -1
  56. package/dist/{chunk-JO5ANTMR.js → chunk-PPUOHBAK.js} +84 -37
  57. package/dist/{chunk-N7G2X2LK.js → chunk-QD4SCW4A.js} +235 -198
  58. package/dist/{chunk-SOPYWTFV.js → chunk-RRUI3VWQ.js} +1 -1
  59. package/dist/{chunk-IN42UISW.js → chunk-SRJ4XWOR.js} +10 -5
  60. package/dist/{chunk-6RJVTUWI.js → chunk-T6UOCF5D.js} +5 -1
  61. package/dist/{chunk-VTQL23UM.js → chunk-TVNWAEJR.js} +1 -1
  62. package/dist/chunk-TY4KIVA6.js +50 -0
  63. package/dist/{chunk-UT2TYK2A.js → chunk-TYTVAFGB.js} +1 -1
  64. package/dist/{chunk-OMZYPQVA.js → chunk-UGYFQF6M.js} +1 -1
  65. package/dist/{chunk-TYF4GJR3.js → chunk-UIKN3CDF.js} +4 -4
  66. package/dist/{chunk-JGDIO2NF.js → chunk-UO3KYTBU.js} +1 -1
  67. package/dist/{chunk-KI7C6ZOD.js → chunk-VIJ7GDKI.js} +1 -1
  68. package/dist/{chunk-NKFKOEYX.js → chunk-WCMHJ6SS.js} +1 -1
  69. package/dist/{chunk-EORRZP3F.js → chunk-WX2OTJXL.js} +1 -1
  70. package/dist/{chunk-BOV4K7FP.js → chunk-WXTHKLNH.js} +9 -1
  71. package/dist/{chunk-CRQORMFF.js → chunk-X37FSYAX.js} +1 -1
  72. package/dist/{chunk-JQCRCDOC.js → chunk-X7E34LKV.js} +15 -15
  73. package/dist/chunk-X7HMDZZQ.js +85 -0
  74. package/dist/{chunk-B4GQTZMT.js → chunk-YDTJ7UBG.js} +4 -4
  75. package/dist/{chunk-K56D3X7S.js → chunk-YKOXJQGX.js} +34 -2
  76. package/dist/{chunk-3GCIXKCI.js → chunk-YLOJWSHB.js} +9 -5
  77. package/dist/{chunk-GKZYTPN2.js → chunk-YMEMN5FG.js} +1 -1
  78. package/dist/chunk-YQNK7HK3.js +87 -0
  79. package/dist/{chunk-M4AIK2SP.js → chunk-Z265MCGC.js} +15 -11
  80. package/dist/{chunk-FTAEPAVY.js → chunk-ZF36LULR.js} +4 -4
  81. package/dist/{chunk-66BNE332.js → chunk-ZJDPYOTK.js} +4 -4
  82. package/dist/{chunk-RM5QMOFY.js → chunk-ZKPQ4KLK.js} +1 -1
  83. package/dist/command-panel-runtime.js +34 -33
  84. package/dist/compact-cache-command-runtime.js +56 -55
  85. package/dist/compact-preflight-runtime.js +21 -21
  86. package/dist/connector-runtime.js +36 -35
  87. package/dist/deep-compact-runtime.js +6 -6
  88. package/dist/deferred-tools-catalog.js +5 -5
  89. package/dist/details-status-runtime.js +34 -33
  90. package/dist/evidence-runtime.d.ts.map +1 -1
  91. package/dist/evidence-runtime.js +12 -12
  92. package/dist/extension-command-runtime.js +7 -7
  93. package/dist/extension-slash-runtime.js +35 -34
  94. package/dist/failure-learning-command-runtime.js +36 -35
  95. package/dist/failure-learning-presenter.js +4 -4
  96. package/dist/failure-learning-runtime.js +3 -3
  97. package/dist/final-answer-gate.js +2 -2
  98. package/dist/git-command-runtime.js +35 -34
  99. package/dist/handoff-session-runtime.js +8 -8
  100. package/dist/headless-bench-runtime.d.ts +108 -0
  101. package/dist/headless-bench-runtime.d.ts.map +1 -0
  102. package/dist/headless-bench-runtime.js +30 -0
  103. package/dist/index-result-presenter.js +5 -5
  104. package/dist/index-runtime.js +5 -5
  105. package/dist/index.d.ts +31 -0
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +531 -78
  108. package/dist/job-agent-command-runtime.d.ts +2 -1
  109. package/dist/job-agent-command-runtime.d.ts.map +1 -1
  110. package/dist/job-agent-command-runtime.js +34 -33
  111. package/dist/job-runner-presenter.js +3 -3
  112. package/dist/job-runtime.js +9 -9
  113. package/dist/mcp-index-command-runtime.js +5 -5
  114. package/dist/mcp-index-runtime.js +39 -38
  115. package/dist/mcp-sse-runtime.js +3 -3
  116. package/dist/mcp-stdio-runtime.js +4 -4
  117. package/dist/memory-command-runtime.js +36 -35
  118. package/dist/memory-extraction-runtime.js +3 -3
  119. package/dist/memory-rules-runtime.js +3 -3
  120. package/dist/meta-scheduler-runtime.d.ts +10 -0
  121. package/dist/meta-scheduler-runtime.d.ts.map +1 -1
  122. package/dist/meta-scheduler-runtime.js +2 -1
  123. package/dist/model-command-runtime.js +35 -34
  124. package/dist/model-loop-runtime.d.ts +1 -1
  125. package/dist/model-loop-runtime.d.ts.map +1 -1
  126. package/dist/model-loop-runtime.js +1 -1
  127. package/dist/model-prompt-runtime.d.ts.map +1 -1
  128. package/dist/model-prompt-runtime.js +10 -10
  129. package/dist/model-stream-runtime.d.ts +4 -0
  130. package/dist/model-stream-runtime.d.ts.map +1 -1
  131. package/dist/model-stream-runtime.js +56 -55
  132. package/dist/model-tool-runtime.d.ts +3 -2
  133. package/dist/model-tool-runtime.d.ts.map +1 -1
  134. package/dist/model-tool-runtime.js +58 -55
  135. package/dist/pending-details-presenter.js +3 -3
  136. package/dist/permission-approval-runtime.js +56 -55
  137. package/dist/permission-continuation-runtime.d.ts.map +1 -1
  138. package/dist/permission-continuation-runtime.js +4 -4
  139. package/dist/process-command-runtime.d.ts.map +1 -1
  140. package/dist/process-command-runtime.js +4 -4
  141. package/dist/process-guard.d.ts +3 -0
  142. package/dist/process-guard.d.ts.map +1 -1
  143. package/dist/process-guard.js +1 -1
  144. package/dist/provider-loop-runtime.js +3 -3
  145. package/dist/remote-command-runtime.js +35 -34
  146. package/dist/runner-runtime.js +8 -8
  147. package/dist/runtime-status-presenter.js +3 -3
  148. package/dist/runtime-status-snapshot.js +4 -4
  149. package/dist/shell/components/AgentProgressTree.js +2 -2
  150. package/dist/shell/components/BackgroundTaskOverlay.js +2 -2
  151. package/dist/shell/components/BtwPanel.js +2 -2
  152. package/dist/shell/components/CommandPanel.js +2 -2
  153. package/dist/shell/components/Composer.d.ts +16 -2
  154. package/dist/shell/components/Composer.d.ts.map +1 -1
  155. package/dist/shell/components/Composer.js +9 -7
  156. package/dist/shell/components/ConfigPanel.js +2 -2
  157. package/dist/shell/components/HelpPanel.js +2 -2
  158. package/dist/shell/components/HistorySearchPanel.js +2 -2
  159. package/dist/shell/components/MessageMarkdown.d.ts +23 -0
  160. package/dist/shell/components/MessageMarkdown.d.ts.map +1 -1
  161. package/dist/shell/components/MessageMarkdown.js +5 -3
  162. package/dist/shell/components/MouseInputRouter.js +5 -80
  163. package/dist/shell/components/OutputLine.d.ts.map +1 -1
  164. package/dist/shell/components/OutputLine.js +5 -3
  165. package/dist/shell/components/ProductBlock.d.ts.map +1 -1
  166. package/dist/shell/components/ProductBlock.js +5 -5
  167. package/dist/shell/components/ScrollViewport.js +3 -82
  168. package/dist/shell/components/SessionsPanel.js +2 -2
  169. package/dist/shell/components/ShellApp.d.ts.map +1 -1
  170. package/dist/shell/components/ShellApp.js +29 -24
  171. package/dist/shell/components/SlashSuggestions.js +2 -2
  172. package/dist/shell/components/StatusFooter.js +2 -2
  173. package/dist/shell/components/StatusTray.d.ts.map +1 -1
  174. package/dist/shell/components/StatusTray.js +2 -1
  175. package/dist/shell/components/StructuredDiff.js +2 -2
  176. package/dist/shell/components/TaskListView.js +2 -2
  177. package/dist/shell/components/TaskSuggestionBar.js +2 -2
  178. package/dist/shell/components/WorkflowProgressView.js +2 -2
  179. package/dist/shell/components/useAnchoredCursor.d.ts +6 -9
  180. package/dist/shell/components/useAnchoredCursor.d.ts.map +1 -1
  181. package/dist/shell/components/useAnchoredCursor.js +1 -1
  182. package/dist/shell/ink-renderer.d.ts.map +1 -1
  183. package/dist/shell/ink-renderer.js +29 -24
  184. package/dist/shell/models/transcript-selection-state.js +2 -2
  185. package/dist/shell/plain-renderer.d.ts.map +1 -1
  186. package/dist/shell/plain-renderer.js +2 -2
  187. package/dist/shell/text-utils.d.ts +16 -0
  188. package/dist/shell/text-utils.d.ts.map +1 -1
  189. package/dist/shell/text-utils.js +3 -1
  190. package/dist/shell/view-model.js +14 -14
  191. package/dist/slash-command-runtime.js +56 -55
  192. package/dist/slash-dispatch.js +4 -4
  193. package/dist/startup-runtime.js +2 -2
  194. package/dist/tool-output-presenter.d.ts.map +1 -1
  195. package/dist/tool-output-presenter.js +1 -1
  196. package/dist/tui-agent-job-runtime.js +11 -11
  197. package/dist/tui-data-types.d.ts +10 -0
  198. package/dist/tui-data-types.d.ts.map +1 -1
  199. package/dist/tui-details-runtime.js +10 -10
  200. package/dist/tui-memory-runtime.js +5 -5
  201. package/dist/tui-output-surface.js +15 -15
  202. package/dist/tui-permission-runtime.js +5 -5
  203. package/dist/tui-state-runtime.js +4 -4
  204. package/dist/verification-command-runtime.js +12 -12
  205. package/dist/workflow-command-runtime.d.ts.map +1 -1
  206. package/dist/workflow-command-runtime.js +34 -33
  207. package/package.json +5 -5
  208. package/dist/chunk-GW5YDCRZ.js +0 -42
package/dist/index.js CHANGED
@@ -13,10 +13,10 @@ import {
13
13
  } from "./chunk-O7EFPSMC.js";
14
14
  import {
15
15
  handleAppsCommand
16
- } from "./chunk-JDWXC2OQ.js";
16
+ } from "./chunk-3MRYQO7X.js";
17
17
  import {
18
18
  handleCapabilitiesCommand
19
- } from "./chunk-QB4VWH7W.js";
19
+ } from "./chunk-HPQ2IHOW.js";
20
20
  import {
21
21
  __testFormatStartAgentDidNotStartMessage,
22
22
  __testParseRunWorkflowToolInput,
@@ -28,9 +28,11 @@ import {
28
28
  __testUpdateCommandPanelSelection,
29
29
  addAllowRuleForTest,
30
30
  cancelPendingInteraction,
31
+ clearRequestActivity,
31
32
  configureSlashCommandRuntime,
32
33
  confirmPendingInteraction,
33
34
  cycleMode,
35
+ evaluateAggregatedFinalAnswerGate,
34
36
  executePermissionApprove,
35
37
  executePermissionDeny,
36
38
  getWorkspaceTrustCommandGuard,
@@ -79,7 +81,7 @@ import {
79
81
  toggleCommandPanelSelection,
80
82
  updateCommandPanelSelection,
81
83
  writeWorkspaceTrustStartupNotice
82
- } from "./chunk-4WHZ6JKD.js";
84
+ } from "./chunk-7R4YXN7Z.js";
83
85
  import {
84
86
  createCommandBlock,
85
87
  createUserTextBlock
@@ -87,7 +89,7 @@ import {
87
89
  import {
88
90
  computeHomePromptPrefix,
89
91
  writePlainShell
90
- } from "./chunk-IN42UISW.js";
92
+ } from "./chunk-SRJ4XWOR.js";
91
93
  import "./chunk-GC55DMZV.js";
92
94
  import "./chunk-DICVLZHH.js";
93
95
  import {
@@ -97,8 +99,8 @@ import {
97
99
  formatTerminalProblemsPanel,
98
100
  formatTerminalReadinessStatus
99
101
  } from "./chunk-ZYSN7AWW.js";
100
- import "./chunk-RM5QMOFY.js";
101
- import "./chunk-WKMBK5UP.js";
102
+ import "./chunk-ZKPQ4KLK.js";
103
+ import "./chunk-4TO2LDMP.js";
102
104
  import {
103
105
  consumeRemoteInboundMessage,
104
106
  createRemoteEvent,
@@ -108,25 +110,25 @@ import {
108
110
  sendRemoteEventReal,
109
111
  validateRemoteInboundEnvelope,
110
112
  validateRemotePairingEnvelope
111
- } from "./chunk-66BNE332.js";
113
+ } from "./chunk-ZJDPYOTK.js";
112
114
  import "./chunk-UT5BOJKU.js";
113
115
  import "./chunk-RM5JDRCW.js";
114
116
  import {
115
117
  formatPendingApprovalDetails
116
- } from "./chunk-QTDGRZMZ.js";
118
+ } from "./chunk-HJOC5WUV.js";
117
119
  import {
118
120
  handleMemoryCommand,
119
121
  resumeSessionWithHandoff,
120
122
  runAutoLearningOnTurnEnd
121
- } from "./chunk-GMUCSNUD.js";
122
- import "./chunk-VTQL23UM.js";
123
- import "./chunk-DNQN74CC.js";
123
+ } from "./chunk-FGGY5KNM.js";
124
+ import "./chunk-TVNWAEJR.js";
125
+ import "./chunk-NL4M3V5D.js";
124
126
  import "./chunk-KQJHVJZB.js";
125
127
  import {
126
128
  handleModelCommand,
127
129
  handleModelSetupInput,
128
130
  startModelSetup
129
- } from "./chunk-D7TCSOAZ.js";
131
+ } from "./chunk-7BHMBWG2.js";
130
132
  import "./chunk-NMNOAFFT.js";
131
133
  import {
132
134
  executeExtraTool,
@@ -137,13 +139,13 @@ import {
137
139
  handleIndexCommand,
138
140
  handleMcpCommand,
139
141
  refreshIndexStatus
140
- } from "./chunk-JQCRCDOC.js";
142
+ } from "./chunk-X7E34LKV.js";
141
143
  import "./chunk-W6NU7ZAV.js";
142
- import "./chunk-OF3K3CU5.js";
143
- import "./chunk-SRZIA6B4.js";
144
144
  import {
145
145
  isPotentiallyMutatingMcpTool
146
- } from "./chunk-OEYW3JE3.js";
146
+ } from "./chunk-DIDRFIIW.js";
147
+ import "./chunk-O2U4XQVM.js";
148
+ import "./chunk-BNC4F63N.js";
147
149
  import {
148
150
  formatProviderGuardSummary,
149
151
  formatRunnerGuardSummary,
@@ -153,23 +155,23 @@ import {
153
155
  validateChangeDeclarationHuman,
154
156
  validateCompletionClaim
155
157
  } from "./chunk-CRW3636S.js";
156
- import "./chunk-W3KHJNSH.js";
157
- import "./chunk-P277M7Z5.js";
158
+ import "./chunk-6CHUZ2NF.js";
159
+ import "./chunk-LBC75QAB.js";
158
160
  import {
159
161
  handleCheckpointCommand,
160
162
  handleGitCommand,
161
163
  handleWorktreeCommand
162
- } from "./chunk-GKZYTPN2.js";
164
+ } from "./chunk-YMEMN5FG.js";
163
165
  import "./chunk-GTP2KPLY.js";
164
166
  import "./chunk-7ZE5JFAZ.js";
165
167
  import {
166
168
  handlePluginsCommand,
167
169
  handleSkillsCommand
168
- } from "./chunk-FTAEPAVY.js";
170
+ } from "./chunk-ZF36LULR.js";
169
171
  import {
170
172
  handleFailuresCommand
171
- } from "./chunk-2FVEKTKN.js";
172
- import "./chunk-X7A22JHP.js";
173
+ } from "./chunk-3PG7I3LA.js";
174
+ import "./chunk-A4H3UTJZ.js";
173
175
  import {
174
176
  startFeishuLongConnection
175
177
  } from "./chunk-WJWYRBWH.js";
@@ -186,14 +188,14 @@ import {
186
188
  processRemoteBindCommand,
187
189
  wecomBridgeAdapter
188
190
  } from "./chunk-CFXB5SE5.js";
189
- import "./chunk-WHFDDZHY.js";
191
+ import "./chunk-5IFNLTOF.js";
190
192
  import {
191
193
  breakCacheTestHooks
192
194
  } from "./chunk-WVAQYKGL.js";
193
195
  import "./chunk-QIU3FJPC.js";
194
196
  import {
195
197
  writeLightHintsForTest
196
- } from "./chunk-LDABZV5V.js";
198
+ } from "./chunk-7RZE45OT.js";
197
199
  import {
198
200
  __testBuildExplicitDetailsCommandPanel,
199
201
  __testCreateShellBlockOutput,
@@ -219,37 +221,37 @@ import {
219
221
  showCommandPanel,
220
222
  t,
221
223
  writeStatus
222
- } from "./chunk-JO5ANTMR.js";
223
- import "./chunk-WQMSRO4D.js";
224
+ } from "./chunk-PPUOHBAK.js";
224
225
  import "./chunk-V7GDHHBL.js";
225
226
  import "./chunk-GCMH5P4W.js";
226
- import "./chunk-THZBFYAH.js";
227
- import {
228
- ShellBlockOutput
229
- } from "./chunk-ECFLCY5V.js";
230
227
  import {
231
228
  addAllowRule,
232
229
  decidePermission,
233
230
  loadPermissionState
234
- } from "./chunk-DDXS2RDZ.js";
231
+ } from "./chunk-HGCTHBUY.js";
232
+ import "./chunk-CJRJR7TP.js";
233
+ import {
234
+ cleanupCompletedBackgroundTasks,
235
+ getDurableJobPaths
236
+ } from "./chunk-OSFBVVEP.js";
237
+ import "./chunk-JY3LI63F.js";
238
+ import {
239
+ ShellBlockOutput
240
+ } from "./chunk-HPIHFENG.js";
235
241
  import {
236
242
  formatCatalogHelp,
237
243
  formatSlashDiscovery,
238
244
  formatUnknownSlashCommand,
239
245
  getSlashPrefixCandidates,
240
246
  slashCommandToTool
241
- } from "./chunk-4K6UB524.js";
247
+ } from "./chunk-IPZZGDUU.js";
242
248
  import {
243
249
  createTerminalReadinessView
244
250
  } from "./chunk-PBIPV4LD.js";
245
- import {
246
- cleanupCompletedBackgroundTasks,
247
- getDurableJobPaths
248
- } from "./chunk-ZZ2CNCXJ.js";
249
251
  import {
250
252
  getDurableJobsRoot
251
- } from "./chunk-TYF4GJR3.js";
252
- import "./chunk-B4GQTZMT.js";
253
+ } from "./chunk-UIKN3CDF.js";
254
+ import "./chunk-YDTJ7UBG.js";
253
255
  import "./chunk-L4XXW6Y5.js";
254
256
  import {
255
257
  classifyProviderVerificationLevel,
@@ -269,16 +271,26 @@ import {
269
271
  formatRuntimePathMarker,
270
272
  formatStartupPathMarker
271
273
  } from "./chunk-VIBENDE3.js";
274
+ import {
275
+ collectHeadlessArtifactChecklist,
276
+ createHeadlessBenchInitialPrompt,
277
+ createHeadlessBenchRepairPrompt,
278
+ resolveHeadlessBenchConfig,
279
+ runHeadlessEnvironmentPreflight,
280
+ validateHeadlessBenchCompletion
281
+ } from "./chunk-4UER2AKI.js";
272
282
  import {
273
283
  formatConfigOverview,
274
284
  formatFeaturePolicy,
275
285
  validateExtensionContributionExecution
276
- } from "./chunk-LVIM2PA7.js";
277
- import "./chunk-RVY34HK4.js";
286
+ } from "./chunk-AGI6GFFL.js";
287
+ import "./chunk-HZ5XNKWS.js";
278
288
  import {
289
+ getTrackedProcessSnapshot,
279
290
  installProcessGuardExitHandlers,
280
- requestTrackedProcessStop
281
- } from "./chunk-JHGWGH2C.js";
291
+ requestTrackedProcessStop,
292
+ trackChildProcess
293
+ } from "./chunk-J6CYFWSW.js";
282
294
  import "./chunk-E72U7WW7.js";
283
295
  import {
284
296
  buildConfigPanelActions,
@@ -286,12 +298,12 @@ import {
286
298
  createShellViewModel,
287
299
  mapPendingApprovalToPermission,
288
300
  mapRequestActivityToView
289
- } from "./chunk-AKPXMCVF.js";
301
+ } from "./chunk-EKYXI6C7.js";
290
302
  import {
291
303
  buildTranscriptScreenBuffer,
292
304
  isSelectionStale,
293
305
  reduceTranscriptSelection
294
- } from "./chunk-NKFKOEYX.js";
306
+ } from "./chunk-WCMHJ6SS.js";
295
307
  import "./chunk-3AKXDMVS.js";
296
308
  import "./chunk-H3T4EF5F.js";
297
309
  import "./chunk-NSIKYD3X.js";
@@ -302,16 +314,16 @@ import {
302
314
  import {
303
315
  messages
304
316
  } from "./chunk-RBOQJFIZ.js";
305
- import "./chunk-KI7C6ZOD.js";
317
+ import "./chunk-VIJ7GDKI.js";
306
318
  import {
307
319
  createModelSystemPrompt,
308
320
  sanitizeMainScreenLeakage
309
- } from "./chunk-3GCIXKCI.js";
310
- import "./chunk-J7ZE2JKP.js";
311
- import "./chunk-BOV4K7FP.js";
321
+ } from "./chunk-YLOJWSHB.js";
322
+ import "./chunk-42ZZUF7P.js";
323
+ import "./chunk-WXTHKLNH.js";
312
324
  import "./chunk-KTWV5JC5.js";
313
325
  import "./chunk-PGNALDEH.js";
314
- import "./chunk-UDQT5CWK.js";
326
+ import "./chunk-PI6T2AGS.js";
315
327
  import {
316
328
  loadProjectKeybindings
317
329
  } from "./chunk-6SMM5CMP.js";
@@ -329,11 +341,12 @@ import {
329
341
  snapshotDeferredToolsSummary,
330
342
  snapshotDiscoveredDeferredToolsSummary,
331
343
  validateCodebaseMemoryToolExecution
332
- } from "./chunk-I3NTAIMF.js";
344
+ } from "./chunk-6DBBXNEG.js";
333
345
  import {
334
- appendSystemEvent
335
- } from "./chunk-64MJP6FK.js";
336
- import "./chunk-O7S3HYE6.js";
346
+ appendSystemEvent,
347
+ createEvidenceRecord,
348
+ rememberEvidence
349
+ } from "./chunk-NK4NMYF5.js";
337
350
  import {
338
351
  BACKGROUND_KIND_CAPS,
339
352
  BACKGROUND_RUNNING_GLOBAL_CAP,
@@ -361,6 +374,7 @@ import {
361
374
  createSingleToolCallContinuation,
362
375
  runtimeFromContinuation
363
376
  } from "./chunk-RDGM4RUE.js";
377
+ import "./chunk-O7S3HYE6.js";
364
378
  import {
365
379
  LINGHUN_BASH_MAX_OUTPUT_DEFAULT,
366
380
  LINGHUN_BASH_MAX_OUTPUT_UPPER_LIMIT,
@@ -378,13 +392,13 @@ import {
378
392
  LINGHUN_TASK_MAX_OUTPUT_DEFAULT,
379
393
  LINGHUN_TASK_MAX_OUTPUT_UPPER_LIMIT
380
394
  } from "./chunk-IWUIOLMF.js";
381
- import "./chunk-MLUIOBKL.js";
395
+ import "./chunk-7ZMDQZ22.js";
382
396
  import {
383
397
  containsSecret
384
- } from "./chunk-LQTVYUT3.js";
398
+ } from "./chunk-OJTMM5CV.js";
385
399
  import {
386
400
  createSolutionCompletenessStatus
387
- } from "./chunk-K56D3X7S.js";
401
+ } from "./chunk-YKOXJQGX.js";
388
402
  import "./chunk-BFVPLGAC.js";
389
403
  import "./chunk-6USL33ZO.js";
390
404
  import "./chunk-4EIC5BCT.js";
@@ -392,11 +406,11 @@ import "./chunk-AO4CXI37.js";
392
406
  import {
393
407
  createFailureLearningState,
394
408
  loadFailureRecords
395
- } from "./chunk-GDQQNPBP.js";
396
- import "./chunk-RMLTVKOY.js";
409
+ } from "./chunk-6GXIGN5W.js";
410
+ import "./chunk-L4YVE3RG.js";
397
411
  import {
398
412
  createIndexState
399
- } from "./chunk-UT2TYK2A.js";
413
+ } from "./chunk-TYTVAFGB.js";
400
414
  import {
401
415
  applyRemoteSessionDisables,
402
416
  codebaseMemoryRequiredArgs,
@@ -415,11 +429,11 @@ import {
415
429
  pathExists,
416
430
  stableId,
417
431
  summarizeProjectRules
418
- } from "./chunk-QLRTQHTR.js";
432
+ } from "./chunk-6JGRNES6.js";
419
433
  import "./chunk-ZJK25VFP.js";
420
434
  import "./chunk-5H7RRF7C.js";
421
435
  import "./chunk-4EP3TUFF.js";
422
- import "./chunk-EORRZP3F.js";
436
+ import "./chunk-WX2OTJXL.js";
423
437
  import {
424
438
  formatStats,
425
439
  formatUsage
@@ -443,7 +457,7 @@ import "./chunk-WV6YJGZR.js";
443
457
  import "./chunk-4T5DJW54.js";
444
458
  import {
445
459
  createAgentCompletionState
446
- } from "./chunk-SYBNJZEL.js";
460
+ } from "./chunk-HPMBSOQ4.js";
447
461
  import {
448
462
  createShellLimitations,
449
463
  formatError,
@@ -456,8 +470,8 @@ import {
456
470
  shouldEnterProductShellCandidate,
457
471
  truncateDisplay,
458
472
  writeLine
459
- } from "./chunk-OMZYPQVA.js";
460
- import "./chunk-APJIC2O5.js";
473
+ } from "./chunk-UGYFQF6M.js";
474
+ import "./chunk-GTIZNO5O.js";
461
475
  import {
462
476
  loadAgentRegistry,
463
477
  loadWorkflowRegistry,
@@ -510,6 +524,11 @@ import {
510
524
  createToolContext
511
525
  } from "@linghun/tools";
512
526
  var tuiStatus = "ready";
527
+ var DEFAULT_HEADLESS_MAX_CONTINUATIONS = 3;
528
+ var MAX_HEADLESS_CONTINUATIONS = 3;
529
+ var HEADLESS_CONTINUATION_BACKOFF_BASE_MS = 250;
530
+ var HEADLESS_CLEANUP_SETTLE_MS = 500;
531
+ var HEADLESS_DEADLINE_CLOSURE_WINDOW_MS = 6e4;
513
532
  async function createAgentRegistryState(projectPath) {
514
533
  const result = await loadAgentRegistry(projectPath);
515
534
  return { agents: result.items, errors: result.errors };
@@ -550,11 +569,7 @@ function toggleCurrentCommandPanelDetails(context) {
550
569
  context.ctrlOExpandState = { active: false };
551
570
  return true;
552
571
  }
553
- async function runTui(options = {}) {
554
- const input = options.stdin ?? defaultStdin;
555
- const output = options.stdout ?? defaultStdout;
556
- const errorOutput = options.stderr ?? defaultStderr;
557
- const projectPath = options.projectPath ?? process.cwd();
572
+ async function createTuiRuntimeContext(projectPath) {
558
573
  const config = await loadConfig(projectPath);
559
574
  const storagePaths = resolveStoragePaths(config, projectPath);
560
575
  const store = new SessionStore({ sessionRootDir: storagePaths.sessions, projectPath });
@@ -600,6 +615,7 @@ async function runTui(options = {}) {
600
615
  backgroundAbortControllers: /* @__PURE__ */ new Map(),
601
616
  discoveredDeferredToolNames: /* @__PURE__ */ new Set()
602
617
  };
618
+ context.tools.trackChildProcess = (child, options) => trackChildProcess(child, options);
603
619
  context.turnContinuity = createInitialContinuityState();
604
620
  context.recentTaskKinds = [];
605
621
  context.workflows.templates = mergeWorkflowTemplates(
@@ -607,8 +623,9 @@ async function runTui(options = {}) {
607
623
  context.agentRegistry.agents.map(registryAgentToWorkflowTemplate),
608
624
  context.workflowRegistry.workflows.map(registryWorkflowToTemplate)
609
625
  );
610
- installProcessGuardExitHandlers();
611
- const startup = await prepareTuiStartup(input, output, context);
626
+ return { context, store };
627
+ }
628
+ async function hydrateRuntimeContext(context) {
612
629
  await refreshIndexStatus(context);
613
630
  await hydrateDurableJobBackgroundTasks(context);
614
631
  await hydratePersistentAgents(context);
@@ -617,8 +634,8 @@ async function runTui(options = {}) {
617
634
  context.store.prune(50).catch(() => {
618
635
  });
619
636
  context.failureLearning.records = await loadFailureRecords(context.failureLearning);
620
- const gateway = createModelGateway(context.config);
621
- context.modelGateway = gateway;
637
+ }
638
+ function attachProviderRuntimeHooks(context) {
622
639
  registerProviderHooks({
623
640
  onRetry: (info) => {
624
641
  if (info.requestContext === "agent") return;
@@ -632,6 +649,19 @@ async function runTui(options = {}) {
632
649
  }
633
650
  });
634
651
  context.pushNotification = (text, tone) => pushTransientNotification(context, text, tone);
652
+ }
653
+ async function runTui(options = {}) {
654
+ const input = options.stdin ?? defaultStdin;
655
+ const output = options.stdout ?? defaultStdout;
656
+ const errorOutput = options.stderr ?? defaultStderr;
657
+ const projectPath = options.projectPath ?? process.cwd();
658
+ const { context, store } = await createTuiRuntimeContext(projectPath);
659
+ installProcessGuardExitHandlers();
660
+ const startup = await prepareTuiStartup(input, output, context);
661
+ await hydrateRuntimeContext(context);
662
+ const gateway = createModelGateway(context.config);
663
+ context.modelGateway = gateway;
664
+ attachProviderRuntimeHooks(context);
635
665
  const sigintHandler = () => {
636
666
  requestTrackedProcessStop(false);
637
667
  void handleInterruptCommand([], context, output).catch((error) => {
@@ -663,6 +693,420 @@ async function runTui(options = {}) {
663
693
  process.removeListener("SIGINT", sigintHandler);
664
694
  }
665
695
  }
696
+ async function runHeadlessTask(options) {
697
+ const output = options.stdout ?? defaultStdout;
698
+ const errorOutput = options.stderr ?? defaultStderr;
699
+ const projectPath = options.projectPath ?? process.cwd();
700
+ const prompt = options.prompt.trim();
701
+ if (!prompt) {
702
+ writeLine(errorOutput, "\u9519\u8BEF\uFF1Aheadless run prompt \u4E0D\u80FD\u4E3A\u7A7A\u3002");
703
+ return 2;
704
+ }
705
+ const runtime = options.__testContext && options.__testStore ? { context: options.__testContext, store: options.__testStore } : await createTuiRuntimeContext(projectPath);
706
+ const { context, store } = runtime;
707
+ context.permissionMode = options.mode ?? "full-access";
708
+ context.planAccepted = false;
709
+ installProcessGuardExitHandlers();
710
+ if (!options.__testSkipHydration) {
711
+ await hydrateRuntimeContext(context);
712
+ }
713
+ const gateway = options.__testGateway ?? createModelGateway(context.config);
714
+ const sendHeadlessMessage = options.__testSendMessage ?? sendMessage;
715
+ context.modelGateway = gateway;
716
+ attachProviderRuntimeHooks(context);
717
+ const maxApprovals = Math.max(0, Math.min(options.maxApprovals ?? 32, 200));
718
+ const autoApprove = options.autoApprove ?? true;
719
+ const maxContinuations = Math.max(
720
+ 0,
721
+ Math.min(options.maxContinuations ?? DEFAULT_HEADLESS_MAX_CONTINUATIONS, MAX_HEADLESS_CONTINUATIONS)
722
+ );
723
+ const deadlineAtMs = resolveHeadlessDeadlineAtMs(options);
724
+ const benchConfig = await resolveHeadlessBenchConfig({
725
+ prompt,
726
+ projectPath,
727
+ ...options.bench ? { options: options.bench } : {}
728
+ });
729
+ const benchPreflight = benchConfig.enabled && benchConfig.preflight ? await runHeadlessEnvironmentPreflight(projectPath) : void 0;
730
+ if (benchConfig.enabled && benchPreflight) {
731
+ writeLine(output, `[headless] bench preflight: ${benchPreflight.summary}`);
732
+ }
733
+ try {
734
+ let approvals = 0;
735
+ let continuations = 0;
736
+ let requestAttempts = 0;
737
+ let benchValidationPassed = !benchConfig.enabled;
738
+ let lastValidation;
739
+ const runOneRequest = async (text) => {
740
+ requestAttempts += 1;
741
+ const previousProviderFailureId = context.lastProviderFailure?.evidenceId;
742
+ const deferredApprovals = [];
743
+ const messagePromise = sendHeadlessMessage(text, context, gateway, output);
744
+ const pump = createHeadlessApprovalPump({
745
+ context,
746
+ gateway,
747
+ output,
748
+ errorOutput,
749
+ autoApprove,
750
+ maxApprovals,
751
+ getApprovals: () => approvals,
752
+ setApprovals: (value) => {
753
+ approvals = value;
754
+ },
755
+ deferredApprovals
756
+ });
757
+ const messageResult = await runWithHeadlessApprovalPump(messagePromise, pump);
758
+ if (messageResult.exitCode !== void 0) {
759
+ return { exitCode: messageResult.exitCode };
760
+ }
761
+ const approvalStatus = await pumpHeadlessApprovals({
762
+ context,
763
+ gateway,
764
+ output,
765
+ errorOutput,
766
+ autoApprove,
767
+ maxApprovals,
768
+ approvals,
769
+ deferredApprovals
770
+ });
771
+ approvals = approvalStatus.approvals;
772
+ if (approvalStatus.exitCode !== void 0) {
773
+ return { exitCode: approvalStatus.exitCode };
774
+ }
775
+ const deferredStatus = await runDeferredHeadlessApprovals({
776
+ context,
777
+ gateway,
778
+ output,
779
+ errorOutput,
780
+ autoApprove,
781
+ maxApprovals,
782
+ approvals,
783
+ deferredApprovals
784
+ });
785
+ approvals = deferredStatus.approvals;
786
+ if (deferredStatus.exitCode !== void 0) {
787
+ return { exitCode: deferredStatus.exitCode };
788
+ }
789
+ const providerFailure = context.lastProviderFailure;
790
+ const hasNewProviderFailure = Boolean(providerFailure) && providerFailure?.evidenceId !== previousProviderFailureId;
791
+ return { providerFailure: hasNewProviderFailure };
792
+ };
793
+ const initialPrompt = createHeadlessBenchInitialPrompt({
794
+ originalPrompt: prompt,
795
+ config: benchConfig,
796
+ ...benchPreflight ? { preflight: benchPreflight } : {}
797
+ });
798
+ let status = await runOneRequest(initialPrompt);
799
+ while (status.exitCode === void 0 && status.providerFailure && continuations < maxContinuations && shouldRunHeadlessProviderContinuation(context)) {
800
+ continuations += 1;
801
+ const sessionId = await ensureSession(context);
802
+ const continuationPrompt = createHeadlessProviderContinuationPrompt(context);
803
+ await appendSystemEvent(
804
+ context,
805
+ sessionId,
806
+ `headless_provider_stream_continuation: attempt=${continuations}; reason=${context.lastProviderFailure?.summary ?? "provider_failure"}`,
807
+ "warning"
808
+ );
809
+ writeLine(output, `[headless] provider stream failed; continuing attempt ${continuations}/${maxContinuations}`);
810
+ context.lastProviderFailure = void 0;
811
+ await sleep(createHeadlessContinuationBackoffMs(continuations));
812
+ status = await runOneRequest(continuationPrompt);
813
+ }
814
+ if (continuations > 0 && !status.providerFailure) {
815
+ context.lastProviderFailure = void 0;
816
+ }
817
+ if (status.exitCode !== void 0) {
818
+ return status.exitCode;
819
+ }
820
+ if (status.providerFailure) {
821
+ writeLine(
822
+ errorOutput,
823
+ createHeadlessProviderFailureDiagnostic(context, {
824
+ requestAttempts,
825
+ continuations,
826
+ maxContinuations
827
+ })
828
+ );
829
+ return 1;
830
+ }
831
+ if (benchConfig.enabled) {
832
+ for (let repairAttempt = 0; repairAttempt <= benchConfig.maxRepairAttempts; repairAttempt += 1) {
833
+ const validation = await validateHeadlessBenchCompletion({ projectPath, config: benchConfig });
834
+ lastValidation = validation;
835
+ if (validation.ok) {
836
+ benchValidationPassed = true;
837
+ writeLine(output, `[headless] bench validation passed: ${validation.summary}`);
838
+ break;
839
+ }
840
+ const failure = validation.failure;
841
+ writeLine(
842
+ errorOutput,
843
+ `[headless] bench validation failed: ${failure.category}; ${failure.summary.split(/\r?\n/u)[0]}`
844
+ );
845
+ if (repairAttempt >= benchConfig.maxRepairAttempts) {
846
+ writeLine(
847
+ errorOutput,
848
+ `\u9519\u8BEF\uFF1Aheadless bench \u4FEE\u8865\u5DF2\u8FBE\u4E0A\u9650 ${benchConfig.maxRepairAttempts}\uFF0C\u6700\u540E\u5931\u8D25\u7C7B\u522B\uFF1A${failure.category}`
849
+ );
850
+ return 5;
851
+ }
852
+ if (isHeadlessDeadlineApproaching(deadlineAtMs)) {
853
+ const remaining = formatHeadlessRemainingTime(deadlineAtMs);
854
+ writeLine(
855
+ errorOutput,
856
+ `[headless] deadline approaching (${remaining}); closure validation ran, skipping repair loop.`
857
+ );
858
+ return 6;
859
+ }
860
+ const repairPrompt = createHeadlessBenchRepairPrompt({
861
+ originalPrompt: prompt,
862
+ failure,
863
+ attempt: repairAttempt + 1,
864
+ maxAttempts: benchConfig.maxRepairAttempts,
865
+ profile: benchConfig.profile,
866
+ ...benchPreflight ? { preflight: benchPreflight } : {}
867
+ });
868
+ const repairStatus = await runOneRequest(repairPrompt);
869
+ if (repairStatus.exitCode !== void 0) {
870
+ return repairStatus.exitCode;
871
+ }
872
+ if (repairStatus.providerFailure) {
873
+ writeLine(errorOutput, "\u9519\u8BEF\uFF1Aheadless bench \u4FEE\u8865\u671F\u95F4 provider stream \u5931\u8D25\u3002");
874
+ return 1;
875
+ }
876
+ }
877
+ }
878
+ if (context.sessionId) {
879
+ await recordHeadlessArtifactChecklist(context, context.sessionId, benchConfig, lastValidation);
880
+ }
881
+ const cleanup = await finishHeadlessRuntime(context);
882
+ if (!cleanup.ok) {
883
+ const cleanupMessage = `\u8B66\u544A\uFF1Aheadless run \u6536\u5C3E\u5931\u8D25\uFF1A${cleanup.reason}`;
884
+ writeLine(errorOutput, cleanupMessage);
885
+ if (context.sessionId) {
886
+ await appendSystemEvent(context, context.sessionId, cleanupMessage, "warning").catch(
887
+ () => void 0
888
+ );
889
+ }
890
+ if (benchValidationPassed) {
891
+ writeLine(errorOutput, "\u8B66\u544A\uFF1A\u4EFB\u52A1\u7ED3\u679C\u5DF2\u5B8C\u6210\u4F46\u6E05\u7406\u5931\u8D25\uFF1B\u8FD9\u4E0D\u662F agent \u89E3\u9898\u5931\u8D25\u3002");
892
+ } else {
893
+ return 4;
894
+ }
895
+ }
896
+ if (context.sessionId && !context.sessionEnded) {
897
+ await store.appendEvent(context.sessionId, createSessionEndEvent(context.sessionId));
898
+ context.sessionEnded = true;
899
+ }
900
+ return 0;
901
+ } catch (error) {
902
+ const message = error instanceof Error ? error.message : "headless run \u6267\u884C\u5931\u8D25\u3002";
903
+ writeLine(errorOutput, `\u9519\u8BEF\uFF1A${message}`);
904
+ return 1;
905
+ } finally {
906
+ await finishHeadlessRuntime(context);
907
+ }
908
+ }
909
+ async function pumpHeadlessApprovals(input) {
910
+ let approvals = input.approvals;
911
+ while (input.context.pendingLocalApproval) {
912
+ if (!input.autoApprove) {
913
+ input.context.activeAbortController?.abort();
914
+ writeLine(
915
+ input.errorOutput,
916
+ `\u9519\u8BEF\uFF1Aheadless run \u505C\u5728\u6743\u9650\u786E\u8BA4\uFF1A${input.context.pendingLocalApproval.kind}\u3002\u8BF7\u5F00\u542F --auto-approve \u6216\u6539\u7528\u4EA4\u4E92\u6A21\u5F0F\u3002`
917
+ );
918
+ return { approvals, exitCode: 3 };
919
+ }
920
+ if (approvals >= input.maxApprovals) {
921
+ input.context.activeAbortController?.abort();
922
+ writeLine(
923
+ input.errorOutput,
924
+ `\u9519\u8BEF\uFF1Aheadless run \u81EA\u52A8\u6279\u51C6\u8D85\u8FC7\u4E0A\u9650 ${input.maxApprovals}\uFF0C\u505C\u5728\u6743\u9650\u786E\u8BA4\uFF1A${input.context.pendingLocalApproval.kind}\u3002`
925
+ );
926
+ return { approvals, exitCode: 3 };
927
+ }
928
+ const approval = input.context.pendingLocalApproval;
929
+ input.context.pendingLocalApproval = void 0;
930
+ approvals += 1;
931
+ writeLine(input.output, `[headless] auto-approved ${approval.kind}`);
932
+ if (input.deferredApprovals && hasModelContinuation(approval)) {
933
+ input.deferredApprovals.push(approval);
934
+ continue;
935
+ }
936
+ await executePermissionApprove(approval, input.context, input.gateway, input.output);
937
+ }
938
+ return { approvals };
939
+ }
940
+ async function runDeferredHeadlessApprovals(input) {
941
+ let approvals = input.approvals;
942
+ while (input.deferredApprovals.length > 0) {
943
+ const approval = input.deferredApprovals.shift();
944
+ if (!approval) continue;
945
+ await executePermissionApprove(approval, input.context, input.gateway, input.output);
946
+ const nested = await pumpHeadlessApprovals({
947
+ context: input.context,
948
+ gateway: input.gateway,
949
+ output: input.output,
950
+ errorOutput: input.errorOutput,
951
+ autoApprove: input.autoApprove,
952
+ maxApprovals: input.maxApprovals,
953
+ approvals
954
+ });
955
+ approvals = nested.approvals;
956
+ if (nested.exitCode !== void 0) {
957
+ return { approvals, exitCode: nested.exitCode };
958
+ }
959
+ }
960
+ return { approvals };
961
+ }
962
+ function hasModelContinuation(approval) {
963
+ return "continuation" in approval && Boolean(approval.continuation);
964
+ }
965
+ function createHeadlessApprovalPump(input) {
966
+ let running;
967
+ return async () => {
968
+ if (running) return running;
969
+ running = pumpHeadlessApprovals({
970
+ context: input.context,
971
+ gateway: input.gateway,
972
+ output: input.output,
973
+ errorOutput: input.errorOutput,
974
+ autoApprove: input.autoApprove,
975
+ maxApprovals: input.maxApprovals,
976
+ approvals: input.getApprovals(),
977
+ deferredApprovals: input.deferredApprovals
978
+ }).then((result) => {
979
+ input.setApprovals(result.approvals);
980
+ return result;
981
+ });
982
+ try {
983
+ return await running;
984
+ } finally {
985
+ running = void 0;
986
+ }
987
+ };
988
+ }
989
+ async function runWithHeadlessApprovalPump(messagePromise, pump) {
990
+ let settled = false;
991
+ let exitCode;
992
+ const loop = (async () => {
993
+ while (!settled && exitCode === void 0) {
994
+ const result = await pump();
995
+ exitCode = result.exitCode;
996
+ if (exitCode !== void 0) break;
997
+ await sleep(50);
998
+ }
999
+ })();
1000
+ try {
1001
+ await messagePromise;
1002
+ } finally {
1003
+ settled = true;
1004
+ await loop;
1005
+ }
1006
+ return exitCode !== void 0 ? { exitCode } : {};
1007
+ }
1008
+ function sleep(ms) {
1009
+ return new Promise((resolveSleep) => setTimeout(resolveSleep, ms));
1010
+ }
1011
+ function createHeadlessContinuationBackoffMs(attempt) {
1012
+ return Math.min(HEADLESS_CONTINUATION_BACKOFF_BASE_MS * 2 ** Math.max(0, attempt - 1), 1500);
1013
+ }
1014
+ function resolveHeadlessDeadlineAtMs(options) {
1015
+ if (typeof options.deadlineAtMs === "number" && Number.isFinite(options.deadlineAtMs)) {
1016
+ return options.deadlineAtMs;
1017
+ }
1018
+ if (typeof options.deadlineMs === "number" && Number.isFinite(options.deadlineMs)) {
1019
+ return Date.now() + Math.max(0, options.deadlineMs);
1020
+ }
1021
+ const envDeadlineAt = Number.parseInt(process.env.LINGHUN_HEADLESS_DEADLINE_AT_MS ?? "", 10);
1022
+ if (Number.isFinite(envDeadlineAt) && envDeadlineAt > 0) {
1023
+ return envDeadlineAt;
1024
+ }
1025
+ return void 0;
1026
+ }
1027
+ function isHeadlessDeadlineApproaching(deadlineAtMs) {
1028
+ return deadlineAtMs !== void 0 && deadlineAtMs - Date.now() <= HEADLESS_DEADLINE_CLOSURE_WINDOW_MS;
1029
+ }
1030
+ function formatHeadlessRemainingTime(deadlineAtMs) {
1031
+ if (deadlineAtMs === void 0) return "unknown";
1032
+ return `${Math.max(0, Math.ceil((deadlineAtMs - Date.now()) / 1e3))}s remaining`;
1033
+ }
1034
+ function shouldRunHeadlessProviderContinuation(context) {
1035
+ return context.evidence.some((record) => !record.supportsClaims.includes("provider_failure")) || context.tools.changedFiles.length > 0;
1036
+ }
1037
+ async function recordHeadlessArtifactChecklist(context, sessionId, config, lastValidation) {
1038
+ const checklist = await collectHeadlessArtifactChecklist({
1039
+ projectPath: context.projectPath,
1040
+ config,
1041
+ changedFiles: context.tools.changedFiles,
1042
+ ...lastValidation ? { lastValidation } : {}
1043
+ });
1044
+ const evidence = createEvidenceRecord(
1045
+ "command_output",
1046
+ `headless artifact checklist: ${checklist.summary}`,
1047
+ "headless:artifact-checklist",
1048
+ [
1049
+ "headless_artifact_checklist",
1050
+ checklist.verificationRan ? "verification_ran" : "verification_not_run",
1051
+ checklist.changedFiles.length > 0 ? "file_written" : "no_file_changes"
1052
+ ]
1053
+ );
1054
+ rememberEvidence(context, evidence);
1055
+ await context.store.appendEvent(sessionId, { type: "evidence_record", ...evidence });
1056
+ await appendSystemEvent(context, sessionId, `headless artifact checklist: ${checklist.summary}`, "info");
1057
+ }
1058
+ var __testHeadlessRuntime = {
1059
+ isDeadlineApproaching: isHeadlessDeadlineApproaching,
1060
+ formatRemainingTime: formatHeadlessRemainingTime
1061
+ };
1062
+ function createHeadlessProviderFailureDiagnostic(context, input) {
1063
+ const failure = context.lastProviderFailure;
1064
+ const lastEvidence = context.evidence.find(
1065
+ (record) => !record.supportsClaims.includes("provider_failure")
1066
+ );
1067
+ const changedFiles = context.tools.changedFiles.length;
1068
+ return [
1069
+ "\u9519\u8BEF\uFF1Aprovider stream \u5931\u8D25\uFF0Cheadless continuation \u5DF2\u8FBE\u4E0A\u9650\u6216\u7F3A\u5C11\u53EF\u6062\u590D\u8BC1\u636E\u3002",
1070
+ `providerKind=${failure?.kind ?? "unknown"}`,
1071
+ `providerCode=${failure?.code ?? "unknown"}`,
1072
+ `attempts=${input.requestAttempts}`,
1073
+ `continuations=${input.continuations}/${input.maxContinuations}`,
1074
+ `lastSuccessfulTool=${lastEvidence?.source ?? "none"}`,
1075
+ `fileChanges=${changedFiles > 0 ? `yes:${changedFiles}` : "no"}`,
1076
+ failure?.summary ? `summary=${failure.summary}` : ""
1077
+ ].filter(Boolean).join(" ");
1078
+ }
1079
+ function createHeadlessProviderContinuationPrompt(context) {
1080
+ return context.language === "en-US" ? "The previous response stream was interrupted. Continue the original task based on the current workspace state, transcript, tool evidence, and any file changes already present. Do not restart from scratch unless needed." : "\u4E0A\u4E00\u8F6E\u54CD\u5E94\u6D41\u4E2D\u65AD\u3002\u8BF7\u57FA\u4E8E\u5F53\u524D\u5DE5\u4F5C\u533A\u72B6\u6001\u3001\u5DF2\u6709 transcript\u3001\u5DE5\u5177\u8BC1\u636E\u548C\u5DF2\u7ECF\u5B58\u5728\u7684\u6587\u4EF6\u6539\u52A8\u7EE7\u7EED\u5B8C\u6210\u539F\u4EFB\u52A1\uFF1B\u9664\u975E\u5FC5\u8981\uFF0C\u4E0D\u8981\u4ECE\u5934\u91CD\u505A\u3002";
1081
+ }
1082
+ async function finishHeadlessRuntime(context) {
1083
+ if (context.pendingLocalApproval) {
1084
+ return { ok: false, reason: `\u4ECD\u6709\u6743\u9650\u786E\u8BA4\u672A\u5904\u7406\uFF1A${context.pendingLocalApproval.kind}` };
1085
+ }
1086
+ if (context.activeAbortController) {
1087
+ context.activeAbortController.abort();
1088
+ }
1089
+ context.tools.abortSignal = void 0;
1090
+ context.interrupt = { type: "idle" };
1091
+ clearRequestActivity(context);
1092
+ context.activeAbortController = void 0;
1093
+ const stopResult = requestTrackedProcessStop(true);
1094
+ await sleep(HEADLESS_CLEANUP_SETTLE_MS);
1095
+ const stillTracked = getTrackedProcessSnapshot();
1096
+ if (stopResult.failures.length > 0) {
1097
+ return {
1098
+ ok: false,
1099
+ reason: `\u6E05\u7406\u672C\u5730\u5B50\u8FDB\u7A0B\u5931\u8D25\uFF1A${stopResult.failures.map((failure) => `${failure.pid}:${failure.message}`).join("; ")}`
1100
+ };
1101
+ }
1102
+ if (stillTracked.length > 0) {
1103
+ return {
1104
+ ok: false,
1105
+ reason: `\u4ECD\u6709\u672C\u5730\u5B50\u8FDB\u7A0B\u672A\u9000\u51FA\uFF1A${stillTracked.map((entry) => `${entry.pid}${entry.label ? `(${entry.label})` : ""}`).join(", ")}`
1106
+ };
1107
+ }
1108
+ return { ok: true };
1109
+ }
666
1110
  var MAX_TOOL_LOG_FILES = 200;
667
1111
  async function cleanStaleToolLogs(context) {
668
1112
  const logsRoot = resolveStoragePaths(context.config, context.projectPath).logs;
@@ -847,14 +1291,17 @@ async function runInkShell(input, output, errorOutput, context, gateway, store,
847
1291
  const controller = {
848
1292
  getViewModel: () => {
849
1293
  const runtime = getSelectedModelRuntime(context);
1294
+ const width = readOutputColumns(output);
1295
+ const height = readOutputRows(output);
1296
+ const activity = mapRequestActivityToView(context);
850
1297
  return createShellViewModel(context, {
851
- width: readOutputColumns(output),
852
- height: readOutputRows(output),
1298
+ width,
1299
+ height,
853
1300
  noColor: isNoColorTerminal(),
854
1301
  setupNeeded: startup.setupNeeded,
855
1302
  projectRouteProblem: startup.projectRouteProblem,
856
1303
  outputBlocks: blocks,
857
- activity: mapRequestActivityToView(context),
1304
+ activity,
858
1305
  permission: mapPendingApprovalToPermission(context),
859
1306
  submitted: submittedPending,
860
1307
  submittedStartedAt: submittedPendingStartedAt,
@@ -1764,8 +2211,11 @@ async function runInkShell(input, output, errorOutput, context, gateway, store,
1764
2211
  cleanupCompletedBackgroundTasks(context);
1765
2212
  const hasAgents = (context.agents ?? []).length > 0;
1766
2213
  const hasWorkflows = (context.workflows?.activeRuns ?? []).length > 0 || Boolean(context.workflows?.activeRun);
1767
- const hasBgTasks = (context.backgroundTasks ?? []).length > 0;
1768
- if (!submittedPending && !context.requestActivityPhase && !context.activeAbortController && !hasAgents && !hasWorkflows && !hasBgTasks) {
2214
+ const hasBgTasks = (context.backgroundTasks ?? []).some((task) => task.status === "running");
2215
+ const hasActiveAbort = Boolean(
2216
+ context.activeAbortController && context.activeAbortController.signal?.aborted !== true
2217
+ );
2218
+ if (!submittedPending && !context.requestActivityPhase && !hasActiveAbort && !hasAgents && !hasWorkflows && !hasBgTasks) {
1769
2219
  return;
1770
2220
  }
1771
2221
  shell?.rerender();
@@ -2220,6 +2670,7 @@ export {
2220
2670
  __testCreateVerificationLevelForReadiness,
2221
2671
  __testFormatStartAgentDidNotStartMessage,
2222
2672
  __testGetCurrentWorkflowStepRequest,
2673
+ __testHeadlessRuntime,
2223
2674
  __testParseRunWorkflowToolInput,
2224
2675
  __testRenderInteractiveChoiceLines,
2225
2676
  __testRunWorkflowStepsWithPlan,
@@ -2273,6 +2724,7 @@ export {
2273
2724
  dingtalkBridgeAdapter,
2274
2725
  dingtalkStreamFrameToBridgeEvent,
2275
2726
  estimateFileMetrics,
2727
+ evaluateAggregatedFinalAnswerGate,
2276
2728
  executeExtraTool,
2277
2729
  executeSearchExtraTools,
2278
2730
  feishuBridgeAdapter,
@@ -2320,6 +2772,7 @@ export {
2320
2772
  recordModelUsage,
2321
2773
  runAutoLearningOnTurnEnd,
2322
2774
  runCommandCaptureForTest,
2775
+ runHeadlessTask,
2323
2776
  runTui,
2324
2777
  runVerificationCommandForTest,
2325
2778
  runtimeFromContinuation,