erosolar-cli 1.7.257 → 1.7.258
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.
- package/README.md +22 -148
- package/dist/core/customCommands.d.ts +1 -0
- package/dist/core/customCommands.d.ts.map +1 -1
- package/dist/core/customCommands.js +3 -0
- package/dist/core/customCommands.js.map +1 -1
- package/dist/core/toolPreconditions.d.ts.map +1 -1
- package/dist/core/toolPreconditions.js +0 -14
- package/dist/core/toolPreconditions.js.map +1 -1
- package/dist/core/toolRuntime.d.ts.map +1 -1
- package/dist/core/toolRuntime.js +0 -5
- package/dist/core/toolRuntime.js.map +1 -1
- package/dist/core/toolValidation.d.ts.map +1 -1
- package/dist/core/toolValidation.js +14 -3
- package/dist/core/toolValidation.js.map +1 -1
- package/dist/core/validationRunner.d.ts +1 -3
- package/dist/core/validationRunner.d.ts.map +1 -1
- package/dist/core/validationRunner.js.map +1 -1
- package/dist/mcp/sseClient.d.ts.map +1 -1
- package/dist/mcp/sseClient.js +9 -18
- package/dist/mcp/sseClient.js.map +1 -1
- package/dist/plugins/tools/build/buildPlugin.d.ts +0 -6
- package/dist/plugins/tools/build/buildPlugin.d.ts.map +1 -1
- package/dist/plugins/tools/build/buildPlugin.js +4 -10
- package/dist/plugins/tools/build/buildPlugin.js.map +1 -1
- package/dist/shell/interactiveShell.d.ts +10 -2
- package/dist/shell/interactiveShell.d.ts.map +1 -1
- package/dist/shell/interactiveShell.js +190 -35
- package/dist/shell/interactiveShell.js.map +1 -1
- package/dist/shell/terminalInput.d.ts +66 -130
- package/dist/shell/terminalInput.d.ts.map +1 -1
- package/dist/shell/terminalInput.js +409 -606
- package/dist/shell/terminalInput.js.map +1 -1
- package/dist/shell/terminalInputAdapter.d.ts +20 -15
- package/dist/shell/terminalInputAdapter.d.ts.map +1 -1
- package/dist/shell/terminalInputAdapter.js +14 -22
- package/dist/shell/terminalInputAdapter.js.map +1 -1
- package/dist/ui/ShellUIAdapter.d.ts.map +1 -1
- package/dist/ui/ShellUIAdapter.js +13 -12
- package/dist/ui/ShellUIAdapter.js.map +1 -1
- package/dist/ui/display.d.ts +19 -0
- package/dist/ui/display.d.ts.map +1 -1
- package/dist/ui/display.js +135 -22
- package/dist/ui/display.js.map +1 -1
- package/dist/ui/theme.d.ts.map +1 -1
- package/dist/ui/theme.js +6 -8
- package/dist/ui/theme.js.map +1 -1
- package/dist/ui/toolDisplay.d.ts +0 -158
- package/dist/ui/toolDisplay.d.ts.map +1 -1
- package/dist/ui/toolDisplay.js +0 -348
- package/dist/ui/toolDisplay.js.map +1 -1
- package/dist/ui/unified/layout.d.ts +1 -0
- package/dist/ui/unified/layout.d.ts.map +1 -1
- package/dist/ui/unified/layout.js +15 -25
- package/dist/ui/unified/layout.js.map +1 -1
- package/package.json +1 -1
- package/dist/core/aiFlowOptimizer.d.ts +0 -26
- package/dist/core/aiFlowOptimizer.d.ts.map +0 -1
- package/dist/core/aiFlowOptimizer.js +0 -31
- package/dist/core/aiFlowOptimizer.js.map +0 -1
- package/dist/core/aiOptimizationEngine.d.ts +0 -158
- package/dist/core/aiOptimizationEngine.d.ts.map +0 -1
- package/dist/core/aiOptimizationEngine.js +0 -428
- package/dist/core/aiOptimizationEngine.js.map +0 -1
- package/dist/core/aiOptimizationIntegration.d.ts +0 -93
- package/dist/core/aiOptimizationIntegration.d.ts.map +0 -1
- package/dist/core/aiOptimizationIntegration.js +0 -250
- package/dist/core/aiOptimizationIntegration.js.map +0 -1
- package/dist/core/enhancedErrorRecovery.d.ts +0 -100
- package/dist/core/enhancedErrorRecovery.d.ts.map +0 -1
- package/dist/core/enhancedErrorRecovery.js +0 -345
- package/dist/core/enhancedErrorRecovery.js.map +0 -1
- package/dist/shell/claudeCodeStreamHandler.d.ts +0 -145
- package/dist/shell/claudeCodeStreamHandler.d.ts.map +0 -1
- package/dist/shell/claudeCodeStreamHandler.js +0 -322
- package/dist/shell/claudeCodeStreamHandler.js.map +0 -1
- package/dist/shell/inputQueueManager.d.ts +0 -144
- package/dist/shell/inputQueueManager.d.ts.map +0 -1
- package/dist/shell/inputQueueManager.js +0 -290
- package/dist/shell/inputQueueManager.js.map +0 -1
- package/dist/shell/streamingOutputManager.d.ts +0 -115
- package/dist/shell/streamingOutputManager.d.ts.map +0 -1
- package/dist/shell/streamingOutputManager.js +0 -225
- package/dist/shell/streamingOutputManager.js.map +0 -1
- package/dist/ui/persistentPrompt.d.ts +0 -50
- package/dist/ui/persistentPrompt.d.ts.map +0 -1
- package/dist/ui/persistentPrompt.js +0 -92
- package/dist/ui/persistentPrompt.js.map +0 -1
- package/dist/ui/terminalUISchema.d.ts +0 -195
- package/dist/ui/terminalUISchema.d.ts.map +0 -1
- package/dist/ui/terminalUISchema.js +0 -113
- package/dist/ui/terminalUISchema.js.map +0 -1
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* InputQueueManager - Queue-based input handling for Claude Code style streaming
|
|
3
|
-
*
|
|
4
|
-
* Key principles from Claude Code:
|
|
5
|
-
* 1. Readline handles input - Uses Node.js readline module
|
|
6
|
-
* 2. User can type while streaming - Input is queued in memory, not rendered
|
|
7
|
-
* 3. Queue-based approach: User types → stored in queue → processed after streaming ends
|
|
8
|
-
*
|
|
9
|
-
* The key insight is that the cursor is never moved during streaming.
|
|
10
|
-
* Input is captured "invisibly" while streaming, then processed when streaming ends.
|
|
11
|
-
*/
|
|
12
|
-
import { EventEmitter } from 'node:events';
|
|
13
|
-
/**
|
|
14
|
-
* Manages input queuing during streaming output.
|
|
15
|
-
*
|
|
16
|
-
* When streaming is active:
|
|
17
|
-
* - Captures keystrokes into a buffer
|
|
18
|
-
* - On Enter, queues the input for later processing
|
|
19
|
-
* - Provides methods to process queue after streaming ends
|
|
20
|
-
*/
|
|
21
|
-
export class InputQueueManager extends EventEmitter {
|
|
22
|
-
state = {
|
|
23
|
-
isCapturing: false,
|
|
24
|
-
buffer: '',
|
|
25
|
-
cursorPosition: 0,
|
|
26
|
-
queue: [],
|
|
27
|
-
};
|
|
28
|
-
inputIdCounter = 0;
|
|
29
|
-
maxQueueSize;
|
|
30
|
-
maxBufferLength;
|
|
31
|
-
constructor(options = {}) {
|
|
32
|
-
super();
|
|
33
|
-
this.maxQueueSize = options.maxQueueSize ?? 100;
|
|
34
|
-
this.maxBufferLength = options.maxBufferLength ?? 10000;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Start capturing input (during streaming)
|
|
38
|
-
* Input will be buffered and queued, not immediately processed
|
|
39
|
-
*/
|
|
40
|
-
startCapturing() {
|
|
41
|
-
if (this.state.isCapturing) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
this.state.isCapturing = true;
|
|
45
|
-
this.state.buffer = '';
|
|
46
|
-
this.state.cursorPosition = 0;
|
|
47
|
-
this.emit('capture-start');
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Stop capturing input (after streaming ends)
|
|
51
|
-
* Returns any remaining buffer content
|
|
52
|
-
*/
|
|
53
|
-
stopCapturing() {
|
|
54
|
-
const remaining = this.state.buffer;
|
|
55
|
-
this.state.isCapturing = false;
|
|
56
|
-
this.state.buffer = '';
|
|
57
|
-
this.state.cursorPosition = 0;
|
|
58
|
-
this.emit('capture-end');
|
|
59
|
-
return remaining;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Check if currently capturing input
|
|
63
|
-
*/
|
|
64
|
-
isCapturing() {
|
|
65
|
-
return this.state.isCapturing;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Handle a character input
|
|
69
|
-
* During capturing, adds to buffer; otherwise ignored
|
|
70
|
-
*/
|
|
71
|
-
handleChar(char) {
|
|
72
|
-
if (!this.state.isCapturing) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
// Respect buffer length limit
|
|
76
|
-
if (this.state.buffer.length >= this.maxBufferLength) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
// Insert at cursor position
|
|
80
|
-
this.state.buffer =
|
|
81
|
-
this.state.buffer.slice(0, this.state.cursorPosition) +
|
|
82
|
-
char +
|
|
83
|
-
this.state.buffer.slice(this.state.cursorPosition);
|
|
84
|
-
this.state.cursorPosition += char.length;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Handle backspace
|
|
88
|
-
*/
|
|
89
|
-
handleBackspace() {
|
|
90
|
-
if (!this.state.isCapturing || this.state.cursorPosition === 0) {
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
this.state.buffer =
|
|
94
|
-
this.state.buffer.slice(0, this.state.cursorPosition - 1) +
|
|
95
|
-
this.state.buffer.slice(this.state.cursorPosition);
|
|
96
|
-
this.state.cursorPosition = Math.max(0, this.state.cursorPosition - 1);
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Handle delete key
|
|
100
|
-
*/
|
|
101
|
-
handleDelete() {
|
|
102
|
-
if (!this.state.isCapturing || this.state.cursorPosition >= this.state.buffer.length) {
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
this.state.buffer =
|
|
106
|
-
this.state.buffer.slice(0, this.state.cursorPosition) +
|
|
107
|
-
this.state.buffer.slice(this.state.cursorPosition + 1);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Handle cursor left
|
|
111
|
-
*/
|
|
112
|
-
handleCursorLeft() {
|
|
113
|
-
if (!this.state.isCapturing)
|
|
114
|
-
return;
|
|
115
|
-
this.state.cursorPosition = Math.max(0, this.state.cursorPosition - 1);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Handle cursor right
|
|
119
|
-
*/
|
|
120
|
-
handleCursorRight() {
|
|
121
|
-
if (!this.state.isCapturing)
|
|
122
|
-
return;
|
|
123
|
-
this.state.cursorPosition = Math.min(this.state.buffer.length, this.state.cursorPosition + 1);
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Handle Enter - queue the current buffer
|
|
127
|
-
* Returns the queued input or null if buffer was empty
|
|
128
|
-
*/
|
|
129
|
-
handleSubmit() {
|
|
130
|
-
if (!this.state.isCapturing) {
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
const text = this.state.buffer.trim();
|
|
134
|
-
if (!text) {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
// Check queue size limit
|
|
138
|
-
if (this.state.queue.length >= this.maxQueueSize) {
|
|
139
|
-
// Remove oldest non-command input to make room
|
|
140
|
-
const idx = this.state.queue.findIndex(q => q.type !== 'command');
|
|
141
|
-
if (idx >= 0) {
|
|
142
|
-
this.state.queue.splice(idx, 1);
|
|
143
|
-
}
|
|
144
|
-
else {
|
|
145
|
-
return null; // Queue is full of commands
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
const input = {
|
|
149
|
-
id: `input-${++this.inputIdCounter}`,
|
|
150
|
-
text,
|
|
151
|
-
timestamp: Date.now(),
|
|
152
|
-
type: text.startsWith('/') ? 'command' : 'message',
|
|
153
|
-
};
|
|
154
|
-
this.state.queue.push(input);
|
|
155
|
-
this.state.buffer = '';
|
|
156
|
-
this.state.cursorPosition = 0;
|
|
157
|
-
this.emit('input-queued', input);
|
|
158
|
-
return input;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Handle Ctrl+C during capture - queue an interrupt
|
|
162
|
-
*/
|
|
163
|
-
handleInterrupt() {
|
|
164
|
-
const input = {
|
|
165
|
-
id: `input-${++this.inputIdCounter}`,
|
|
166
|
-
text: '',
|
|
167
|
-
timestamp: Date.now(),
|
|
168
|
-
type: 'interrupt',
|
|
169
|
-
};
|
|
170
|
-
// Interrupt goes to front of queue
|
|
171
|
-
this.state.queue.unshift(input);
|
|
172
|
-
this.state.buffer = '';
|
|
173
|
-
this.state.cursorPosition = 0;
|
|
174
|
-
this.emit('input-queued', input);
|
|
175
|
-
return input;
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Get current buffer contents (for display purposes)
|
|
179
|
-
*/
|
|
180
|
-
getBuffer() {
|
|
181
|
-
return this.state.buffer;
|
|
182
|
-
}
|
|
183
|
-
/**
|
|
184
|
-
* Get current cursor position
|
|
185
|
-
*/
|
|
186
|
-
getCursorPosition() {
|
|
187
|
-
return this.state.cursorPosition;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Get the number of queued inputs
|
|
191
|
-
*/
|
|
192
|
-
getQueueLength() {
|
|
193
|
-
return this.state.queue.length;
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* Check if there are queued inputs
|
|
197
|
-
*/
|
|
198
|
-
hasQueuedInput() {
|
|
199
|
-
return this.state.queue.length > 0;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Get the next queued input without removing it
|
|
203
|
-
*/
|
|
204
|
-
peekQueue() {
|
|
205
|
-
return this.state.queue[0];
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* Get and remove the next queued input
|
|
209
|
-
*/
|
|
210
|
-
dequeue() {
|
|
211
|
-
const input = this.state.queue.shift();
|
|
212
|
-
if (input) {
|
|
213
|
-
this.emit('input-processed', input);
|
|
214
|
-
}
|
|
215
|
-
return input;
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Get all queued inputs (copy)
|
|
219
|
-
*/
|
|
220
|
-
getQueue() {
|
|
221
|
-
return [...this.state.queue];
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Clear all queued inputs
|
|
225
|
-
*/
|
|
226
|
-
clearQueue() {
|
|
227
|
-
const hadItems = this.state.queue.length > 0;
|
|
228
|
-
this.state.queue = [];
|
|
229
|
-
if (hadItems) {
|
|
230
|
-
this.emit('queue-cleared');
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Clear the current buffer
|
|
235
|
-
*/
|
|
236
|
-
clearBuffer() {
|
|
237
|
-
this.state.buffer = '';
|
|
238
|
-
this.state.cursorPosition = 0;
|
|
239
|
-
}
|
|
240
|
-
/**
|
|
241
|
-
* Set the buffer content directly (for paste handling)
|
|
242
|
-
*/
|
|
243
|
-
setBuffer(content, cursorPos) {
|
|
244
|
-
this.state.buffer = content.slice(0, this.maxBufferLength);
|
|
245
|
-
this.state.cursorPosition = cursorPos ?? this.state.buffer.length;
|
|
246
|
-
}
|
|
247
|
-
/**
|
|
248
|
-
* Get queue summary for display
|
|
249
|
-
*/
|
|
250
|
-
getQueueSummary() {
|
|
251
|
-
const count = this.state.queue.length;
|
|
252
|
-
if (count === 0) {
|
|
253
|
-
return '';
|
|
254
|
-
}
|
|
255
|
-
const commands = this.state.queue.filter(q => q.type === 'command').length;
|
|
256
|
-
const messages = this.state.queue.filter(q => q.type === 'message').length;
|
|
257
|
-
const interrupts = this.state.queue.filter(q => q.type === 'interrupt').length;
|
|
258
|
-
const parts = [];
|
|
259
|
-
if (interrupts > 0) {
|
|
260
|
-
parts.push(`${interrupts} interrupt${interrupts === 1 ? '' : 's'}`);
|
|
261
|
-
}
|
|
262
|
-
if (commands > 0) {
|
|
263
|
-
parts.push(`${commands} command${commands === 1 ? '' : 's'}`);
|
|
264
|
-
}
|
|
265
|
-
if (messages > 0) {
|
|
266
|
-
parts.push(`${messages} message${messages === 1 ? '' : 's'}`);
|
|
267
|
-
}
|
|
268
|
-
return parts.join(', ') + ' queued';
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Get full state (for debugging)
|
|
272
|
-
*/
|
|
273
|
-
getState() {
|
|
274
|
-
return { ...this.state, queue: [...this.state.queue] };
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* Singleton instance for global use
|
|
279
|
-
*/
|
|
280
|
-
let globalInstance = null;
|
|
281
|
-
export function getInputQueueManager() {
|
|
282
|
-
if (!globalInstance) {
|
|
283
|
-
globalInstance = new InputQueueManager();
|
|
284
|
-
}
|
|
285
|
-
return globalInstance;
|
|
286
|
-
}
|
|
287
|
-
export function resetInputQueueManager() {
|
|
288
|
-
globalInstance = null;
|
|
289
|
-
}
|
|
290
|
-
//# sourceMappingURL=inputQueueManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inputQueueManager.js","sourceRoot":"","sources":["../../src/shell/inputQueueManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAwB3C;;;;;;;GAOG;AACH,MAAM,OAAO,iBAAkB,SAAQ,YAAY;IACzC,KAAK,GAAoB;QAC/B,WAAW,EAAE,KAAK;QAClB,MAAM,EAAE,EAAE;QACV,cAAc,EAAE,CAAC;QACjB,KAAK,EAAE,EAAE;KACV,CAAC;IAEM,cAAc,GAAG,CAAC,CAAC;IACV,YAAY,CAAS;IACrB,eAAe,CAAS;IAEzC,YAAY,UAA+D,EAAE;QAC3E,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,GAAG,CAAC;QAChD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,KAAK,CAAC;IAC1D,CAAC;IAED;;;OAGG;IACH,cAAc;QACZ,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YAC3B,OAAO;QACT,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,CAAC,cAAc,GAAG,CAAC,CAAC;QAE9B,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAEpC,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC;QAC/B,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,EAAE,CAAC;QAC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* Key design principle:
|
|
5
|
-
* - Buffer streaming output instead of writing directly to stdout
|
|
6
|
-
* - This keeps the cursor at the prompt area (no cursor movement during streaming)
|
|
7
|
-
* - Render complete response when streaming ends
|
|
8
|
-
* - The UI (prompt) stays fixed at the bottom
|
|
9
|
-
*
|
|
10
|
-
* Two modes:
|
|
11
|
-
* 1. Direct mode (bufferedMode=false): Write chunks directly to stdout (original behavior)
|
|
12
|
-
* 2. Buffered mode (bufferedMode=true): Collect chunks, render when complete
|
|
13
|
-
*/
|
|
14
|
-
import { EventEmitter } from 'node:events';
|
|
15
|
-
export interface StreamingOutputState {
|
|
16
|
-
isStreaming: boolean;
|
|
17
|
-
charsWritten: number;
|
|
18
|
-
linesWritten: number;
|
|
19
|
-
startTime: number | null;
|
|
20
|
-
}
|
|
21
|
-
export interface StreamingOutputEvents {
|
|
22
|
-
'stream-start': () => void;
|
|
23
|
-
'stream-chunk': (chunk: string) => void;
|
|
24
|
-
'stream-end': (stats: {
|
|
25
|
-
duration: number;
|
|
26
|
-
chars: number;
|
|
27
|
-
lines: number;
|
|
28
|
-
}) => void;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Manages streaming output with optional buffering.
|
|
32
|
-
*
|
|
33
|
-
* Buffered mode:
|
|
34
|
-
* - Chunks are collected in a buffer
|
|
35
|
-
* - Output is rendered all at once when streaming ends
|
|
36
|
-
* - Cursor stays at prompt area (no jumping during streaming)
|
|
37
|
-
*
|
|
38
|
-
* Direct mode:
|
|
39
|
-
* - Chunks written directly to stdout (original behavior)
|
|
40
|
-
* - Cursor moves with output
|
|
41
|
-
*/
|
|
42
|
-
export declare class StreamingOutputManager extends EventEmitter {
|
|
43
|
-
private state;
|
|
44
|
-
private readonly writeStream;
|
|
45
|
-
private lastChunk;
|
|
46
|
-
private bufferedMode;
|
|
47
|
-
private outputBuffer;
|
|
48
|
-
constructor(writeStream?: NodeJS.WriteStream);
|
|
49
|
-
/**
|
|
50
|
-
* Enable or disable buffered mode
|
|
51
|
-
* When buffered, chunks are collected and rendered at the end
|
|
52
|
-
*/
|
|
53
|
-
setBufferedMode(enabled: boolean): void;
|
|
54
|
-
/**
|
|
55
|
-
* Check if buffered mode is enabled
|
|
56
|
-
*/
|
|
57
|
-
isBufferedMode(): boolean;
|
|
58
|
-
/**
|
|
59
|
-
* Get the buffered content (for rendering)
|
|
60
|
-
*/
|
|
61
|
-
getBuffer(): string;
|
|
62
|
-
/**
|
|
63
|
-
* Clear the buffer
|
|
64
|
-
*/
|
|
65
|
-
clearBuffer(): void;
|
|
66
|
-
/**
|
|
67
|
-
* Check if currently streaming output
|
|
68
|
-
*/
|
|
69
|
-
isStreaming(): boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Begin a streaming session
|
|
72
|
-
* Resets counters and marks streaming as active
|
|
73
|
-
* In buffered mode, clears the buffer
|
|
74
|
-
*/
|
|
75
|
-
startStream(): void;
|
|
76
|
-
/**
|
|
77
|
-
* Write a chunk of content
|
|
78
|
-
*
|
|
79
|
-
* In buffered mode: Collect in buffer (cursor stays at prompt)
|
|
80
|
-
* In direct mode: Write to stdout immediately
|
|
81
|
-
*/
|
|
82
|
-
writeChunk(chunk: string): void;
|
|
83
|
-
/**
|
|
84
|
-
* Write a complete line (adds newline)
|
|
85
|
-
*/
|
|
86
|
-
writeLine(line?: string): void;
|
|
87
|
-
/**
|
|
88
|
-
* End the streaming session
|
|
89
|
-
* In buffered mode: Renders the complete buffered output
|
|
90
|
-
* Returns statistics about what was streamed
|
|
91
|
-
*/
|
|
92
|
-
endStream(): {
|
|
93
|
-
duration: number;
|
|
94
|
-
chars: number;
|
|
95
|
-
lines: number;
|
|
96
|
-
buffer?: string;
|
|
97
|
-
};
|
|
98
|
-
/**
|
|
99
|
-
* Get current streaming statistics
|
|
100
|
-
*/
|
|
101
|
-
getStats(): {
|
|
102
|
-
chars: number;
|
|
103
|
-
lines: number;
|
|
104
|
-
elapsed: number;
|
|
105
|
-
};
|
|
106
|
-
/**
|
|
107
|
-
* Force a flush (for buffered output)
|
|
108
|
-
*/
|
|
109
|
-
flush(): void;
|
|
110
|
-
private countNewlines;
|
|
111
|
-
private writeLocked;
|
|
112
|
-
}
|
|
113
|
-
export declare function getStreamingOutputManager(): StreamingOutputManager;
|
|
114
|
-
export declare function resetStreamingOutputManager(): void;
|
|
115
|
-
//# sourceMappingURL=streamingOutputManager.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"streamingOutputManager.d.ts","sourceRoot":"","sources":["../../src/shell/streamingOutputManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;CACnF;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,sBAAuB,SAAQ,YAAY;IACtD,OAAO,CAAC,KAAK,CAKX;IAEF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;IACjD,OAAO,CAAC,SAAS,CAAc;IAG/B,OAAO,CAAC,YAAY,CAAkB;IACtC,OAAO,CAAC,YAAY,CAAgB;gBAExB,WAAW,GAAE,MAAM,CAAC,WAA4B;IAK5D;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAIvC;;OAEG;IACH,cAAc,IAAI,OAAO;IAIzB;;OAEG;IACH,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,WAAW,IAAI,IAAI;IAInB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;;;OAIG;IACH,WAAW,IAAI,IAAI;IAiBnB;;;;;OAKG;IACH,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAqB/B;;OAEG;IACH,SAAS,CAAC,IAAI,GAAE,MAAW,GAAG,IAAI;IAIlC;;;;OAIG;IACH,SAAS,IAAI;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IA0ChF;;OAEG;IACH,QAAQ,IAAI;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;IAQ7D;;OAEG;IACH,KAAK,IAAI,IAAI;IAYb,OAAO,CAAC,aAAa;IAUrB,OAAO,CAAC,WAAW;CAWpB;AAOD,wBAAgB,yBAAyB,IAAI,sBAAsB,CAKlE;AAED,wBAAgB,2BAA2B,IAAI,IAAI,CAElD"}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* StreamingOutputManager - Buffered output for Claude Code style UI
|
|
3
|
-
*
|
|
4
|
-
* Key design principle:
|
|
5
|
-
* - Buffer streaming output instead of writing directly to stdout
|
|
6
|
-
* - This keeps the cursor at the prompt area (no cursor movement during streaming)
|
|
7
|
-
* - Render complete response when streaming ends
|
|
8
|
-
* - The UI (prompt) stays fixed at the bottom
|
|
9
|
-
*
|
|
10
|
-
* Two modes:
|
|
11
|
-
* 1. Direct mode (bufferedMode=false): Write chunks directly to stdout (original behavior)
|
|
12
|
-
* 2. Buffered mode (bufferedMode=true): Collect chunks, render when complete
|
|
13
|
-
*/
|
|
14
|
-
import { EventEmitter } from 'node:events';
|
|
15
|
-
import { writeLock } from '../ui/writeLock.js';
|
|
16
|
-
/**
|
|
17
|
-
* Manages streaming output with optional buffering.
|
|
18
|
-
*
|
|
19
|
-
* Buffered mode:
|
|
20
|
-
* - Chunks are collected in a buffer
|
|
21
|
-
* - Output is rendered all at once when streaming ends
|
|
22
|
-
* - Cursor stays at prompt area (no jumping during streaming)
|
|
23
|
-
*
|
|
24
|
-
* Direct mode:
|
|
25
|
-
* - Chunks written directly to stdout (original behavior)
|
|
26
|
-
* - Cursor moves with output
|
|
27
|
-
*/
|
|
28
|
-
export class StreamingOutputManager extends EventEmitter {
|
|
29
|
-
state = {
|
|
30
|
-
isStreaming: false,
|
|
31
|
-
charsWritten: 0,
|
|
32
|
-
linesWritten: 0,
|
|
33
|
-
startTime: null,
|
|
34
|
-
};
|
|
35
|
-
writeStream;
|
|
36
|
-
lastChunk = '';
|
|
37
|
-
// Buffered mode support
|
|
38
|
-
bufferedMode = false;
|
|
39
|
-
outputBuffer = [];
|
|
40
|
-
constructor(writeStream = process.stdout) {
|
|
41
|
-
super();
|
|
42
|
-
this.writeStream = writeStream;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Enable or disable buffered mode
|
|
46
|
-
* When buffered, chunks are collected and rendered at the end
|
|
47
|
-
*/
|
|
48
|
-
setBufferedMode(enabled) {
|
|
49
|
-
this.bufferedMode = enabled;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* Check if buffered mode is enabled
|
|
53
|
-
*/
|
|
54
|
-
isBufferedMode() {
|
|
55
|
-
return this.bufferedMode;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Get the buffered content (for rendering)
|
|
59
|
-
*/
|
|
60
|
-
getBuffer() {
|
|
61
|
-
return this.outputBuffer.join('');
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Clear the buffer
|
|
65
|
-
*/
|
|
66
|
-
clearBuffer() {
|
|
67
|
-
this.outputBuffer = [];
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Check if currently streaming output
|
|
71
|
-
*/
|
|
72
|
-
isStreaming() {
|
|
73
|
-
return this.state.isStreaming;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Begin a streaming session
|
|
77
|
-
* Resets counters and marks streaming as active
|
|
78
|
-
* In buffered mode, clears the buffer
|
|
79
|
-
*/
|
|
80
|
-
startStream() {
|
|
81
|
-
if (this.state.isStreaming) {
|
|
82
|
-
return; // Already streaming
|
|
83
|
-
}
|
|
84
|
-
this.state = {
|
|
85
|
-
isStreaming: true,
|
|
86
|
-
charsWritten: 0,
|
|
87
|
-
linesWritten: 0,
|
|
88
|
-
startTime: Date.now(),
|
|
89
|
-
};
|
|
90
|
-
this.lastChunk = '';
|
|
91
|
-
this.outputBuffer = [];
|
|
92
|
-
this.emit('stream-start');
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Write a chunk of content
|
|
96
|
-
*
|
|
97
|
-
* In buffered mode: Collect in buffer (cursor stays at prompt)
|
|
98
|
-
* In direct mode: Write to stdout immediately
|
|
99
|
-
*/
|
|
100
|
-
writeChunk(chunk) {
|
|
101
|
-
if (!chunk) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
// Track statistics
|
|
105
|
-
this.state.charsWritten += chunk.length;
|
|
106
|
-
this.state.linesWritten += this.countNewlines(chunk);
|
|
107
|
-
this.lastChunk = chunk;
|
|
108
|
-
if (this.bufferedMode) {
|
|
109
|
-
// Buffered mode: collect chunks, don't write yet
|
|
110
|
-
this.outputBuffer.push(chunk);
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
// Direct mode: write immediately
|
|
114
|
-
this.writeLocked(chunk);
|
|
115
|
-
}
|
|
116
|
-
this.emit('stream-chunk', chunk);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Write a complete line (adds newline)
|
|
120
|
-
*/
|
|
121
|
-
writeLine(line = '') {
|
|
122
|
-
this.writeChunk(`${line}\n`);
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
|
-
* End the streaming session
|
|
126
|
-
* In buffered mode: Renders the complete buffered output
|
|
127
|
-
* Returns statistics about what was streamed
|
|
128
|
-
*/
|
|
129
|
-
endStream() {
|
|
130
|
-
const stats = {
|
|
131
|
-
duration: this.state.startTime ? Date.now() - this.state.startTime : 0,
|
|
132
|
-
chars: this.state.charsWritten,
|
|
133
|
-
lines: this.state.linesWritten,
|
|
134
|
-
buffer: undefined,
|
|
135
|
-
};
|
|
136
|
-
if (this.bufferedMode) {
|
|
137
|
-
// In buffered mode, render the collected output now
|
|
138
|
-
const bufferedContent = this.outputBuffer.join('');
|
|
139
|
-
stats.buffer = bufferedContent;
|
|
140
|
-
if (bufferedContent) {
|
|
141
|
-
this.writeLocked(bufferedContent);
|
|
142
|
-
// Ensure we end with a newline
|
|
143
|
-
if (!bufferedContent.endsWith('\n')) {
|
|
144
|
-
this.writeLocked('\n');
|
|
145
|
-
stats.lines += 1;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
this.outputBuffer = [];
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
// Direct mode: just ensure newline
|
|
152
|
-
if (this.lastChunk && !this.lastChunk.endsWith('\n')) {
|
|
153
|
-
this.writeLocked('\n');
|
|
154
|
-
stats.lines += 1;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
this.state = {
|
|
158
|
-
isStreaming: false,
|
|
159
|
-
charsWritten: 0,
|
|
160
|
-
linesWritten: 0,
|
|
161
|
-
startTime: null,
|
|
162
|
-
};
|
|
163
|
-
this.lastChunk = '';
|
|
164
|
-
this.emit('stream-end', stats);
|
|
165
|
-
return stats;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Get current streaming statistics
|
|
169
|
-
*/
|
|
170
|
-
getStats() {
|
|
171
|
-
return {
|
|
172
|
-
chars: this.state.charsWritten,
|
|
173
|
-
lines: this.state.linesWritten,
|
|
174
|
-
elapsed: this.state.startTime ? Date.now() - this.state.startTime : 0,
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
/**
|
|
178
|
-
* Force a flush (for buffered output)
|
|
179
|
-
*/
|
|
180
|
-
flush() {
|
|
181
|
-
// Cork/uncork pattern for optimal buffering
|
|
182
|
-
if (typeof this.writeStream.cork === 'function') {
|
|
183
|
-
this.writeStream.cork();
|
|
184
|
-
process.nextTick(() => {
|
|
185
|
-
if (typeof this.writeStream.uncork === 'function') {
|
|
186
|
-
this.writeStream.uncork();
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
countNewlines(text) {
|
|
192
|
-
let count = 0;
|
|
193
|
-
for (const char of text) {
|
|
194
|
-
if (char === '\n') {
|
|
195
|
-
count += 1;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
return count;
|
|
199
|
-
}
|
|
200
|
-
writeLocked(chunk) {
|
|
201
|
-
// If lock is already held, write directly - we're in a protected context
|
|
202
|
-
// This prevents queuing issues where content gets delayed during streaming
|
|
203
|
-
if (writeLock.isLocked()) {
|
|
204
|
-
this.writeStream.write(chunk);
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
writeLock.withLock(() => {
|
|
208
|
-
this.writeStream.write(chunk);
|
|
209
|
-
}, 'streamingOutputManager.write');
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Singleton instance for global use
|
|
214
|
-
*/
|
|
215
|
-
let globalInstance = null;
|
|
216
|
-
export function getStreamingOutputManager() {
|
|
217
|
-
if (!globalInstance) {
|
|
218
|
-
globalInstance = new StreamingOutputManager();
|
|
219
|
-
}
|
|
220
|
-
return globalInstance;
|
|
221
|
-
}
|
|
222
|
-
export function resetStreamingOutputManager() {
|
|
223
|
-
globalInstance = null;
|
|
224
|
-
}
|
|
225
|
-
//# sourceMappingURL=streamingOutputManager.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"streamingOutputManager.js","sourceRoot":"","sources":["../../src/shell/streamingOutputManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAe/C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,sBAAuB,SAAQ,YAAY;IAC9C,KAAK,GAAyB;QACpC,WAAW,EAAE,KAAK;QAClB,YAAY,EAAE,CAAC;QACf,YAAY,EAAE,CAAC;QACf,SAAS,EAAE,IAAI;KAChB,CAAC;IAEe,WAAW,CAAqB;IACzC,SAAS,GAAW,EAAE,CAAC;IAE/B,wBAAwB;IAChB,YAAY,GAAY,KAAK,CAAC;IAC9B,YAAY,GAAa,EAAE,CAAC;IAEpC,YAAY,cAAkC,OAAO,CAAC,MAAM;QAC1D,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,OAAgB;QAC9B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,WAAW;QACT,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,WAAW;QACT,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;IAChC,CAAC;IAED;;;;OAIG;IACH,WAAW;QACT,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;YAC3B,OAAO,CAAC,oBAAoB;QAC9B,CAAC;QAED,IAAI,CAAC,KAAK,GAAG;YACX,WAAW,EAAE,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