clean up config loading bugs

This commit is contained in:
Nate 2025-01-19 18:27:49 -08:00
parent 2d865425ce
commit cbdc79e601
9 changed files with 61 additions and 32 deletions

View file

@ -14,9 +14,11 @@ 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 { ConfigResult, ConfigYaml } from "@continuedev/config-yaml";
import * as YAML from "yaml";
import { controlPlaneEnv } from "../control-plane/env.js";
import { usePlatform } from "../control-plane/flags.js";
import { localPathToUri } from "../util/pathToUri.js";
import {
LOCAL_ONBOARDING_CHAT_MODEL,
ONBOARDING_LOCAL_MODEL_TITLE,
@ -28,7 +30,7 @@ import {
ProfileDescription,
ProfileLifecycleManager,
} from "./ProfileLifecycleManager.js";
import { localPathToUri } from "../util/pathToUri.js";
import { clientRenderHelper } from "./yaml/clientRender.js";
export type { ProfileDescription };
@ -109,19 +111,30 @@ export class ConfigHandler {
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));
});
await Promise.all(
assistants.map(async (assistant) => {
let renderedConfig: ConfigYaml | undefined = undefined;
if (assistant.configResult.config) {
renderedConfig = await clientRenderHelper(
YAML.stringify(assistant.configResult.config),
this.ide,
this.controlPlaneClient,
);
}
const profileLoader = new PlatformProfileLoader(
{ ...assistant.configResult, config: renderedConfig },
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),

View file

@ -28,7 +28,7 @@ export function clientRenderHelper(
};
const platformClient: PlatformClient = {
resolveFQSNs: controlPlaneClient.resolveFQSNs,
resolveFQSNs: controlPlaneClient.resolveFQSNs.bind(controlPlaneClient),
};
return clientRender(unrolledAssistant, ideSecretStore, platformClient);

View file

@ -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.13",
"@continuedev/config-yaml": "^1.0.15",
"@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.13",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.13.tgz",
"integrity": "sha512-mBet+NPqQHDvIx+CKLaR3dCSlvhrVaJSZ9DAMuZ2bqTNLUGN6I7GikJi0CmhiiD8qU2dlrfNfdkLDfnoCwpaOA==",
"version": "1.0.15",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.15.tgz",
"integrity": "sha512-00c1pz+FqAVEWLo8t71OJzm1KBAAJCXqIjd917Vy8lr7xO0Eoj42lo2GFlVRnqQ0hQvhFQ0s9onHhRag/phHZA==",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",

View file

@ -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.13",
"@continuedev/config-yaml": "^1.0.15",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.2",
"@continuedev/openai-adapters": "^1.0.10",

View file

@ -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.13",
"@continuedev/config-yaml": "^1.0.15",
"@continuedev/fetch": "^1.0.4",
"@continuedev/llm-info": "^1.0.2",
"@continuedev/openai-adapters": "^1.0.10",

10
gui/package-lock.json generated
View file

@ -7,7 +7,7 @@
"name": "gui",
"license": "Apache-2.0",
"dependencies": {
"@continuedev/config-yaml": "^1.0.13",
"@continuedev/config-yaml": "^1.0.15",
"@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.13",
"@continuedev/config-yaml": "^1.0.15",
"@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.13",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.13.tgz",
"integrity": "sha512-mBet+NPqQHDvIx+CKLaR3dCSlvhrVaJSZ9DAMuZ2bqTNLUGN6I7GikJi0CmhiiD8qU2dlrfNfdkLDfnoCwpaOA==",
"version": "1.0.15",
"resolved": "https://registry.npmjs.org/@continuedev/config-yaml/-/config-yaml-1.0.15.tgz",
"integrity": "sha512-00c1pz+FqAVEWLo8t71OJzm1KBAAJCXqIjd917Vy8lr7xO0Eoj42lo2GFlVRnqQ0hQvhFQ0s9onHhRag/phHZA==",
"dependencies": {
"@continuedev/config-types": "^1.0.14",
"yaml": "^2.6.1",

View file

@ -15,7 +15,7 @@
"test:watch": "vitest"
},
"dependencies": {
"@continuedev/config-yaml": "^1.0.13",
"@continuedev/config-yaml": "^1.0.15",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@reduxjs/toolkit": "^2.3.0",

View file

@ -1,6 +1,6 @@
{
"name": "@continuedev/config-yaml",
"version": "1.0.13",
"version": "1.0.15",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",

View file

@ -39,7 +39,17 @@ export async function clientRender(
// 4. (back to the client) Any “user” secrets that were returned back are added to the local secret store so we don’t have to request them again
for (const secretResult of secretResults) {
if (!secretResult?.found) continue;
if (!secretResult) {
continue;
}
if (!secretResult.found) {
// When a secret isn't found anywhere, we keep it templated as just the secret name
// in case it can be found in the on-prem proxy's env
secretsTemplateData["secrets." + encodeFQSN(secretResult.fqsn)] =
`\${{ secrets.${secretResult.fqsn.secretName} }}`;
continue;
}
if ("value" in secretResult) {
secretStore.set(secretResult.fqsn.secretName, secretResult.value);
@ -73,8 +83,14 @@ function getUnrenderedSecretLocation(
const templateVars = getTemplateVariables(value);
if (templateVars.length === 1) {
const secretLocationEncoded = templateVars[0].split("secrets.")[1];
const secretLocation = decodeSecretLocation(secretLocationEncoded);
return secretLocation;
try {
const secretLocation = decodeSecretLocation(secretLocationEncoded);
return secretLocation;
} catch (e) {
// If it's templated but not a valid secret location, leave it be
// in case on-prem proxy has the secret in an env variable
return undefined;
}
}
return undefined;