fix: expose dynamic provider profiles in backends list
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user