You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -42,6 +43,31 @@ describe('erase_sims tool (UDID or ALL only)', () => {
42
43
content: [{type: 'text',text: 'Failed to erase simulator: Booted device'}],
43
44
});
44
45
});
46
+
47
+
it('adds tool hint when booted error occurs without shutdownFirst',async()=>{
48
+
constbootedError=
49
+
'An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=405):\nUnable to erase contents and settings in current state: Booted\n';
{type: 'text',text: `Failed to erase simulator: ${errText}`},
60
67
{
61
68
type: 'text',
62
-
text: `Failed to erase all simulators: ${result.error??'Unknown error'}`,
69
+
text: `Tool hint: The simulator appears to be Booted. Re-run erase_sims with { simulatorUuid: '${udid}', shutdownFirst: true } to shut it down before erasing.`,
63
70
},
64
71
],
65
72
};
66
73
}
74
+
75
+
return{
76
+
content: [{type: 'text',text: `Failed to erase simulator: ${errText}`}],
77
+
};
78
+
}
79
+
80
+
if(params.all===true){
81
+
log('info',`Erasing ALL simulators${params.shutdownFirst ? ' (shutdownFirst=true)' : ''}`);
82
+
if(params.shutdownFirst){
83
+
try{
84
+
awaitexecutor(
85
+
['xcrun','simctl','shutdown','all'],
86
+
'Shutdown All Simulators',
87
+
true,
88
+
undefined,
89
+
);
90
+
}catch{
91
+
// ignore and continue to erase
92
+
}
93
+
}
94
+
95
+
constresult=awaitexecutor(
96
+
['xcrun','simctl','erase','all'],
97
+
'Erase All Simulators',
98
+
true,
99
+
undefined,
100
+
);
101
+
if(!result.success){
102
+
consterrText=result.error??'Unknown error';
103
+
constcontent=[{type: 'text',text: `Failed to erase all simulators: ${errText}`}];
text: 'Tool hint: One or more simulators appear to be Booted. Re-run erase_sims with { all: true, shutdownFirst: true } to shut them down before erasing.',
111
+
});
112
+
}
113
+
return{ content };
114
+
}
67
115
return{content: [{type: 'text',text: 'Successfully erased all simulators'}]};
68
116
}
69
117
@@ -80,7 +128,7 @@ export async function erase_simsLogic(
80
128
exportdefault{
81
129
name: 'erase_sims',
82
130
description:
83
-
'Erases simulator content and settings. Provide exactly one of: simulatorUuid or all=true.',
131
+
'Erases simulator content and settings. Provide exactly one of: simulatorUuid or all=true. Optional: shutdownFirst to shut down before erasing.',
0 commit comments