mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-31 04:57:23 +08:00
- ChainBase 拆分为 RecognitionMixin/MessageProcessingMixin/NotificationMixin - TransferChain 拆分为 7 个功能 mixin(_mixins.py),SubscribeChain 音乐订阅域拆出 _music.py - 斜杠命令交互四件套收敛为 InteractionChainMixin 委托,会话管理器移至 application 层,chain 层不再 re-export - 模块基础类收敛到 app/modules/_base(notification/mediaserver 语义重命名) - 清理 app/chain/__init__.py 24 个未使用导入,修正 49 处测试 patch 目标到实际命名空间 - 兼容层 legacy 符号不再并入 __all__,根治 schemas 初始化反向拉起 application.transfer 的循环导入 - 修复 bangumi 集数为字符串时 set_bangumi_info 抛 TypeError - 新增重复代码等架构门禁测试;capability 清单校验排除下划线内部目录
51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
from typing import Optional, Type
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from app.agent.tools.base import MoviePilotTool
|
|
from app.agent.tools.tags import ToolTag
|
|
from app.db.oper.agenttask import AgentTaskOper
|
|
|
|
|
|
class DeleteAgentTaskInput(BaseModel):
|
|
"""删除 Agent 自主定时任务的输入参数。"""
|
|
|
|
task_id: int = Field(..., ge=1, description="ID of the task to permanently delete.")
|
|
|
|
|
|
class DeleteAgentTaskTool(MoviePilotTool):
|
|
"""永久删除 Agent 自主定时任务。"""
|
|
|
|
name: str = "delete_agent_task"
|
|
tags: list[str] = [ToolTag.Write, ToolTag.AgentTask, ToolTag.Admin]
|
|
description: str = (
|
|
"Permanently delete an autonomous agent task and remove its runtime schedule. "
|
|
"Use update_agent_task with enabled=false when the user only wants to pause it."
|
|
)
|
|
args_schema: Type[BaseModel] = DeleteAgentTaskInput
|
|
require_admin: bool = True
|
|
|
|
def get_tool_message(self, **kwargs: object) -> Optional[str]:
|
|
"""生成删除定时任务的提示消息。"""
|
|
return f"删除自主定时任务:{kwargs.get('task_id', '')}"
|
|
|
|
def _delete_task(self, task_id: int) -> bool:
|
|
"""删除当前用户的任务并移除运行时调度。"""
|
|
from app.application.scheduling import remove_agent_task_job
|
|
|
|
deleted = AgentTaskOper().delete(
|
|
task_id=task_id,
|
|
user_id=str(self._user_id),
|
|
)
|
|
if deleted:
|
|
remove_agent_task_job(task_id)
|
|
return deleted
|
|
|
|
async def run(self, task_id: int, **kwargs: object) -> str:
|
|
"""删除 Agent 自主定时任务。"""
|
|
payload = DeleteAgentTaskInput(task_id=task_id)
|
|
deleted = await self.run_blocking("db", self._delete_task, payload.task_id)
|
|
if not deleted:
|
|
return f"Agent 定时任务 {task_id} 不存在或不属于当前用户"
|
|
return f"Agent 定时任务 {task_id} 已删除"
|