@@ -12,6 +12,7 @@ import {
1212 resolveCliExecutionAuthProfileId ,
1313} from "../agents/cli-execution-auth.js" ;
1414import type { OpenClawConfig } from "../config/types.openclaw.js" ;
15+ import type { PluginMetadataSnapshot } from "../plugins/plugin-metadata-snapshot.types.js" ;
1516import { normalizeAgentId } from "../routing/session-key.js" ;
1617
1718export type SystemAgentConfiguredRoute = {
@@ -46,7 +47,12 @@ export function resolveSystemAgentTargetAgentId(
4647export type SystemAgentConfiguredRouteDeps = {
4748 readConfigFileSnapshot ?: typeof import ( "../config/config.js" ) . readConfigFileSnapshot ;
4849 loadAuthProfileStoreForRuntime ?: typeof import ( "../agents/auth-profiles/store.js" ) . loadAuthProfileStoreForRuntime ;
50+ pluginMetadataPlugins ?: PluginMetadataSnapshot [ "plugins" ] ;
4951} ;
52+ type SystemAgentRouteProjectionDeps = Pick <
53+ SystemAgentConfiguredRouteDeps ,
54+ "loadAuthProfileStoreForRuntime" | "pluginMetadataPlugins"
55+ > ;
5056
5157type DistributiveOmit < T , K extends PropertyKey > = T extends unknown ? Omit < T , K > : never ;
5258
@@ -114,7 +120,7 @@ function projectSystemAgentExecutionConfig(
114120export async function resolveSystemAgentConfiguredRouteFromConfig (
115121 runConfig : OpenClawConfig ,
116122 requestedAgentId ?: string ,
117- deps : Pick < SystemAgentConfiguredRouteDeps , "loadAuthProfileStoreForRuntime" > = { } ,
123+ deps : SystemAgentRouteProjectionDeps = { } ,
118124) : Promise < SystemAgentConfiguredRoute | null > {
119125 const [ agentScope , modelSelection , modelRuntimeAliases , simpleCompletion , harnessPolicy ] =
120126 await Promise . all ( [
@@ -131,16 +137,21 @@ export async function resolveSystemAgentConfiguredRouteFromConfig(
131137 const selection = simpleCompletion . resolveSimpleCompletionSelectionForAgent ( {
132138 cfg : runConfig ,
133139 agentId : modelOwnerAgentId ,
140+ manifestPlugins : deps . pluginMetadataPlugins ,
134141 } ) ;
135142 if ( ! selection ) {
136143 return null ;
137144 }
145+ const metadataSnapshot = deps . pluginMetadataPlugins
146+ ? { plugins : deps . pluginMetadataPlugins }
147+ : undefined ;
138148 const cliExecutionProvider = modelRuntimeAliases . resolveCliRuntimeExecutionProvider ( {
139149 provider : selection . provider ,
140150 cfg : runConfig ,
141151 agentId : modelOwnerAgentId ,
142152 modelId : selection . modelId ,
143153 ...( selection . profileId ? { authProfileId : selection . profileId } : { } ) ,
154+ ...( metadataSnapshot ? { metadataSnapshot } : { } ) ,
144155 } ) ;
145156 const executionProvider = cliExecutionProvider ?? selection . runtimeProvider ?? selection . provider ;
146157 const isCliRoute = modelSelection . isCliProvider ( executionProvider , runConfig ) ;
@@ -220,15 +231,16 @@ function projectRelevantModelMap(params: {
220231/** Project every config input that can change the configured default-agent route. */
221232export async function projectDefaultInferenceRoute (
222233 config : OpenClawConfig ,
234+ deps : SystemAgentRouteProjectionDeps = { } ,
223235) : Promise < DefaultInferenceRouteProjection > {
224- return await projectInferenceRoute ( config ) ;
236+ return await projectInferenceRoute ( config , undefined , deps ) ;
225237}
226238
227239/** Project every config input that can change one configured agent route. */
228240export async function projectInferenceRoute (
229241 config : OpenClawConfig ,
230242 requestedAgentId ?: string ,
231- deps : Pick < SystemAgentConfiguredRouteDeps , "loadAuthProfileStoreForRuntime" > = { } ,
243+ deps : SystemAgentRouteProjectionDeps = { } ,
232244) : Promise < DefaultInferenceRouteProjection > {
233245 const { resolveProviderIdForAuth } = await import ( "../agents/provider-auth-aliases.js" ) ;
234246 const routeAgentId = resolveSystemAgentTargetAgentId ( config , requestedAgentId ) ;
@@ -243,17 +255,24 @@ export async function projectInferenceRoute(
243255 const providerIds = new Set (
244256 [ logicalProvider , normalizeProviderId ( route ?. provider ?? "" ) ] . filter ( Boolean ) ,
245257 ) ;
258+ const metadataSnapshot = deps . pluginMetadataPlugins
259+ ? { plugins : deps . pluginMetadataPlugins }
260+ : undefined ;
261+ const authAliasParams = {
262+ config,
263+ ...( metadataSnapshot ? { metadataSnapshot } : { } ) ,
264+ } ;
246265 const authProviderIds = new Set (
247- [ ...providerIds ] . map ( ( provider ) => resolveProviderIdForAuth ( provider , { config } ) ) ,
266+ [ ...providerIds ] . map ( ( provider ) => resolveProviderIdForAuth ( provider , authAliasParams ) ) ,
248267 ) ;
249268 const authProfiles = Object . fromEntries (
250269 Object . entries ( config . auth ?. profiles ?? { } ) . filter ( ( [ , profile ] ) =>
251- authProviderIds . has ( resolveProviderIdForAuth ( profile . provider , { config } ) ) ,
270+ authProviderIds . has ( resolveProviderIdForAuth ( profile . provider , authAliasParams ) ) ,
252271 ) ,
253272 ) ;
254273 const authOrder = Object . fromEntries (
255274 Object . entries ( config . auth ?. order ?? { } ) . filter ( ( [ provider ] ) =>
256- authProviderIds . has ( resolveProviderIdForAuth ( provider , { config } ) ) ,
275+ authProviderIds . has ( resolveProviderIdForAuth ( provider , authAliasParams ) ) ,
257276 ) ,
258277 ) ;
259278 const modelProviders = Object . fromEntries (
0 commit comments