Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x | import {
Controller,
Get,
Post,
Delete,
Body,
Param,
HttpCode,
HttpStatus,
} from '@nestjs/common';
import { ApiTags, ApiOperation, ApiResponse, ApiParam } from '@nestjs/swagger';
import { ApplicationStateService } from './application-state.service';
import { SetWebsocketEnabledDto } from './dto/set-websocket-enabled.dto';
import { SetThemeDto } from './dto/set-theme.dto';
import { SetAutoContextFetchEnabledDto } from './dto/set-auto-context-fetch-enabled.dto';
import { SetAutoSendToAIStudioEnabledDto } from './dto/set-auto-send-to-ai-studio-enabled.dto';
import { SetContextTokenLimitDto } from './dto/set-context-token-limit.dto';
import { SetManualLlmEnabledDto } from './dto/set-manual-llm-enabled.dto';
import { SetExecutionStrategyDto } from './dto/set-execution-strategy.dto';
import { SetYoloModeDto } from './dto/set-yolo-mode.dto';
import { SetOpenrouterConfigDto } from './dto/set-openrouter-config.dto';
import { SetZaiConfigDto } from './dto/set-zai-config.dto';
import { SetAlibabaConfigDto } from './dto/set-alibaba-config.dto';
import { SetOllamaConfigDto } from './dto/set-ollama-config.dto';
import { SetOpenaiConfigDto } from './dto/set-openai-config.dto';
import { SetStreamingEnabledDto } from './dto/set-streaming-enabled.dto';
import { SetToolsEnabledDto } from './dto/set-tools-enabled.dto';
import { SetYoloModeMessageDto } from './dto/set-yolo-mode-message.dto';
import { SetSyntaxValidationEnabledDto } from './dto/set-syntax-validation-enabled.dto';
import { SetFollowupTokenLimitDto } from './dto/set-followup-token-limit.dto';
import { SetHistoryCompressionEnabledDto } from './dto/set-history-compression-enabled.dto';
import { SetLlmRetryEnabledDto } from './dto/set-llm-retry-enabled.dto';
import { SetLlmRetryMaxAttemptsDto } from './dto/set-llm-retry-max-attempts.dto';
@ApiTags('application-state')
@Controller('application-state')
export class ApplicationStateController {
constructor(
private readonly applicationStateService: ApplicationStateService,
) {}
// ===== NEW ENDPOINTS FOR RESOLUTION SYSTEM =====
@Get('effective')
@ApiOperation({
summary:
'Get all effective settings with their values merged from defaults and overrides',
})
@ApiResponse({ status: 200, description: 'Effective settings object' })
async getEffectiveSettings() {
return this.applicationStateService.getEffectiveSettings();
}
@Get('overrides')
@ApiOperation({ summary: 'Get all project-level setting overrides' })
@ApiResponse({
status: 200,
description: 'Object containing override key-value pairs',
})
async getProjectOverrides(): Promise<{ overrides: Record<string, string> }> {
const overrides = await this.applicationStateService.getProjectOverrides();
return { overrides };
}
@Delete('override/:key')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Clear a specific setting override' })
@ApiParam({ name: 'key', description: 'The setting key to clear' })
@ApiResponse({ status: 204, description: 'Override cleared successfully' })
async clearOverride(@Param('key') key: string): Promise<void> {
await this.applicationStateService.clearOverride(key);
}
// ===== EXISTING ENDPOINTS (UPDATED TO RETURN SOURCE) =====
@Get('websocket-enabled')
@ApiOperation({ summary: 'Get WebSocket enabled status' })
@ApiResponse({
status: 200,
description: 'WebSocket enabled status with source',
})
async getWebsocketEnabled() {
const result =
await this.applicationStateService.getWebsocketEnabledWithSource();
return { enabled: result.value, source: result.source };
}
@Post('websocket-enabled')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set WebSocket enabled status' })
@ApiResponse({ status: 204, description: 'WebSocket setting updated' })
async setWebsocketEnabled(
@Body() dto: SetWebsocketEnabledDto,
): Promise<void> {
await this.applicationStateService.setWebsocketEnabled(dto.enabled);
}
@Get('auto-context-fetch-enabled')
@ApiOperation({ summary: 'Get auto context fetch enabled status' })
@ApiResponse({
status: 200,
description: 'Auto context fetch status with source',
})
async getAutoContextFetchEnabled() {
const result =
await this.applicationStateService.getAutoContextFetchEnabledWithSource();
return { enabled: result.value, source: result.source };
}
@Post('auto-context-fetch-enabled')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set auto context fetch enabled status' })
@ApiResponse({
status: 204,
description: 'Auto context fetch setting updated',
})
async setAutoContextFetchEnabled(
@Body() dto: SetAutoContextFetchEnabledDto,
): Promise<void> {
await this.applicationStateService.setAutoContextFetchEnabled(dto.enabled);
}
@Get('auto-send-to-ai-studio-enabled')
@ApiOperation({ summary: 'Get auto-send to AI Studio enabled status' })
@ApiResponse({ status: 200, description: 'Auto-send status with source' })
async getAutoSendToAIStudioEnabled() {
const result =
await this.applicationStateService.getAutoSendToAIStudioEnabledWithSource();
return { enabled: result.value, source: result.source };
}
@Post('auto-send-to-ai-studio-enabled')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set auto-send to AI Studio enabled status' })
@ApiResponse({ status: 204, description: 'Auto-send setting updated' })
async setAutoSendToAIStudioEnabled(
@Body() dto: SetAutoSendToAIStudioEnabledDto,
): Promise<void> {
await this.applicationStateService.setAutoSendToAIStudioEnabled(
dto.enabled,
);
}
@Get('manual-llm-enabled')
@ApiOperation({ summary: 'Get manual LLM mode enabled status' })
@ApiResponse({ status: 200, description: 'Manual LLM mode status' })
async getManualLlmEnabled(): Promise<{ enabled: boolean }> {
const enabled = await this.applicationStateService.getManualLlmEnabled();
return { enabled };
}
@Post('manual-llm-enabled')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set manual LLM mode enabled status' })
@ApiResponse({ status: 204, description: 'Manual LLM mode setting updated' })
async setManualLlmEnabled(
@Body() dto: SetManualLlmEnabledDto,
): Promise<void> {
await this.applicationStateService.setManualLlmEnabled(dto.enabled);
}
@Get('yolo-mode-enabled')
@ApiOperation({
summary: 'Get YOLO mode enabled status (auto-execute without review)',
})
@ApiResponse({ status: 200, description: 'YOLO mode status with source' })
async getYoloModeEnabled() {
const result =
await this.applicationStateService.getYoloModeEnabledWithSource();
return { enabled: result.value, source: result.source };
}
@Post('yolo-mode-enabled')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set YOLO mode enabled status' })
@ApiResponse({ status: 204, description: 'YOLO mode setting updated' })
async setYoloModeEnabled(@Body() dto: SetYoloModeDto): Promise<void> {
await this.applicationStateService.setYoloModeEnabled(dto.enabled);
}
@Get('execution-strategy')
@ApiOperation({ summary: 'Get execution strategy for AI actions' })
@ApiResponse({ status: 200, description: 'Execution strategy with source' })
async getExecutionStrategy() {
const result =
await this.applicationStateService.getExecutionStrategyWithSource();
return { strategy: result.value, source: result.source };
}
@Post('execution-strategy')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set execution strategy for AI actions' })
@ApiResponse({ status: 204, description: 'Execution strategy updated' })
async setExecutionStrategy(
@Body() dto: SetExecutionStrategyDto,
): Promise<void> {
await this.applicationStateService.setExecutionStrategy(dto.strategy);
}
@Get('theme')
@ApiOperation({ summary: 'Get UI theme setting' })
@ApiResponse({ status: 200, description: 'Current theme' })
async getTheme(): Promise<{ theme: string }> {
const theme = await this.applicationStateService.getTheme();
return { theme };
}
@Post('theme')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set UI theme' })
@ApiResponse({ status: 204, description: 'Theme updated' })
async setTheme(@Body() dto: SetThemeDto): Promise<void> {
await this.applicationStateService.setTheme(dto.theme);
}
@Get('context-token-limit')
@ApiOperation({ summary: 'Get context token limit' })
@ApiResponse({ status: 200, description: 'Context token limit with source' })
async getContextTokenLimit() {
const result =
await this.applicationStateService.getContextTokenLimitWithSource();
return { limit: result.value, source: result.source };
}
@Post('context-token-limit')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set context token limit' })
@ApiResponse({ status: 204, description: 'Context token limit updated' })
async setContextTokenLimit(
@Body() dto: SetContextTokenLimitDto,
): Promise<void> {
await this.applicationStateService.setContextTokenLimit(dto.limit);
}
@Get('openrouter-config')
@ApiOperation({ summary: 'Get OpenRouter API configuration' })
@ApiResponse({ status: 200, description: 'OpenRouter API key with source' })
async getOpenrouterConfig() {
const result =
await this.applicationStateService.getOpenrouterApiKeyWithSource();
return { apiKey: result.value, source: result.source };
}
@Post('openrouter-config')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set OpenRouter API key' })
@ApiResponse({ status: 204, description: 'OpenRouter config updated' })
async setOpenrouterConfig(
@Body() dto: SetOpenrouterConfigDto,
): Promise<void> {
await this.applicationStateService.setOpenrouterApiKey(dto.apiKey);
}
@Get('zai-config')
@ApiOperation({ summary: 'Get Z.ai API configuration' })
@ApiResponse({ status: 200, description: 'Z.ai API key with source' })
async getZaiConfig() {
const result = await this.applicationStateService.getZaiApiKeyWithSource();
return { apiKey: result.value, source: result.source };
}
@Post('zai-config')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set Z.ai API key' })
@ApiResponse({ status: 204, description: 'Z.ai config updated' })
async setZaiConfig(@Body() dto: SetZaiConfigDto): Promise<void> {
await this.applicationStateService.setZaiApiKey(dto.apiKey);
}
@Get('alibaba-config')
@ApiOperation({ summary: 'Get Alibaba (Qwen) API configuration' })
@ApiResponse({ status: 200, description: 'Alibaba API key with source' })
async getAlibabaConfig() {
const result =
await this.applicationStateService.getAlibabaApiKeyWithSource();
return { apiKey: result.value, source: result.source };
}
@Post('alibaba-config')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set Alibaba (Qwen) API key' })
@ApiResponse({ status: 204, description: 'Alibaba config updated' })
async setAlibabaConfig(@Body() dto: SetAlibabaConfigDto): Promise<void> {
await this.applicationStateService.setAlibabaApiKey(dto.apiKey);
}
@Get('ollama-config')
@ApiOperation({ summary: 'Get Ollama Cloud API configuration' })
@ApiResponse({ status: 200, description: 'Ollama API key with source' })
async getOllamaConfig() {
const result =
await this.applicationStateService.getOllamaApiKeyWithSource();
return { apiKey: result.value, source: result.source };
}
@Post('ollama-config')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set Ollama Cloud API key' })
@ApiResponse({ status: 204, description: 'Ollama config updated' })
async setOllamaConfig(@Body() dto: SetOllamaConfigDto): Promise<void> {
await this.applicationStateService.setOllamaApiKey(dto.apiKey);
}
@Get('openai-config')
@ApiOperation({ summary: 'Get OpenAI Compatible API configuration' })
@ApiResponse({ status: 200, description: 'OpenAI config with source' })
async getOpenaiConfig() {
const [apiKeyResult, baseUrlResult] = await Promise.all([
this.applicationStateService.getOpenaiApiKeyWithSource(),
this.applicationStateService.getOpenaiBaseUrlWithSource(),
]);
return {
apiKey: apiKeyResult.value,
apiKeySource: apiKeyResult.source,
baseUrl: baseUrlResult.value,
baseUrlSource: baseUrlResult.source,
};
}
@Post('openai-config')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set OpenAI Compatible API configuration' })
@ApiResponse({ status: 204, description: 'OpenAI config updated' })
async setOpenaiConfig(@Body() dto: SetOpenaiConfigDto): Promise<void> {
Iif (dto.apiKey !== undefined) {
await this.applicationStateService.setOpenaiApiKey(dto.apiKey);
}
Iif (dto.baseUrl !== undefined) {
await this.applicationStateService.setOpenaiBaseUrl(dto.baseUrl);
}
}
@Get('recent-models')
@ApiOperation({ summary: 'Get list of recently used models' })
@ApiResponse({ status: 200, description: 'List of recent model IDs' })
async getRecentModels(): Promise<{ models: string[] }> {
const models = await this.applicationStateService.getRecentModels();
return { models };
}
@Get('streaming-enabled')
@ApiOperation({ summary: 'Get streaming enabled status for LLM responses' })
@ApiResponse({ status: 200, description: 'Streaming status with source' })
async getStreamingEnabled() {
const result =
await this.applicationStateService.getStreamingEnabledWithSource();
return { enabled: result.value, source: result.source };
}
@Post('streaming-enabled')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set streaming enabled status' })
@ApiResponse({ status: 204, description: 'Streaming setting updated' })
async setStreamingEnabled(
@Body() dto: SetStreamingEnabledDto,
): Promise<void> {
await this.applicationStateService.setStreamingEnabled(dto.enabled);
}
@Get('tools-enabled')
@ApiOperation({ summary: 'Get tools (function calling) enabled status' })
@ApiResponse({ status: 200, description: 'Tools status with source' })
async getToolsEnabled() {
const result =
await this.applicationStateService.getToolsEnabledWithSource();
return { enabled: result.value, source: result.source };
}
@Post('tools-enabled')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set tools enabled status' })
@ApiResponse({ status: 204, description: 'Tools setting updated' })
async setToolsEnabled(@Body() dto: SetToolsEnabledDto): Promise<void> {
await this.applicationStateService.setToolsEnabled(dto.enabled);
}
@Get('yolo-mode-message')
@ApiOperation({ summary: 'Get YOLO mode auto-execute message' })
@ApiResponse({ status: 200, description: 'YOLO mode message with source' })
async getYoloModeMessage() {
const result =
await this.applicationStateService.getYoloModeMessageWithSource();
return { message: result.value, source: result.source };
}
@Post('yolo-mode-message')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set YOLO mode auto-execute message' })
@ApiResponse({ status: 204, description: 'YOLO mode message updated' })
async setYoloModeMessage(@Body() dto: SetYoloModeMessageDto): Promise<void> {
await this.applicationStateService.setYoloModeMessage(dto.message);
}
@Get('syntax-validation-enabled')
@ApiOperation({
summary: 'Get syntax validation enabled status for generated code',
})
@ApiResponse({
status: 200,
description: 'Syntax validation status with source',
})
async getSyntaxValidationEnabled() {
const result =
await this.applicationStateService.getSyntaxValidationEnabledWithSource();
return { enabled: result.value, source: result.source };
}
@Post('syntax-validation-enabled')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set syntax validation enabled status' })
@ApiResponse({
status: 204,
description: 'Syntax validation setting updated',
})
async setSyntaxValidationEnabled(
@Body() dto: SetSyntaxValidationEnabledDto,
): Promise<void> {
await this.applicationStateService.setSyntaxValidationEnabled(dto.enabled);
}
@Get('followup-token-limit')
@ApiOperation({ summary: 'Get follow-up token limit' })
@ApiResponse({
status: 200,
description: 'Follow-up token limit with source',
})
async getFollowupTokenLimit() {
const result =
await this.applicationStateService.getFollowupTokenLimitWithSource();
return { limit: result.value, source: result.source };
}
@Post('followup-token-limit')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set follow-up token limit' })
@ApiResponse({ status: 204, description: 'Follow-up token limit updated' })
async setFollowupTokenLimit(
@Body() dto: SetFollowupTokenLimitDto,
): Promise<void> {
await this.applicationStateService.setFollowupTokenLimit(dto.limit);
}
@Get('history-compression-enabled')
@ApiOperation({ summary: 'Get history compression enabled status' })
@ApiResponse({
status: 200,
description: 'History compression status with source',
})
async getHistoryCompressionEnabled() {
const result =
await this.applicationStateService.getHistoryCompressionEnabledWithSource();
return { enabled: result.value, source: result.source };
}
@Post('history-compression-enabled')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set history compression enabled status' })
@ApiResponse({
status: 204,
description: 'History compression setting updated',
})
async setHistoryCompressionEnabled(
@Body() dto: SetHistoryCompressionEnabledDto,
): Promise<void> {
await this.applicationStateService.setHistoryCompressionEnabled(
dto.enabled,
);
}
@Get('llm-retry-enabled')
@ApiOperation({ summary: 'Get LLM retry enabled status' })
@ApiResponse({ status: 200, description: 'LLM retry status with source' })
async getLlmRetryEnabled() {
const result =
await this.applicationStateService.getLlmRetryEnabledWithSource();
return { enabled: result.value, source: result.source };
}
@Post('llm-retry-enabled')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set LLM retry enabled status' })
@ApiResponse({ status: 204, description: 'LLM retry setting updated' })
async setLlmRetryEnabled(@Body() dto: SetLlmRetryEnabledDto): Promise<void> {
await this.applicationStateService.setLlmRetryEnabled(dto.enabled);
}
@Get('llm-retry-max-attempts')
@ApiOperation({ summary: 'Get LLM retry max attempts' })
@ApiResponse({
status: 200,
description: 'LLM retry max attempts with source',
})
async getLlmRetryMaxAttempts() {
const result =
await this.applicationStateService.getLlmRetryMaxAttemptsWithSource();
return { attempts: result.value, source: result.source };
}
@Post('llm-retry-max-attempts')
@HttpCode(HttpStatus.NO_CONTENT)
@ApiOperation({ summary: 'Set LLM retry max attempts' })
@ApiResponse({ status: 204, description: 'LLM retry max attempts updated' })
async setLlmRetryMaxAttempts(
@Body() dto: SetLlmRetryMaxAttemptsDto,
): Promise<void> {
await this.applicationStateService.setLlmRetryMaxAttempts(dto.attempts);
}
}
|