@@ -60,11 +60,12 @@ discoverConfigSecretTargetsByIds(forcedFallbackConfig, new Set([firecrawlPath]))
6060
6161function activateMinimalSecretsRuntimeSnapshot ( params : {
6262 config : OpenClawConfig ;
63+ resolvedConfig ?: OpenClawConfig ;
6364 env : Record < string , string | undefined > ;
6465} ) {
6566 const snapshot = {
6667 sourceConfig : structuredClone ( params . config ) ,
67- config : structuredClone ( params . config ) ,
68+ config : structuredClone ( params . resolvedConfig ?? params . config ) ,
6869 authStores : [ ] ,
6970 warnings : [ ] ,
7071 webTools : createEmptyRuntimeWebToolsMetadata ( ) ,
@@ -157,4 +158,58 @@ describe("runtime command secrets", () => {
157158 expect ( resolved . diagnostics ) . toEqual ( [ ] ) ;
158159 expect ( resolved . inactiveRefPaths ) . toEqual ( [ ] ) ;
159160 } ) ;
161+
162+ it ( "returns resolved snapshot assignments when exec targets remain unresolved" , async ( ) => {
163+ const sourceConfig = {
164+ models : {
165+ providers : {
166+ google : {
167+ enabled : true ,
168+ apiKey : { source : "exec" , provider : "default" , id : "models/google/api-key" } ,
169+ } ,
170+ openai : {
171+ enabled : true ,
172+ apiKey : { source : "env" , provider : "default" , id : "OPENAI_API_KEY" } ,
173+ } ,
174+ } ,
175+ } ,
176+ secrets : {
177+ providers : {
178+ default : { source : "env" } ,
179+ } ,
180+ } ,
181+ } as unknown as OpenClawConfig ;
182+ activateMinimalSecretsRuntimeSnapshot ( {
183+ config : sourceConfig ,
184+ resolvedConfig : {
185+ ...sourceConfig ,
186+ models : {
187+ providers : {
188+ ...sourceConfig . models ?. providers ,
189+ openai : {
190+ ...sourceConfig . models ?. providers ?. openai ,
191+ apiKey : "gateway-openai-key" ,
192+ } ,
193+ } ,
194+ } ,
195+ } as OpenClawConfig ,
196+ env : {
197+ HOME : process . env . HOME ,
198+ } ,
199+ } ) ;
200+
201+ const resolved = await resolveCommandSecretsFromActiveRuntimeSnapshot ( {
202+ commandName : "reply" ,
203+ targetIds : new Set ( [ "models.providers.*.apiKey" ] ) ,
204+ } ) ;
205+
206+ expect ( resolved . assignments ) . toMatchObject ( [
207+ {
208+ path : "models.providers.openai.apiKey" ,
209+ value : "gateway-openai-key" ,
210+ } ,
211+ ] ) ;
212+ expect ( resolved . diagnostics ) . toEqual ( [ ] ) ;
213+ expect ( resolved . inactiveRefPaths ) . toEqual ( [ ] ) ;
214+ } ) ;
160215} ) ;
0 commit comments