@@ -92,8 +92,11 @@ const mocks = vi.hoisted(() => ({
9292 maybeRepairLegacyPluginManifestContracts : vi . fn ( ) . mockResolvedValue ( undefined ) ,
9393 detectLegacyClawdBrowserProfileResidue : vi . fn ( ) ,
9494 maybeArchiveLegacyClawdBrowserProfileResidue : vi . fn ( ) ,
95- resolveAgentWorkspaceDir : vi . fn ( ( ) => "/tmp/openclaw-workspace" ) ,
96- resolveDefaultAgentId : vi . fn ( ( ) => "default" ) ,
95+ listAgentIds : vi . fn < ( _cfg : OpenClawConfig ) => string [ ] > ( ( ) => [ "default" ] ) ,
96+ resolveAgentWorkspaceDir : vi . fn < ( _cfg : OpenClawConfig , agentId : string ) => string > (
97+ ( ) => "/tmp/openclaw-workspace" ,
98+ ) ,
99+ resolveDefaultAgentId : vi . fn < ( _cfg : OpenClawConfig ) => string > ( ( ) => "default" ) ,
97100 resolveAgentContextLimits : vi . fn (
98101 ( cfg : { agents ?: { defaults ?: { contextLimits ?: unknown } } } ) =>
99102 cfg . agents ?. defaults ?. contextLimits ?? { } ,
@@ -117,8 +120,8 @@ const mocks = vi.hoisted(() => ({
117120 gatherDaemonStatus : vi . fn ( ) ,
118121 noteWorkspaceStatus : vi . fn ( ) ,
119122 collectWorkspaceStatusHealthFindings : vi . fn ( ) . mockResolvedValue ( [ ] ) ,
120- collectWorkspaceBackupTip : vi . fn ( ( ) : string | undefined => undefined ) ,
121- shouldSuggestMemorySystem : vi . fn ( async ( ) => false ) ,
123+ collectWorkspaceBackupTip : vi . fn < ( workspaceDir : string ) => string | undefined > ( ( ) => undefined ) ,
124+ shouldSuggestMemorySystem : vi . fn < ( workspaceDir : string ) => Promise < boolean > > ( async ( ) => false ) ,
122125 collectDiskSpaceHealthFindings : vi . fn ( ( ) : readonly HealthFinding [ ] => [ ] ) ,
123126 collectHeartbeatCadenceMigrationFindings : vi . fn ( async ( ) => [ ] as unknown [ ] ) ,
124127 maybeMigrateHeartbeatCadenceToCron : vi . fn ( ) . mockResolvedValue ( { changes : [ ] , warnings : [ ] } ) ,
@@ -362,6 +365,7 @@ vi.mock("../commands/doctor-browser.js", () => ({
362365} ) ) ;
363366
364367vi . mock ( "../agents/agent-scope.js" , ( ) => ( {
368+ listAgentIds : mocks . listAgentIds ,
365369 resolveAgentWorkspaceDir : mocks . resolveAgentWorkspaceDir ,
366370 resolveDefaultAgentId : mocks . resolveDefaultAgentId ,
367371 resolveAgentContextLimits : mocks . resolveAgentContextLimits ,
@@ -673,6 +677,8 @@ describe("doctor health contributions", () => {
673677 } ) ;
674678 mocks . resolveAgentWorkspaceDir . mockReset ( ) ;
675679 mocks . resolveAgentWorkspaceDir . mockReturnValue ( "/tmp/openclaw-workspace" ) ;
680+ mocks . listAgentIds . mockReset ( ) ;
681+ mocks . listAgentIds . mockReturnValue ( [ "default" ] ) ;
676682 mocks . resolveDefaultAgentId . mockReset ( ) ;
677683 mocks . resolveDefaultAgentId . mockReturnValue ( "default" ) ;
678684 mocks . resolveAgentContextLimits . mockReset ( ) ;
@@ -2268,6 +2274,69 @@ describe("doctor health contributions", () => {
22682274 expect ( mocks . collectWorkspaceBackupTip ) . toHaveBeenCalledWith ( "/tmp/openclaw-workspace" ) ;
22692275 } ) ;
22702276
2277+ it ( "labels normal workspace suggestions for secondary agents" , async ( ) => {
2278+ const contribution = requireDoctorContribution ( "doctor:workspace-suggestions" ) ;
2279+ const cfg = { } as OpenClawConfig ;
2280+ const ctx = {
2281+ cfg,
2282+ cfgForPersistence : cfg ,
2283+ configResult : { cfg } ,
2284+ configPath : "/tmp/fake-openclaw.json" ,
2285+ sourceConfigValid : true ,
2286+ prompter : buildDoctorPrompter ( false ) ,
2287+ runtime : { log : vi . fn ( ) , error : vi . fn ( ) , exit : vi . fn ( ) } ,
2288+ options : { } ,
2289+ env : { } ,
2290+ } as DoctorContributionRunContext ;
2291+ mocks . listAgentIds . mockReturnValue ( [ "default" , "secondary" ] ) ;
2292+ mocks . resolveAgentWorkspaceDir . mockImplementation ( ( _cfg , agentId ) => `/tmp/${ agentId } ` ) ;
2293+ mocks . collectWorkspaceBackupTip . mockImplementation ( ( workspaceDir ) =>
2294+ workspaceDir === "/tmp/secondary" ? "- Back up this workspace." : undefined ,
2295+ ) ;
2296+ mocks . shouldSuggestMemorySystem . mockImplementation (
2297+ async ( workspaceDir ) => workspaceDir === "/tmp/secondary" ,
2298+ ) ;
2299+
2300+ await contribution . run ( ctx ) ;
2301+
2302+ expect ( mocks . note ) . toHaveBeenCalledWith (
2303+ 'Agent "secondary": - Back up this workspace.' ,
2304+ "Workspace" ,
2305+ ) ;
2306+ expect ( mocks . note ) . toHaveBeenCalledWith (
2307+ 'Agent "secondary": Enable memory system for better recall.' ,
2308+ "Workspace" ,
2309+ ) ;
2310+ expect ( mocks . note ) . toHaveBeenCalledTimes ( 2 ) ;
2311+ } ) ;
2312+
2313+ it ( "keeps single-agent workspace suggestion wording unchanged" , async ( ) => {
2314+ const contribution = requireDoctorContribution ( "doctor:workspace-suggestions" ) ;
2315+ const cfg = { } as OpenClawConfig ;
2316+ const ctx = {
2317+ cfg,
2318+ cfgForPersistence : cfg ,
2319+ configResult : { cfg } ,
2320+ configPath : "/tmp/fake-openclaw.json" ,
2321+ sourceConfigValid : true ,
2322+ prompter : buildDoctorPrompter ( false ) ,
2323+ runtime : { log : vi . fn ( ) , error : vi . fn ( ) , exit : vi . fn ( ) } ,
2324+ options : { } ,
2325+ env : { } ,
2326+ } as DoctorContributionRunContext ;
2327+ mocks . collectWorkspaceBackupTip . mockReturnValue ( "- Back up this workspace." ) ;
2328+ mocks . shouldSuggestMemorySystem . mockResolvedValue ( true ) ;
2329+
2330+ await contribution . run ( ctx ) ;
2331+
2332+ expect ( mocks . note ) . toHaveBeenNthCalledWith ( 1 , "- Back up this workspace." , "Workspace" ) ;
2333+ expect ( mocks . note ) . toHaveBeenNthCalledWith (
2334+ 2 ,
2335+ "Enable memory system for better recall." ,
2336+ "Workspace" ,
2337+ ) ;
2338+ } ) ;
2339+
22712340 it ( "keeps disk space opt-in for default lint selection" , async ( ) => {
22722341 const contributionChecks = await resolveDoctorContributionHealthChecks ( ) ;
22732342 const diskSpaceCheck = contributionChecks . find (
0 commit comments