"""取消任务 — cancel a running operation. tripocli cancel --operator --type remesh 实测请求体 ``{operator_id, scene, operation_type}``;``scene`` ∈ {workspace, assets}, ``operation_type`` 的取值由服务端枚举决定(下面这份清单来自真实报错信息): text_to_model image_to_model multiview_to_model ai_segmentation ai_completion mesh_fill modification skeleton_adjustment texture_generation pre_rig_check rigging retarget stylize export retexture apply_texture pbr remesh texture_upscaler image_edit_to_model ⚠️ 图片生成任务**不在**该枚举内,无法取消。 """ NAME = "cancel" HELP = "取消正在运行的任务(需指定操作类型)" OPERATION_TYPES = ( "text_to_model", "image_to_model", "multiview_to_model", "ai_segmentation", "ai_completion", "mesh_fill", "modification", "skeleton_adjustment", "texture_generation", "pre_rig_check", "rigging", "retarget", "stylize", "export", "retexture", "apply_texture", "pbr", "remesh", "texture_upscaler", "image_edit_to_model", ) def add_arguments(parser): parser.add_argument("--operator", required=True, help="要取消的 operator_id") parser.add_argument("--type", required=True, choices=OPERATION_TYPES, help="要取消的任务类型") parser.add_argument("--scene", default="workspace", choices=["workspace", "assets"], help="场景(默认 workspace)") def run(ctx): args = ctx.args data = ctx.client.get_data( "POST", "/v2/studio/operation/cancel", body={"operator_id": args.operator, "scene": args.scene, "operation_type": args.type}, ) payload = data or {"operator_id": args.operator, "cancelled": True} ctx.out.data(payload, human=lambda: ctx.out.line(f"✅ 已取消: {args.operator}")) return payload