From aa8de1af3dae0012f73e9cfe04ff1a334a78d77f Mon Sep 17 00:00:00 2001 From: Nate Date: Tue, 14 Jan 2025 00:11:22 -0800 Subject: [PATCH] better platform profile loading --- core/config/ConfigHandler.test.ts | 2 +- core/config/ConfigHandler.ts | 122 ++++++++++-------- core/config/ProfileLifecycleManager.ts | 27 +--- core/config/load.ts | 9 +- .../profile/ControlPlaneProfileLoader.ts | 19 ++- core/config/profile/IProfileLoader.ts | 6 +- core/config/profile/LocalProfileLoader.ts | 16 ++- core/config/profile/PlatformProfileLoader.ts | 47 +++++-- core/config/profile/doLoadConfig.ts | 9 +- core/config/validation.ts | 6 +- core/config/yaml/convertFromJson.ts | 1 + core/config/yaml/default.ts | 2 + core/config/yaml/loadYaml.ts | 54 ++++---- core/config/yaml/models.ts | 12 +- core/context/mcp/index.ts | 2 +- core/control-plane/auth/index.ts | 4 +- core/control-plane/client.ts | 23 +++- core/control-plane/env.ts | 13 +- core/core.ts | 4 +- core/index.d.ts | 5 + core/indexing/docs/DocsService.ts | 2 +- core/package-lock.json | 26 ++-- core/package.json | 2 +- core/protocol/core.ts | 2 +- core/protocol/ide.ts | 6 +- core/protocol/messenger/messageIde.ts | 10 +- core/protocol/webview.ts | 5 +- core/util/filesystem.ts | 7 + extensions/vscode/package-lock.json | 6 +- extensions/vscode/src/VsCodeIde.ts | 37 +++++- .../vscode/src/extension/VsCodeExtension.ts | 2 +- gui/package-lock.json | 11 +- gui/package.json | 2 +- .../dialogs/AboutAssistantDialog.tsx | 80 ++++++++++++ .../platform/AssistantAndModelSelect.tsx | 43 +++++- .../platform/AssistantSelect.tsx | 36 +++++- .../modelSelection/platform/shared.tsx | 41 +++++- gui/src/hooks/useSetup.ts | 2 +- gui/src/redux/slices/configSlice.ts | 6 +- gui/src/redux/slices/sessionSlice.ts | 1 + packages/config-yaml/package.json | 2 +- packages/config-yaml/src/index.ts | 1 - packages/config-yaml/src/validation.ts | 13 +- 43 files changed, 498 insertions(+), 228 deletions(-) create mode 100644 gui/src/components/dialogs/AboutAssistantDialog.tsx diff --git a/core/config/ConfigHandler.test.ts b/core/config/ConfigHandler.test.ts index 5a25e71fc..deb1deded 100644 --- a/core/config/ConfigHandler.test.ts +++ b/core/config/ConfigHandler.test.ts @@ -14,7 +14,7 @@ describe.skip("Test the ConfigHandler and E2E config loading", () => { expect(profiles[0].id).toBe("local"); const currentProfile = testConfigHandler.currentProfile; - expect(currentProfile.profileId).toBe("local"); + expect(currentProfile.profileDescription.id).toBe("local"); }); test("should load the default config successfully", async () => { diff --git a/core/config/ConfigHandler.ts b/core/config/ConfigHandler.ts index cc4895048..3e90b8c4f 100644 --- a/core/config/ConfigHandler.ts +++ b/core/config/ConfigHandler.ts @@ -14,9 +14,10 @@ import Ollama from "../llm/llms/Ollama.js"; import { GlobalContext } from "../util/GlobalContext.js"; import { getConfigJsonPath } from "../util/paths.js"; +import { ConfigResult } from "@continuedev/config-yaml"; import { pathToFileURL } from "url"; +import { controlPlaneEnv } from "../control-plane/env.js"; import { usePlatform } from "../control-plane/flags.js"; -import { ConfigResult } from "./load.js"; import { LOCAL_ONBOARDING_CHAT_MODEL, ONBOARDING_LOCAL_MODEL_TITLE, @@ -59,7 +60,7 @@ export class ConfigHandler { writeLog, ); this.profiles = [new ProfileLifecycleManager(localProfileLoader)]; - this.selectedProfileId = localProfileLoader.profileId; + this.selectedProfileId = localProfileLoader.description.id; // Always load local profile immediately in case control plane doesn't load try { @@ -79,13 +80,16 @@ export class ConfigHandler { get currentProfile() { return ( - this.profiles.find((p) => p.profileId === this.selectedProfileId) ?? - this.fallbackProfile + this.profiles.find( + (p) => p.profileDescription.id === this.selectedProfileId, + ) ?? this.fallbackProfile ); } get inactiveProfiles() { - return this.profiles.filter((p) => p.profileId !== this.selectedProfileId); + return this.profiles.filter( + (p) => p.profileDescription.id !== this.selectedProfileId, + ); } async openConfigProfile(profileId?: string) { @@ -93,66 +97,74 @@ export class ConfigHandler { if (openProfileId === "local") { await this.ide.openFile(pathToFileURL(getConfigJsonPath()).toString()); } else { - await this.ide.openUrl( - "https://app.continue.dev/", - // `https://app.continue.dev/workspaces/${openProfileId}/chat`, - ); + await this.ide.openUrl(`${controlPlaneEnv.APP_URL}${openProfileId}`); } } + private async loadPlatformProfiles() { + // Get the profiles and create their lifecycle managers + this.controlPlaneClient + .listAssistants() + .then(async (assistants) => { + this.profiles = this.profiles.filter( + (profile) => profile.profileDescription.id === "local", + ); + assistants.forEach((assistant) => { + const profileLoader = new PlatformProfileLoader( + assistant.configResult, + assistant.ownerSlug, + assistant.packageSlug, + this.controlPlaneClient, + this.ide, + this.ideSettingsPromise, + this.writeLog, + this.reloadConfig.bind(this), + ); + this.profiles.push(new ProfileLifecycleManager(profileLoader)); + }); + + this.notifyProfileListeners( + this.profiles.map((profile) => profile.profileDescription), + ); + + // Check the last selected workspace, and reload if it isn't local + const workspaceId = await this.getWorkspaceId(); + const lastSelectedWorkspaceIds = + this.globalContext.get("lastSelectedProfileForWorkspace") ?? {}; + const selectedWorkspaceId = lastSelectedWorkspaceIds[workspaceId]; + if (selectedWorkspaceId) { + this.selectedProfileId = selectedWorkspaceId; + await this.loadConfig(); + } else { + // Otherwise we stick with local profile, and record choice + lastSelectedWorkspaceIds[workspaceId] = this.selectedProfileId; + this.globalContext.update( + "lastSelectedProfileForWorkspace", + lastSelectedWorkspaceIds, + ); + } + }) + .catch((e) => { + console.error("Failed to list assistants: ", e); + }); + } + + private platformProfilesRefreshInterval: NodeJS.Timeout | undefined; + private async fetchControlPlaneProfiles() { if (usePlatform()) { - // Get the profiles and create their lifecycle managers - this.controlPlaneClient - .listAssistants() - .then(async (assistants) => { - this.profiles = this.profiles.filter( - (profile) => profile.profileId === "local", - ); - assistants.forEach((assistant) => { - const profileLoader = new PlatformProfileLoader( - assistant.configYaml, - assistant.ownerSlug, - assistant.packageSlug, - this.controlPlaneClient, - this.ide, - this.ideSettingsPromise, - this.writeLog, - this.reloadConfig.bind(this), - ); - this.profiles.push(new ProfileLifecycleManager(profileLoader)); - }); - - this.notifyProfileListeners( - this.profiles.map((profile) => profile.profileDescription), - ); - - // Check the last selected workspace, and reload if it isn't local - const workspaceId = await this.getWorkspaceId(); - const lastSelectedWorkspaceIds = - this.globalContext.get("lastSelectedProfileForWorkspace") ?? {}; - const selectedWorkspaceId = lastSelectedWorkspaceIds[workspaceId]; - if (selectedWorkspaceId) { - this.selectedProfileId = selectedWorkspaceId; - await this.loadConfig(); - } else { - // Otherwise we stick with local profile, and record choice - lastSelectedWorkspaceIds[workspaceId] = this.selectedProfileId; - this.globalContext.update( - "lastSelectedProfileForWorkspace", - lastSelectedWorkspaceIds, - ); - } - }) - .catch((e) => { - console.error("Failed to list assistants: ", e); - }); + clearInterval(this.platformProfilesRefreshInterval); + await this.loadPlatformProfiles(); + this.platformProfilesRefreshInterval = setInterval( + this.loadPlatformProfiles.bind(this), + PlatformProfileLoader.RELOAD_INTERVAL, + ); } else { this.controlPlaneClient .listWorkspaces() .then(async (workspaces) => { this.profiles = this.profiles.filter( - (profile) => profile.profileId === "local", + (profile) => profile.profileDescription.id === "local", ); workspaces.forEach((workspace) => { const profileLoader = new ControlPlaneProfileLoader( diff --git a/core/config/ProfileLifecycleManager.ts b/core/config/ProfileLifecycleManager.ts index c5ae16f91..88fc387c5 100644 --- a/core/config/ProfileLifecycleManager.ts +++ b/core/config/ProfileLifecycleManager.ts @@ -1,15 +1,17 @@ +import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml"; import { BrowserSerializedContinueConfig, ContinueConfig, IContextProvider, } from "../index.js"; -import { ConfigResult, finalToBrowserConfig } from "./load.js"; +import { finalToBrowserConfig } from "./load.js"; import { IProfileLoader } from "./profile/IProfileLoader.js"; export interface ProfileDescription { title: string; id: string; + errors: ConfigValidationError[] | undefined; } export class ProfileLifecycleManager { @@ -19,19 +21,8 @@ export class ProfileLifecycleManager { constructor(private readonly profileLoader: IProfileLoader) {} - get profileId() { - return this.profileLoader.profileId; - } - - get profileTitle() { - return this.profileLoader.profileTitle; - } - get profileDescription(): ProfileDescription { - return { - title: this.profileTitle, - id: this.profileId, - }; + return this.profileLoader.description; } clearConfig() { @@ -71,14 +62,10 @@ export class ProfileLifecycleManager { result.config.contextProviders = ( result.config.contextProviders ?? [] ).concat(additionalContextProviders); - - this.savedConfigResult = result; - resolve(result); - } else if (result.errors) { - reject( - `Error in config.json: ${result.errors.map((item) => item.message).join(" | ")}`, - ); } + + this.savedConfigResult = result; + resolve(result); }); // Wait for the config promise to resolve diff --git a/core/config/load.ts b/core/config/load.ts index 8243b9c38..da8640c72 100644 --- a/core/config/load.ts +++ b/core/config/load.ts @@ -63,6 +63,7 @@ import { getEsbuildBinaryPath, } from "../util/paths"; +import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml"; import { usePlatform } from "../control-plane/flags"; import { defaultContextProvidersJetBrains, @@ -72,13 +73,7 @@ import { } from "./default"; import { getSystemPromptDotFile } from "./getSystemPromptDotFile"; import { isSupportedLanceDbCpuTarget } from "./util"; -import { ConfigValidationError, validateConfig } from "./validation.js"; - -export interface ConfigResult { - config: T | undefined; - errors: ConfigValidationError[] | undefined; - configLoadInterrupted: boolean; -} +import { validateConfig } from "./validation.js"; function resolveSerializedConfig(filepath: string): SerializedContinueConfig { let content = fs.readFileSync(filepath, "utf8"); diff --git a/core/config/profile/ControlPlaneProfileLoader.ts b/core/config/profile/ControlPlaneProfileLoader.ts index 0ccea714e..38c7fb389 100644 --- a/core/config/profile/ControlPlaneProfileLoader.ts +++ b/core/config/profile/ControlPlaneProfileLoader.ts @@ -7,16 +7,16 @@ import { IdeSettings, SerializedContinueConfig, } from "../../index.js"; -import { ConfigResult } from "../load.js"; +import { ConfigResult } from "@continuedev/config-yaml"; +import { ProfileDescription } from "../ProfileLifecycleManager.js"; import doLoadConfig from "./doLoadConfig.js"; import { IProfileLoader } from "./IProfileLoader.js"; export default class ControlPlaneProfileLoader implements IProfileLoader { private static RELOAD_INTERVAL = 1000 * 60 * 15; // every 15 minutes - readonly profileId: string; - profileTitle: string; + description: ProfileDescription; workspaceSettings: ConfigJson | undefined; @@ -29,12 +29,17 @@ export default class ControlPlaneProfileLoader implements IProfileLoader { private writeLog: (message: string) => Promise, private readonly onReload: () => void, ) { - this.profileId = workspaceId; - this.profileTitle = workspaceTitle; + this.description = { + id: workspaceId, + title: workspaceTitle, + errors: undefined, + }; setInterval(async () => { this.workspaceSettings = - await this.controlPlaneClient.getSettingsForWorkspace(this.profileId); + await this.controlPlaneClient.getSettingsForWorkspace( + this.description.id, + ); this.onReload(); }, ControlPlaneProfileLoader.RELOAD_INTERVAL); } @@ -43,7 +48,7 @@ export default class ControlPlaneProfileLoader implements IProfileLoader { const settings = this.workspaceSettings ?? ((await this.controlPlaneClient.getSettingsForWorkspace( - this.profileId, + this.description.id, )) as any); const serializedConfig: SerializedContinueConfig = settings; diff --git a/core/config/profile/IProfileLoader.ts b/core/config/profile/IProfileLoader.ts index 2d22a821e..5d0717252 100644 --- a/core/config/profile/IProfileLoader.ts +++ b/core/config/profile/IProfileLoader.ts @@ -1,12 +1,12 @@ // ProfileHandlers manage the loading of a config, allowing us to abstract over different ways of getting to a ContinueConfig +import { ConfigResult } from "@continuedev/config-yaml"; import { ContinueConfig } from "../../index.js"; -import { ConfigResult } from "../load.js"; +import { ProfileDescription } from "../ProfileLifecycleManager.js"; // After we have the ContinueConfig, the ConfigHandler takes care of everything else (loading models, lifecycle, etc.) export interface IProfileLoader { - profileTitle: string; - profileId: string; + description: ProfileDescription; doLoadConfig(): Promise>; setIsActive(isActive: boolean): void; } diff --git a/core/config/profile/LocalProfileLoader.ts b/core/config/profile/LocalProfileLoader.ts index f54fe612c..644e97069 100644 --- a/core/config/profile/LocalProfileLoader.ts +++ b/core/config/profile/LocalProfileLoader.ts @@ -1,14 +1,18 @@ +import { ConfigResult } from "@continuedev/config-yaml"; import { ControlPlaneClient } from "../../control-plane/client.js"; import { ContinueConfig, IDE, IdeSettings } from "../../index.js"; -import { ConfigResult } from "../load.js"; +import { ProfileDescription } from "../ProfileLifecycleManager.js"; import doLoadConfig from "./doLoadConfig.js"; import { IProfileLoader } from "./IProfileLoader.js"; export default class LocalProfileLoader implements IProfileLoader { static ID = "local"; - profileId = LocalProfileLoader.ID; - profileTitle = "Local Config"; + description: ProfileDescription = { + id: LocalProfileLoader.ID, + title: "Local Config", + errors: undefined, + }; constructor( private ide: IDE, @@ -18,7 +22,7 @@ export default class LocalProfileLoader implements IProfileLoader { ) {} async doLoadConfig(): Promise> { - return doLoadConfig( + const result = await doLoadConfig( this.ide, this.ideSettingsPromise, this.controlPlaneClient, @@ -27,6 +31,10 @@ export default class LocalProfileLoader implements IProfileLoader { undefined, undefined, ); + + this.description.errors = result.errors; + + return result; } setIsActive(isActive: boolean): void {} diff --git a/core/config/profile/PlatformProfileLoader.ts b/core/config/profile/PlatformProfileLoader.ts index 16347e2b2..d0f7d6f80 100644 --- a/core/config/profile/PlatformProfileLoader.ts +++ b/core/config/profile/PlatformProfileLoader.ts @@ -1,24 +1,30 @@ +import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js"; + import { ControlPlaneClient } from "../../control-plane/client.js"; import { ContinueConfig, IDE, IdeSettings } from "../../index.js"; -import { ConfigResult } from "../load.js"; -import { ConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js"; +import { ConfigResult } from "@continuedev/config-yaml"; +import { ProfileDescription } from "../ProfileLifecycleManager.js"; import doLoadConfig from "./doLoadConfig.js"; import { IProfileLoader } from "./IProfileLoader.js"; +/** + * Metadata about the package that is currently being loaded + * If this is `undefined`, it's not a config from the platform, + * could be local for example. + */ export interface PlatformConfigMetadata { ownerSlug: string; packageSlug: string; } export default class PlatformProfileLoader implements IProfileLoader { - private static RELOAD_INTERVAL = 1000 * 60 * 15; // every 15 minutes + static RELOAD_INTERVAL = 1000 * 60 * 15; // every 15 minutes - readonly profileId: string; - profileTitle: string; + description: ProfileDescription; constructor( - private configYaml: ConfigYaml, + private configResult: ConfigResult, private readonly ownerSlug: string, private readonly packageSlug: string, private readonly controlPlaneClient: ControlPlaneClient, @@ -27,32 +33,47 @@ export default class PlatformProfileLoader implements IProfileLoader { private writeLog: (message: string) => Promise, private readonly onReload: () => void, ) { - this.profileId = `${ownerSlug}/${packageSlug}`; - this.profileTitle = `${ownerSlug}/${packageSlug}`; + this.description = { + id: `${ownerSlug}/${packageSlug}`, + title: `${ownerSlug}/${packageSlug}`, + errors: configResult.errors, + }; setInterval(async () => { const assistants = await this.controlPlaneClient.listAssistants(); - const newConfigYaml = assistants.find( + const newConfigResult = assistants.find( (assistant) => assistant.packageSlug === this.packageSlug && assistant.ownerSlug === this.ownerSlug, - )?.configYaml; - if (!newConfigYaml) { + )?.configResult; + if (!newConfigResult) { return; } - this.configYaml = newConfigYaml; + this.configResult = { + config: newConfigResult.config, + errors: newConfigResult.errors, + configLoadInterrupted: false, + }; this.onReload(); }, PlatformProfileLoader.RELOAD_INTERVAL); } async doLoadConfig(): Promise> { + if (this.configResult.errors?.length) { + return { + config: undefined, + errors: this.configResult.errors, + configLoadInterrupted: false, + }; + } + const results = await doLoadConfig( this.ide, this.ideSettingsPromise, this.controlPlaneClient, this.writeLog, undefined, - this.configYaml, + this.configResult.config, { ownerSlug: this.ownerSlug, packageSlug: this.packageSlug, diff --git a/core/config/profile/doLoadConfig.ts b/core/config/profile/doLoadConfig.ts index 747a582cd..5f20ac7e2 100644 --- a/core/config/profile/doLoadConfig.ts +++ b/core/config/profile/doLoadConfig.ts @@ -1,6 +1,7 @@ import fs from "fs"; -import { ConfigYaml } from "@continuedev/config-yaml/dist/schemas"; +import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml"; +import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas"; import { ContinueConfig, ContinueRcJson, @@ -16,8 +17,7 @@ import ContinueProxy from "../../llm/llms/stubs/ContinueProxy"; import { getConfigYamlPath } from "../../util/paths"; import { Telemetry } from "../../util/posthog"; import { TTS } from "../../util/tts"; -import { ConfigResult, loadFullConfigNode } from "../load"; -import { ConfigValidationError } from "../validation"; +import { loadFullConfigNode } from "../load"; import { loadContinueConfigFromYaml } from "../yaml/loadYaml"; import { PlatformConfigMetadata } from "./PlatformProfileLoader"; @@ -27,7 +27,7 @@ export default async function doLoadConfig( controlPlaneClient: ControlPlaneClient, writeLog: (message: string) => Promise, overrideConfigJson: SerializedContinueConfig | undefined, - overrideConfigYaml: ConfigYaml | undefined, + overrideConfigYaml: ClientConfigYaml | undefined, platformConfigMetadata: PlatformConfigMetadata | undefined, workspaceId?: string, ): Promise> { @@ -54,6 +54,7 @@ export default async function doLoadConfig( workOsAccessToken, overrideConfigYaml, platformConfigMetadata, + controlPlaneClient, ); newConfig = result.config; errors = result.errors; diff --git a/core/config/validation.ts b/core/config/validation.ts index e10b3f523..d28bb7809 100644 --- a/core/config/validation.ts +++ b/core/config/validation.ts @@ -1,11 +1,7 @@ +import { ConfigValidationError } from "@continuedev/config-yaml"; import { ModelDescription, SerializedContinueConfig } from "../"; import { Telemetry } from "../util/posthog"; -export interface ConfigValidationError { - fatal: boolean; - message: string; -} - /** * Validates a SerializedContinueConfig object to ensure all properties are correctly formed. * @param config The configuration object to validate. diff --git a/core/config/yaml/convertFromJson.ts b/core/config/yaml/convertFromJson.ts index 59482b5c3..4109d7d37 100644 --- a/core/config/yaml/convertFromJson.ts +++ b/core/config/yaml/convertFromJson.ts @@ -8,6 +8,7 @@ export function convertConfigJsonToConfigYaml( ): ConfigYaml { return { name: "Local Config", + version: "1.0.0", models: [ ...configJson.models.map( (model): ModelConfig => ({ diff --git a/core/config/yaml/default.ts b/core/config/yaml/default.ts index f991561df..cfdffc12d 100644 --- a/core/config/yaml/default.ts +++ b/core/config/yaml/default.ts @@ -5,10 +5,12 @@ export const defaultConfigYaml: ConfigYaml = { models: [], context: [], name: "Local Config", + version: "1.0.0", }; export const defaultConfigYamlJetBrains: ConfigYaml = { models: [], context: [], name: "Local Config", + version: "1.0.0", }; diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 2a6d1f415..8cb0375cb 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -1,12 +1,12 @@ import fs from "node:fs"; import { - extendConfig, + ConfigResult, fillTemplateVariables, + resolveSecretsOnClient, validateConfigYaml, } from "@continuedev/config-yaml"; -import { ConfigYaml } from "@continuedev/config-yaml/dist/schemas"; -import { ValidationLevel } from "@continuedev/config-yaml/dist/validation"; +import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas"; import { fetchwithRequestOptions } from "@continuedev/fetch"; import * as YAML from "yaml"; @@ -25,20 +25,14 @@ import { contextProviderClassFromName } from "../../context/providers/index"; import { allEmbeddingsProviders } from "../../indexing/allEmbeddingsProviders"; import FreeTrial from "../../llm/llms/FreeTrial"; import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider"; -import { getConfigYamlPath, getContinueDotEnv } from "../../util/paths"; -import { getSystemPromptDotFile } from "../getSystemPromptDotFile"; -import { ConfigValidationError } from "../validation.js"; - import { slashCommandFromPromptFileV1 } from "../../promptFiles/v1/slashCommandFromPromptFile"; import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles"; +import { getConfigYamlPath, getContinueDotEnv } from "../../util/paths"; +import { getSystemPromptDotFile } from "../getSystemPromptDotFile"; import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader"; -import { llmsFromModelConfig } from "./models"; -export interface ConfigResult { - config: T | undefined; - errors: ConfigValidationError[] | undefined; - configLoadInterrupted: boolean; -} +import { ControlPlaneClient } from "../../control-plane/client"; +import { llmsFromModelConfig } from "./models"; function renderTemplateVars(configYaml: string): string { const data: Record = {}; @@ -57,19 +51,16 @@ function renderTemplateVars(configYaml: string): string { function loadConfigYaml( workspaceConfigs: string[], rawYaml: string, - overrideConfigYaml: ConfigYaml | undefined, -): ConfigResult { + overrideConfigYaml: ClientConfigYaml | undefined, +): ConfigResult { let config = overrideConfigYaml ?? - (YAML.parse(renderTemplateVars(rawYaml)) as ConfigYaml); + (YAML.parse(renderTemplateVars(rawYaml)) as ClientConfigYaml); const errors = validateConfigYaml(config); - if (errors?.some((error) => error.level === ValidationLevel.Error)) { + if (errors?.some((error) => error.fatal)) { return { - errors: errors.map((error) => ({ - message: error.message, - fatal: error.level === ValidationLevel.Error, - })), + errors, config: undefined, configLoadInterrupted: true, }; @@ -80,7 +71,7 @@ function loadConfigYaml( config, errors: errors.map((error) => ({ message: error.message, - fatal: error.level === ValidationLevel.Error, + fatal: error.fatal, })), configLoadInterrupted: false, }; @@ -104,7 +95,7 @@ async function slashCommandsFromV1PromptFiles( } async function configYamlToContinueConfig( - config: ConfigYaml, + config: ClientConfigYaml, ide: IDE, ideSettings: IdeSettings, uniqueId: string, @@ -279,8 +270,9 @@ export async function loadContinueConfigFromYaml( uniqueId: string, writeLog: (log: string) => Promise, workOsAccessToken: string | undefined, - overrideConfigYaml: ConfigYaml | undefined, + overrideConfigYaml: ClientConfigYaml | undefined, platformConfigMetadata: PlatformConfigMetadata | undefined, + controlPlaneClient: ControlPlaneClient, ): Promise> { const configYamlPath = getConfigYamlPath(ideType); const rawYaml = @@ -288,7 +280,7 @@ export async function loadContinueConfigFromYaml( ? fs.readFileSync(configYamlPath, "utf-8") : ""; - const configYamlResult = await loadConfigYaml( + const configYamlResult = loadConfigYaml( workspaceConfigs, rawYaml, overrideConfigYaml, @@ -302,8 +294,18 @@ export async function loadContinueConfigFromYaml( }; } - const continueConfig = await configYamlToContinueConfig( + const configYaml = await resolveSecretsOnClient( configYamlResult.config, + ide.readSecrets.bind(ide), + async (secretNames: string[]) => { + const secretValues = await controlPlaneClient.syncSecrets(secretNames); + await ide.writeSecrets(secretValues); + return secretValues; + }, + ); + + const continueConfig = await configYamlToContinueConfig( + configYaml, ide, ideSettings, uniqueId, diff --git a/core/config/yaml/models.ts b/core/config/yaml/models.ts index bcb46ec7c..f7bd717a1 100644 --- a/core/config/yaml/models.ts +++ b/core/config/yaml/models.ts @@ -8,21 +8,11 @@ import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader"; const AUTODETECT = "AUTODETECT"; -const ALWAYS_LOCAL_PROVIDERS = [ - "ollama", - "lmstudio", - "llamafile", - "llama.cpp", - "msty", -]; - function useContinueProxy( model: ModelConfig, platformConfigMetadata: PlatformConfigMetadata | undefined, ): boolean { - return ( - !!platformConfigMetadata && !ALWAYS_LOCAL_PROVIDERS.includes(model.provider) - ); + return !!platformConfigMetadata && model.apiKeySecret !== undefined; } function getModelClass( diff --git a/core/context/mcp/index.ts b/core/context/mcp/index.ts index 26be2f471..304c2a8c4 100644 --- a/core/context/mcp/index.ts +++ b/core/context/mcp/index.ts @@ -4,9 +4,9 @@ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js" import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js"; import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; +import { ConfigValidationError } from "@continuedev/config-yaml"; import { ContinueConfig, MCPOptions, SlashCommand, Tool } from "../.."; import { constructMcpSlashCommand } from "../../commands/slash/mcp"; -import { ConfigValidationError } from "../../config/validation"; import { encodeMCPToolUri } from "../../tools/callTool"; import MCPContextProvider from "../providers/MCPContextProvider"; diff --git a/core/control-plane/auth/index.ts b/core/control-plane/auth/index.ts index ecb6221c7..c1a6f881d 100644 --- a/core/control-plane/auth/index.ts +++ b/core/control-plane/auth/index.ts @@ -1,5 +1,7 @@ import { v4 as uuidv4 } from "uuid"; +import { controlPlaneEnv } from "../env"; + const CLIENT_ID = "client_01J0FW6XN8N2XJAECF7NE0Y65J"; // const CLIENT_ID = "client_01J0FW6XCPMJMQ3CG51RB4HBZQ"; // Staging @@ -8,7 +10,7 @@ export async function getAuthUrlForTokenPage(): Promise { const params = { response_type: "code", client_id: CLIENT_ID, - redirect_uri: "https://app.continue.dev/tokens/callback", + redirect_uri: `${controlPlaneEnv.APP_URL}tokens/callback`, // redirect_uri: "http://localhost:3000/tokens/callback", state: uuidv4(), provider: "authkit", diff --git a/core/control-plane/client.ts b/core/control-plane/client.ts index 92645ab73..3a29b3fee 100644 --- a/core/control-plane/client.ts +++ b/core/control-plane/client.ts @@ -1,9 +1,10 @@ import { ConfigJson } from "@continuedev/config-types"; +import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js"; import fetch, { RequestInit, Response } from "node-fetch"; import { ModelDescription } from "../index.js"; -import { ConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js"; +import { ConfigResult } from "@continuedev/config-yaml"; import { controlPlaneEnv } from "./env.js"; export interface ControlPlaneSessionInfo { @@ -88,9 +89,10 @@ export class ControlPlaneClient { public async listAssistants(): Promise< { - configYaml: ConfigYaml; + configResult: ConfigResult; ownerSlug: string; packageSlug: string; + iconUrl: string; }[] > { const userId = await this.userId; @@ -119,4 +121,21 @@ export class ControlPlaneClient { }); return ((await resp.json()) as any).settings; } + + async syncSecrets(secretNames: string[]): Promise> { + const userId = await this.userId; + if (!userId) { + throw new Error("No user id"); + } + + try { + const resp = await this.request("ide/sync-secrets", { + method: "POST", + body: JSON.stringify({ secretNames }), + }); + return (await resp.json()) as any; + } catch (e) { + return {}; + } + } } diff --git a/core/control-plane/env.ts b/core/control-plane/env.ts index 064d30a5c..596fa5fce 100644 --- a/core/control-plane/env.ts +++ b/core/control-plane/env.ts @@ -23,7 +23,7 @@ const PRODUCTION_ENV: ControlPlaneEnv = { "https://control-plane-api-service-i3dqylpbqa-uc.a.run.app/", AUTH_TYPE: WORKOS_ENV_ID_PRODUCTION, WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_PRODUCTION, - APP_URL: "https://app.continue.dev", + APP_URL: "https://app.continue.dev/", }; const STAGING_ENV: ControlPlaneEnv = { @@ -33,16 +33,15 @@ const STAGING_ENV: ControlPlaneEnv = { "https://control-plane-api-service-537175798139.us-central1.run.app/", AUTH_TYPE: WORKOS_CLIENT_ID_STAGING, WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING, - APP_URL: "https://app-preview.continue.dev", + APP_URL: "https://app-preview.continue.dev/", }; const TEST_ENV: ControlPlaneEnv = { - DEFAULT_CONTROL_PLANE_PROXY_URL: - "https://control-plane-api.continue-dev.tools/", - CONTROL_PLANE_URL: "https://control-plane-api.continue-dev.tools/", + DEFAULT_CONTROL_PLANE_PROXY_URL: "https://api-test.continue.dev/", + CONTROL_PLANE_URL: "https://api-test.continue.dev/", AUTH_TYPE: WORKOS_ENV_ID_STAGING, WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING, - APP_URL: "https://app-test.continue.dev", + APP_URL: "https://app-test.continue.dev/", }; const LOCAL_ENV: ControlPlaneEnv = { @@ -50,7 +49,7 @@ const LOCAL_ENV: ControlPlaneEnv = { CONTROL_PLANE_URL: "http://localhost:3001/", AUTH_TYPE: WORKOS_ENV_ID_STAGING, WORKOS_CLIENT_ID: WORKOS_CLIENT_ID_STAGING, - APP_URL: "http://localhost:3000", + APP_URL: "http://localhost:3000/", }; export const controlPlaneEnv = diff --git a/core/core.ts b/core/core.ts index cc92f9d0b..dde3091ee 100644 --- a/core/core.ts +++ b/core/core.ts @@ -125,7 +125,7 @@ export class Core { const serializedResult = await this.configHandler.getSerializedConfig(); this.messenger.send("configUpdate", { result: serializedResult, - profileId: this.configHandler.currentProfile.profileId, + profileId: this.configHandler.currentProfile.profileDescription.id, }); }); @@ -379,7 +379,7 @@ export class Core { on("config/getSerializedProfileInfo", async (msg) => { return { result: await this.configHandler.getSerializedConfig(), - profileId: this.configHandler.currentProfile.profileId, + profileId: this.configHandler.currentProfile.profileDescription.id, }; }); diff --git a/core/index.d.ts b/core/index.d.ts index 07b2d9ff6..13cd7dc65 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -684,6 +684,11 @@ export interface IDE { getGitHubAuthToken(args: GetGhTokenArgs): Promise; + // Secret Storage + readSecrets(keys: string[]): Promise>; + + writeSecrets(secrets: { [key: string]: string }): Promise; + // LSP gotoDefinition(location: Location): Promise; diff --git a/core/indexing/docs/DocsService.ts b/core/indexing/docs/DocsService.ts index 105d24b9e..cab6c35da 100644 --- a/core/indexing/docs/DocsService.ts +++ b/core/indexing/docs/DocsService.ts @@ -25,7 +25,7 @@ import { } from "../../util/paths"; import { Telemetry } from "../../util/posthog"; -import { ConfigResult } from "../../config/load"; +import { ConfigResult } from "@continuedev/config-yaml"; import { Article, chunkArticle, pageToArticle } from "./article"; import DocsCrawler from "./DocsCrawler"; import { runLanceMigrations, runSqliteMigrations } from "./migrations"; diff --git a/core/package-lock.json b/core/package-lock.json index 92371eda1..3303adaa3 100644 --- a/core/package-lock.json +++ b/core/package-lock.json @@ -13,7 +13,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.4", + "@continuedev/config-yaml": "file:../packages/config-yaml", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", @@ -106,6 +106,21 @@ "node": ">=20.11.0" } }, + "../packages/config-yaml": { + "name": "@continuedev/config-yaml", + "version": "1.0.10", + "license": "Apache-2.0", + "dependencies": { + "@continuedev/config-types": "file:../config-types", + "yaml": "^2.6.1", + "zod": "^3.23.8" + }, + "devDependencies": { + "cross-env": "^7.0.3", + "ts-jest": "^29.2.3", + "ts-node": "^10.9.2" + } + }, "node_modules/@75lb/deep-merge": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@75lb/deep-merge/-/deep-merge-1.1.2.tgz", @@ -3038,13 +3053,8 @@ } }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.4.tgz", - "integrity": "sha512-hMU+Svgjj/7XM3ZsHJTB0mfLUSnt58cXszoV8gj5nj9jtqNhKhbkVaz4eKsFe0A//DAk/QwWolKykE/xYZyBVg==", - "dependencies": { - "yaml": "^2.6.1", - "zod": "^3.23.8" - } + "resolved": "../packages/config-yaml", + "link": true }, "node_modules/@continuedev/fetch": { "version": "1.0.4", diff --git a/core/package.json b/core/package.json index cb39e2cdd..38d5a0ff5 100644 --- a/core/package.json +++ b/core/package.json @@ -46,7 +46,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.4", + "@continuedev/config-yaml": "file:../packages/config-yaml", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/core/protocol/core.ts b/core/protocol/core.ts index 9495dc3b2..27f1c92ad 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -1,6 +1,7 @@ import { AutocompleteInput } from "../autocomplete/util/types"; import { ProfileDescription } from "../config/ConfigHandler"; +import { ConfigResult } from "@continuedev/config-yaml"; import type { BrowserSerializedContinueConfig, ChatMessage, @@ -21,7 +22,6 @@ import type { SiteIndexingConfig, ToolCall, } from "../"; -import { ConfigResult } from "../config/load"; export type ProtocolGeneratorYield = { done?: boolean; diff --git a/core/protocol/ide.ts b/core/protocol/ide.ts index 8ac2f476f..5b2a7ab1f 100644 --- a/core/protocol/ide.ts +++ b/core/protocol/ide.ts @@ -13,8 +13,8 @@ import type { Problem, Range, RangeInFile, + TerminalOptions, Thread, - TerminalOptions } from "../"; export interface GetGhTokenArgs { @@ -29,7 +29,7 @@ export type ToIdeFromWebviewOrCoreProtocol = { showVirtualFile: [{ name: string; content: string }, void]; openFile: [{ path: string }, void]; openUrl: [string, void]; - runCommand: [{ command: string, options?: TerminalOptions }, void]; + runCommand: [{ command: string; options?: TerminalOptions }, void]; getSearchResults: [{ query: string }, string]; subprocess: [{ command: string; cwd?: string }, [string, string]]; saveFile: [{ filepath: string }, void]; @@ -72,6 +72,8 @@ export type ToIdeFromWebviewOrCoreProtocol = { isTelemetryEnabled: [undefined, boolean]; getUniqueId: [undefined, string]; getTags: [string, IndexTag[]]; + readSecrets: [{ keys: string[] }, Record]; + writeSecrets: [{ secrets: Record }, void]; // end methods from IDE type getIdeSettings: [undefined, IdeSettings]; diff --git a/core/protocol/messenger/messageIde.ts b/core/protocol/messenger/messageIde.ts index aaa567f39..4bb78e0ed 100644 --- a/core/protocol/messenger/messageIde.ts +++ b/core/protocol/messenger/messageIde.ts @@ -29,6 +29,14 @@ export class MessageIde implements IDE { ) => void, ) {} + async readSecrets(keys: string[]): Promise> { + return this.request("readSecrets", { keys }); + } + + async writeSecrets(secrets: { [key: string]: string }): Promise { + return this.request("writeSecrets", { secrets }); + } + fileExists(fileUri: string): Promise { return this.request("fileExists", { filepath: fileUri }); } @@ -152,7 +160,7 @@ export class MessageIde implements IDE { await this.request("openUrl", url); } - async runCommand(command: string, options?: TerminalOptions): Promise { + async runCommand(command: string, options?: TerminalOptions): Promise { await this.request("runCommand", { command, options }); } diff --git a/core/protocol/webview.ts b/core/protocol/webview.ts index 5e22faae6..822d9b532 100644 --- a/core/protocol/webview.ts +++ b/core/protocol/webview.ts @@ -1,11 +1,8 @@ -import { ConfigResult } from "../config/load.js"; -import { ConfigValidationError } from "../config/validation.js"; - +import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml"; import type { BrowserSerializedContinueConfig, ContextItemWithId, ContextProviderName, - ContextSubmenuItem, IndexingProgressUpdate, IndexingStatus, PackageDocsResult, diff --git a/core/util/filesystem.ts b/core/util/filesystem.ts index b4297f7bc..ccb550ec9 100644 --- a/core/util/filesystem.ts +++ b/core/util/filesystem.ts @@ -21,6 +21,13 @@ import { GetGhTokenArgs } from "../protocol/ide.js"; class FileSystemIde implements IDE { constructor(private readonly workspaceDir: string) {} + + async readSecrets(keys: string[]): Promise> { + return {}; + } + + async writeSecrets(secrets: { [key: string]: string }): Promise {} + showToast( type: ToastType, message: string, diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index eaf4fd970..645c9ad1e 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "0.9.251", + "version": "0.9.252", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "0.9.251", + "version": "0.9.252", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", @@ -106,7 +106,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.4", + "@continuedev/config-yaml": "file:../packages/config-yaml", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 2cec274e9..51008db8a 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -28,15 +28,41 @@ import type { TerminalOptions, Thread, } from "core"; +import { SecretStorage } from "./stubs/SecretStorage"; class VsCodeIde implements IDE { ideUtils: VsCodeIdeUtils; + secretStorage: SecretStorage; constructor( private readonly vscodeWebviewProtocolPromise: Promise, private readonly context: vscode.ExtensionContext, ) { this.ideUtils = new VsCodeIdeUtils(); + this.secretStorage = new SecretStorage(context); + } + + async readSecrets(keys: string[]): Promise> { + const secretValuePromises = keys.map((key) => this.secretStorage.get(key)); + const secretValues = await Promise.all(secretValuePromises); + + return keys.reduce( + (acc, key, index) => { + if (secretValues[index] === undefined) { + return acc; + } + + acc[key] = secretValues[index]; + return acc; + }, + {} as Record, + ); + } + + async writeSecrets(secrets: { [key: string]: string }): Promise { + for (const [key, value] of Object.entries(secrets)) { + await this.secretStorage.store(key, value); + } } async fileExists(uri: string): Promise { @@ -399,17 +425,22 @@ class VsCodeIde implements IDE { ); } - async runCommand(command: string, options: TerminalOptions = {reuseTerminal: true}): Promise { + async runCommand( + command: string, + options: TerminalOptions = { reuseTerminal: true }, + ): Promise { let terminal: vscode.Terminal | undefined; if (vscode.window.terminals.length && options.reuseTerminal) { if (options.terminalName) { - terminal = vscode.window.terminals.find(t => t?.name === options.terminalName); + terminal = vscode.window.terminals.find( + (t) => t?.name === options.terminalName, + ); } else { terminal = vscode.window.activeTerminal ?? vscode.window.terminals[0]; } } - if( !terminal) { + if (!terminal) { terminal = vscode.window.createTerminal(options?.terminalName); } terminal.show(); diff --git a/extensions/vscode/src/extension/VsCodeExtension.ts b/extensions/vscode/src/extension/VsCodeExtension.ts index 19dfdb3be..9e6da728d 100644 --- a/extensions/vscode/src/extension/VsCodeExtension.ts +++ b/extensions/vscode/src/extension/VsCodeExtension.ts @@ -171,7 +171,7 @@ export class VsCodeExtension { const result = await this.configHandler.getSerializedConfig(); this.sidebar.webviewProtocol?.request("configUpdate", { result, - profileId: this.configHandler.currentProfile.profileId, + profileId: this.configHandler.currentProfile.profileDescription.id, }); this.tabAutocompleteModel.clearLlm(); diff --git a/gui/package-lock.json b/gui/package-lock.json index 7f2c9ef3c..df7b640ac 100644 --- a/gui/package-lock.json +++ b/gui/package-lock.json @@ -7,7 +7,7 @@ "name": "gui", "license": "Apache-2.0", "dependencies": { - "@continuedev/config-yaml": "^1.0.7", + "@continuedev/config-yaml": "^1.0.10", "@headlessui/react": "^1.7.17", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", @@ -108,7 +108,7 @@ "@aws-sdk/client-sagemaker-runtime": "^3.621.0", "@aws-sdk/credential-providers": "^3.620.1", "@continuedev/config-types": "^1.0.13", - "@continuedev/config-yaml": "^1.0.4", + "@continuedev/config-yaml": "file:../packages/config-yaml", "@continuedev/fetch": "^1.0.4", "@continuedev/llm-info": "^1.0.2", "@continuedev/openai-adapters": "^1.0.10", @@ -548,10 +548,11 @@ "dev": true }, "node_modules/@continuedev/config-yaml": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.7.tgz", - "integrity": "sha512-qng9yj5m54b5UHfdTYBM+rEINWs+S+IOm/dzm/PMlmz3CmpRt3OiBZaHLl/iYRCSB4xeOqFKoBPird58sxQ8YA==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.10.tgz", + "integrity": "sha512-BBYAkkTyzYUBxntsgHaCo7IcQVIaI73Cpg2dWnjtIQOzYySn+rdgyfZTZJXFExYWl6h12YXqyMG+gRwp15dtvQ==", "dependencies": { + "@continuedev/config-types": "file:../config-types", "yaml": "^2.6.1", "zod": "^3.23.8" } diff --git a/gui/package.json b/gui/package.json index 0c0eb3fa5..ea009fbaa 100644 --- a/gui/package.json +++ b/gui/package.json @@ -15,7 +15,7 @@ "test:watch": "vitest" }, "dependencies": { - "@continuedev/config-yaml": "^1.0.7", + "@continuedev/config-yaml": "^1.0.10", "@headlessui/react": "^1.7.17", "@heroicons/react": "^2.0.18", "@reduxjs/toolkit": "^2.3.0", diff --git a/gui/src/components/dialogs/AboutAssistantDialog.tsx b/gui/src/components/dialogs/AboutAssistantDialog.tsx new file mode 100644 index 000000000..6f1734a92 --- /dev/null +++ b/gui/src/components/dialogs/AboutAssistantDialog.tsx @@ -0,0 +1,80 @@ +import { useAppSelector } from "../../redux/hooks"; +import { RootState } from "../../redux/store"; + +export default function AboutAssistantDialog() { + const configJson = useAppSelector((store: RootState) => store.config.config); + + const selectedProfileId = useAppSelector( + (store) => store.session.selectedProfileId, + ); + + return ( +
+

About {selectedProfileId} assistant

+ {configJson.models?.length > 0 && ( +
+ Chat models +
    + {configJson.models.map((model, index) => ( +
  • {model.title}
  • + ))} +
+
+ )} + + {configJson.embeddingsProvider && ( +
+ Embedding model +

{configJson.embeddingsProvider}

+
+ )} + + {configJson.reranker?.name && ( +
+ Rerank model +

{configJson.reranker.name}

+
+ )} + + {configJson.systemMessage && ( +
+ Rules +

{configJson.systemMessage}

+
+ )} + + {configJson.contextProviders?.length ? ( +
+ Context +
    + {configJson.contextProviders.map((provider, index) => ( +
  • {provider.title}
  • + ))} +
+
+ ) : null} + + {configJson.tools.length > 0 && ( +
+ Tools +
    + {configJson.tools.map((tool, index) => ( +
  • {tool.displayTitle}
  • + ))} +
+
+ )} + + {configJson.docs?.length ? ( +
+ Docs +
    + {configJson.docs.map((doc, index) => ( +
  • {doc.title}
  • + ))} +
+
+ ) : null} +
+ ); +} diff --git a/gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx b/gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx index 7c1767f83..4d0df15e7 100644 --- a/gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx +++ b/gui/src/components/modelSelection/platform/AssistantAndModelSelect.tsx @@ -1,8 +1,13 @@ import { Popover } from "@headlessui/react"; -import { ChevronDownIcon } from "@heroicons/react/24/outline"; +import { + ChevronDownIcon, + DocumentIcon, + SparklesIcon, +} from "@heroicons/react/24/outline"; import { useEffect, useRef, useState } from "react"; import styled from "styled-components"; import { defaultBorderRadius, lightGray, vscInputBackground } from "../.."; +import { useAuth } from "../../../context/Auth"; import AddModelForm from "../../../forms/AddModelForm"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { @@ -57,6 +62,8 @@ function AssistantAndModelSelect() { (store) => store.session.selectedProfileId, ); + const { profiles, selectedProfile } = useAuth(); + useEffect(() => { const handleResize = () => calculatePosition(); window.addEventListener("resize", handleResize); @@ -131,9 +138,29 @@ function AssistantAndModelSelect() { onClick={calculatePosition} >
- - {modelSelectTitle(defaultModel) || "Select model"}{" "} - + {selectedProfile?.id === "local" ? ( + <> +