@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
@@ -47,6 +47,89 @@ function displayWidth(value) {
47
47
  for (const char of value) width += charWidth(char);
48
48
  return width;
49
49
  }
50
+ function computeWrappedInputState(input) {
51
+ const normalizedText = String(input.text ?? "").replace(/\r/g, "");
52
+ const chars = Array.from(normalizedText);
53
+ const cursorOffset = clamp(input.cursorOffset, 0, chars.length);
54
+ const safeWidth = Math.max(0, Math.floor(Number.isFinite(input.width) ? input.width : 0));
55
+ const safePrefixWidth = Math.max(0, Math.floor(input.prefixWidth ?? 0));
56
+ const safePaddingLeft = Math.max(0, Math.floor(input.paddingLeft ?? 0));
57
+ const safePaddingRight = Math.max(0, Math.floor(input.paddingRight ?? 0));
58
+ const safeMinContentWidth = Math.max(0, Math.floor(input.minContentWidth ?? 0));
59
+ const contentWidth = Math.max(
60
+ safeMinContentWidth,
61
+ safeWidth - safePaddingLeft - safePaddingRight
62
+ );
63
+ const firstLineWidth = Math.max(1, contentWidth - safePrefixWidth);
64
+ const wrappedLines = [];
65
+ let cursorRow = 0;
66
+ let cursorCol = 0;
67
+ let cursorResolved = false;
68
+ const logicalLines = normalizedText.split("\n");
69
+ let logicalLineStart = 0;
70
+ let fallbackLineStart = 0;
71
+ let fallbackLineChars = [];
72
+ for (let logicalIndex = 0; logicalIndex < logicalLines.length; logicalIndex += 1) {
73
+ const lineText = logicalLines[logicalIndex] ?? "";
74
+ const lineChars = Array.from(lineText);
75
+ const lineStartOffset = logicalLineStart;
76
+ const lineEndOffset = lineStartOffset + lineChars.length;
77
+ const wrapWidth = logicalIndex === 0 ? firstLineWidth : Math.max(1, contentWidth);
78
+ const segments = wrapInputLine(lineChars, wrapWidth);
79
+ fallbackLineStart = lineStartOffset;
80
+ fallbackLineChars = lineChars;
81
+ for (const segment of segments) {
82
+ const segmentText = lineChars.slice(segment.start, segment.end).join("");
83
+ wrappedLines.push(segmentText);
84
+ if (!cursorResolved && cursorOffset >= lineStartOffset && cursorOffset <= lineEndOffset) {
85
+ const lineCursorOffset = cursorOffset - lineStartOffset;
86
+ if (lineCursorOffset >= segment.start && lineCursorOffset <= segment.end) {
87
+ cursorRow = wrappedLines.length - 1;
88
+ cursorCol = displayWidth(lineChars.slice(segment.start, lineCursorOffset).join(""));
89
+ cursorResolved = true;
90
+ }
91
+ }
92
+ }
93
+ logicalLineStart += lineChars.length + 1;
94
+ }
95
+ if (!cursorResolved) {
96
+ cursorRow = Math.max(0, wrappedLines.length - 1);
97
+ cursorCol = displayWidth(
98
+ fallbackLineChars.slice(0, clamp(cursorOffset - fallbackLineStart, 0, fallbackLineChars.length)).join("")
99
+ );
100
+ if (chars.length === 0) cursorCol = 0;
101
+ }
102
+ return {
103
+ lines: wrappedLines.length > 0 ? wrappedLines : [""],
104
+ cursorRow,
105
+ cursorCol,
106
+ contentWidth
107
+ };
108
+ }
109
+ function wrapInputLine(chars, wrapWidth) {
110
+ const safeWrapWidth = Math.max(1, Math.floor(wrapWidth));
111
+ const segments = [];
112
+ let start = 0;
113
+ while (start < chars.length || chars.length === 0 && start === 0) {
114
+ let end = start;
115
+ let width = 0;
116
+ while (end < chars.length) {
117
+ const nextWidth = charWidth(chars[end] ?? "");
118
+ if (width > 0 && width + nextWidth > safeWrapWidth) break;
119
+ width += nextWidth;
120
+ end += 1;
121
+ }
122
+ if (end === start && chars.length > 0) end += 1;
123
+ segments.push({ start, end });
124
+ if (chars.length === 0) break;
125
+ start = end;
126
+ }
127
+ return segments;
128
+ }
129
+ function clamp(value, min, max) {
130
+ if (!Number.isFinite(value)) return min;
131
+ return Math.min(max, Math.max(min, Math.floor(value)));
132
+ }
50
133
  function truncateDisplay(value, max) {
51
134
  const normalized = String(value || "").replace(/\s+/gu, " ").trim();
52
135
  if (displayWidth(normalized) <= max) return normalized;
@@ -140,6 +223,7 @@ export {
140
223
  wrapText,
141
224
  charWidth,
142
225
  displayWidth,
226
+ computeWrappedInputState,
143
227
  truncateDisplay,
144
228
  truncateMiddle,
145
229
  composerMaxWidth,
@@ -5,7 +5,7 @@ import {
5
5
  fitText,
6
6
  lineChar,
7
7
  wrapText
8
- } from "./chunk-APJIC2O5.js";
8
+ } from "./chunk-GTIZNO5O.js";
9
9
 
10
10
  // src/shell/components/CommandPanel.tsx
11
11
  import { Box, Text } from "@linghun/ink-runtime";
@@ -4,7 +4,7 @@ import {
4
4
  formatPermissionSummary,
5
5
  getHardDenyReason,
6
6
  isPlanAllowedTool
7
- } from "./chunk-J7ZE2JKP.js";
7
+ } from "./chunk-42ZZUF7P.js";
8
8
  import {
9
9
  classifyToolRequest
10
10
  } from "./chunk-LHHKPGLX.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  truncateDisplay
