|
1 | | -import { safeWriteJson } from "../../utils/safeWriteJson" |
2 | | -import * as path from "path" |
3 | | -import * as os from "os" |
4 | 1 | import * as fs from "fs/promises" |
| 2 | +import * as os from "os" |
5 | 3 | import pWaitFor from "p-wait-for" |
| 4 | +import * as path from "path" |
6 | 5 | import * as vscode from "vscode" |
7 | | -import * as yaml from "yaml" |
| 6 | +import { safeWriteJson } from "../../utils/safeWriteJson" |
8 | 7 |
|
| 8 | +import { CloudService } from "@roo-code/cloud" |
| 9 | +import { TelemetryService } from "@roo-code/telemetry" |
9 | 10 | import { |
| 11 | + type ClineMessage, |
| 12 | + type GlobalState, |
10 | 13 | type Language, |
11 | 14 | type ProviderSettings, |
12 | | - type GlobalState, |
13 | | - type ClineMessage, |
14 | 15 | TelemetryEventName, |
15 | 16 | } from "@roo-code/types" |
16 | | -import { CloudService } from "@roo-code/cloud" |
17 | | -import { TelemetryService } from "@roo-code/telemetry" |
18 | 17 | import { type ApiMessage } from "../task-persistence/apiMessages" |
19 | 18 |
|
20 | | -import { ClineProvider } from "./ClineProvider" |
21 | 19 | import { changeLanguage, t } from "../../i18n" |
| 20 | +import { ModelRecord, RouterName, toRouterName } from "../../shared/api" |
22 | 21 | import { Package } from "../../shared/package" |
23 | | -import { RouterName, toRouterName, ModelRecord } from "../../shared/api" |
24 | 22 | import { supportPrompt } from "../../shared/support-prompt" |
| 23 | +import { ClineProvider } from "./ClineProvider" |
25 | 24 |
|
26 | | -import { checkoutDiffPayloadSchema, checkoutRestorePayloadSchema, WebviewMessage } from "../../shared/WebviewMessage" |
27 | | -import { checkExistKey } from "../../shared/checkExistApiConfig" |
28 | | -import { experimentDefault } from "../../shared/experiments" |
29 | | -import { Terminal } from "../../integrations/terminal/Terminal" |
30 | | -import { openFile } from "../../integrations/misc/open-file" |
| 25 | +import { flushModels, getModels } from "../../api/providers/fetchers/modelCache" |
| 26 | +import { getOpenAiModels } from "../../api/providers/openai" |
| 27 | +import { getVsCodeLmModels } from "../../api/providers/vscode-lm" |
31 | 28 | import { openImage, saveImage } from "../../integrations/misc/image-handler" |
| 29 | +import { openFile } from "../../integrations/misc/open-file" |
32 | 30 | import { selectImages } from "../../integrations/misc/process-images" |
| 31 | +import { Terminal } from "../../integrations/terminal/Terminal" |
33 | 32 | import { getTheme } from "../../integrations/theme/getTheme" |
34 | 33 | import { discoverChromeHostUrl, tryChromeHostUrl } from "../../services/browser/browserDiscovery" |
35 | 34 | import { searchWorkspaceFiles } from "../../services/search/file-search" |
| 35 | +import { TelemetrySetting } from "../../shared/TelemetrySetting" |
| 36 | +import { checkoutDiffPayloadSchema, checkoutRestorePayloadSchema, WebviewMessage } from "../../shared/WebviewMessage" |
| 37 | +import { GetModelsOptions } from "../../shared/api" |
| 38 | +import { checkExistKey } from "../../shared/checkExistApiConfig" |
| 39 | +import { experimentDefault } from "../../shared/experiments" |
| 40 | +import { defaultModeSlug, Mode } from "../../shared/modes" |
| 41 | +import { getCommand } from "../../utils/commands" |
36 | 42 | import { fileExistsAtPath } from "../../utils/fs" |
37 | | -import { playTts, setTtsEnabled, setTtsSpeed, stopTts } from "../../utils/tts" |
38 | | -import { singleCompletionHandler } from "../../utils/single-completion-handler" |
39 | 43 | import { searchCommits } from "../../utils/git" |
| 44 | +import { getWorkspacePath } from "../../utils/path" |
| 45 | +import { singleCompletionHandler } from "../../utils/single-completion-handler" |
| 46 | +import { playTts, setTtsEnabled, setTtsSpeed, stopTts } from "../../utils/tts" |
40 | 47 | import { exportSettings, importSettingsWithFeedback } from "../config/importExport" |
41 | | -import { getOpenAiModels } from "../../api/providers/openai" |
42 | | -import { getVsCodeLmModels } from "../../api/providers/vscode-lm" |
43 | 48 | import { openMention } from "../mentions" |
44 | | -import { TelemetrySetting } from "../../shared/TelemetrySetting" |
45 | | -import { getWorkspacePath } from "../../utils/path" |
46 | | -import { ensureSettingsDirectoryExists } from "../../utils/globalContext" |
47 | | -import { Mode, defaultModeSlug } from "../../shared/modes" |
48 | | -import { getModels, flushModels } from "../../api/providers/fetchers/modelCache" |
49 | | -import { GetModelsOptions } from "../../shared/api" |
50 | 49 | import { generateSystemPrompt } from "./generateSystemPrompt" |
51 | | -import { getCommand } from "../../utils/commands" |
52 | 50 |
|
53 | 51 | const ALLOWED_VSCODE_SETTINGS = new Set(["terminal.integrated.inheritEnv"]) |
54 | 52 |
|
55 | | -import { MarketplaceManager, MarketplaceItemType } from "../../services/marketplace" |
| 53 | +import { MarketplaceItemType, MarketplaceManager } from "../../services/marketplace" |
56 | 54 | import { setPendingTodoList } from "../tools/updateTodoListTool" |
57 | 55 |
|
58 | 56 | export const webviewMessageHandler = async ( |
@@ -555,6 +553,12 @@ export const webviewMessageHandler = async ( |
555 | 553 | }) |
556 | 554 | } |
557 | 555 |
|
| 556 | + const lmStudioBaseUrl = apiConfiguration.lmStudioBaseUrl || message?.values?.lmStudioBaseUrl |
| 557 | + modelFetchPromises.push({ |
| 558 | + key: "lmstudio", |
| 559 | + options: { provider: "lmstudio", baseUrl: lmStudioBaseUrl }, |
| 560 | + }) |
| 561 | + |
558 | 562 | const results = await Promise.allSettled( |
559 | 563 | modelFetchPromises.map(async ({ key, options }) => { |
560 | 564 | const models = await safeGetModels(options) |
@@ -633,30 +637,6 @@ export const webviewMessageHandler = async ( |
633 | 637 | } |
634 | 638 | break |
635 | 639 | } |
636 | | - case "requestLmStudioModels": { |
637 | | - // Specific handler for LM Studio models only |
638 | | - const { apiConfiguration: lmStudioApiConfig } = await provider.getState() |
639 | | - try { |
640 | | - // Flush cache first to ensure fresh models |
641 | | - await flushModels("lmstudio") |
642 | | - |
643 | | - const lmStudioModels = await getModels({ |
644 | | - provider: "lmstudio", |
645 | | - baseUrl: lmStudioApiConfig.lmStudioBaseUrl, |
646 | | - }) |
647 | | - |
648 | | - if (Object.keys(lmStudioModels).length > 0) { |
649 | | - provider.postMessageToWebview({ |
650 | | - type: "lmStudioModels", |
651 | | - lmStudioModels: Object.keys(lmStudioModels), |
652 | | - }) |
653 | | - } |
654 | | - } catch (error) { |
655 | | - // Silently fail - user hasn't configured LM Studio yet |
656 | | - console.debug("LM Studio models fetch failed:", error) |
657 | | - } |
658 | | - break |
659 | | - } |
660 | 640 | case "requestOpenAiModels": |
661 | 641 | if (message?.values?.baseUrl && message?.values?.apiKey) { |
662 | 642 | const openAiModels = await getOpenAiModels( |
|
0 commit comments