(options: ExtensionHostOptions)
| 173 | // ========================================================================== |
| 174 | |
| 175 | constructor(options: ExtensionHostOptions) { |
| 176 | super() |
| 177 | |
| 178 | this.options = options |
| 179 | // Mark this process as CLI runtime so extension code can apply |
| 180 | // CLI-specific behavior without affecting VS Code desktop usage. |
| 181 | this.previousCliRuntimeEnv = process.env.ROO_CLI_RUNTIME |
| 182 | process.env.ROO_CLI_RUNTIME = "1" |
| 183 | |
| 184 | // Enable file-based debug logging only when --debug is passed. |
| 185 | if (options.debug) { |
| 186 | setDebugLogEnabled(true) |
| 187 | } |
| 188 | |
| 189 | // Set up quiet mode early, before any extension code runs. |
| 190 | // This suppresses console output from the extension during load. |
| 191 | this.setupQuietMode() |
| 192 | |
| 193 | // Initialize client - single source of truth for agent state (including mode). |
| 194 | this.client = new ExtensionClient({ |
| 195 | sendMessage: (msg) => this.sendToExtension(msg), |
| 196 | debug: options.debug, // Enable debug logging in the client. |
| 197 | }) |
| 198 | |
| 199 | // Initialize output manager. |
| 200 | this.outputManager = new OutputManager({ disabled: options.disableOutput }) |
| 201 | |
| 202 | // Initialize prompt manager with console mode callbacks. |
| 203 | this.promptManager = new PromptManager({ |
| 204 | onBeforePrompt: () => this.restoreConsole(), |
| 205 | onAfterPrompt: () => this.setupQuietMode(), |
| 206 | }) |
| 207 | |
| 208 | // Initialize ask dispatcher. |
| 209 | this.askDispatcher = new AskDispatcher({ |
| 210 | outputManager: this.outputManager, |
| 211 | promptManager: this.promptManager, |
| 212 | sendMessage: (msg) => this.sendToExtension(msg), |
| 213 | nonInteractive: options.nonInteractive, |
| 214 | exitOnError: options.exitOnError, |
| 215 | disabled: options.disableOutput, // TUI mode handles asks directly. |
| 216 | }) |
| 217 | |
| 218 | // Wire up client events. |
| 219 | this.setupClientEventHandlers() |
| 220 | |
| 221 | // Populate initial settings. |
| 222 | const baseSettings: RooCodeSettings = { |
| 223 | mode: this.options.mode, |
| 224 | consecutiveMistakeLimit: this.options.consecutiveMistakeLimit ?? DEFAULT_FLAGS.consecutiveMistakeLimit, |
| 225 | commandExecutionTimeout: 300, |
| 226 | enableCheckpoints: false, |
| 227 | experiments: { |
| 228 | customTools: true, |
| 229 | }, |
| 230 | ...getProviderSettings(this.options.provider, this.options.apiKey, this.options.model), |
| 231 | } |
| 232 |
nothing calls this directly
no test coverage detected