centaurus-cli 2.9.1 → 2.9.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 (127) hide show
  1. package/dist/cli-adapter.d.ts +70 -0
  2. package/dist/cli-adapter.d.ts.map +1 -1
  3. package/dist/cli-adapter.js +349 -156
  4. package/dist/cli-adapter.js.map +1 -1
  5. package/dist/config/mcp-config-manager.d.ts +21 -0
  6. package/dist/config/mcp-config-manager.d.ts.map +1 -1
  7. package/dist/config/mcp-config-manager.js +184 -1
  8. package/dist/config/mcp-config-manager.js.map +1 -1
  9. package/dist/config/models.d.ts +1 -0
  10. package/dist/config/models.d.ts.map +1 -1
  11. package/dist/config/models.js +7 -2
  12. package/dist/config/models.js.map +1 -1
  13. package/dist/config/slash-commands.d.ts.map +1 -1
  14. package/dist/config/slash-commands.js +4 -3
  15. package/dist/config/slash-commands.js.map +1 -1
  16. package/dist/index.js +60 -11
  17. package/dist/index.js.map +1 -1
  18. package/dist/mcp/mcp-command-handler.d.ts +34 -3
  19. package/dist/mcp/mcp-command-handler.d.ts.map +1 -1
  20. package/dist/mcp/mcp-command-handler.js +171 -83
  21. package/dist/mcp/mcp-command-handler.js.map +1 -1
  22. package/dist/mcp/mcp-server-manager.d.ts.map +1 -1
  23. package/dist/mcp/mcp-server-manager.js +9 -23
  24. package/dist/mcp/mcp-server-manager.js.map +1 -1
  25. package/dist/mcp/mcp-tool-wrapper.d.ts.map +1 -1
  26. package/dist/mcp/mcp-tool-wrapper.js +42 -5
  27. package/dist/mcp/mcp-tool-wrapper.js.map +1 -1
  28. package/dist/services/api-client.d.ts +9 -0
  29. package/dist/services/api-client.d.ts.map +1 -1
  30. package/dist/services/api-client.js +25 -0
  31. package/dist/services/api-client.js.map +1 -1
  32. package/dist/services/input-detection-agent.d.ts +40 -0
  33. package/dist/services/input-detection-agent.d.ts.map +1 -0
  34. package/dist/services/input-detection-agent.js +213 -0
  35. package/dist/services/input-detection-agent.js.map +1 -0
  36. package/dist/services/input-requirement-detector.d.ts +28 -0
  37. package/dist/services/input-requirement-detector.d.ts.map +1 -0
  38. package/dist/services/input-requirement-detector.js +203 -0
  39. package/dist/services/input-requirement-detector.js.map +1 -0
  40. package/dist/services/monitored-shell-manager.d.ts +120 -0
  41. package/dist/services/monitored-shell-manager.d.ts.map +1 -0
  42. package/dist/services/monitored-shell-manager.js +239 -0
  43. package/dist/services/monitored-shell-manager.js.map +1 -0
  44. package/dist/services/shell-input-agent.d.ts +89 -0
  45. package/dist/services/shell-input-agent.d.ts.map +1 -0
  46. package/dist/services/shell-input-agent.js +361 -0
  47. package/dist/services/shell-input-agent.js.map +1 -0
  48. package/dist/services/sub-agent-manager.d.ts +139 -0
  49. package/dist/services/sub-agent-manager.d.ts.map +1 -0
  50. package/dist/services/sub-agent-manager.js +517 -0
  51. package/dist/services/sub-agent-manager.js.map +1 -0
  52. package/dist/tools/background-command.d.ts.map +1 -1
  53. package/dist/tools/background-command.js +33 -13
  54. package/dist/tools/background-command.js.map +1 -1
  55. package/dist/tools/command.d.ts.map +1 -1
  56. package/dist/tools/command.js +64 -1
  57. package/dist/tools/command.js.map +1 -1
  58. package/dist/tools/file-ops.d.ts.map +1 -1
  59. package/dist/tools/file-ops.js +33 -19
  60. package/dist/tools/file-ops.js.map +1 -1
  61. package/dist/tools/get-diff.js +1 -1
  62. package/dist/tools/get-diff.js.map +1 -1
  63. package/dist/tools/grep-search.d.ts.map +1 -1
  64. package/dist/tools/grep-search.js +41 -15
  65. package/dist/tools/grep-search.js.map +1 -1
  66. package/dist/tools/plan-mode.js +3 -3
  67. package/dist/tools/plan-mode.js.map +1 -1
  68. package/dist/tools/registry.js +1 -1
  69. package/dist/tools/registry.js.map +1 -1
  70. package/dist/tools/sub-agent.d.ts +9 -0
  71. package/dist/tools/sub-agent.d.ts.map +1 -0
  72. package/dist/tools/sub-agent.js +232 -0
  73. package/dist/tools/sub-agent.js.map +1 -0
  74. package/dist/tools/task-complete.d.ts.map +1 -1
  75. package/dist/tools/task-complete.js +14 -26
  76. package/dist/tools/task-complete.js.map +1 -1
  77. package/dist/ui/components/App.d.ts +43 -0
  78. package/dist/ui/components/App.d.ts.map +1 -1
  79. package/dist/ui/components/App.js +560 -94
  80. package/dist/ui/components/App.js.map +1 -1
  81. package/dist/ui/components/CircularSelectInput.d.ts +24 -0
  82. package/dist/ui/components/CircularSelectInput.d.ts.map +1 -0
  83. package/dist/ui/components/CircularSelectInput.js +71 -0
  84. package/dist/ui/components/CircularSelectInput.js.map +1 -0
  85. package/dist/ui/components/ErrorBoundary.d.ts +3 -2
  86. package/dist/ui/components/ErrorBoundary.d.ts.map +1 -1
  87. package/dist/ui/components/ErrorBoundary.js +29 -1
  88. package/dist/ui/components/ErrorBoundary.js.map +1 -1
  89. package/dist/ui/components/InputBox.d.ts +2 -0
  90. package/dist/ui/components/InputBox.d.ts.map +1 -1
  91. package/dist/ui/components/InputBox.js +23 -3
  92. package/dist/ui/components/InputBox.js.map +1 -1
  93. package/dist/ui/components/InteractiveShell.d.ts +6 -0
  94. package/dist/ui/components/InteractiveShell.d.ts.map +1 -1
  95. package/dist/ui/components/InteractiveShell.js +57 -6
  96. package/dist/ui/components/InteractiveShell.js.map +1 -1
  97. package/dist/ui/components/MCPAddScreen.d.ts +13 -0
  98. package/dist/ui/components/MCPAddScreen.d.ts.map +1 -0
  99. package/dist/ui/components/MCPAddScreen.js +54 -0
  100. package/dist/ui/components/MCPAddScreen.js.map +1 -0
  101. package/dist/ui/components/MCPListScreen.d.ts +17 -0
  102. package/dist/ui/components/MCPListScreen.d.ts.map +1 -0
  103. package/dist/ui/components/MCPListScreen.js +50 -0
  104. package/dist/ui/components/MCPListScreen.js.map +1 -0
  105. package/dist/ui/components/MCPServerListScreen.d.ts +16 -0
  106. package/dist/ui/components/MCPServerListScreen.d.ts.map +1 -0
  107. package/dist/ui/components/MCPServerListScreen.js +59 -0
  108. package/dist/ui/components/MCPServerListScreen.js.map +1 -0
  109. package/dist/ui/components/MonitorModeAIPanel.d.ts +23 -0
  110. package/dist/ui/components/MonitorModeAIPanel.d.ts.map +1 -0
  111. package/dist/ui/components/MonitorModeAIPanel.js +69 -0
  112. package/dist/ui/components/MonitorModeAIPanel.js.map +1 -0
  113. package/dist/ui/components/MultiLineInput.d.ts +13 -0
  114. package/dist/ui/components/MultiLineInput.d.ts.map +1 -0
  115. package/dist/ui/components/MultiLineInput.js +223 -0
  116. package/dist/ui/components/MultiLineInput.js.map +1 -0
  117. package/dist/ui/components/StatusBar.d.ts +2 -0
  118. package/dist/ui/components/StatusBar.d.ts.map +1 -1
  119. package/dist/ui/components/StatusBar.js +33 -2
  120. package/dist/ui/components/StatusBar.js.map +1 -1
  121. package/dist/ui/components/ToolExecutionMessage.d.ts.map +1 -1
  122. package/dist/ui/components/ToolExecutionMessage.js +226 -12
  123. package/dist/ui/components/ToolExecutionMessage.js.map +1 -1
  124. package/dist/ui/components/VersionUpdatePrompt.d.ts.map +1 -1
  125. package/dist/ui/components/VersionUpdatePrompt.js +3 -2
  126. package/dist/ui/components/VersionUpdatePrompt.js.map +1 -1
  127. package/package.json +2 -1
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Monitored Shell Manager Service
3
+ *
4
+ * Manages agent-controlled shell sessions, detecting when input is required
5
+ * and coordinating with the AI to provide appropriate responses.
6
+ */
7
+ import { InputDetectionResult } from './input-requirement-detector.js';
8
+ /**
9
+ * Represents a message displayed during monitoring mode
10
+ */
11
+ export interface MonitorMessage {
12
+ id: string;
13
+ type: 'thinking' | 'tool_call' | 'text' | 'input_sent';
14
+ content: string;
15
+ timestamp: Date;
16
+ isAnswered?: boolean;
17
+ }
18
+ /**
19
+ * Represents an active monitored shell session
20
+ */
21
+ export interface MonitoredShellSession {
22
+ shellId: string;
23
+ command: string;
24
+ cwd: string;
25
+ output: string;
26
+ isRunning: boolean;
27
+ lastOutputTime: number;
28
+ monitoringMessages: MonitorMessage[];
29
+ inputCheckInterval?: NodeJS.Timeout;
30
+ onInputRequired?: (session: MonitoredShellSession, detectionResult: InputDetectionResult) => void;
31
+ }
32
+ /**
33
+ * Callback when the AI needs to be prompted for shell input
34
+ */
35
+ export type OnAIInputRequestCallback = (shellId: string, shellOutput: string, promptContext: string, inputType: string) => Promise<string | null>;
36
+ /**
37
+ * Monitored Shell Manager
38
+ *
39
+ * Handles tracking of agent-controlled shells and coordinating input detection.
40
+ */
41
+ declare class MonitoredShellManagerClass {
42
+ private sessions;
43
+ private onAIInputRequest?;
44
+ private onMonitoringMessage?;
45
+ private inputCheckIntervalMs;
46
+ private shellIdCounter;
47
+ /**
48
+ * Generate a unique shell ID
49
+ */
50
+ generateShellId(): string;
51
+ /**
52
+ * Set the callback for requesting AI input
53
+ */
54
+ setOnAIInputRequest(callback: OnAIInputRequestCallback): void;
55
+ /**
56
+ * Set the callback for new monitoring messages
57
+ */
58
+ setOnMonitoringMessage(callback: (shellId: string, message: MonitorMessage) => void): void;
59
+ /**
60
+ * Start monitoring a shell session
61
+ */
62
+ startMonitoring(shellId: string, command: string, cwd: string, onInputRequired?: (session: MonitoredShellSession, detectionResult: InputDetectionResult) => void): MonitoredShellSession;
63
+ /**
64
+ * Stop monitoring a shell session
65
+ */
66
+ stopMonitoring(shellId: string): void;
67
+ /**
68
+ * Update shell output for a monitored session
69
+ */
70
+ updateOutput(shellId: string, newOutput: string): void;
71
+ /**
72
+ * Mark a shell session as complete
73
+ */
74
+ markComplete(shellId: string): void;
75
+ /**
76
+ * Get a session by ID
77
+ */
78
+ getSession(shellId: string): MonitoredShellSession | undefined;
79
+ /**
80
+ * Check if a specific shell session is active
81
+ */
82
+ isSessionActive(shellId: string): boolean;
83
+ /**
84
+ * Get all active shell IDs
85
+ */
86
+ getActiveShellIds(): string[];
87
+ /**
88
+ * Add a monitoring message to a session
89
+ */
90
+ addMonitoringMessage(shellId: string, type: MonitorMessage['type'], content: string): MonitorMessage;
91
+ /**
92
+ * Get monitoring messages for a session
93
+ */
94
+ getMonitoringMessages(shellId: string): MonitorMessage[];
95
+ /**
96
+ * Clear monitoring messages for a session
97
+ */
98
+ clearMonitoringMessages(shellId: string): void;
99
+ /**
100
+ * Mark the most recent 'thinking' message as answered
101
+ * This changes the spinner to a tick in the UI
102
+ */
103
+ markLastThinkingAsAnswered(shellId: string): void;
104
+ /**
105
+ * Check if a shell requires input and trigger AI prompt if needed
106
+ */
107
+ private checkForInputRequirement;
108
+ /**
109
+ * Build a prompt for the AI to provide shell input
110
+ * This is used when the AI needs to decide what to input
111
+ */
112
+ buildInputPrompt(shellOutput: string, promptContext: string, inputType: string, originalCommand: string): string;
113
+ /**
114
+ * Get the last N lines of output
115
+ */
116
+ private getLastNLines;
117
+ }
118
+ export declare const MonitoredShellManager: MonitoredShellManagerClass;
119
+ export {};
120
+ //# sourceMappingURL=monitored-shell-manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitored-shell-manager.d.ts","sourceRoot":"","sources":["../../src/services/monitored-shell-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAyE,oBAAoB,EAA4B,MAAM,iCAAiC,CAAC;AAGxK;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,GAAG,WAAW,GAAG,MAAM,GAAG,YAAY,CAAC;IACvD,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,kBAAkB,EAAE,cAAc,EAAE,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC;IACpC,e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AO,EAAE,MAAM,GAAG,OAAO;IAIzC;;OAEG;IACH,iBAAiB,IAAI,MAAM,EAAE;IAI7B;;OAEG;IACH,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc;IAqBpG;;OAEG;IACH,qBAAqB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE;IAIxD;;OAEG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAO9C;;;OAGG;IACH,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAejD;;OAEG;YACW,wBAAwB;IA6CtC;;;OAGG;IACH,gBAAgB,CAAC,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM;IAuBhH;;OAEG;IACH,OAAO,CAAC,aAAa;CAIxB;AAGD,eAAO,MAAM,qBAAqB,4BAAmC,CAAC"}
@@ -0,0 +1,239 @@
1
+ /**
2
+ * Monitored Shell Manager Service
3
+ *
4
+ * Manages agent-controlled shell sessions, detecting when input is required
5
+ * and coordinating with the AI to provide appropriate responses.
6
+ */
7
+ import { detectInputRequirement, extractPromptContext, getInputTypeDescription } from './input-requirement-detector.js';
8
+ import { quickLog } from '../utils/conversation-logger.js';
9
+ /**
10
+ * Monitored Shell Manager
11
+ *
12
+ * Handles tracking of agent-controlled shells and coordinating input detection.
13
+ */
14
+ class MonitoredShellManagerClass {
15
+ sessions = new Map();
16
+ onAIInputRequest;
17
+ onMonitoringMessage;
18
+ inputCheckIntervalMs = 500;
19
+ shellIdCounter = 0;
20
+ /**
21
+ * Generate a unique shell ID
22
+ */
23
+ generateShellId() {
24
+ this.shellIdCounter++;
25
+ return `shell-${Date.now()}-${this.shellIdCounter}`;
26
+ }
27
+ /**
28
+ * Set the callback for requesting AI input
29
+ */
30
+ setOnAIInputRequest(callback) {
31
+ this.onAIInputRequest = callback;
32
+ }
33
+ /**
34
+ * Set the callback for new monitoring messages
35
+ */
36
+ setOnMonitoringMessage(callback) {
37
+ this.onMonitoringMessage = callback;
38
+ }
39
+ /**
40
+ * Start monitoring a shell session
41
+ */
42
+ startMonitoring(shellId, command, cwd, onInputRequired) {
43
+ // Clean up any existing session with the same ID
44
+ this.stopMonitoring(shellId);
45
+ const session = {
46
+ shellId,
47
+ command,
48
+ cwd,
49
+ output: '',
50
+ isRunning: true,
51
+ lastOutputTime: Date.now(),
52
+ monitoringMessages: [],
53
+ onInputRequired
54
+ };
55
+ // Start periodic input detection
56
+ session.inputCheckInterval = setInterval(() => {
57
+ this.checkForInputRequirement(shellId);
58
+ }, this.inputCheckIntervalMs);
59
+ this.sessions.set(shellId, session);
60
+ quickLog(`[${new Date().toISOString()}] [MonitoredShellManager] Started monitoring shell ${shellId}: ${command}\n`);
61
+ return session;
62
+ }
63
+ /**
64
+ * Stop monitoring a shell session
65
+ */
66
+ stopMonitoring(shellId) {
67
+ const session = this.sessions.get(shellId);
68
+ if (session) {
69
+ if (session.inputCheckInterval) {
70
+ clearInterval(session.inputCheckInterval);
71
+ }
72
+ this.sessions.delete(shellId);
73
+ quickLog(`[${new Date().toISOString()}] [MonitoredShellManager] Stopped monitoring shell ${shellId}\n`);
74
+ }
75
+ }
76
+ /**
77
+ * Update shell output for a monitored session
78
+ */
79
+ updateOutput(shellId, newOutput) {
80
+ const session = this.sessions.get(shellId);
81
+ if (session) {
82
+ session.output += newOutput;
83
+ session.lastOutputTime = Date.now();
84
+ }
85
+ }
86
+ /**
87
+ * Mark a shell session as complete
88
+ */
89
+ markComplete(shellId) {
90
+ const session = this.sessions.get(shellId);
91
+ if (session) {
92
+ session.isRunning = false;
93
+ this.stopMonitoring(shellId);
94
+ }
95
+ }
96
+ /**
97
+ * Get a session by ID
98
+ */
99
+ getSession(shellId) {
100
+ return this.sessions.get(shellId);
101
+ }
102
+ /**
103
+ * Check if a specific shell session is active
104
+ */
105
+ isSessionActive(shellId) {
106
+ return this.sessions.has(shellId);
107
+ }
108
+ /**
109
+ * Get all active shell IDs
110
+ */
111
+ getActiveShellIds() {
112
+ return Array.from(this.sessions.keys());
113
+ }
114
+ /**
115
+ * Add a monitoring message to a session
116
+ */
117
+ addMonitoringMessage(shellId, type, content) {
118
+ const session = this.sessions.get(shellId);
119
+ const message = {
120
+ id: `msg-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`,
121
+ type,
122
+ content,
123
+ timestamp: new Date()
124
+ };
125
+ if (session) {
126
+ session.monitoringMessages.push(message);
127
+ // Callback to notify UI
128
+ if (this.onMonitoringMessage) {
129
+ this.onMonitoringMessage(shellId, message);
130
+ }
131
+ }
132
+ return message;
133
+ }
134
+ /**
135
+ * Get monitoring messages for a session
136
+ */
137
+ getMonitoringMessages(shellId) {
138
+ return this.sessions.get(shellId)?.monitoringMessages || [];
139
+ }
140
+ /**
141
+ * Clear monitoring messages for a session
142
+ */
143
+ clearMonitoringMessages(shellId) {
144
+ const session = this.sessions.get(shellId);
145
+ if (session) {
146
+ session.monitoringMessages = [];
147
+ }
148
+ }
149
+ /**
150
+ * Mark the most recent 'thinking' message as answered
151
+ * This changes the spinner to a tick in the UI
152
+ */
153
+ markLastThinkingAsAnswered(shellId) {
154
+ const session = this.sessions.get(shellId);
155
+ if (session) {
156
+ // Find the last 'thinking' message that isn't already answered
157
+ for (let i = session.monitoringMessages.length - 1; i >= 0; i--) {
158
+ const msg = session.monitoringMessages[i];
159
+ if (msg.type === 'thinking' && !msg.isAnswered) {
160
+ msg.isAnswered = true;
161
+ quickLog(`[${new Date().toISOString()}] [MonitoredShellManager] Marked message ${msg.id} as answered\n`);
162
+ break;
163
+ }
164
+ }
165
+ }
166
+ }
167
+ /**
168
+ * Check if a shell requires input and trigger AI prompt if needed
169
+ */
170
+ async checkForInputRequirement(shellId) {
171
+ const session = this.sessions.get(shellId);
172
+ if (!session || !session.isRunning) {
173
+ return;
174
+ }
175
+ const timeSinceLastOutput = Date.now() - session.lastOutputTime;
176
+ const result = detectInputRequirement(session.output, timeSinceLastOutput);
177
+ if (result.requiresInput && result.confidence !== 'low') {
178
+ quickLog(`[${new Date().toISOString()}] [MonitoredShellManager] Input detected for ${shellId}: ${result.matchedPattern}\n`);
179
+ // Notify session callback
180
+ if (session.onInputRequired) {
181
+ session.onInputRequired(session, result);
182
+ }
183
+ // Request AI input
184
+ if (this.onAIInputRequest) {
185
+ const promptContext = extractPromptContext(session.output);
186
+ const inputType = getInputTypeDescription(result);
187
+ // Add "thinking" message
188
+ this.addMonitoringMessage(shellId, 'thinking', 'Analyzing shell prompt...');
189
+ try {
190
+ const aiInput = await this.onAIInputRequest(shellId, session.output, promptContext, inputType);
191
+ if (aiInput !== null) {
192
+ // Add message showing what input was sent
193
+ this.addMonitoringMessage(shellId, 'input_sent', `Sent input: ${aiInput}`);
194
+ }
195
+ }
196
+ catch (error) {
197
+ quickLog(`[${new Date().toISOString()}] [MonitoredShellManager] Error requesting AI input: ${error.message}\n`);
198
+ this.addMonitoringMessage(shellId, 'text', `Error: ${error.message}`);
199
+ }
200
+ }
201
+ }
202
+ }
203
+ /**
204
+ * Build a prompt for the AI to provide shell input
205
+ * This is used when the AI needs to decide what to input
206
+ */
207
+ buildInputPrompt(shellOutput, promptContext, inputType, originalCommand) {
208
+ return `The command "${originalCommand}" is currently running and requires user input.
209
+
210
+ **Current shell output (last 50 lines):**
211
+ \`\`\`
212
+ ${this.getLastNLines(shellOutput, 50)}
213
+ \`\`\`
214
+
215
+ **The command is asking for:** ${promptContext}
216
+
217
+ **Expected input type:** ${inputType}
218
+
219
+ Please provide the appropriate input to respond to this prompt. Use the execute_command tool with the shell_input parameter to send your response.
220
+
221
+ Guidelines:
222
+ - For yes/no prompts, respond with "y" or "n" (or "yes"/"no" if the prompt requires full words)
223
+ - For password prompts, you should NOT provide passwords - ask the user to handle this manually
224
+ - For npm init style prompts, provide reasonable defaults or press Enter for default values
225
+ - For other prompts, provide the most appropriate response based on context
226
+
227
+ If this appears to be a security-sensitive prompt (passwords, authentication), respond with a message indicating the user should handle this manually.`;
228
+ }
229
+ /**
230
+ * Get the last N lines of output
231
+ */
232
+ getLastNLines(text, n) {
233
+ const lines = text.split('\n');
234
+ return lines.slice(-n).join('\n');
235
+ }
236
+ }
237
+ // Export singleton instance
238
+ export const MonitoredShellManager = new MonitoredShellManagerClass();
239
+ //# sourceMappingURL=monitored-shell-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"monitored-shell-manager.js","sourceRoot":"","sources":["../../src/services/monitored-shell-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,uBAAuB,EAAkD,MAAM,iCAAiC,CAAC;AACxK,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAsC3D;;;;GAIG;AACH,MAAM,0BAA0B;IACpB,QAAQ,GAAuC,IAAI,GAAG,EAAE,CAAC;IACzD,gBAAgB,CAA4B;IAC5C,mBAAmB,CAAsD;IACzE,oBAAoB,GAAW,GAAG,CAAC;IACnC,cAAc,GAAW,CAAC,CAAC;IAEnC;;OAEG;IACH,eAAe;QACX,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,OAAO,SAAS,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;IACxD,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,QAAkC;QAClD,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,sBAAsB,CAAC,QAA4D;QAC/E,IAAI,CAAC,mBAAmB,GAAG,QAAQ,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,eAAe,CACX,OAAe,EACf,OAAe,EACf,GAAW,EACX,eAAiG;QAEjG,iDAAiD;QACjD,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QAE7B,MAAM,OAAO,GAA0B;YAC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oBAClB,QAAQ,CAAC,IAAI,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,wDAAwD,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC;oBAChH,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC1E,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,gBAAgB,CAAC,WAAmB,EAAE,aAAqB,EAAE,SAAiB,EAAE,eAAuB;QACnG,OAAO,gBAAgB,eAAe;;;;EAI5C,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,CAAC;;;iCAGJ,aAAa;;2BAEnB,SAAS;;;;;;;;;;uJAUmH,CAAC;IACpJ,CAAC;IAED;;OAEG;IACK,aAAa,CAAC,IAAY,EAAE,CAAS;QACzC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/B,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;CACJ;AAED,4BAA4B;AAC5B,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,0BAA0B,EAAE,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Shell Input Agent Service
3
+ *
4
+ * An isolated AI agent that handles shell input prompts during Agent Control Mode.
5
+ * Completely separate from the main chat agent - has its own conversation history,
6
+ * tools, and lifecycle. Terminates immediately when the shell command completes.
7
+ */
8
+ import { Message as AIMessage } from './ai-service-client.js';
9
+ import { ToolRegistry } from '../tools/registry.js';
10
+ export interface ShellInputSession {
11
+ shellId: string;
12
+ command: string;
13
+ cwd: string;
14
+ isActive: boolean;
15
+ abortController: AbortController;
16
+ conversationHistory: AIMessage[];
17
+ mainConversationContext?: AIMessage[];
18
+ turnCount: number;
19
+ startTime: Date;
20
+ lastInputTime?: Date;
21
+ }
22
+ declare class ShellInputAgentClass {
23
+ private sessions;
24
+ private toolRegistry?;
25
+ private onShellInput?;
26
+ private onToolExecutionUpdate?;
27
+ private onPromptAnswered?;
28
+ private processingLock;
29
+ /**
30
+ * Initialize the agent with a tool registry
31
+ */
32
+ initialize(toolRegistry: ToolRegistry): void;
33
+ /**
34
+ * Set callback for sending input to shell (bridges to App.tsx's onShellInput)
35
+ */
36
+ setOnShellInput(callback: (shellId: string, input: string) => void): void;
37
+ /**
38
+ * Set callback for tool execution updates (for UI feedback)
39
+ */
40
+ setOnToolExecutionUpdate(callback: (update: any) => void): void;
41
+ /**
42
+ * Set callback for when a prompt has been answered
43
+ * This is used to update the UI to show a tick instead of spinner
44
+ */
45
+ setOnPromptAnswered(callback: (shellId: string) => void): void;
46
+ /**
47
+ * Start a new shell input session
48
+ * @param shellId Unique identifier for this shell session
49
+ * @param command The command being run
50
+ * @param cwd Current working directory
51
+ * @param mainConversation Optional main agent conversation history for context
52
+ */
53
+ startSession(shellId: string, command: string, cwd: string, mainConversation?: AIMessage[]): void;
54
+ /**
55
+ * Handle an input prompt detected in shell output
56
+ * Returns quickly - AI call runs in background
57
+ */
58
+ handleInputPrompt(shellId: string, shellOutput: string, promptContext: string, inputType: string, confidence: string): Promise<void>;
59
+ /**
60
+ * Process an input prompt with AI
61
+ */
62
+ private processInputPrompt;
63
+ /**
64
+ * Build the input prompt for AI
65
+ */
66
+ private buildInputPrompt;
67
+ /**
68
+ * Terminate a shell input session immediately
69
+ */
70
+ terminateSession(shellId: string): void;
71
+ /**
72
+ * Check if a session is active
73
+ */
74
+ isSessionActive(shellId: string): boolean;
75
+ /**
76
+ * Get session info (for debugging)
77
+ */
78
+ getSessionInfo(shellId: string): {
79
+ turnCount: number;
80
+ isActive: boolean;
81
+ } | undefined;
82
+ /**
83
+ * Terminate all active sessions
84
+ */
85
+ terminateAllSessions(): void;
86
+ }
87
+ export declare const ShellInputAgent: ShellInputAgentClass;
88
+ export {};
89
+ //# sourceMappingURL=shell-input-agent.d.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