3
- } from "./chunk-OMZYPQVA.js";
3
+ } from "./chunk-UGYFQF6M.js";
4
4
 
5
5
  // src/pending-details-presenter.ts
6
6
  import { relative } from "path";
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  createOutputBlock
3
- } from "./chunk-AKPXMCVF.js";
3
+ } from "./chunk-EKYXI6C7.js";
4
4
  import {
5
5
  writeLine
6
- } from "./chunk-OMZYPQVA.js";
6
+ } from "./chunk-UGYFQF6M.js";
7
7
 
8
8
  // src/tui-output-surface.ts
9
9
  import { createHash, randomUUID } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  truncateDisplay
3
- } from "./chunk-OMZYPQVA.js";
3
+ } from "./chunk-UGYFQF6M.js";
4
4
 
5
5
  // src/agent-completion-finalizer.ts
6
6
  import { randomUUID } from "crypto";
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  ensureSession,
3
3
  showCommandPanel
4
- } from "./chunk-JO5ANTMR.js";
4
+ } from "./chunk-PPUOHBAK.js";
5
5
  import {
6
6
  decidePermission
7
- } from "./chunk-DDXS2RDZ.js";
7
+ } from "./chunk-HGCTHBUY.js";
8
8
  import {
9
9
  appendSystemEvent,
10
10
  budgetToolResultTranscriptContent,
11
11
  createEvidenceRecord,
12
12
  rememberEvidence
13
- } from "./chunk-64MJP6FK.js";
13
+ } from "./chunk-NK4NMYF5.js";
14
14
  import {
15
15
  sanitizeDiagnosticText,
16
16
  truncateDisplay,
17
17
  writeLine
18
- } from "./chunk-OMZYPQVA.js";
18
+ } from "./chunk-UGYFQF6M.js";
19
19
 
20
20
  // src/capability-runtime.ts
21
21
  import { randomUUID } from "crypto";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createProcessGuard
3
- } from "./chunk-JHGWGH2C.js";
3
+ } from "./chunk-J6CYFWSW.js";
4
4
  import {
5
5
  sanitizeDiagnosticText,
6
6
  truncateDisplay
7
- } from "./chunk-OMZYPQVA.js";
7
+ } from "./chunk-UGYFQF6M.js";
8
8
 
9
9
  // src/process-command-runtime.ts
