openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
57 lines (56 loc) • 3.56 kB
JavaScript
import { r as normalizeProviderId } from "./provider-id-DMd-TDFp.js";
import { f as prepareAmbientAgentCredentialsForDiscovery, h as resolveUsableAgentCredentialModes } from "./prepared-model-runtime.plugin-generation-t_16307i.js";
import { i as prepareFullCatalogFacts, r as materializePreparedModelCatalog } from "./prepared-model-runtime.full-catalog-CFj7JJlS.js";
import { r as prepareImplicitProviderStaticCatalog } from "./models-config-FHEukKjA.js";
import { i as prepareWorkspaceBuildGroup, n as prepareAgentCatalogSource, o as listPreparedSyntheticAuthProviderRefs, s as prepareSyntheticAuth } from "./prepared-model-runtime.facts-vxXJKbiM.js";
//#region src/agents/prepared-model-runtime.scoped-catalog.ts
async function prepareScopedReadOnlyModelCatalogWithMode(input, providerDiscoveryProviderIds, catalogMode) {
const scopedInput = input.readOnly ? input : {
...input,
readOnly: true
};
const { agentFacts, pluginGeneration } = await prepareWorkspaceBuildGroup([scopedInput], catalogMode, { providerDiscoveryProviderIds });
const agentFactsForInput = agentFacts[0];
if (!agentFactsForInput) throw new Error("scoped prepared model catalog facts are missing");
const catalogSource = await prepareAgentCatalogSource(agentFactsForInput, pluginGeneration, catalogMode, false, catalogMode === "live" ? { providerDiscoveryProviderIds } : {});
const { modelCatalog } = await prepareFullCatalogFacts(agentFactsForInput, pluginGeneration, catalogMode, catalogSource);
return materializePreparedModelCatalog(modelCatalog, agentFactsForInput.runtimeCapabilityModels);
}
/** Resolves provider-scoped, secret-free auth modes without live model discovery. */
async function prepareScopedReadOnlyModelAuthModes(input, providerDiscoveryProviderIds, pluginMetadataSnapshot) {
const providerIds = [...new Set(providerDiscoveryProviderIds.map(normalizeProviderId).filter(Boolean))];
const providers = (await prepareImplicitProviderStaticCatalog({
config: input.config,
env: input.env,
pluginMetadataSnapshot,
providerDiscoveryProviderIds: providerIds,
staticCatalogProviderIds: providerIds,
...input.workspaceDir ? { workspaceDir: input.workspaceDir } : {}
})).providers ?? [];
const credentials = await prepareAmbientAgentCredentialsForDiscovery({
config: input.config,
env: input.env,
authoritativeSyntheticAuthProviderRefs: pluginMetadataSnapshot.owners.cliBackends.keys(),
syntheticAuthProviderRefs: listPreparedSyntheticAuthProviderRefs(providers),
resolveSyntheticAuth: (provider) => prepareSyntheticAuth({
...input,
provider,
providers
}),
...input.workspaceDir ? { workspaceDir: input.workspaceDir } : {}
});
const modes = resolveUsableAgentCredentialModes(credentials);
const scoped = {};
for (const provider of providerIds) if (modes[provider]) scoped[provider] = modes[provider];
return scoped;
}
/** Builds a request-scoped read-only catalog without executing live provider discovery. */
function prepareScopedReadOnlyModelCatalog(input, providerDiscoveryProviderIds) {
return prepareScopedReadOnlyModelCatalogWithMode(input, providerDiscoveryProviderIds, "static");
}
/** Builds a request-scoped read-only catalog with live discovery for selected providers. */
function prepareScopedReadOnlyLiveModelCatalog(input, providerDiscoveryProviderIds) {
return prepareScopedReadOnlyModelCatalogWithMode(input, providerDiscoveryProviderIds, "live");
}
//#endregion
export { prepareScopedReadOnlyModelAuthModes as n, prepareScopedReadOnlyModelCatalog as r, prepareScopedReadOnlyLiveModelCatalog as t };