diff --git a/CHANGELOG.md b/CHANGELOG.md index f2a6c20f..8dbaa69b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [4.4.0] + +### Added + +- **models.dev auto-update**: Two new toggles in Settings → General — "Update models via models.dev" (default: on) and "Update pricing via models.dev" (default: off). When enabled, the latest provider model catalog (models.json) and model pricing (api.json) are fetched from models.dev on every startup and merged into the built-in model lists +- New models released by providers (DeepSeek, Qwen, GLM, Kimi, Doubao, MiniMax, etc.) now appear in the model dropdowns without waiting for an extension update — locally fine-tuned metadata (context limits, thinking budgets, vision support) is always preserved +- Fetched catalogs are cached to disk as an offline fallback, and pushed to the webview via a subscription with an active pull-on-subscribe fallback to avoid startup race conditions + ## [4.3.1] ### Fixed diff --git a/package.json b/package.json index 563c4360..6ddfd768 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "cline-multi", "displayName": "Cline Multi", "description": "%cline.description%", - "version": "4.3.1", + "version": "4.4.0", "icon": "assets/icons/icon.png", "workspaces": [ "." diff --git a/proto/cline/models.proto b/proto/cline/models.proto index f616b1ae..7b364bb0 100644 --- a/proto/cline/models.proto +++ b/proto/cline/models.proto @@ -55,6 +55,10 @@ service ModelsService { rpc getAihubmixModels(EmptyRequest) returns (OpenRouterCompatibleModelInfo); // Refreshes and returns Vercel AI Gateway models rpc refreshVercelAiGatewayModelsRpc(EmptyRequest) returns (OpenRouterCompatibleModelInfo); + // Refreshes models and pricing from models.dev and returns serialized JSON + rpc refreshModelsDevModelsRpc(EmptyRequest) returns (String); + // Subscribe to models.dev models updates (serialized JSON payload) + rpc subscribeToModelsDevModels(EmptyRequest) returns (stream String); } // List of VS Code LM models diff --git a/proto/cline/state.proto b/proto/cline/state.proto index 10936b22..8b0d8507 100644 --- a/proto/cline/state.proto +++ b/proto/cline/state.proto @@ -295,6 +295,8 @@ message Settings { optional OpenRouterModelInfo plan_mode_deep_seek_model_info = 188; optional OpenRouterModelInfo act_mode_deep_seek_model_info = 189; optional int32 file_optimization_threshold = 190; + optional bool models_dev_update_models = 191; + optional bool models_dev_update_pricing = 192; } message State { @@ -438,6 +440,8 @@ message UpdateSettingsRequest { optional bool double_check_completion_enabled = 41; optional bool show_feature_tips = 42; optional bool lazy_teammate_mode_enabled = 43; + optional bool models_dev_update_models = 44; + optional bool models_dev_update_pricing = 45; } message UpdateTerminalConnectionTimeoutRequest { diff --git a/src/common.ts b/src/common.ts index 85426303..1f60a656 100644 --- a/src/common.ts +++ b/src/common.ts @@ -77,6 +77,14 @@ export async function initialize(storageContext: StorageContext): Promise refreshModelsDevModels()) + .catch((error) => Logger.error("[models.dev] Startup refresh failed:", error)) + telemetryService.captureExtensionActivated() return webview diff --git a/src/core/controller/index.ts b/src/core/controller/index.ts index ac48a08e..cbf50f49 100644 --- a/src/core/controller/index.ts +++ b/src/core/controller/index.ts @@ -699,7 +699,6 @@ export class Controller { } } - // Read OpenRouter models from disk cache async readOpenRouterModels(): Promise | undefined> { const openRouterModelsFilePath = path.join(await ensureCacheDirectoryExists(), GlobalFileNames.openRouterModels) @@ -849,6 +848,8 @@ export class Controller { const doubleCheckCompletionEnabled = this.stateManager.getGlobalSettingsKey("doubleCheckCompletionEnabled") const lazyTeammateModeEnabled = this.stateManager.getGlobalSettingsKey("lazyTeammateModeEnabled") const showFeatureTips = this.stateManager.getGlobalSettingsKey("showFeatureTips") + const modelsDevUpdateModels = this.stateManager.getGlobalSettingsKey("modelsDevUpdateModels") + const modelsDevUpdatePricing = this.stateManager.getGlobalSettingsKey("modelsDevUpdatePricing") const localClineRulesToggles = this.stateManager.getWorkspaceStateKey("localClineRulesToggles") const localWindsurfRulesToggles = this.stateManager.getWorkspaceStateKey("localWindsurfRulesToggles") @@ -961,6 +962,8 @@ export class Controller { doubleCheckCompletionEnabled, lazyTeammateModeEnabled, showFeatureTips, + modelsDevUpdateModels, + modelsDevUpdatePricing, banners, welcomeBanners, openAiCodexIsAuthenticated, @@ -990,7 +993,7 @@ export class Controller { /* It seems that some API messages do not comply with vscode state requirements. Either the Anthropic library is manipulating these values somehow in the backend in a way that's creating cyclic references, or the API returns a function or a Symbol as part of the message content. - VSCode docs about state: "The value must be JSON-stringifyable ... value â€?A value. MUST not contain cyclic references." + VSCode docs about state: "The value must be JSON-stringifyable ... value â€?A value. MUST not contain cyclic references." For now we'll store the conversation history in memory, and if we need to store in state directly we'd need to do a manual conversion to ensure proper json stringification. */ diff --git a/src/core/controller/models/refreshModelsDevModels.ts b/src/core/controller/models/refreshModelsDevModels.ts new file mode 100644 index 00000000..82592c0f --- /dev/null +++ b/src/core/controller/models/refreshModelsDevModels.ts @@ -0,0 +1,145 @@ +import { ensureCacheDirectoryExists, GlobalFileNames } from "@core/storage/disk" +import { fileExistsAtPath } from "@utils/fs" +import axios from "axios" +import fs from "fs/promises" +import path from "path" +import { StateManager } from "@/core/storage/StateManager" +import { + applyModelsDevCatalog, + deserializeModelsDevCatalog, + type ModelsDevCatalog, + parseModelsDevCatalog, + serializeModelsDevCatalog, +} from "@/shared/models-dev" +import { getAxiosSettings } from "@/shared/net" +import { Logger } from "@/shared/services/Logger" +import { sendModelsDevModelsEvent } from "./subscribeToModelsDevModels" + +// Track pending refresh promise to prevent duplicate concurrent fetches +let pendingRefresh: Promise | null = null + +// Last successfully fetched/loaded catalog for this process run. +// The webview may subscribe AFTER the startup fetch has completed, so it +// actively requests the catalog via RPC; serve it from here without refetching. +let lastCatalogJson: string | null = null + +/** + * Reads the models.dev settings (update models / update pricing toggles). + */ +function getModelsDevOptions(): { updateModels: boolean; updatePricing: boolean } { + const stateManager = StateManager.get() + return { + updateModels: stateManager.getGlobalSettingsKey("modelsDevUpdateModels") ?? true, + updatePricing: stateManager.getGlobalSettingsKey("modelsDevUpdatePricing") ?? false, + } +} + +/** + * Returns the last cached models.dev catalog as serialized JSON (without fetching). + */ +export async function readModelsDevCatalogJson(): Promise { + const filePath = path.join(await ensureCacheDirectoryExists(), GlobalFileNames.modelsDevModels) + if (await fileExistsAtPath(filePath)) { + try { + const contents = await fs.readFile(filePath, "utf8") + if (deserializeModelsDevCatalog(contents)) { + return contents + } + } catch (error) { + Logger.error("Error reading cached models.dev catalog:", error) + } + } + return null +} + +/** + * Fetches the models.dev catalogs (models + pricing), applies them onto the static + * model constants in this process, caches them to disk, and pushes the result to + * webview subscribers. + * + * Both toggles OFF short-circuits (returns cached data if present). + * On network failure the disk cache is used as fallback so models stay consistent. + * + * @returns Serialized ModelsDevCatalog JSON + */ +export async function refreshModelsDevModels(force = false): Promise { + // Already fetched during this process run: serve cached result without refetching + // (unless force is requested, e.g. a toggle was just re-enabled) + if (lastCatalogJson && !force) { + return lastCatalogJson + } + + if (force) { + lastCatalogJson = null + } + + // If a fetch is already in progress, return the same promise + if (pendingRefresh) { + return pendingRefresh + } + + // Start new fetch and track the promise + pendingRefresh = (async () => { + try { + return await fetchAndCacheModels() + } finally { + pendingRefresh = null + } + })() + + return pendingRefresh +} + +async function fetchAndCacheModels(): Promise { + const filePath = path.join(await ensureCacheDirectoryExists(), GlobalFileNames.modelsDevModels) + const { updateModels, updatePricing } = getModelsDevOptions() + + // Both toggles off: nothing to do, return cached catalog if present + if (!updateModels && !updatePricing) { + const cached = await readModelsDevCatalogJson() + return cached ?? serializeModelsDevCatalog({ fetchedAt: new Date(0).toISOString(), providers: {} }) + } + + let catalog: ModelsDevCatalog | null = null + try { + // models.json contains limits/modalities/reasoning for every provider/model + // api.json contains per-provider pricing (cost) — both are per-million USD + const [modelsRes, apiRes] = await Promise.all([ + axios.get("https://models.dev/models.json?type=all", { timeout: 15000, ...getAxiosSettings() }), + axios.get("https://models.dev/api.json", { timeout: 15000, ...getAxiosSettings() }), + ]) + catalog = parseModelsDevCatalog(modelsRes.data, apiRes.data) + if (!catalog.providers || Object.keys(catalog.providers).length === 0) { + throw new Error("models.dev catalog parsed to zero providers") + } + // Persist to disk cache for offline fallback + await fs.writeFile(filePath, serializeModelsDevCatalog(catalog)) + } catch (error) { + Logger.error("Error fetching models.dev catalog:", error) + // Fall back to disk cache so previously fetched data stays effective + const cached = await readModelsDevCatalogJson() + if (cached) { + catalog = deserializeModelsDevCatalog(cached) + } + } + + if (!catalog) { + // Nothing fetched and nothing cached: keep static defaults untouched + return serializeModelsDevCatalog({ fetchedAt: new Date(0).toISOString(), providers: {} }) + } + + // Apply onto this process's static model constants + const applied = applyModelsDevCatalog(catalog, { updateModels, updatePricing }) + Logger.log( + `[models.dev] catalog applied: ${applied.added} new models added, ${applied.priced} models repriced ` + + `(updateModels=${updateModels}, updatePricing=${updatePricing})`, + ) + + const serialized = serializeModelsDevCatalog(catalog) + lastCatalogJson = serialized + + // Push to webview subscribers (they apply the catalog onto their own copies) + await sendModelsDevModelsEvent(serialized) + + return serialized +} diff --git a/src/core/controller/models/refreshModelsDevModelsRpc.ts b/src/core/controller/models/refreshModelsDevModelsRpc.ts new file mode 100644 index 00000000..5964f6fa --- /dev/null +++ b/src/core/controller/models/refreshModelsDevModelsRpc.ts @@ -0,0 +1,15 @@ +import { EmptyRequest, String } from "@shared/proto/cline/common" +import type { Controller } from "../index" +import { refreshModelsDevModels } from "./refreshModelsDevModels" + +/** + * Refreshes models and pricing from models.dev, applies them to the local + * static model constants, caches the catalog, and pushes it to subscribers. + * @param controller The controller instance + * @param request Empty request (unused but required for gRPC signature) + * @returns Serialized ModelsDevCatalog JSON + */ +export async function refreshModelsDevModelsRpc(_controller: Controller, _request: EmptyRequest): Promise { + const catalogJson = await refreshModelsDevModels() + return String.create({ value: catalogJson }) +} diff --git a/src/core/controller/models/subscribeToModelsDevModels.ts b/src/core/controller/models/subscribeToModelsDevModels.ts new file mode 100644 index 00000000..c7874e4f --- /dev/null +++ b/src/core/controller/models/subscribeToModelsDevModels.ts @@ -0,0 +1,57 @@ +import { EmptyRequest, String } from "@shared/proto/cline/common" +import { Logger } from "@/shared/services/Logger" +import { getRequestRegistry, StreamingResponseHandler } from "../grpc-handler" +import { Controller } from "../index" + +// Keep track of active models.dev models subscriptions +const activeModelsDevModelsSubscriptions = new Set>() + +/** + * Subscribe to models.dev models events (serialized ModelsDevCatalog JSON payloads) + * @param controller The controller instance + * @param request The empty request + * @param responseStream The streaming response handler + * @param requestId The ID of the request (passed by the gRPC handler) + */ +export async function subscribeToModelsDevModels( + _controller: Controller, + _request: EmptyRequest, + responseStream: StreamingResponseHandler, + requestId?: string, +): Promise { + // Add this subscription to the active subscriptions + activeModelsDevModelsSubscriptions.add(responseStream) + + // Register cleanup when the connection is closed + const cleanup = () => { + activeModelsDevModelsSubscriptions.delete(responseStream) + } + + // Register the cleanup function with the request registry if we have a requestId + if (requestId) { + getRequestRegistry().registerRequest(requestId, cleanup, { type: "modelsDevModels_subscription" }, responseStream) + } +} + +/** + * Send a models.dev models event to all active subscribers + * @param catalogJson Serialized ModelsDevCatalog JSON + */ +export async function sendModelsDevModelsEvent(catalogJson: string): Promise { + const payload = String.create({ value: catalogJson }) + // Send the event to all active subscribers + const promises = Array.from(activeModelsDevModelsSubscriptions).map(async (responseStream) => { + try { + await responseStream( + payload, + false, // Not the last message + ) + } catch (error) { + Logger.error("Error sending models.dev models event:", error) + // Remove the subscription if there was an error + activeModelsDevModelsSubscriptions.delete(responseStream) + } + }) + + await Promise.all(promises) +} diff --git a/src/core/controller/state/updateSettings.ts b/src/core/controller/state/updateSettings.ts index e746271b..d16bc268 100644 --- a/src/core/controller/state/updateSettings.ts +++ b/src/core/controller/state/updateSettings.ts @@ -352,6 +352,28 @@ export async function updateSettings(controller: Controller, request: UpdateSett controller.stateManager.setGlobalState("showFeatureTips", request.showFeatureTips) } + // Update models.dev integration toggles; trigger a refresh when enabling either toggle + if (request.modelsDevUpdateModels !== undefined || request.modelsDevUpdatePricing !== undefined) { + const prevModels = controller.stateManager.getGlobalSettingsKey("modelsDevUpdateModels") ?? true + const prevPricing = controller.stateManager.getGlobalSettingsKey("modelsDevUpdatePricing") ?? false + if (request.modelsDevUpdateModels !== undefined) { + controller.stateManager.setGlobalState("modelsDevUpdateModels", request.modelsDevUpdateModels) + } + if (request.modelsDevUpdatePricing !== undefined) { + controller.stateManager.setGlobalState("modelsDevUpdatePricing", request.modelsDevUpdatePricing) + } + const enabledAny = + (request.modelsDevUpdateModels === true && !prevModels) || + (request.modelsDevUpdatePricing === true && !prevPricing) + if (enabledAny) { + // Fire-and-forget: apply immediately and push the catalog to subscribers + // (force bypasses the in-process catalog cache since toggles just changed) + import("../models/refreshModelsDevModels") + .then(({ refreshModelsDevModels }) => refreshModelsDevModels(true)) + .catch((error) => Logger.error("Failed to refresh models.dev models:", error)) + } + } + // Post updated state to webview await controller.postStateToWebview() diff --git a/src/core/storage/disk.ts b/src/core/storage/disk.ts index 6a233d76..0bc28223 100644 --- a/src/core/storage/disk.ts +++ b/src/core/storage/disk.ts @@ -48,6 +48,7 @@ export const GlobalFileNames = { clineRecommendedModels: "cline_recommended_models.json", clineModels: "cline_models.json", openRouterModels: "openrouter_models.json", + modelsDevModels: "models_dev_models.json", vercelAiGatewayModels: "vercel_ai_gateway_models.json", groqModels: "groq_models.json", basetenModels: "baseten_models.json", diff --git a/src/shared/ExtensionMessage.ts b/src/shared/ExtensionMessage.ts index a033fb58..9493e822 100644 --- a/src/shared/ExtensionMessage.ts +++ b/src/shared/ExtensionMessage.ts @@ -110,6 +110,8 @@ export interface ExtensionState { doubleCheckCompletionEnabled?: boolean lazyTeammateModeEnabled?: boolean showFeatureTips?: boolean + modelsDevUpdateModels?: boolean + modelsDevUpdatePricing?: boolean banners?: BannerCardData[] welcomeBanners?: BannerCardData[] openAiCodexIsAuthenticated?: boolean diff --git a/src/shared/models-dev.ts b/src/shared/models-dev.ts new file mode 100644 index 00000000..1cf0d6d3 --- /dev/null +++ b/src/shared/models-dev.ts @@ -0,0 +1,297 @@ +import type { ModelInfo } from "./api" +import { + anthropicModels, + askSageModels, + basetenModels, + bedrockModels, + cerebrasModels, + claudeCodeModels, + deepSeekModels, + doubaoModels, + fireworksModels, + geminiModels, + groqModels, + huaweiCloudMaasModels, + huggingFaceModels, + internationalQwenModels, + internationalZAiModels, + mainlandQwenModels, + mainlandZAiModels, + minimaxModels, + mistralModels, + moonshotModels, + nebiusModels, + nousResearchModels, + openAiNativeModels, + sambanovaModels, + vertexModels, + wandbModels, + xaiModels, +} from "./api" + +/** + * models.dev integration — shared between the extension core and the webview. + * + * The models.dev catalogs are fetched at startup (core) and pushed to the webview. + * Both sides then "apply" the catalog onto the static model constants from + * `@shared/api` so that new models appear in pickers and pricing stays current. + */ + +/** Raw model entry from https://models.dev/models.json (or api.json). */ +export interface ModelsDevRawModel { + id?: string + name?: string + description?: string + /** modalities.input may contain "text" | "image" | "pdf" | "audio" | ... */ + modalities?: { input?: string[]; output?: string[] } + /** models.json (type=all) embeds limits directly */ + limit?: { context?: number; output?: number; input?: number } + reasoning?: boolean + release_date?: string + last_updated?: string + /** api.json only: pricing per million tokens */ + cost?: { input?: number; output?: number; cache_read?: number; cache_write?: number } +} + +/** + * The fetched catalog: for each Cline model constant key (e.g. "anthropicModels"), + * the models.dev entries that should be merged into it. + */ +export interface ModelsDevCatalog { + /** ISO timestamp of when the catalog was fetched */ + fetchedAt: string + /** providerKey (Cline constant name) -> modelId -> ModelInfo */ + providers: Record> +} + +/** Model constants registry, keyed by the names used in the catalog. */ +const MODEL_CONSTANTS: Record> = { + anthropicModels, + claudeCodeModels, + bedrockModels, + vertexModels, + geminiModels, + openAiNativeModels, + deepSeekModels, + huggingFaceModels, + internationalQwenModels, + mainlandQwenModels, + doubaoModels, + mistralModels, + askSageModels, + nebiusModels, + wandbModels, + xaiModels, + sambanovaModels, + cerebrasModels, + groqModels, + moonshotModels, + huaweiCloudMaasModels, + basetenModels, + internationalZAiModels, + mainlandZAiModels, + fireworksModels, + minimaxModels, + nousResearchModels, +} + +/** + * Mapping from models.dev provider ids to Cline model constant names. + * models.dev model ids are "provider/model-id"; the provider prefix is stripped + * before looking up the model id in the target constants. + */ +export const MODELS_DEV_PROVIDER_MAP: Record = { + anthropic: ["anthropicModels", "claudeCodeModels"], + google: ["geminiModels"], + "google-vertex": ["vertexModels"], + "amazon-bedrock": ["bedrockModels"], + openai: ["openAiNativeModels"], + deepseek: ["deepSeekModels"], + xai: ["xaiModels"], + moonshotai: ["moonshotModels"], + moonshot: ["moonshotModels"], + alibaba: ["internationalQwenModels"], + "alibaba-cn": ["mainlandQwenModels"], + zhipuai: ["internationalZAiModels"], + "zhipuai-cn": ["mainlandZAiModels"], + minimax: ["minimaxModels"], + mistral: ["mistralModels"], + cohere: ["askSageModels"], + fireworks: ["fireworksModels"], + groq: ["groqModels"], + cerebras: ["cerebrasModels"], + nebius: ["nebiusModels"], + sambanova: ["sambanovaModels"], + bytedance: ["doubaoModels"], + "bytedance-ark": ["doubaoModels"], + huggingface: ["huggingFaceModels"], + nousresearch: ["nousResearchModels"], + wandb: ["wandbModels"], + baseten: ["basetenModels"], +} + +/** + * Parse raw models.dev data (models.json + api.json) into a ModelsDevCatalog. + * + * - models.json (type=all): flat map "provider/model-id" -> entry (limits, modalities, reasoning) + * - api.json: provider -> { models: { modelId -> entry (limits, modalities, cost) } } + * + * @param modelsJson Raw `models.json` payload (may be undefined to skip) + * @param apiJson Raw `api.json` payload (may be undefined to skip) + */ +export function parseModelsDevCatalog( + modelsJson?: Record, + apiJson?: Record, +): ModelsDevCatalog { + const providers: ModelsDevCatalog["providers"] = {} + + const addModel = (providerKey: string, modelId: string, info: ModelInfo) => { + if (!providers[providerKey]) { + providers[providerKey] = {} + } + providers[providerKey][modelId] = info + } + + const convert = (raw: ModelsDevRawModel): ModelInfo | null => { + const contextWindow = raw.limit?.context + if (!contextWindow || contextWindow <= 0) { + return null + } + const inputs = raw.modalities?.input ?? [] + const supportsReasoning = raw.reasoning === true + return { + name: raw.name ?? undefined, + description: raw.description ?? undefined, + contextWindow, + maxTokens: raw.limit?.output ?? undefined, + supportsImages: inputs.includes("image"), + supportsPromptCache: false, + inputPrice: raw.cost?.input ?? undefined, + outputPrice: raw.cost?.output ?? undefined, + cacheReadsPrice: raw.cost?.cache_read ?? undefined, + cacheWritesPrice: raw.cost?.cache_write ?? undefined, + supportsReasoning, + // Reasoning models get a thinking budget placeholder so the thinking UI works + thinkingConfig: supportsReasoning ? { maxBudget: 8192 } : undefined, + } + } + + // --- models.json (type=all): flat "provider/model" keys --- + if (modelsJson) { + for (const [fullId, raw] of Object.entries(modelsJson)) { + const slashIdx = fullId.indexOf("/") + if (slashIdx <= 0) { + continue + } + const devProvider = fullId.slice(0, slashIdx) + const modelId = fullId.slice(slashIdx + 1) + const targets = MODELS_DEV_PROVIDER_MAP[devProvider] + if (!targets) { + continue + } + const info = convert(raw) + if (!info) { + continue + } + for (const target of targets) { + addModel(target, modelId, info) + } + } + } + + // --- api.json: provider -> { models: {...} } --- + if (apiJson) { + for (const [devProvider, providerData] of Object.entries(apiJson)) { + const targets = MODELS_DEV_PROVIDER_MAP[devProvider] + if (!targets || !providerData?.models) { + continue + } + for (const [modelId, raw] of Object.entries(providerData.models)) { + const info = convert(raw) + if (!info) { + continue + } + for (const target of targets) { + addModel(target, modelId, info) + } + } + } + } + + return { fetchedAt: new Date().toISOString(), providers } +} + +/** + * Apply a models.dev catalog onto Cline's static model constants (mutates them). + * + * Rules: + * - "Update models" ON: new model IDs found in the catalog are ADDED to the constants. + * Existing model IDs keep their locally curated metadata (never overwritten). + * - "Update pricing" ON: pricing fields (input/output/cache read/write) of EXISTING + * models are refreshed from the catalog when the catalog provides them. + * + * @returns number of new models added and models whose pricing was updated. + */ +export function applyModelsDevCatalog( + catalog: ModelsDevCatalog, + options: { updateModels: boolean; updatePricing: boolean }, +): { added: number; priced: number } { + let added = 0 + let priced = 0 + + for (const [constantKey, models] of Object.entries(catalog.providers)) { + const target = MODEL_CONSTANTS[constantKey] + if (!target) { + continue + } + + for (const [modelId, incoming] of Object.entries(models)) { + const existing = target[modelId] + if (!existing) { + if (!options.updateModels) { + continue + } + // New model: add with catalog info + target[modelId] = incoming + added++ + } else if (options.updatePricing) { + // Existing model: refresh pricing when provided + let touched = false + for (const key of ["inputPrice", "outputPrice", "cacheReadsPrice", "cacheWritesPrice"] as const) { + const v = incoming[key] + if (v !== undefined && existing[key] !== v) { + ;(existing as any)[key] = v + touched = true + } + } + if (touched) { + priced++ + } + } + } + } + + return { added, priced } +} + +/** + * Serialize the catalog for transport (gRPC String payloads / disk cache). + */ +export function serializeModelsDevCatalog(catalog: ModelsDevCatalog): string { + return JSON.stringify(catalog) +} + +/** + * Deserialize a catalog from transport (gRPC String payloads / disk cache). + */ +export function deserializeModelsDevCatalog(json: string): ModelsDevCatalog | null { + try { + const parsed = JSON.parse(json) + if (!parsed || typeof parsed !== "object" || !parsed.providers || typeof parsed.providers !== "object") { + return null + } + return parsed as ModelsDevCatalog + } catch { + return null + } +} diff --git a/src/shared/storage/state-keys.ts b/src/shared/storage/state-keys.ts index fbe62b1c..8076e487 100644 --- a/src/shared/storage/state-keys.ts +++ b/src/shared/storage/state-keys.ts @@ -291,6 +291,8 @@ const USER_SETTINGS_FIELDS = { doubleCheckCompletionEnabled: { default: false as boolean }, lazyTeammateModeEnabled: { default: false as boolean }, showFeatureTips: { default: true as boolean }, + modelsDevUpdateModels: { default: true as boolean }, + modelsDevUpdatePricing: { default: false as boolean }, // OpenTelemetry configuration openTelemetryEnabled: { default: true as boolean }, diff --git a/webview-ui/src/components/settings/sections/AboutSection.tsx b/webview-ui/src/components/settings/sections/AboutSection.tsx index 0b9982ee..cb6b648f 100644 --- a/webview-ui/src/components/settings/sections/AboutSection.tsx +++ b/webview-ui/src/components/settings/sections/AboutSection.tsx @@ -2,6 +2,11 @@ import { VSCodeLink } from "@vscode/webview-ui-toolkit/react" import { useTranslation } from "react-i18next" import Section from "../Section" +const PROJECT_GITHUB_URL = "https://github.com/Adam-PAN/cline-multi" +const PROJECT_ISSUES_URL = "https://github.com/Adam-PAN/cline-multi/issues" +const PROJECT_RELEASES_URL = "https://github.com/Adam-PAN/cline-multi/releases" +const UPSTREAM_CLINE_URL = "https://github.com/cline/cline" + interface AboutSectionProps { version: string renderSectionHeader: (tabId: string) => JSX.Element | null @@ -16,32 +21,29 @@ const AboutSection = ({ version, renderSectionHeader }: AboutSectionProps) => {