10
10
  import { spawn } from "child_process";
@@ -37,6 +37,9 @@ async function runCommandCapture(command, args, cwd, timeoutMs) {
37
37
  const stderr = [];
38
38
  const timer = setTimeout(() => {
39
39
  guard.requestStop(false);
40
+ setTimeout(() => {
41
+ guard.requestStop(true);
42
+ }, 1e3).unref();
40
43
  resolvePromise({
41
44
  exitCode: 124,
42
45
  stdout: Buffer.concat(stdout).toString("utf8"),
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  formatPermissionModeLabel
3
- } from "./chunk-KI7C6ZOD.js";
3
+ } from "./chunk-VIJ7GDKI.js";
4
4
  import {
5
5
  getUserVisibleCommandCapabilities
6
6
  } from "./chunk-PGNALDEH.js";
@@ -17,9 +17,20 @@ var ProcessGuardRegistry = class {
17
17
  child,
18
18
  pid,
19
19
  detached: options.detached === true,
20
- label: options.label
20
+ label: options.label,
21
+ cwd: options.cwd,
22
+ retainAfterExit: options.retainAfterExit === true,
23
+ childExited: false,
24
+ workspaceSweep: options.workspaceSweep === true
21
25
  });
22
- const cleanup = () => this.untrack(pid);
26
+ const cleanup = () => {
27
+ const entry = this.tracked.get(pid);
28
+ if (!entry) return;
29
+ entry.childExited = true;
30
+ if (!entry.retainAfterExit) {
31
+ this.untrack(pid);
32
+ }
33
+ };
23
34
  child.once("exit", cleanup);
24
35
  child.once("close", cleanup);
25
36
  return true;
@@ -45,11 +56,17 @@ var ProcessGuardRegistry = class {
45
56
  skipped: 0,
46
57
  failures: []
47
58
  };
59
+ const removePids = [];
48
60
  for (const entry of this.tracked.values()) {
49
61
  if (onlyPids && !onlyPids.has(entry.pid)) {
50
62
  continue;
51
63
  }
52
- stopEntry(entry, force, deps, allowAsyncWindowsTreeKill, result);
64
+ if (stopEntry(entry, force, deps, allowAsyncWindowsTreeKill, result)) {
65
+ removePids.push(entry.pid);
66
+ }
67
+ }
68
+ for (const pid of removePids) {
69
+ this.untrack(pid);
53
70
  }
54
71
  return result;
55
72
  }
@@ -127,15 +144,15 @@ function recordStopResult(result) {
127
144
  function stopEntry(entry, force, deps, allowAsyncWindowsTreeKill, result) {
128
145
  if (entry.stopState === "force" || entry.stopState === "graceful" && !force) {
129
146
  result.skipped += 1;
130
- return;
147
+ return false;
131
148
  }
132
149
  entry.stopState = force ? "force" : "graceful";
133
150
  result.attempted += 1;
134
151
  if (deps.platform === "win32" && allowAsyncWindowsTreeKill) {
135
152
  stopWindowsTree(entry, force, deps, result);
136
- return;
153
+ return force;
137
154
  }
138
- stopWithSignal(entry, force, deps, result);
155
+ return stopWithSignal(entry, force, deps, result);
139
156
  }
140
157
  function stopWindowsTree(entry, force, deps, result) {
141
158
  const args = ["/pid", String(entry.pid), "/t"];
@@ -152,19 +169,84 @@ function stopWindowsTree(entry, force, deps, result) {
152
169
  result.failures.push({ pid: entry.pid, message: formatError(error) });
153
170
  stopWithSignal(entry, force, deps, result);
154
171
  }
172
+ if (force && entry.cwd && shouldRunWindowsWorkspaceSweep(entry)) {
173
+ stopWindowsWorkspaceProcesses(entry.pid, entry.cwd, deps);
174
+ }
155
175
  }
156
176
  function stopWithSignal(entry, force, deps, result) {
157
177
  const signal = force ? "SIGKILL" : "SIGTERM";
158
178
  try {
159
179
  if (deps.platform !== "win32" && entry.detached) {
160
180
  deps.kill(-entry.pid, signal);
161
- return;
181
+ return force;
162
182
  }
163
183
  entry.child.kill(signal);
184
+ return force;
164
185
  } catch (error) {
186
+ if (isProcessGone(error)) {
187
+ return true;
188
+ }
165
189
  result.failures.push({ pid: entry.pid, message: formatError(error) });
190
+ return false;
166
191
  }
167
192
  }
193
+ function stopWindowsWorkspaceProcesses(rootPid, cwd, deps) {
194
+ const script = `
195
+ $rootPid = ${rootPid}
196
+ $cwd = ${JSON.stringify(cwd)}
197
+ $cwdLower = $cwd.ToLowerInvariant()
198
+ $rows = @(Get-CimInstance Win32_Process | Select-Object ProcessId,ParentProcessId,CommandLine)
199
+ $byPid = @{}
200
+ $children = @{}
201
+ foreach ($row in $rows) {
202
+ $pidInt = [int]$row.ProcessId
203
+ $parentInt = [int]$row.ParentProcessId
204
+ $byPid[$pidInt] = $row
205
+ if (-not $children.ContainsKey($parentInt)) { $children[$parentInt] = @() }
206
+ $children[$parentInt] += $pidInt
207
+ }
208
+ $protected = New-Object 'System.Collections.Generic.HashSet[int]'
209
+ $cursor = $PID
210
+ while ($cursor -gt 0 -and $byPid.ContainsKey($cursor)) {
211
+ [void]$protected.Add($cursor)
212
+ $cursor = [int]$byPid[$cursor].ParentProcessId
213
+ }
214
+ $targets = New-Object 'System.Collections.Generic.HashSet[int]'
215
+ $queue = New-Object 'System.Collections.Generic.Queue[int]'
216
+ $queue.Enqueue($rootPid)
217
+ while ($queue.Count -gt 0) {
218
+ $pid = $queue.Dequeue()
219
+ if (-not $targets.Add($pid)) { continue }
220
+ if ($children.ContainsKey($pid)) {
221
+ foreach ($childPid in $children[$pid]) { $queue.Enqueue($childPid) }
222
+ }
223
+ }
224
+ foreach ($row in $rows) {
225
+ $cmd = [string]$row.CommandLine
226
+ if ($cmd.ToLowerInvariant().Contains($cwdLower)) {
227
+ [void]$targets.Add([int]$row.ProcessId)
228
+ }
229
+ }
230
+ foreach ($targetPid in $targets) {
231
+ if ($targetPid -gt 0 -and -not $protected.Contains($targetPid)) {
232
+ Stop-Process -Id $targetPid -Force -ErrorAction SilentlyContinue
233
+ }
234
+ }
235
+ `;
236
+ try {
237
+ deps.spawn("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", script], {
238
+ windowsHide: true,
239
+ stdio: "ignore"
240
+ });
241
+ } catch {
242
+ }
243
+ }
244
+ function isProcessGone(error) {
245
+ return typeof error === "object" && error !== null && "code" in error && error.code === "ESRCH";
246
+ }
247
+ function shouldRunWindowsWorkspaceSweep(entry) {
248
+ return entry.workspaceSweep || process.env.LINGHUN_PROCESS_GUARD_WORKSPACE_SWEEP === "1";
249
+ }
168
250
  function formatError(error) {
169
251
  return error instanceof Error ? error.message : String(error);
170
252
  }
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  fitText,
6
6
  wrapText
7
- } from "./chunk-APJIC2O5.js";
7
+ } from "./chunk-GTIZNO5O.js";
8
8
 
