From f3ae78f95e1ec56c8ebae085970f0ff06dd1db31 Mon Sep 17 00:00:00 2001 From: catlog22 Date: Sun, 8 Mar 2026 21:43:43 +0800 Subject: [PATCH] fix(configStore): add type guard for CLI tool type validation - Add isValidType type guard to ensure type safety - Validate tool type against allowed values before assignment - Fixes TypeScript compilation error in build --- ccw/frontend/src/stores/configStore.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ccw/frontend/src/stores/configStore.ts b/ccw/frontend/src/stores/configStore.ts index 729e39b7..85472870 100644 --- a/ccw/frontend/src/stores/configStore.ts +++ b/ccw/frontend/src/stores/configStore.ts @@ -114,6 +114,10 @@ function extractCliToolsFromBackend(data: unknown): Record + typeof t === 'string' && (validTypes as readonly string[]).includes(t); + const cliTools: Record = {}; for (const [key, tool] of Object.entries(backendTools)) { const typedTool = tool as Record; @@ -122,7 +126,7 @@ function extractCliToolsFromBackend(data: unknown): Record typeof tag === 'string') : [], - type: typeof typedTool.type === 'string' ? typedTool.type : 'builtin', + type: isValidType(typedTool.type) ? typedTool.type : 'builtin', envFile: typeof typedTool.envFile === 'string' ? typedTool.envFile : undefined, settingsFile: typeof typedTool.settingsFile === 'string' ? typedTool.settingsFile : undefined, availableModels: Array.isArray(typedTool.availableModels)