From 5b6f88dd9550c59a087a73ce3d62451ec6e9e4d6 Mon Sep 17 00:00:00 2001 From: can1357 Date: Sat, 7 Feb 2026 02:43:46 +0100 Subject: [PATCH] fix: fixed #11 schema normalization, #10 version parsing, and variable declarations - Fixed schema normalization in Google provider to handle array-valued type fields by converting them to single type with nullable flag. - Refactored version parsing in install script to use bash parameter expansion instead of IFS field splitting. - Changed variable declarations from let to var in theme module global scope. --- packages/ai/CHANGELOG.md | 3 +++ packages/ai/src/providers/google-shared.ts | 11 +++++++++++ packages/coding-agent/src/modes/theme/theme.ts | 12 ++++++------ scripts/install.sh | 18 ++++++++++-------- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/packages/ai/CHANGELOG.md b/packages/ai/CHANGELOG.md index 9e80da887..09427c5bf 100644 --- a/packages/ai/CHANGELOG.md +++ b/packages/ai/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog ## [Unreleased] +### Fixed + +- Fixed schema normalization to handle array-valued `type` fields by converting them to a single type with nullable flag for Google provider compatibility ## [11.3.0] - 2026-02-06 ### Added diff --git a/packages/ai/src/providers/google-shared.ts b/packages/ai/src/providers/google-shared.ts index 27ad0bffe..e86815c1f 100644 --- a/packages/ai/src/providers/google-shared.ts +++ b/packages/ai/src/providers/google-shared.ts @@ -332,6 +332,17 @@ function sanitizeSchemaImpl(value: unknown, isInsideProperties: boolean): unknow result[key] = sanitizeSchemaImpl(entry, key === "properties"); } + // Normalize array-valued "type" (e.g. ["string", "null"]) to a single type + nullable. + // Google's Schema proto expects type to be a single enum string, not an array. + if (Array.isArray(result.type)) { + const types = result.type as string[]; + const nonNull = types.filter(t => t !== "null"); + if (types.includes("null")) { + result.nullable = true; + } + result.type = nonNull[0] ?? types[0]; + } + if (constValue !== undefined) { // Convert const to enum, merging with existing enum if present const existingEnum = Array.isArray(result.enum) ? result.enum : []; diff --git a/packages/coding-agent/src/modes/theme/theme.ts b/packages/coding-agent/src/modes/theme/theme.ts index 508ab2431..4c060b3da 100644 --- a/packages/coding-agent/src/modes/theme/theme.ts +++ b/packages/coding-agent/src/modes/theme/theme.ts @@ -1724,12 +1724,12 @@ function getDefaultTheme(): string { // Global Theme Instance // ============================================================================ -export let theme: Theme; -let currentThemeName: string | undefined; -let currentSymbolPresetOverride: SymbolPreset | undefined; -let currentColorBlindMode: boolean = false; -let themeWatcher: fs.FSWatcher | undefined; -let onThemeChangeCallback: (() => void) | undefined; +export var theme: Theme; +var currentThemeName: string | undefined; +var currentSymbolPresetOverride: SymbolPreset | undefined; +var currentColorBlindMode: boolean = false; +var themeWatcher: fs.FSWatcher | undefined; +var onThemeChangeCallback: (() => void) | undefined; function getCurrentThemeOptions(): CreateThemeOptions { return { diff --git a/scripts/install.sh b/scripts/install.sh index 4f06aa7e9..a120bbfc9 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -75,15 +75,17 @@ version_ge() { current="$1" minimum="$2" - IFS=. set -- $current - current_major=${1:-0} - current_minor=${2:-0} - current_patch=${3:-0} + current_major="${current%%.*}" + current_rest="${current#*.}" + current_minor="${current_rest%%.*}" + current_patch="${current_rest#*.}" + current_patch="${current_patch%%.*}" - IFS=. set -- $minimum - minimum_major=${1:-0} - minimum_minor=${2:-0} - minimum_patch=${3:-0} + minimum_major="${minimum%%.*}" + minimum_rest="${minimum#*.}" + minimum_minor="${minimum_rest%%.*}" + minimum_patch="${minimum_rest#*.}" + minimum_patch="${minimum_patch%%.*}" if [ "$current_major" -ne "$minimum_major" ]; then [ "$current_major" -gt "$minimum_major" ]