9
9
  // src/shell/components/BackgroundTaskOverlay.tsx
10
10
  import { Box, Text } from "@linghun/ink-runtime";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  fitText,
6
6
  wrapText
7
- } from "./chunk-APJIC2O5.js";
7
+ } from "./chunk-GTIZNO5O.js";
8
8
 
9
9
  // src/shell/components/ConfigPanel.tsx
10
10
  import { Box, Text, useInput } from "@linghun/ink-runtime";
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  deriveAgentDisplayName
3
- } from "./chunk-TYF4GJR3.js";
3
+ } from "./chunk-UIKN3CDF.js";
4
4
  import {
5
5
  formatDisplayPath,
6
6
  sanitizeDisplayPaths,
7
7
  truncateDisplay
8
- } from "./chunk-OMZYPQVA.js";
8
+ } from "./chunk-UGYFQF6M.js";
9
9
 
10
10
  // src/tui-details-runtime.ts
11
11
  import { join } from "path";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  formatIndexRuntimeRef
3
- } from "./chunk-UT2TYK2A.js";
3
+ } from "./chunk-TYTVAFGB.js";
4
4
  import {
5
5
  withProviderRetry
6
6
  } from "./chunk-EBACIBJP.js";
@@ -14,7 +14,7 @@ import {
14
14
  sanitizeDiagnosticText,
15
15
  sanitizeDisplayPaths,
16
16
  truncateDisplay
17
- } from "./chunk-OMZYPQVA.js";
17
+ } from "./chunk-UGYFQF6M.js";
18
18
 
