// Copyright 2025 eat-pray-ai & OpenWaygate
// SPDX-License-Identifier: Apache-2.0
package caption
import (
"io"
"github.com/eat-pray-ai/yutu/cmd"
"github.com/eat-pray-ai/yutu/pkg/caption"
"github.com/eat-pray-ai/yutu/pkg/utils"
"github.com/google/jsonschema-go/jsonschema"
"github.com/modelcontextprotocol/go-sdk/mcp"
"github.com/spf13/cobra"
)
const (
deleteTool = "caption-delete"
deleteShort = "Delete captions"
deleteLong = "Delete captions of a video by ids"
deleteIdsUsage = "IDs of the captions to delete"
)
var deleteInSchema = &jsonschema.Schema{
Type: "object",
Required: []string{"ids"},
Properties: map[string]*jsonschema.Schema{
"ids": {
Type: "array", Description: deleteIdsUsage,
Items: &jsonschema.Schema{Type: "string"},
},
"on_behalf_of": {Type: "string"},
"on_behalf_of_content_owner": {Type: "string"},
},
}
func init() {
mcp.AddTool(
cmd.Server, &mcp.Tool{
Name: deleteTool, Title: deleteShort, Description: deleteLong,
InputSchema: deleteInSchema, Annotations: &mcp.ToolAnnotations{
DestructiveHint: jsonschema.Ptr(true),
IdempotentHint: true,
OpenWorldHint: jsonschema.Ptr(true),
ReadOnlyHint: false,
},
}, cmd.GenToolHandler(
deleteTool, func(input caption.Caption, writer io.Writer) error {
return input.Delete(writer)
},
),
)
captionCmd.AddCommand(deleteCmd)
deleteCmd.Flags().StringSliceVarP(&ids, "ids", "i", []string{}, deleteIdsUsage)
deleteCmd.Flags().StringVarP(&onBehalfOf, "onBehalfOf", "b", "", "")
deleteCmd.Flags().StringVarP(
&onBehalfOfContentOwner, "onBehalfOfContentOwner", "B", "", "",
)
_ = deleteCmd.MarkFlagRequired("ids")
}
var deleteCmd = &cobra.Command{
Use: "delete",
Short: deleteShort,
Long: deleteLong,
Run: func(cmd *cobra.Command, args []string) {
input := caption.NewCaption(
caption.WithIds(ids),
caption.WithOnBehalfOf(onBehalfOf),
caption.WithOnBehalfOfContentOwner(onBehalfOfContentOwner),
)
utils.HandleCmdError(input.Delete(cmd.OutOrStdout()), cmd)
},
}