updates to yaml loading
This commit is contained in:
parent
40700c40be
commit
2d865425ce
11 changed files with 108 additions and 79 deletions
|
|
@ -1,10 +1,12 @@
|
|||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js";
|
||||
import { ConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
import { ControlPlaneClient } from "../../control-plane/client.js";
|
||||
import { ContinueConfig, IDE, IdeSettings } from "../../index.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ProfileDescription } from "../ProfileLifecycleManager.js";
|
||||
import { clientRenderHelper } from "../yaml/clientRender.js";
|
||||
import doLoadConfig from "./doLoadConfig.js";
|
||||
import { IProfileLoader } from "./IProfileLoader.js";
|
||||
|
||||
|
|
@ -24,7 +26,7 @@ export default class PlatformProfileLoader implements IProfileLoader {
|
|||
description: ProfileDescription;
|
||||
|
||||
constructor(
|
||||
private configResult: ConfigResult<ClientConfigYaml>,
|
||||
private configResult: ConfigResult<ConfigYaml>,
|
||||
private readonly ownerSlug: string,
|
||||
private readonly packageSlug: string,
|
||||
private readonly controlPlaneClient: ControlPlaneClient,
|
||||
|
|
@ -49,8 +51,18 @@ export default class PlatformProfileLoader implements IProfileLoader {
|
|||
if (!newConfigResult) {
|
||||
return;
|
||||
}
|
||||
|
||||
let renderedConfig: ConfigYaml | undefined = undefined;
|
||||
if (newConfigResult.config) {
|
||||
renderedConfig = await clientRenderHelper(
|
||||
YAML.stringify(newConfigResult.config),
|
||||
this.ide,
|
||||
this.controlPlaneClient,
|
||||
);
|
||||
}
|
||||
|
||||
this.configResult = {
|
||||
config: newConfigResult.config,
|
||||
config: renderedConfig,
|
||||
errors: newConfigResult.errors,
|
||||
configLoadInterrupted: false,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
import fs from "fs";
|
||||
|
||||
import { ConfigResult, ConfigValidationError } from "@continuedev/config-yaml";
|
||||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas";
|
||||
import {
|
||||
ConfigResult,
|
||||
ConfigValidationError,
|
||||
ConfigYaml,
|
||||
} from "@continuedev/config-yaml";
|
||||
import {
|
||||
ContinueConfig,
|
||||
ContinueRcJson,
|
||||
|
|
@ -27,7 +30,7 @@ export default async function doLoadConfig(
|
|||
controlPlaneClient: ControlPlaneClient,
|
||||
writeLog: (message: string) => Promise<void>,
|
||||
overrideConfigJson: SerializedContinueConfig | undefined,
|
||||
overrideConfigYaml: ClientConfigYaml | undefined,
|
||||
overrideConfigYaml: ConfigYaml | undefined,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
workspaceId?: string,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
|
|
|
|||
35
core/config/yaml/clientRender.ts
Normal file
35
core/config/yaml/clientRender.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import {
|
||||
clientRender,
|
||||
PlatformClient,
|
||||
SecretStore,
|
||||
} from "@continuedev/config-yaml";
|
||||
|
||||
import { IDE } from "../..";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
|
||||
export function clientRenderHelper(
|
||||
unrolledAssistant: string,
|
||||
ide: IDE,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
) {
|
||||
const ideSecretStore: SecretStore = {
|
||||
get: async function (secretName: string): Promise<string | undefined> {
|
||||
const results = await ide.readSecrets([secretName]);
|
||||
return results[secretName];
|
||||
},
|
||||
set: async function (
|
||||
secretName: string,
|
||||
secretValue: string,
|
||||
): Promise<void> {
|
||||
return await ide.writeSecrets({
|
||||
[secretName]: secretValue,
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
const platformClient: PlatformClient = {
|
||||
resolveFQSNs: controlPlaneClient.resolveFQSNs,
|
||||
};
|
||||
|
||||
return clientRender(unrolledAssistant, ideSecretStore, platformClient);
|
||||
}
|
||||
|
|
@ -2,13 +2,10 @@ import fs from "node:fs";
|
|||
|
||||
import {
|
||||
ConfigResult,
|
||||
fillTemplateVariables,
|
||||
resolveSecretsOnClient,
|
||||
ConfigYaml,
|
||||
validateConfigYaml,
|
||||
} from "@continuedev/config-yaml";
|
||||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas";
|
||||
import { fetchwithRequestOptions } from "@continuedev/fetch";
|
||||
import * as YAML from "yaml";
|
||||
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
|
|
@ -21,44 +18,33 @@ import {
|
|||
} from "../..";
|
||||
import { AllRerankers } from "../../context/allRerankers";
|
||||
import { MCPManagerSingleton } from "../../context/mcp";
|
||||
import CodebaseContextProvider from "../../context/providers/CodebaseContextProvider";
|
||||
import FileContextProvider from "../../context/providers/FileContextProvider";
|
||||
import { contextProviderClassFromName } from "../../context/providers/index";
|
||||
import PromptFilesContextProvider from "../../context/providers/PromptFilesContextProvider";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
import { allEmbeddingsProviders } from "../../indexing/allEmbeddingsProviders";
|
||||
import FreeTrial from "../../llm/llms/FreeTrial";
|
||||
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
|
||||
import { slashCommandFromPromptFileV1 } from "../../promptFiles/v1/slashCommandFromPromptFile";
|
||||
import { getAllPromptFiles } from "../../promptFiles/v2/getPromptFiles";
|
||||
import { getConfigYamlPath, getContinueDotEnv } from "../../util/paths";
|
||||
import { getConfigYamlPath } from "../../util/paths";
|
||||
import { getSystemPromptDotFile } from "../getSystemPromptDotFile";
|
||||
import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader";
|
||||
|
||||
import CodebaseContextProvider from "../../context/providers/CodebaseContextProvider";
|
||||
import FileContextProvider from "../../context/providers/FileContextProvider";
|
||||
import PromptFilesContextProvider from "../../context/providers/PromptFilesContextProvider";
|
||||
import { ControlPlaneClient } from "../../control-plane/client";
|
||||
import { clientRenderHelper } from "./clientRender";
|
||||
import { llmsFromModelConfig } from "./models";
|
||||
|
||||
function renderTemplateVars(configYaml: string): string {
|
||||
const data: Record<string, string> = {};
|
||||
|
||||
// env.*
|
||||
const envVars = getContinueDotEnv();
|
||||
Object.entries(envVars).forEach(([key, value]) => {
|
||||
data[`env.${key}`] = value;
|
||||
});
|
||||
|
||||
// secrets.* not filled in
|
||||
|
||||
return fillTemplateVariables(configYaml, data);
|
||||
}
|
||||
|
||||
function loadConfigYaml(
|
||||
async function loadConfigYaml(
|
||||
workspaceConfigs: string[],
|
||||
rawYaml: string,
|
||||
overrideConfigYaml: ClientConfigYaml | undefined,
|
||||
): ConfigResult<ClientConfigYaml> {
|
||||
overrideConfigYaml: ConfigYaml | undefined,
|
||||
ide: IDE,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
): Promise<ConfigResult<ConfigYaml>> {
|
||||
let config =
|
||||
overrideConfigYaml ??
|
||||
(YAML.parse(renderTemplateVars(rawYaml)) as ClientConfigYaml);
|
||||
(await clientRenderHelper(rawYaml, ide, controlPlaneClient));
|
||||
const errors = validateConfigYaml(config);
|
||||
|
||||
if (errors?.some((error) => error.fatal)) {
|
||||
|
|
@ -98,7 +84,7 @@ async function slashCommandsFromV1PromptFiles(
|
|||
}
|
||||
|
||||
async function configYamlToContinueConfig(
|
||||
config: ClientConfigYaml,
|
||||
config: ConfigYaml,
|
||||
ide: IDE,
|
||||
ideSettings: IdeSettings,
|
||||
uniqueId: string,
|
||||
|
|
@ -304,7 +290,7 @@ export async function loadContinueConfigFromYaml(
|
|||
uniqueId: string,
|
||||
writeLog: (log: string) => Promise<void>,
|
||||
workOsAccessToken: string | undefined,
|
||||
overrideConfigYaml: ClientConfigYaml | undefined,
|
||||
overrideConfigYaml: ConfigYaml | undefined,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
controlPlaneClient: ControlPlaneClient,
|
||||
): Promise<ConfigResult<ContinueConfig>> {
|
||||
|
|
@ -314,10 +300,12 @@ export async function loadContinueConfigFromYaml(
|
|||
? fs.readFileSync(configYamlPath, "utf-8")
|
||||
: "";
|
||||
|
||||
const configYamlResult = loadConfigYaml(
|
||||
const configYamlResult = await loadConfigYaml(
|
||||
workspaceConfigs,
|
||||
rawYaml,
|
||||
overrideConfigYaml,
|
||||
ide,
|
||||
controlPlaneClient,
|
||||
);
|
||||
|
||||
if (!configYamlResult.config || configYamlResult.configLoadInterrupted) {
|
||||
|
|
@ -328,18 +316,8 @@ export async function loadContinueConfigFromYaml(
|
|||
};
|
||||
}
|
||||
|
||||
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,
|
||||
configYamlResult.config,
|
||||
ide,
|
||||
ideSettings,
|
||||
uniqueId,
|
||||
|
|
|
|||
|
|
@ -3,25 +3,13 @@ import { ModelConfig } from "@continuedev/config-yaml";
|
|||
import { IDE, IdeSettings, LLMOptions } from "../..";
|
||||
import { BaseLLM } from "../../llm";
|
||||
import { LLMClasses } from "../../llm/llms";
|
||||
import ContinueProxy from "../../llm/llms/stubs/ContinueProxy";
|
||||
import { PlatformConfigMetadata } from "../profile/PlatformProfileLoader";
|
||||
|
||||
const AUTODETECT = "AUTODETECT";
|
||||
|
||||
function useContinueProxy(
|
||||
model: ModelConfig,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
): boolean {
|
||||
return !!platformConfigMetadata && model.apiKeySecret !== undefined;
|
||||
}
|
||||
|
||||
function getModelClass(
|
||||
model: ModelConfig,
|
||||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
): (typeof LLMClasses)[number] | undefined {
|
||||
if (useContinueProxy(model, platformConfigMetadata)) {
|
||||
return ContinueProxy;
|
||||
}
|
||||
return LLMClasses.find((llm) => llm.providerName === model.provider);
|
||||
}
|
||||
|
||||
|
|
@ -41,13 +29,13 @@ async function modelConfigToBaseLLM(
|
|||
platformConfigMetadata: PlatformConfigMetadata | undefined,
|
||||
systemMessage: string | undefined,
|
||||
): Promise<BaseLLM | undefined> {
|
||||
const cls = getModelClass(model, platformConfigMetadata);
|
||||
const cls = getModelClass(model);
|
||||
|
||||
if (!cls) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const usingContinueProxy = useContinueProxy(model, platformConfigMetadata);
|
||||
const usingContinueProxy = model.provider === "continue-proxy";
|
||||
const modelName = usingContinueProxy
|
||||
? getContinueProxyModelName(
|
||||
platformConfigMetadata!.ownerSlug,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { ConfigJson } from "@continuedev/config-types";
|
||||
import { ClientConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js";
|
||||
import { ConfigYaml } from "@continuedev/config-yaml/dist/schemas/index.js";
|
||||
import fetch, { RequestInit, Response } from "node-fetch";
|
||||
|
||||
import { ModelDescription } from "../index.js";
|
||||
|
||||
import { ConfigResult } from "@continuedev/config-yaml";
|
||||
import { ConfigResult, FQSN, SecretResult } from "@continuedev/config-yaml";
|
||||
import { controlPlaneEnv } from "./env.js";
|
||||
|
||||
export interface ControlPlaneSessionInfo {
|
||||
|
|
@ -38,6 +38,19 @@ export class ControlPlaneClient {
|
|||
>,
|
||||
) {}
|
||||
|
||||
async resolveFQSNs(fqsns: FQSN[]): Promise<(SecretResult | undefined)[]> {
|
||||
const userId = await this.userId;
|
||||
if (!userId) {
|
||||
throw new Error("No user id");
|
||||
}
|
||||
|
||||
const resp = await this.request("ide/sync-secrets", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ fqsns }),
|
||||
});
|
||||
return (await resp.json()) as any;
|
||||
}
|
||||
|
||||
get userId(): Promise<string | undefined> {
|
||||
return this.sessionInfoPromise.then(
|
||||
(sessionInfo) => sessionInfo?.account.id,
|
||||
|
|
@ -89,7 +102,7 @@ export class ControlPlaneClient {
|
|||
|
||||
public async listAssistants(): Promise<
|
||||
{
|
||||
configResult: ConfigResult<ClientConfigYaml>;
|
||||
configResult: ConfigResult<ConfigYaml>;
|
||||
ownerSlug: string;
|
||||
packageSlug: string;
|
||||
iconUrl: string;
|
||||
|
|
|
|||
8
core/package-lock.json
generated
8
core/package-lock.json
generated
|
|
@ -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.11",
|
||||
"@continuedev/config-yaml": "^1.0.13",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
@ -3038,9 +3038,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-yaml": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.11.tgz",
|
||||
"integrity": "sha512-E3RBQfNEPBGBmlnAbCXgeAasDzTjo4ON/HH0hr5g292i+WdAN3i/omjQ6Iusx00L1Fz7klZGJePZ3GVQKOGEUg==",
|
||||
"version": "1.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.13.tgz",
|
||||
"integrity": "sha512-mBet+NPqQHDvIx+CKLaR3dCSlvhrVaJSZ9DAMuZ2bqTNLUGN6I7GikJi0CmhiiD8qU2dlrfNfdkLDfnoCwpaOA==",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
|
|
|
|||
|
|
@ -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.11",
|
||||
"@continuedev/config-yaml": "^1.0.13",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
2
extensions/vscode/package-lock.json
generated
2
extensions/vscode/package-lock.json
generated
|
|
@ -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.11",
|
||||
"@continuedev/config-yaml": "^1.0.13",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
|
|||
16
gui/package-lock.json
generated
16
gui/package-lock.json
generated
|
|
@ -7,7 +7,7 @@
|
|||
"name": "gui",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@continuedev/config-yaml": "^1.0.13",
|
||||
"@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.11",
|
||||
"@continuedev/config-yaml": "^1.0.13",
|
||||
"@continuedev/fetch": "^1.0.4",
|
||||
"@continuedev/llm-info": "^1.0.2",
|
||||
"@continuedev/openai-adapters": "^1.0.10",
|
||||
|
|
@ -556,9 +556,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@continuedev/config-yaml": {
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.11.tgz",
|
||||
"integrity": "sha512-E3RBQfNEPBGBmlnAbCXgeAasDzTjo4ON/HH0hr5g292i+WdAN3i/omjQ6Iusx00L1Fz7klZGJePZ3GVQKOGEUg==",
|
||||
"version": "1.0.13",
|
||||
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.13.tgz",
|
||||
"integrity": "sha512-mBet+NPqQHDvIx+CKLaR3dCSlvhrVaJSZ9DAMuZ2bqTNLUGN6I7GikJi0CmhiiD8qU2dlrfNfdkLDfnoCwpaOA==",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
"yaml": "^2.6.1",
|
||||
|
|
@ -13748,9 +13748,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/zod": {
|
||||
"version": "3.23.8",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.23.8.tgz",
|
||||
"integrity": "sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==",
|
||||
"version": "3.24.1",
|
||||
"resolved": "https://registry.npmjs.org/zod/-/zod-3.24.1.tgz",
|
||||
"integrity": "sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/colinhacks"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
"test:watch": "vitest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@continuedev/config-yaml": "^1.0.11",
|
||||
"@continuedev/config-yaml": "^1.0.13",
|
||||
"@headlessui/react": "^1.7.17",
|
||||
"@heroicons/react": "^2.0.18",
|
||||
"@reduxjs/toolkit": "^2.3.0",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue