Elffuss BraidHub

kikocis/continue public

proxy missing env secrets
Changesetc1fda47286faa64e2de04dc0d8ec36351f1389cb115ffe8cdc84ebde0519260d
AuthorDallin Romney <dallinromney@gmail.com> · 2025-07-07 19:26 -07:00
CommitterDallin Romney <dallinromney@gmail.com> · 2025-07-07 19:26 -07:00
Parentsec79a4d62a4e

Browse the files at this changeset

9 files changed

modified core/config/load.ts +1 −0
@@ -650,6 +650,7 @@
650650 roles: llm.roles,
651651 configurationStatus: llm.getConfigurationStatus(),
652652 apiKeyLocation: llm.apiKeyLocation,
653+ envSecretLocations: llm.envSecretLocations,
653654 };
654655 }
655656
modified core/index.d.ts +2 −0
@@ -583,6 +583,7 @@
583583
584584 // continueProperties
585585 apiKeyLocation?: string;
586+ envSecretLocations?: Record<string, string>;
586587 apiBase?: string;
587588 orgScopeId?: string | null;
588589
@@ -1084,6 +1085,7 @@
10841085
10851086 apiBase?: string;
10861087 apiKeyLocation?: string;
1088+ envSecretLocations?: Record<string, string>;
10871089 orgScopeId?: string | null;
10881090
10891091 onPremProxyUrl?: string | null;
modified core/llm/constants.ts +1 −0
@@ -15,6 +15,7 @@
1515 export enum LLMConfigurationStatuses {
1616 VALID = "valid",
1717 MISSING_API_KEY = "missing-api-key",
18+ MISSING_ENV_SECRET = "missing-env-secret",
1819 }
1920
2021 export {
modified core/llm/index.ts +2 −0
@@ -155,6 +155,7 @@
155155
156156 // continueProperties
157157 apiKeyLocation?: string;
158+ envSecretLocations?: Record<string, string>;
158159 apiBase?: string;
159160 orgScopeId?: string | null;
160161
@@ -248,6 +249,7 @@
248249
249250 // continueProperties
250251 this.apiKeyLocation = options.apiKeyLocation;
252+ this.envSecretLocations = options.envSecretLocations;
251253 this.orgScopeId = options.orgScopeId;
252254 this.apiBase = options.apiBase;
253255
modified core/llm/llms/stubs/ContinueProxy.ts +17 −4
@@ -40,6 +40,7 @@
4040 this.apiType = undefined;
4141 this.actualApiBase = options.apiBase;
4242 this.apiKeyLocation = options.apiKeyLocation;
43+ this.envSecretLocations = options.envSecretLocations;
4344 this.orgScopeId = options.orgScopeId;
4445 this.onPremProxyUrl = options.onPremProxyUrl;
4546 if (this.onPremProxyUrl) {
@@ -60,6 +61,7 @@
6061 protected extraBodyProperties(): Record<string, any> {
6162 const continueProperties: ContinueProperties = {
6263 apiKeyLocation: this.apiKeyLocation,
64+ envSecretLocations: this.envSecretLocations,
6365 apiBase: this.actualApiBase,
6466 orgScopeId: this.orgScopeId ?? null,
6567 env: this.configEnv,
@@ -70,13 +72,24 @@
7072 }
7173
7274 getConfigurationStatus() {
73- if (!this.apiKeyLocation) {
75+ if (!this.apiKeyLocation && !this.envSecretLocations) {
7476 return LLMConfigurationStatuses.VALID;
7577 }
7678
77- const secretLocation = decodeSecretLocation(this.apiKeyLocation);
78- if (secretLocation.secretType === SecretType.NotFound) {
79- return LLMConfigurationStatuses.MISSING_API_KEY;
79+ if (this.apiKeyLocation) {
80+ const secretLocation = decodeSecretLocation(this.apiKeyLocation);
81+ if (secretLocation.secretType === SecretType.NotFound) {
82+ return LLMConfigurationStatuses.MISSING_API_KEY;
83+ }
84+ }
85+
86+ if (this.envSecretLocations) {
87+ for (const secretLocation of Object.values(this.envSecretLocations)) {
88+ const decoded = decodeSecretLocation(secretLocation);
89+ if (decoded.secretType === SecretType.NotFound) {
90+ return LLMConfigurationStatuses.MISSING_ENV_SECRET;
91+ }
92+ }
8093 }
8194
8295 return LLMConfigurationStatuses.VALID;
modified gui/src/pages/config/ModelRoleSelector.tsx +19 −6
@@ -119,19 +119,32 @@
119119 {[...models]
120120 .sort((a, b) => a.title.localeCompare(b.title))
121121 .map((option, idx) => {
122- const showMissingApiKeyMsg =
122+ const isConfigInvalid =
123+ option.configurationStatus !==
124+ LLMConfigurationStatuses.VALID;
125+ let invalidMessage = "(Invalid config)";
126+ if (
123127 option.configurationStatus ===
124- LLMConfigurationStatuses.MISSING_API_KEY;
128+ LLMConfigurationStatuses.MISSING_ENV_SECRET
129+ ) {
130+ invalidMessage = "(Missing env secret)";
131+ }
132+ if (
133+ option.configurationStatus ===
134+ LLMConfigurationStatuses.MISSING_API_KEY
135+ ) {
136+ invalidMessage = "(Missing API Key)";
137+ }
125138
126139 return (
127140 <ListboxOption
128141 key={idx}
129142 value={option.title}
130- disabled={showMissingApiKeyMsg}
143+ disabled={isConfigInvalid}
131144 onMouseEnter={() => setHoveredIdx(idx)}
132145 onMouseLeave={() => setHoveredIdx(null)}
133146 onClick={(e: any) =>
134- handleOptionClick(showMissingApiKeyMsg, e)
147+ handleOptionClick(isConfigInvalid, e)
135148 }
136149 className=""
137150 >
@@ -144,9 +157,9 @@
144157 style={{ fontSize: fontSize(-3) }}
145158 >
146159 {option.title}
147- {showMissingApiKeyMsg && (
160+ {isConfigInvalid && (
148161 <span className="ml-2 text-[10px] italic">
149- (Missing API key)
162+ {invalidMessage}
150163 </span>
151164 )}
152165 </span>
modified packages/config-yaml/src/load/clientRender.ts +24 −2
@@ -133,7 +133,27 @@
133133 const apiKeyLocation = getUnrenderedSecretLocation(
134134 config.models[i]?.apiKey,
135135 );
136- if (apiKeyLocation) {
136+ const encodedApiKeyLocation = apiKeyLocation
137+ ? encodeSecretLocation(apiKeyLocation)
138+ : undefined;
139+
140+ let encodedEnvSecretLocations: Record<string, string> | undefined =
141+ undefined;
142+ if (config.models[i]?.env) {
143+ Object.entries(config.models[i]?.env!).forEach(([key, value]) => {
144+ if (typeof value === "string") {
145+ const secretLocation = getUnrenderedSecretLocation(value);
146+ if (secretLocation) {
147+ encodedEnvSecretLocations = {
148+ ...encodedEnvSecretLocations,
149+ [key]: encodeSecretLocation(secretLocation),
150+ };
151+ }
152+ }
153+ });
154+ }
155+
156+ if (encodedApiKeyLocation || encodedEnvSecretLocations) {
137157 config.models[i] = {
138158 ...config.models[i],
139159 name: config.models[i]?.name ?? "",
@@ -143,7 +163,8 @@
143163 config.models[i]?.provider ?? "",
144164 config.models[i]?.model ?? "",
145165 ),
146- apiKeyLocation: encodeSecretLocation(apiKeyLocation),
166+ apiKeyLocation: encodedApiKeyLocation,
167+ envSecretLocations: encodedEnvSecretLocations,
147168 orgScopeId,
148169 onPremProxyUrl,
149170 apiKey: undefined,
@@ -158,6 +179,7 @@
158179 /** The additional properties that are added to the otherwise OpenAI-compatible body when requesting a Continue proxy */
159180 export const continuePropertiesSchema = z.object({
160181 apiKeyLocation: z.string().optional(),
182+ envSecretLocations: z.record(z.string(), z.string()).optional(),
161183 apiBase: z.string().optional(),
162184 orgScopeId: z.string().nullable(),
163185 env: z.record(z.string(), z.any()).optional(),
modified packages/config-yaml/src/schemas/models.ts +4 −2
@@ -154,7 +154,8 @@
154154 z.object({
155155 ...baseModelFields,
156156 provider: z.literal("continue-proxy"),
157- apiKeyLocation: z.string(),
157+ apiKeyLocation: z.string().optional(),
158+ envSecretLocations: z.record(z.string(), z.string()).optional(),
158159 orgScopeId: z.string().nullable(),
159160 onPremProxyUrl: z.string().nullable(),
160161 }),
@@ -169,7 +170,8 @@
169170 .object({
170171 ...baseModelFields,
171172 provider: z.literal("continue-proxy"),
172- apiKeyLocation: z.string(),
173+ apiKeyLocation: z.string().optional(),
174+ envSecretLocations: z.record(z.string(), z.string()).optional(),
173175 })
174176 .partial(),
175177 z
modified packages/continue-sdk/typescript/src/createOpenAIClient.ts +1 −0
@@ -79,6 +79,7 @@
7979
8080 const continueProperties: ContinueProperties = {
8181 apiKeyLocation: modelConfig.apiKeyLocation,
82+ envSecretLocations: modelConfig.envSecretLocations,
8283 orgScopeId: organizationId ?? null,
8384 };
8485