{t("settingsSections.aboutVersion", { version })}

{t("settingsSections.aboutDescription")}

-

{t("settingsSections.communitySupport")}

+

{t("settingsSections.coreFeatures")}

+
    +
  • {t("settingsSections.featureMultiModelHotSwap")}
  • +
  • {t("settingsSections.featureCnModelAdaptation")}
  • +
  • {t("settingsSections.featureFriendlyErrors")}
  • +
  • {t("settingsSections.featureCostMonitoring")}
  • +
  • {t("settingsSections.featureCnSupport")}
  • +
  • {t("settingsSections.featureSmartContext")}
  • +
+ +

{t("settingsSections.projectLinks")}

- X + GitHub {" • "} - Discord + {t("settingsSections.releases")} {" • "} - r/cline + {t("settingsSections.issues")}

-

{t("settingsSections.development")}

+

{t("settingsSections.acknowledgement")}

- GitHub - {" • "} - {t("settingsSections.issues")} - {" • "} - - {" "} - {t("settingsSections.featureRequests")} - -

- -

{t("settingsSections.resources")}

-

- {t("settingsSections.documentation")} - {" • "} - https://cline.bot + {t("settingsSections.acknowledgementPrefix")} Cline + {t("settingsSections.acknowledgementSuffix")}

diff --git a/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx b/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx index 6a402d7c..b2ca4790 100644 --- a/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx +++ b/webview-ui/src/components/settings/sections/GeneralSettingsSection.tsx @@ -12,7 +12,7 @@ interface GeneralSettingsSectionProps { const GeneralSettingsSection = ({ renderSectionHeader }: GeneralSettingsSectionProps) => { const { t } = useTranslation("settings") - const { telemetrySetting, remoteConfigSettings } = useExtensionState() + const { telemetrySetting, remoteConfigSettings, modelsDevUpdateModels, modelsDevUpdatePricing } = useExtensionState() return (
@@ -20,6 +20,28 @@ const GeneralSettingsSection = ({ renderSectionHeader }: GeneralSettingsSectionP
+
+ { + const checked = e.target.checked === true + updateSetting("modelsDevUpdateModels", checked) + }}> + {t("settingsSections.modelsDevUpdateModels")} + +

{t("settingsSections.modelsDevUpdateDescription")}

+
+ { + const checked = e.target.checked === true + updateSetting("modelsDevUpdatePricing", checked) + }}> + {t("settingsSections.modelsDevUpdatePricing")} + +
+
+