19
19
  // src/deep-compact-runtime.ts
20
20
  import { randomUUID } from "crypto";
@@ -4,7 +4,7 @@ import {
4
4
  extractStructuredFinalAnswerClaims,
5
5
  finalAnswerHasCompletenessClassification,
6
6
  hasArchitectureEvidenceForClaims
7
- } from "./chunk-K56D3X7S.js";
7
+ } from "./chunk-YKOXJQGX.js";
8
8
  import {
9
9
  detectArchitectureDrift
10
10
  } from "./chunk-MVONSJEN.js";
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  fitText,
6
6
  wrapText
7
- } from "./chunk-APJIC2O5.js";
7
+ } from "./chunk-GTIZNO5O.js";
8
8
 
9
9
  // src/shell/components/BtwPanel.tsx
10
10
  import { Box, Text, useInput } from "@linghun/ink-runtime";
@@ -1,31 +1,31 @@
1
+ import {
2
+ MAX_EVIDENCE_RECORDS
3
+ } from "./chunk-RDGM4RUE.js";
1
4
  import {
2
5
  applyToolResultBudgetToMessages,
3
6
  formatToolResultBudgetEvidenceSummary,
4
7
  formatToolResultBudgetSystemEvent
5
8
  } from "./chunk-O7S3HYE6.js";
6
- import {
7
- MAX_EVIDENCE_RECORDS
8
- } from "./chunk-RDGM4RUE.js";
9
9
  import {
10
10
  LINGHUN_DEFAULT_TOOL_RESULT_CHARS,
11
11
  LINGHUN_MAX_TOOL_RESULT_BYTES
12
12
  } from "./chunk-IWUIOLMF.js";
13
13
  import {
14
14
  writeHandoffPacket
15
- } from "./chunk-MLUIOBKL.js";
15
+ } from "./chunk-7ZMDQZ22.js";
16
16
  import {
17
17
  deriveToolSupportsClaims
18
- } from "./chunk-K56D3X7S.js";
18
+ } from "./chunk-YKOXJQGX.js";
19
19
  import {
20
20
  mergeFailureRecord,
21
21
  writeFailureRecord
22
- } from "./chunk-GDQQNPBP.js";
22
+ } from "./chunk-6GXIGN5W.js";
23
23
  import {
24
24
  classifyProviderFailure
25
25
  } from "./chunk-OZMX3E35.js";
26
26
  import {
27
27
  truncateDisplay
28
- } from "./chunk-OMZYPQVA.js";
28
+ } from "./chunk-UGYFQF6M.js";
29
29
  import {
30
30
  summarizeArchitectureCard
31
31
  } from "./chunk-MVONSJEN.js";
@@ -215,11 +215,11 @@ async function recordArchitectureRuntimeCard(context, sessionId, card) {
215
215
  return evidence;
216
216
  }
