fix: expose dynamic provider profiles in backends list

This commit is contained in:
Codex
2026-06-09 00:28:32 +08:00
parent 56761b8e5f
commit c685b749e4
6 changed files with 65 additions and 20 deletions
+19 -2
View File
@@ -70,6 +70,17 @@ export const backendProfileSpecs = builtinBackendProfileSpecs;
export const backendProfiles = builtinBackendProfileSpecs.map((item) => item.profile) as readonly BackendProfile[];
export function compareBackendProfiles(left: string, right: string): number {
const leftIndex = builtinBackendProfileSpecs.findIndex((item) => item.profile === left);
const rightIndex = builtinBackendProfileSpecs.findIndex((item) => item.profile === right);
if (leftIndex >= 0 || rightIndex >= 0) {
if (leftIndex < 0) return 1;
if (rightIndex < 0) return -1;
if (leftIndex !== rightIndex) return leftIndex - rightIndex;
}
return left.localeCompare(right);
}
export function defaultSecretNameForProfile(profile: string): string {
return `agentrun-v01-provider-${profile}`;
}
@@ -138,8 +149,14 @@ export function mergeBackendCapability(profile: string, storedCapabilities: Json
};
}
export function backendCapabilities(): JsonRecord[] {
return builtinBackendProfileSpecs.map(backendCapability);
export function backendCapabilities(profiles: readonly string[] = backendProfiles): JsonRecord[] {
const profileIds = new Set<BackendProfile>(backendProfiles);
for (const profile of profiles) {
if (isBackendProfileSlug(profile)) profileIds.add(profile as BackendProfile);
}
return [...profileIds]
.sort(compareBackendProfiles)
.map((profile) => backendCapability(backendProfileSpec(profile) as BackendProfileSpec));
}
export function backendCapabilitiesSqlValues(profiles?: readonly BackendProfile[], options: { requiredSecretKeysByProfile?: Record<string, readonly string[]> } = {}): string {