Files
aiagent/backend/app/models/execution.py
renjianbo 7ee80c74b2 feat: 集成飞书通知和机器人对话系统
- 新增通知系统 (notifications 表、服务、API)
- 新增飞书定时任务结果推送 (webhook + 应用消息)
- 新增飞书应用消息发送服务 (feishu_app_service)
- 新增飞书 WebSocket 长连接事件监听 (苹果应用)
- 新增飞书账号绑定/解绑 API
- 新增橙子飞书机器人 (独立 WS 连接,固定路由到橙子助手 Agent)
- 执行记录添加 schedule_id,用户添加飞书绑定字段

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-02 16:17:49 +08:00

44 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
执行记录模型
"""
from sqlalchemy import Column, String, Text, Integer, DateTime, JSON, ForeignKey, func
from sqlalchemy.dialects.mysql import CHAR
from sqlalchemy.orm import relationship
from app.core.database import Base
import uuid
class Execution(Base):
"""执行记录表"""
__tablename__ = "executions"
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="执行ID")
agent_id = Column(CHAR(36), ForeignKey("agents.id"), nullable=True, comment="智能体ID")
workflow_id = Column(CHAR(36), ForeignKey("workflows.id"), nullable=True, comment="工作流ID")
input_data = Column(JSON, comment="输入数据")
output_data = Column(JSON, comment="输出数据")
status = Column(
String(32),
nullable=False,
comment="状态: pending/running/completed/failed/awaiting_approval",
)
error_message = Column(Text, comment="错误信息")
execution_time = Column(Integer, comment="执行时间(ms)")
task_id = Column(String(100), comment="Celery任务ID")
schedule_id = Column(
CHAR(36), ForeignKey("agent_schedules.id"), nullable=True, comment="定时任务ID"
)
parent_execution_id = Column(
CHAR(36), ForeignKey("executions.id"), nullable=True, comment="父执行ID"
)
depth = Column(Integer, default=0, nullable=False, comment="执行深度根为0")
pause_state = Column(JSON, nullable=True, comment="挂起快照(审批节点 HITL恢复时消费")
created_at = Column(DateTime, default=func.now(), comment="创建时间")
# 关系
agent = relationship("Agent", backref="executions")
workflow = relationship("Workflow", backref="executions")
def __repr__(self):
return f"<Execution(id={self.id}, status={self.status})>"