217
217
  async function recordToolEvidence(context, sessionId, name, output, input) {
218
- const kind = name === "Read" ? "file_read" : name === "Grep" || name === "Glob" ? "grep_result" : name === "Bash" || name === "Write" || name === "Edit" || name === "MultiEdit" ? "command_output" : null;
218
+ const kind = name === "Read" || name === "ReadSnippets" || name === "SourcePack" ? "file_read" : name === "Grep" || name === "Glob" ? "grep_result" : name === "Bash" || name === "Write" || name === "Edit" || name === "MultiEdit" ? "command_output" : null;
219
219
  if (!kind) {
220
220
  return null;
221
221
  }
222
- const readOnlyEvidence = name === "Read" || name === "Grep" || name === "Glob";
222
+ const readOnlyEvidence = name === "Read" || name === "ReadSnippets" || name === "SourcePack" || name === "Grep" || name === "Glob";
223
223
  const evidence = createEvidenceRecord(
224
224
  kind,
225
225
  readOnlyEvidence ? formatReadOnlyToolEvidenceSummary(name, output, input) : `${name}: ${truncateDisplay(output.text.replace(/\s+/g, " "), 120)}`,
@@ -237,11 +237,44 @@ async function recordToolEvidence(context, sessionId, name, output, input) {
237
237
  return evidence;
238
238
  }
239
239
  function formatReadOnlyToolEvidenceSummary(name, output, input) {
240
- const target = readToolEvidenceTarget(input);
240
+ const target = name === "SourcePack" ? sourcePackEvidenceTarget(input, output) : name === "ReadSnippets" ? readSnippetsEvidenceTarget(input) : readToolEvidenceTarget(input);
241
241
  const artifact = output.fullOutputPath ? "artifact=yes" : "artifact=no";
242
242
  const bytes = output.text.length;
243
243
  return `${name}: ${target}; output_chars=${bytes}; ${artifact}`;
244
244
  }
245
+ function sourcePackEvidenceTarget(input, output) {
246
+ const query = readStringField(input, "query");
247
+ const paths = extractOutputCandidatePaths(output.data);
248
+ const pathText = paths.length > 0 ? `; paths=${truncateDisplay(paths.slice(0, 4).join(","), 120)}` : "";
249
+ return `query=${truncateDisplay((query ?? "unspecified").replace(/\s+/g, " "), 90)}${pathText}`;
250
+ }
251
+ function readSnippetsEvidenceTarget(input) {
252
+ if (!input || typeof input !== "object" || Array.isArray(input)) return "ranges=unspecified";
253
+ const ranges = input.ranges;
254
+ if (!Array.isArray(ranges)) return "ranges=unspecified";
255
+ const paths = ranges.map(
256
+ (item) => item && typeof item === "object" && typeof item.path === "string" ? item.path : void 0
257
+ ).filter((item) => Boolean(item));
258
+ return paths.length > 0 ? `ranges=${truncateDisplay(paths.slice(0, 4).join(","), 120)}` : "ranges=unspecified";
259
+ }
260
+ function readStringField(input, key) {
261
+ if (!input || typeof input !== "object" || Array.isArray(input)) return void 0;
262
+ const value = input[key];
263
+ return typeof value === "string" && value.trim() ? value : void 0;
264
+ }
265
+ function extractOutputCandidatePaths(data) {
266
+ if (!data || typeof data !== "object" || Array.isArray(data)) return [];
267
+ const record = data;
268
+ const candidatePaths = record.candidatePaths;
269
+ if (Array.isArray(candidatePaths)) {
270
+ return candidatePaths.filter((item) => typeof item === "string");
271
+ }
272
+ const snippets = record.snippets;
273
+ if (!Array.isArray(snippets)) return [];
274
+ return snippets.map(
275
+ (item) => item && typeof item === "object" && typeof item.path === "string" ? item.path : void 0
276
+ ).filter((item) => Boolean(item));
277
+ }
245
278
  function readToolEvidenceTarget(input) {
246
279
  if (!input || typeof input !== "object" || Array.isArray(input)) return "target=unspecified";
247
280
  const record = input;
@@ -258,6 +291,15 @@ function readToolEvidenceTarget(input) {
258
291
  return `paths=${truncateDisplay(values.slice(0, 3).join(","), 90)}`;
259
292
  }
260
293
  }
294
+ const ranges = record.ranges;
295
+ if (Array.isArray(ranges)) {
296
+ const values = ranges.map(
297
+ (item) => item && typeof item === "object" && typeof item.path === "string" ? item.path : void 0
298
+ ).filter((item) => Boolean(item));
299
+ if (values.length > 0) {
300
+ return `ranges=${truncateDisplay(values.slice(0, 3).join(","), 90)}`;
301
+ }
302
+ }
261
303
  return "target=unspecified";
262
304
  }
263
305
  async function recordVerificationEvidence(context, sessionId, report) {
@@ -1,6 +1,11 @@
1
1
  import {
2
2
  evaluateUserStateSignal
3
3
  } from "./chunk-KQJHVJZB.js";
4
+ import {
5
+ detectEngineeringArtifactTargets,
6
+ formatEngineeringFailureBoundaryHint,
7
+ formatEngineeringProfileStrategyHint
8
+ } from "./chunk-4UER2AKI.js";
4
9
  import {
5
10
  LINGHUN_AGENT_CHILD_TURNS_AGENT,
6
11
  LINGHUN_AGENT_CHILD_TURNS_BASE,
@@ -119,6 +124,23 @@ function evaluateMetaScheduler(input) {
119
124
  const suggestedRole = highRiskClaim ? "verifier" : taskKind === "workflow" || taskKind === "agent" ? "planner" : void 0;
120
125
  const recentDeniedCount = input.recentDeniedCount ?? 0;
121
126
  const providerPlan = input.providerCooldownBlocked ? "cooldownBlocked" : providerFailure ? "fallbackCandidate" : "keepCurrent";
127
+ const engineeringProfile = input.engineeringProfile ?? "generic";
128
+ const inferredFailureCategory = input.engineeringFailureCategory ?? inferEngineeringFailureCategory({
129
+ providerFailure,
130
+ lastVerificationStatus: input.lastVerificationStatus,
131
+ lastToolFailure: input.lastToolFailure
132
+ });
133
+ const finalBoundaryHint = formatEngineeringFailureBoundaryHint({
134
+ profile: engineeringProfile,
135
+ failureCategory: inferredFailureCategory
136
+ });
137
+ const engineeringSignal = {
138
+ profile: engineeringProfile,
139
+ strategyHint: formatEngineeringProfileStrategyHint(engineeringProfile),
140
+ artifactTargets: detectEngineeringArtifactTargets(input.userText),
141
+ ...inferredFailureCategory ? { failureCategory: inferredFailureCategory } : {},
142
+ ...finalBoundaryHint ? { finalBoundaryHint } : {}
143
+ };
122
144
  const trustScore = input.trustScore ?? 50;
123
145
  const consecutiveFailures = input.consecutiveFailures ?? 0;
124
146
  const consecutiveSuccesses = input.consecutiveSuccesses ?? 0;
@@ -230,6 +252,7 @@ function evaluateMetaScheduler(input) {
230
252
  userState: adjustedUserStateDecision,
231
253
  capabilityPlan,
232
254
  userStatePersistence,
255
+ engineeringSignal,
233
256
  permissionSignal: {
234
257
  permissionMode: input.permissionMode ?? "default",
235
258
  recentDenied: recentDeniedCount > 0,
@@ -364,6 +387,7 @@ function formatMetaSchedulerDirective(decision) {
364
387
  "MetaSchedulerForModel:",
365
388
  ...decision.directives.map((item) => `- ${item}`),
366
389
  `- Typed policy route: task ${decision.policyDecision.taskKind}; risk ${decision.policyDecision.riskLevel}; budget ${decision.suggestedMaxTodoRounds} rounds; agent-max-turns ${decision.suggestedMaxAgentChildTurns}; agent-tool-rounds ${decision.suggestedMaxAgentToolRounds}; bg-concurrency ${decision.suggestedBackgroundConcurrency}; provider ${decision.policyDecision.providerPlan}; source-first ${decision.policyDecision.executionPlan.preferSourceFirst ? "yes" : "no"}; verification ${decision.policyDecision.executionPlan.requireVerification ? "required" : "normal"}; explicit-gate ${decision.policyDecision.permissionPlan.requireExplicitGate ? "required" : "normal"}; user-state ${decision.policyDecision.userState.kind}; capability ${decision.policyDecision.capabilitySignal.active ? "candidate" : "none"}.`,
390
+ `- EngineeringTaskProfile: profile=${decision.policyDecision.engineeringSignal.profile}; strategy=${decision.policyDecision.engineeringSignal.strategyHint}; failure=${decision.policyDecision.engineeringSignal.failureCategory ?? "none"}; final-boundary=${decision.policyDecision.engineeringSignal.finalBoundaryHint ?? "normal"}.`,
367
391
  ...decision.policyDecision.executionPlan.preferAgent || decision.policyDecision.executionPlan.preferWorkflow ? ["- Action: this is an agent/workflow-classified task. Delegate execution via StartAgent or RunWorkflow tools. Do not serial-Todo-plan every step yourself; use the extended planning budget to set up delegation, then call the tool."] : [],
368
392
  "- Keep RuntimeStatusForModel, UserStateDecision, capabilitySignal, capabilityPlan, CapabilityExecutionRequest, CapabilityExecutionResult, raw capability payload, interactionPlan, verificationPlan, notificationPlan, confidence, gateId, raw evidence, raw tool_result, and internal scheduler labels out of the user-visible final answer."
369
393
  ].join("\n");
@@ -832,6 +856,14 @@ function classifyVerificationLevel(input) {
832
856
  function isRiskyVerificationStatus(status) {
833
857
  return status === "fail" || status === "partial" || status === "stale" || status === "cancelled" || status === "timeout";
834
858
  }
859
+ function inferEngineeringFailureCategory(input) {
860
+ if (input.providerFailure) return "provider_error";
861
+ if (input.lastVerificationStatus === "timeout") return "test_timeout";
862
+ if (input.lastToolFailure && /missing artifact|missing required artifact|no such file|not found/iu.test(input.lastToolFailure.summary)) {
863
+ return "missing_artifact";
864
+ }
865
+ return void 0;
866
+ }
835
867
  function summarizeRuntimeSignal(input, evidenceFreshness) {
836
868
  let runningAgents = 0;
837
869
  let runningJobs = 0;
@@ -1097,6 +1129,7 @@ function createPolicyDecision(input) {
1097
1129
  permission: input.capabilityPlan.permission,
1098
1130
  riskLevel: input.capabilityPlan.riskLevel
1099
1131
  },
1132
+ engineeringSignal: input.engineeringSignal,
1100
1133
  capabilityPlan: input.capabilityPlan,
1101
1134
  runtimeSignal: input.runtimeSignal,
1102
1135
  userState: input.userState,
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  redactedPath
3
- } from "./chunk-RVY34HK4.js";
3
+ } from "./chunk-HZ5XNKWS.js";
4
4
  import {
5
5
  truncateDisplay
6
- } from "./chunk-OMZYPQVA.js";
6
+ } from "./chunk-UGYFQF6M.js";
7
7
 
8
8
  // src/mcp-index-command-runtime.ts
9
9
  import { basename } from "path";
@@ -2,14 +2,14 @@ import {
2
2
  normalizeMemoryStatus,
3
3
  pathExists,
4
4
  summarizeProjectRules
5
- } from "./chunk-QLRTQHTR.js";
5
+ } from "./chunk-6JGRNES6.js";
6
6
  import {
7
7
  MEMORY_LEARNING_STATE_FILE
8
8
  } from "./chunk-5H7RRF7C.js";
9
9
  import {
10
10
  formatDisplayPath,
11
11
  truncateDisplay
12
- } from "./chunk-OMZYPQVA.js";
12
+ } from "./chunk-UGYFQF6M.js";
13
13
 
14
14
  // src/tui-memory-runtime.ts
15
15
  import { randomUUID } from "crypto";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  fitText
3
- } from "./chunk-APJIC2O5.js";
3
+ } from "./chunk-GTIZNO5O.js";
4
4
 
5
5
  // src/shell/components/SlashSuggestions.tsx
6
6
  import { Box, Text } from "@linghun/ink-runtime";