centaurus-cli 2.7.3 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/cli-adapter.d.ts +10 -6
  2. package/dist/cli-adapter.d.ts.map +1 -1
  3. package/dist/cli-adapter.js +613 -154
  4. package/dist/cli-adapter.js.map +1 -1
  5. package/dist/config/slash-commands.d.ts.map +1 -1
  6. package/dist/config/slash-commands.js +1 -0
  7. package/dist/config/slash-commands.js.map +1 -1
  8. package/dist/context/context-manager.d.ts +4 -1
  9. package/dist/context/context-manager.d.ts.map +1 -1
  10. package/dist/context/context-manager.js +30 -7
  11. package/dist/context/context-manager.js.map +1 -1
  12. package/dist/context/handlers/wsl-handler.d.ts +10 -0
  13. package/dist/context/handlers/wsl-handler.d.ts.map +1 -1
  14. package/dist/context/handlers/wsl-handler.js +31 -2
  15. package/dist/context/handlers/wsl-handler.js.map +1 -1
  16. package/dist/index.js +33 -0
  17. package/dist/index.js.map +1 -1
  18. package/dist/services/ai-service-client.d.ts +1 -0
  19. package/dist/services/ai-service-client.d.ts.map +1 -1
  20. package/dist/services/ai-service-client.js +20 -0
  21. package/dist/services/ai-service-client.js.map +1 -1
  22. package/dist/tools/command.d.ts.map +1 -1
  23. package/dist/tools/command.js +136 -21
  24. package/dist/tools/command.js.map +1 -1
  25. package/dist/tools/file-ops.d.ts +1 -0
  26. package/dist/tools/file-ops.d.ts.map +1 -1
  27. package/dist/tools/file-ops.js +144 -3
  28. package/dist/tools/file-ops.js.map +1 -1
  29. package/dist/tools/inspect-symbol.js +27 -27
  30. package/dist/tools/inspect-symbol.js.map +1 -1
  31. package/dist/tools/plan-mode.d.ts +55 -19
  32. package/dist/tools/plan-mode.d.ts.map +1 -1
  33. package/dist/tools/plan-mode.js +204 -123
  34. package/dist/tools/plan-mode.js.map +1 -1
  35. package/dist/tools/types.d.ts +1 -1
  36. package/dist/tools/types.d.ts.map +1 -1
  37. package/dist/types/index.d.ts +11 -1
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/dist/ui/components/App.d.ts +6 -5
  40. package/dist/ui/components/App.d.ts.map +1 -1
  41. package/dist/ui/components/App.js +277 -125
  42. package/dist/ui/components/App.js.map +1 -1
  43. package/dist/ui/components/InputBox.d.ts.map +1 -1
  44. package/dist/ui/components/InputBox.js +24 -5
  45. package/dist/ui/components/InputBox.js.map +1 -1
  46. package/dist/ui/components/InteractiveShell.d.ts +2 -1
  47. package/dist/ui/components/InteractiveShell.d.ts.map +1 -1
  48. package/dist/ui/components/InteractiveShell.js +41 -106
  49. package/dist/ui/components/InteractiveShell.js.map +1 -1
  50. package/dist/ui/components/MarkdownRenderer.d.ts.map +1 -1
  51. package/dist/ui/components/MarkdownRenderer.js +12 -8
  52. package/dist/ui/components/MarkdownRenderer.js.map +1 -1
  53. package/dist/ui/components/MessageDisplay.d.ts.map +1 -1
  54. package/dist/ui/components/MessageDisplay.js +11 -3
  55. package/dist/ui/components/MessageDisplay.js.map +1 -1
  56. package/dist/ui/components/PlanAcceptedMessage.d.ts +12 -0
  57. package/dist/ui/components/PlanAcceptedMessage.d.ts.map +1 -0
  58. package/dist/ui/components/PlanAcceptedMessage.js +22 -0
  59. package/dist/ui/components/PlanAcceptedMessage.js.map +1 -0
  60. package/dist/ui/components/PlanReviewScreen.d.ts +14 -0
  61. package/dist/ui/components/PlanReviewScreen.d.ts.map +1 -0
  62. package/dist/ui/components/PlanReviewScreen.js +52 -0
  63. package/dist/ui/components/PlanReviewScreen.js.map +1 -0
  64. package/dist/ui/components/StreamingMessageDisplay.d.ts.map +1 -1
  65. package/dist/ui/components/StreamingMessageDisplay.js +5 -5
  66. package/dist/ui/components/StreamingMessageDisplay.js.map +1 -1
  67. package/dist/ui/components/TaskCompletedMessage.d.ts +14 -0
  68. package/dist/ui/components/TaskCompletedMessage.d.ts.map +1 -0
  69. package/dist/ui/components/TaskCompletedMessage.js +25 -0
  70. package/dist/ui/components/TaskCompletedMessage.js.map +1 -0
  71. package/dist/ui/components/ToolExecutionMessage.d.ts.map +1 -1
  72. package/dist/ui/components/ToolExecutionMessage.js +174 -17
  73. package/dist/ui/components/ToolExecutionMessage.js.map +1 -1
  74. package/dist/utils/conversation-logger.d.ts +127 -0
  75. package/dist/utils/conversation-logger.d.ts.map +1 -0
  76. package/dist/utils/conversation-logger.js +283 -0
  77. package/dist/utils/conversation-logger.js.map +1 -0
  78. package/dist/utils/editor-utils.d.ts +87 -0
  79. package/dist/utils/editor-utils.d.ts.map +1 -0
  80. package/dist/utils/editor-utils.js +712 -0
  81. package/dist/utils/editor-utils.js.map +1 -0
  82. package/dist/utils/input-classifier.d.ts.map +1 -1
  83. package/dist/utils/input-classifier.js +12 -4
  84. package/dist/utils/input-classifier.js.map +1 -1
  85. package/dist/utils/markdown-parser.d.ts.map +1 -1
  86. package/dist/utils/markdown-parser.js +4 -2
  87. package/dist/utils/markdown-parser.js.map +1 -1
  88. package/dist/utils/shell.d.ts +32 -1
  89. package/dist/utils/shell.d.ts.map +1 -1
  90. package/dist/utils/shell.js +97 -161
  91. package/dist/utils/shell.js.map +1 -1
  92. package/dist/utils/syntax-checker.d.ts +24 -0
  93. package/dist/utils/syntax-checker.d.ts.map +1 -0
  94. package/dist/utils/syntax-checker.js +320 -0
  95. package/dist/utils/syntax-checker.js.map +1 -0
  96. package/package.json +4 -3
  97. package/prompts/system-prompt-autonomous.md +0 -377
