import { z } from 'zod';
import { simctl } from '../executor/simctl.js';
import { resolveDevice } from '../utils/device-resolver.js';
export const uninstallSchema = z.object({
device: z
.string()
.describe('Device UDID, name, or "booted"'),
bundle_id: z
.string()
.describe('Bundle identifier of the app to uninstall'),
});
export type UninstallInput = z.infer<typeof uninstallSchema>;
export const uninstallTool = {
name: 'simctl_uninstall',
description: 'Uninstall an app from a simulator',
inputSchema: uninstallSchema,
handler: async (input: UninstallInput) => {
const udid = resolveDevice(input.device);
const result = simctl('uninstall', [udid, input.bundle_id]);
if (result.exitCode !== 0) {
throw new Error(`Failed to uninstall app: ${result.stderr || result.stdout}`);
}
return {
content: [
{
type: 'text' as const,
text: `Successfully uninstalled ${input.bundle_id} from device ${input.device}`,
},
],
};
},
};