@@ -15,11 +15,13 @@ import { runLocalAgentProvider } from "./local-agent-adapters.js";
1515import {
1616 isLocalAgentProvider ,
1717 loadLocalAgentProfiles ,
18+ LOCAL_AGENT_PROVIDERS ,
1819 type LocalAgentProfile ,
1920} from "./local-agent-profiles.js" ;
2021import {
2122 assertLocalAgentProviderAvailable ,
2223 formatLocalAgentProviderAvailabilitySummary ,
24+ getLocalAgentProviderAvailabilitySnapshot ,
2325} from "./local-agent-availability.js" ;
2426import {
2527 formatAvailableLocalAgentTargets ,
@@ -169,12 +171,18 @@ async function runInit({ force }: { force: boolean }): Promise<void> {
169171 validate : validateRequiredPublicBaseUrl ,
170172 } ) ) ;
171173
174+ const subagents = resolveSubagentsFlag ( files . config ) ;
175+ const agentProviders =
176+ subagents === true
177+ ? probeAndBuildAgentProviders ( files . config . agentProviders )
178+ : files . config . agentProviders ;
172179 const config : DevspaceUserConfig = {
173180 host : files . config . host ?? "127.0.0.1" ,
174181 port,
175182 allowedRoots,
176183 publicBaseUrl,
177- subagents : resolveSubagentsFlag ( files . config ) ,
184+ subagents,
185+ ...( agentProviders ? { agentProviders } : { } ) ,
178186 } ;
179187 const auth = {
180188 ownerToken : files . auth . ownerToken ?? generateOwnerToken ( ) ,
@@ -277,11 +285,71 @@ async function runDoctor(): Promise<void> {
277285 console . log ( `Public MCP URL: ${ new URL ( "/mcp" , config . publicBaseUrl ) . toString ( ) } ` ) ;
278286 console . log ( `Allowed roots: ${ config . allowedRoots . join ( ", " ) } ` ) ;
279287 console . log ( `Allowed hosts: ${ config . allowedHosts . join ( ", " ) } ` ) ;
288+ console . log ( `Subagents: ${ config . subagents ? "enabled" : "disabled" } ` ) ;
289+ if ( config . subagents ) {
290+ const snapshot = getLocalAgentProviderAvailabilitySnapshot ( ) ;
291+ console . log (
292+ `Agent providers (live): ${ formatLocalAgentProviderAvailabilitySummary ( snapshot ) } ` ,
293+ ) ;
294+ if ( config . agentProviders ) {
295+ console . log (
296+ `Agent providers (enabled): ${
297+ config . agentProviders . enabled . length
298+ ? config . agentProviders . enabled . join ( ", " )
299+ : "(empty — no providers)"
300+ } `,
301+ ) ;
302+ if ( config . agentProviders . detectedAt ) {
303+ console . log ( `Agent providers last probe: ${ config . agentProviders . detectedAt } ` ) ;
304+ }
305+ } else {
306+ console . log ( "Agent providers (config): missing (compat = all available)" ) ;
307+ }
308+
309+ // Refresh lastProbe write-back when subagents on and config exists
310+ if ( files . configExists ) {
311+ const refreshed = probeAndBuildAgentProviders ( files . config . agentProviders ) ;
312+ writeDevspaceConfig ( {
313+ ...files . config ,
314+ agentProviders : {
315+ // keep user enable-list if set; only refresh probe metadata + available adds when empty
316+ enabled :
317+ files . config . agentProviders ?. enabled ?? refreshed . enabled ,
318+ detectedAt : refreshed . detectedAt ,
319+ lastProbe : refreshed . lastProbe ,
320+ } ,
321+ } ) ;
322+ console . log ( `Agent providers probe written to ${ files . configPath } ` ) ;
323+ }
324+ }
280325 } catch ( error ) {
281326 console . log ( `Config status : ${error instanceof Error ? error . message : String ( error ) } `) ;
282327 }
283328}
284329
330+ /** Probe PATH and build AgentProvidersConfig (available ids in product order). */
331+ function probeAndBuildAgentProviders (
332+ existing ?: DevspaceUserConfig [ "agentProviders "] ,
333+ ) : NonNullable < DevspaceUserConfig [ "agentProviders "] > {
334+ const snapshot = getLocalAgentProviderAvailabilitySnapshot ( ) ;
335+ const available = new Set (
336+ snapshot . filter ( ( row ) => row . available ) . map ( ( row ) => row . name ) ,
337+ ) ;
338+ const enabled =
339+ existing ?. enabled && existing . enabled . length > 0
340+ ? existing . enabled . filter ( ( id ) => LOCAL_AGENT_PROVIDERS . includes ( id as never ) )
341+ : LOCAL_AGENT_PROVIDERS . filter ( ( id ) => available . has ( id ) ) ;
342+ return {
343+ enabled ,
344+ detectedAt : new Date ( ) . toISOString ( ) ,
345+ lastProbe : snapshot . map ( ( row ) => ( {
346+ id : row . name ,
347+ available : row . available ,
348+ detail : row . reason ,
349+ } ) ) ,
350+ } ;
351+ }
352+
285353function runConfigCommand ( args : string [ ] ) : void {
286354 const [ subcommand , key , ...rest ] = args ;
287355 const files = loadDevspaceFiles ( ) ;
0 commit comments