import { z } from 'zod'
import type { TodoistTool } from '../todoist-tool.js'
import { ToolNames } from '../utils/tool-names.js'
const ArgsSchema = {
type: z
.enum(['project', 'section', 'task', 'comment'])
.describe('The type of entity to delete.'),
id: z.string().min(1).describe('The ID of the entity to delete.'),
}
const OutputSchema = {
deletedEntity: z
.object({
type: z
.enum(['project', 'section', 'task', 'comment'])
.describe('The type of deleted entity.'),
id: z.string().describe('The ID of the deleted entity.'),
})
.describe('Information about the deleted entity.'),
success: z.boolean().describe('Whether the deletion was successful.'),
}
const deleteObject = {
name: ToolNames.DELETE_OBJECT,
description: 'Delete a project, section, task, or comment by its ID.',
parameters: ArgsSchema,
outputSchema: OutputSchema,
mutability: 'mutating' as const,
async execute(args, client) {
switch (args.type) {
case 'project':
await client.deleteProject(args.id)
break
case 'section':
await client.deleteSection(args.id)
break
case 'task':
await client.deleteTask(args.id)
break
case 'comment':
await client.deleteComment(args.id)
break
}
return {
textContent: `Deleted ${args.type}: id=${args.id}`,
structuredContent: {
deletedEntity: { type: args.type, id: args.id },
success: true,
},
}
},
} satisfies TodoistTool<typeof ArgsSchema, typeof OutputSchema>
export { deleteObject }