fix: expose dynamic provider profiles in backends list
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { createHash, randomUUID } from "node:crypto";
|
||||
import { spawn } from "node:child_process";
|
||||
import { AgentRunError } from "../common/errors.js";
|
||||
import { backendProfileSpec, backendProfileSpecs, isBackendProfileSlug } from "../common/backend-profiles.js";
|
||||
import { backendCapabilities, backendProfileSpec, backendProfileSpecs, compareBackendProfiles, isBackendProfileSlug } from "../common/backend-profiles.js";
|
||||
import { dsflashGoModelCatalogFile, dsflashGoModelCatalogJson, dsflashGoModelSlug, dsflashGoRuntimeModelCatalogPath } from "../common/model-catalogs.js";
|
||||
import type { AgentRunStore } from "./store.js";
|
||||
import type { BackendProfile, ExecutionPolicy, JsonRecord, JsonValue } from "../common/types.js";
|
||||
@@ -48,6 +48,33 @@ export async function listProviderProfiles(options: ProviderProfileOptions = {})
|
||||
return { items, count: items.length, valuesPrinted: false };
|
||||
}
|
||||
|
||||
export async function listBackendCapabilities(options: ProviderProfileOptions = {}): Promise<JsonRecord> {
|
||||
const profiles = new Set<BackendProfile>(backendProfileSpecs.map((spec) => spec.profile));
|
||||
try {
|
||||
for (const profile of await listProviderProfileIds(options)) profiles.add(profile);
|
||||
const dynamicProfiles = [...profiles].filter((profile) => !isBuiltinProviderProfile(profile)).sort(compareBackendProfiles);
|
||||
return {
|
||||
items: backendCapabilities([...profiles]),
|
||||
dynamicProfileDiscovery: {
|
||||
status: "succeeded",
|
||||
dynamicProfiles,
|
||||
dynamicProfileCount: dynamicProfiles.length,
|
||||
valuesPrinted: false,
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
return {
|
||||
items: backendCapabilities([...profiles]),
|
||||
dynamicProfileDiscovery: {
|
||||
status: "failed",
|
||||
failureKind: error instanceof AgentRunError ? error.failureKind : "infra-failed",
|
||||
message: redactText(error instanceof Error ? error.message : String(error)),
|
||||
valuesPrinted: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function showProviderProfile(profile: string, options: ProviderProfileOptions = {}): Promise<JsonRecord> {
|
||||
return providerProfileStatus(validateBackendProfile(profile), options);
|
||||
}
|
||||
@@ -328,14 +355,7 @@ async function listProviderProfileIds(options: ProviderProfileOptions): Promise<
|
||||
}
|
||||
|
||||
function compareProviderProfiles(left: string, right: string): number {
|
||||
const leftIndex = backendProfileSpecs.findIndex((item) => item.profile === left);
|
||||
const rightIndex = backendProfileSpecs.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);
|
||||
return compareBackendProfiles(left, right);
|
||||
}
|
||||
|
||||
function isBuiltinProviderProfile(profile: BackendProfile): boolean {
|
||||
|
||||
Reference in New Issue
Block a user