@@ -0,0 +1,283 @@
1
+ /**
2
+ * Conversation Logger
3
+ *
4
+ * Comprehensive logging utility for AI conversation debugging.
5
+ * Logs all messages, tool calls, thoughts, and feedback to help
6
+ * debug issues like hallucination, looping, or getting stuck.
7
+ */
8
+ import * as fs from 'fs';
9
+ // Log levels
10
+ export var LogLevel;
11
+ (function (LogLevel) {
12
+ LogLevel["DEBUG"] = "DEBUG";
13
+ LogLevel["INFO"] = "INFO";
14
+ LogLevel["WARN"] = "WARN";
15
+ LogLevel["ERROR"] = "ERROR";
16
+ })(LogLevel || (LogLevel = {}));
17
+ // Log categories for filtering
18
+ export var LogCategory;
19
+ (function (LogCategory) {
20
+ LogCategory["SESSION"] = "SESSION";
21
+ LogCategory["USER_MSG"] = "USER_MSG";
22
+ LogCategory["AI_TEXT"] = "AI_TEXT";
23
+ LogCategory["THOUGHT"] = "THOUGHT";
24
+ LogCategory["TOOL_CALL"] = "TOOL_CALL";
25
+ LogCategory["TOOL_EXEC"] = "TOOL_EXEC";
26
+ LogCategory["TOOL_RESULT"] = "TOOL_RESULT";
27
+ LogCategory["LOOP"] = "LOOP";
28
+ LogCategory["NARRATION"] = "NARRATION";
29
+ LogCategory["ERROR"] = "ERROR";
30
+ LogCategory["SYSTEM"] = "SYSTEM";
31
+ })(LogCategory || (LogCategory = {}));
32
+ /**
33
+ * ConversationLogger class for structured conversation logging
34
+ */
35
+ export class ConversationLogger {
36
+ logFilePath;
37
+ sessionId = '';
38
+ currentTurn = 0;
39
+ accumulatedThought = '';
40
+ accumulatedAIText = '';
41
+ enabled = true;
42
+ constructor(logFilePath = 'cli_frontend_logs.txt') {
43
+ this.logFilePath = logFilePath;
44
+ }
45
+ /**
46
+ * Enable or disable logging
47
+ */
48
+ setEnabled(enabled) {
49
+ this.enabled = enabled;
50
+ }
51
+ /**
52
+ * Start a new conversation session
53
+ */
54
+ startSession() {
55
+ // Generate a short session ID
56
+ this.sessionId = `sess_${Date.now().toString(36)}`;
57
+ this.currentTurn = 0;
58
+ this.accumulatedThought = '';
59
+ this.accumulatedAIText = '';
60
+ this.log(LogLevel.INFO, LogCategory.SESSION, '═══════════════════════════════════════════════════════════════════════════════');
61
+ this.log(LogLevel.INFO, LogCategory.SESSION, `NEW CONVERSATION SESSION STARTED`);
62
+ this.log(LogLevel.INFO, LogCategory.SESSION, '═══════════════════════════════════════════════════════════════════════════════');
63
+ }
64
+ /**
65
+ * Log a user message
66
+ */
67
+ logUserMessage(message) {
68
+ this.log(LogLevel.INFO, LogCategory.USER_MSG, 'User message received', {
69
+ content: message,
70
+ length: message.length,
71
+ });
72
+ }
73
+ /**
74
+ * Log AI text chunk (streaming)
75
+ */
76
+ logAITextChunk(chunk) {
77
+ this.accumulatedAIText += chunk;
78
+ this.log(LogLevel.DEBUG, LogCategory.AI_TEXT, 'AI text chunk received', {
79
+ chunkLength: chunk.length,
80
+ totalLength: this.accumulatedAIText.length,
81
+ chunk: chunk.substring(0, 200) + (chunk.length > 200 ? '...' : ''),
82
+ });
83
+ }
84
+ /**
85
+ * Log completed AI text response
86
+ */
87
+ logAITextComplete() {
88
+ if (this.accumulatedAIText) {
89
+ this.log(LogLevel.INFO, LogCategory.AI_TEXT, 'AI text response complete', {
90
+ totalLength: this.accumulatedAIText.length,
91
+ preview: this.accumulatedAIText.substring(0, 500) + (this.accumulatedAIText.length > 500 ? '...' : ''),
92
+ fullContent: this.accumulatedAIText,
93
+ });
94
+ }
95
+ this.accumulatedAIText = '';
96
+ }
97
+ /**
98
+ * Log thought chunk (streaming)
99
+ */
100
+ logThoughtChunk(thought) {
101
+ this.accumulatedThought += thought;
102
+ this.log(LogLevel.DEBUG, LogCategory.THOUGHT, 'Thought chunk received', {
103
+ chunkLength: thought.length,
104
+ totalLength: this.accumulatedThought.length,
105
+ chunk: thought.substring(0, 200) + (thought.length > 200 ? '...' : ''),
106
+ });
107
+ }
108
+ /**
109
+ * Log thought completion with duration
110
+ */
111
+ logThoughtComplete(durationSeconds) {
112
+ this.log(LogLevel.INFO, LogCategory.THOUGHT, 'Thinking completed', {
113
+ durationSeconds,
114
+ totalLength: this.accumulatedThought.length,
115
+ preview: this.accumulatedThought.substring(0, 500) + (this.accumulatedThought.length > 500 ? '...' : ''),
116
+ fullThought: this.accumulatedThought,
117
+ });
118
+ this.accumulatedThought = '';
119
+ }
120
+ /**
121
+ * Log a tool call being received from AI
122
+ */
123
+ logToolCall(name, id, args) {
124
+ // Sanitize args to avoid logging huge content
125
+ const sanitizedArgs = {};
126
+ for (const [key, value] of Object.entries(args)) {
127
+ if (typeof value === 'string' && value.length > 1000) {
128
+ sanitizedArgs[key] = value.substring(0, 1000) + `... [truncated ${value.length - 1000} chars]`;
129
+ }
130
+ else {
131
+ sanitizedArgs[key] = value;
132
+ }
133
+ }
134
+ this.log(LogLevel.INFO, LogCategory.TOOL_CALL, `Tool call received: ${name}`, {
135
+ toolName: name,
136
+ toolCallId: id,
137
+ arguments: sanitizedArgs,
138
+ });
139
+ }
140
+ /**
141
+ * Log tool execution starting
142
+ */
143
+ logToolExecutionStart(name, id) {
144
+ this.log(LogLevel.INFO, LogCategory.TOOL_EXEC, `Executing tool: ${name}`, {
145
+ toolName: name,
146
+ toolCallId: id,
147
+ });
148
+ }
149
+ /**
150
+ * Log tool execution result
151
+ */
152
+ logToolResult(name, id, result, success, error) {
153
+ // Sanitize result to avoid logging huge content
154
+ let sanitizedResult = result;
155
+ if (typeof result === 'string' && result.length > 2000) {
156
+ sanitizedResult = result.substring(0, 2000) + `... [truncated ${result.length - 2000} chars]`;
157
+ }
158
+ this.log(success ? LogLevel.INFO : LogLevel.WARN, LogCategory.TOOL_RESULT, `Tool ${success ? 'completed' : 'failed'}: ${name}`, {
159
+ toolName: name,
160
+ toolCallId: id,
161
+ success,
162
+ result: sanitizedResult,
163
+ error: error,
164
+ });
165
+ }
166
+ /**
167
+ * Log loop state at turn boundaries
168
+ */
169
+ logLoopState(turn, state) {
170
+ this.currentTurn = turn;
171
+ this.log(LogLevel.INFO, LogCategory.LOOP, `Turn ${turn} state`, state);
172
+ }
173
+ /**
174
+ * Log when narration/completion detection triggers
175
+ */
176
+ logNarrationDetection(type, details) {
177
+ this.log(LogLevel.WARN, LogCategory.NARRATION, `Detection: ${type}`, details);
178
+ }
179
+ /**
180
+ * Log system prompts added to conversation
181
+ */
182
+ logSystemPrompt(promptType, content) {
183
+ this.log(LogLevel.INFO, LogCategory.SYSTEM, `System prompt: ${promptType}`, {
184
+ contentLength: content.length,
185
+ content: content.substring(0, 500) + (content.length > 500 ? '...' : ''),
186
+ });
187
+ }
188
+ /**
189
+ * Log an error
190
+ */
191
+ logError(context, error) {
192
+ const errorMessage = error instanceof Error ? error.message : error;
193
+ const errorStack = error instanceof Error ? error.stack : undefined;
194
+ this.log(LogLevel.ERROR, LogCategory.ERROR, `Error in ${context}`, {
195
+ message: errorMessage,
196
+ stack: errorStack,
197
+ });
198
+ }
199
+ /**
200
+ * Log stream completion
201
+ */
202
+ logStreamEnd(reason) {
203
+ this.log(LogLevel.INFO, LogCategory.LOOP, 'Stream ended', { reason });
204
+ }
205
+ /**
206
+ * Log task completion
207
+ */
208
+ logTaskComplete(summary) {
209
+ this.log(LogLevel.INFO, LogCategory.SESSION, 'Task completed', {
210
+ summaryLength: summary.length,
211
+ summary: summary.substring(0, 500) + (summary.length > 500 ? '...' : ''),
212
+ });
213
+ }
214
+ /**
215
+ * Log session end
216
+ */
217
+ endSession(finalMessage, turnCount) {
218
+ this.log(LogLevel.INFO, LogCategory.SESSION, '═══════════════════════════════════════════════════════════════════════════════');
219
+ this.log(LogLevel.INFO, LogCategory.SESSION, 'CONVERSATION SESSION ENDED', {
220
+ totalTurns: turnCount,
221
+ finalMessageLength: finalMessage.length,
222
+ finalMessagePreview: finalMessage.substring(0, 300) + (finalMessage.length > 300 ? '...' : ''),
223
+ });
224
+ this.log(LogLevel.INFO, LogCategory.SESSION, '═══════════════════════════════════════════════════════════════════════════════');
225
+ this.log(LogLevel.INFO, LogCategory.SESSION, ''); // Empty line for separation
226
+ }
227
+ /**
228
+ * Log messages array state (for debugging conversation history)
229
+ */
230
+ logConversationHistory(messages) {
231
+ this.log(LogLevel.DEBUG, LogCategory.LOOP, 'Current conversation history', {
232
+ messageCount: messages.length,
233
+ messages: messages.map((m, i) => ({
234
+ index: i,
235
+ role: m.role,
236
+ contentLength: m.content.length,
237
+ contentPreview: m.content.substring(0, 100) + (m.content.length > 100 ? '...' : ''),
238
+ hasToolCalls: !!(m.tool_calls && m.tool_calls.length > 0),
239
+ toolCallCount: m.tool_calls?.length || 0,
240
+ })),
241
+ });
242
+ }
243
+ /**
244
+ * Core logging function
245
+ */
246
+ log(level, category, message, details) {
247
+ if (!this.enabled)
248
+ return;
249
+ const timestamp = new Date().toISOString();
250
+ const sessionId = this.sessionId || 'no_session';
251
+ const entry = {
252
+ timestamp,
253
+ sessionId,
254
+ level,
255
+ category,
256
+ message,
257
+ details,
258
+ };
259
+ // Format the log line
260
+ let logLine = `[${timestamp}] [${sessionId}] [${level}] [${category}] ${message}`;
261
+ if (details) {
262
+ try {
263
+ const detailsStr = JSON.stringify(details, null, 2);
264
+ // Indent details for readability
265
+ const indentedDetails = detailsStr.split('\n').map(line => ' ' + line).join('\n');
266
+ logLine += '\n' + indentedDetails;
267
+ }
268
+ catch (e) {
269
+ logLine += '\n [Details could not be serialized]';
270
+ }
271
+ }
272
+ logLine += '\n';
273
+ try {
274
+ fs.appendFileSync(this.logFilePath, logLine);
275
+ }
276
+ catch (e) {
277
+ // Silently fail if we can't write logs
278
+ }
279
+ }
280
+ }
281
+ // Export singleton instance
282
+ export const conversationLogger = new ConversationLogger();
283
+ //# sourceMappingURL=conversation-logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation-logger.js","sourceRoot":"","sources":["../../src/utils/conversation-logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB,aAAa;AACb,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAChB,2BAAe,CAAA;IACf,yBAAa,CAAA;IACb,yBAAa,CAAA;IACb,2BAAe,CAAA;AACnB,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;AAED,+BAA+B;AAC/B,MAAM,CAAN,IAAY,WAYX;AAZD,WAAY,WAAW;IACnB,kCAAmB,CAAA;IACnB,oCAAqB,CAAA;IACrB,kCAAmB,CAAA;IACnB,kCAAmB,CAAA;IACnB,sCAAuB,CAAA;IACvB,sCAAuB,CAAA;IACvB,0CAA2B,CAAA;IAC3B,4BAAa,CAAA;IACb,sCAA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MAAM,QAAQ,KAAK,OAAO,EAAE,CAAC;QAElF,IAAI,OAAO,EAAE,CAAC;YACV,IAAI,CAAC;gBACD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;gBACpD,iCAAiC;gBACjC,MAAM,eAAe,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnF,OAAO,IAAI,IAAI,GAAG,eAAe,CAAC;YACtC,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACT,OAAO,IAAI,uCAAuC,CAAC;YACvD,CAAC;QACL,CAAC;QAED,OAAO,IAAI,IAAI,CAAC;QAEhB,IAAI,CAAC;YACD,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACT,uCAAuC;QAC3C,CAAC;IACL,CAAC;CACJ;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Check if a command is an interactive editor that needs full terminal control
3
+ */
4
+ export declare function isInteractiveEditorCommand(command: string): boolean;
5
+ /**
6
+ * Check if the command is specifically for nano editor (the only remote-supported editor currently)
7
+ */
8
+ export declare function isNanoEditor(command: string): boolean;
9
+ /**
10
+ * Get the display name of an editor command for user-friendly messages
11
+ */
12
+ export declare function getEditorName(command: string): string;
13
+ /**
14
+ * Run an interactive editor with full terminal control (LOCAL mode).
15
+ * This function:
16
+ * 1. Clears the screen and enters alternate screen buffer
17
+ * 2. Spawns a PTY process
18
+ * 3. Pipes stdin directly to the PTY (raw mode)
19
+ * 4. Pipes PTY output directly to stdout
20
+ * 5. Handles cleanup on exit
21
+ *
22
+ * Uses alternate screen buffer to prevent chat history from showing through.
23
+ */
24
+ export declare function runInteractiveEditor(command: string, cwd: string, onExit: (exitCode: number) => void): {
25
+ kill: () => void;
26
+ };
27
+ /**
28
+ * Run an interactive editor in WSL session via node-pty.
29
+ * Uses wsl.exe to execute the editor command in the specified distribution.
30
+ */
31
+ export declare function runWSLEditor(distribution: string, command: string, cwd: string, onExit: (exitCode: number) => void): {
32
+ kill: () => void;
33
+ };
34
+ /**
35
+ * Interactive process interface for WSL PTY commands
36
+ */
37
+ export interface WSLPtyProcess {
38
+ write: (data: string) => void;
39
+ kill: () => void;
40
+ resize: (cols: number, rows: number) => void;
41
+ isRunning: () => boolean;
42
+ }
43
+ /**
44
+ * Run a command in WSL session via node-pty with streaming output.
45
+ * Unlike runWSLEditor, this doesn't take over the terminal - it streams output to a callback.
46
+ * This is essential for sudo commands that need TTY for password prompts.
47
+ */
48
+ export declare function runWSLCommand(distribution: string, command: string, cwd: string, onData: (data: string) => void, onExit: (exitCode: number) => void): WSLPtyProcess;
49
+ /**
50
+ * Run a command in Docker container via node-pty with streaming output.
51
+ * Unlike runDockerEditor, this doesn't take over the terminal - it streams output to a callback.
52
+ * This is essential for sudo commands that need TTY for password prompts.
53
+ */
54
+ export declare function runDockerCommand(containerId: string, command: string, cwd: string, onData: (data: string) => void, onExit: (exitCode: number) => void): WSLPtyProcess;
55
+ /**
56
+ * Run an interactive editor in Docker container via node-pty.
57
+ * Uses docker exec -it to execute the editor command in the container.
58
+ */
59
+ export declare function runDockerEditor(containerId: string, command: string, cwd: string, onExit: (exitCode: number) => void): {
60
+ kill: () => void;
61
+ };
62
+ /**
63
+ * Run an interactive editor in SSH session via ssh2's interactive shell.
64
+ * This is more complex as we need to use the ssh2 client's shell() method
65
+ * instead of exec() to get a proper interactive PTY.
66
+ */
67
+ export declare function runSSHEditor(sshClient: any, // ssh2 Client
68
+ command: string, cwd: string, onExit: (exitCode: number) => void): {
69
+ kill: () => void;
70
+ };
71
+ /**
72
+ * SSH PTY process interface for SSH commands with streaming output
73
+ */
74
+ export interface SSHPtyProcess {
75
+ write: (data: string) => void;
76
+ kill: () => void;
77
+ resize: (cols: number, rows: number) => void;
78
+ isRunning: () => boolean;
79
+ }
80
+ /**
81
+ * Run a command in SSH session via ssh2's interactive shell with streaming output.
82
+ * Unlike runSSHEditor, this doesn't take over the terminal - it streams output to a callback.
83
+ * This is essential for sudo commands that need TTY for password prompts.
84
+ */
85
+ export declare function runSSHCommand(sshClient: any, // ssh2 Client
86
+ command: string, cwd: string, onData: (data: string) => void, onExit: (exitCode: number) => void): SSHPtyProcess;
87
+ //# sourceMappingURL=editor-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editor-utils.d.ts","sourceRoot":"","sources":["../../src/utils/editor-utils.ts"],"names":[],"mappings":"AA0BA;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAwBnE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAWrD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA2BrD;AAwKD;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAChC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GACnC;IAAE,IAAI,EAAE,MAAM,IAAI,CAAA;CAAE,CA6GtB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CACxB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GACnC;IAAE,IAAI,EAAE,MAAM,IAAI,CAAA;CAAE,CA6BtB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B,KAAK,EAAE,CAAC,IAAI,EAAE,M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