human_task.py 1.7 KB

1234567891011121314151617181920212223242526272829
  1. from datetime import datetime
  2. from sqlalchemy import DateTime, String, Text
  3. from sqlalchemy.dialects.sqlite import JSON
  4. from sqlalchemy.orm import Mapped, mapped_column
  5. from core_db import AuditMixin, Base, TenantMixin, VersionMixin
  6. from core_shared import JSONValue
  7. class HumanTask(TenantMixin, AuditMixin, VersionMixin, Base):
  8. __tablename__ = "human_task"
  9. task_type: Mapped[str] = mapped_column(String(32), index=True)
  10. status: Mapped[str] = mapped_column(String(32), default="pending", index=True)
  11. title: Mapped[str] = mapped_column(String(128))
  12. description: Mapped[str | None] = mapped_column(Text, nullable=True)
  13. source_type: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
  14. source_id: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True)
  15. run_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
  16. node_run_id: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
  17. requested_by: Mapped[str | None] = mapped_column(String(36), nullable=True)
  18. assigned_to: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
  19. claimed_by: Mapped[str | None] = mapped_column(String(36), nullable=True, index=True)
  20. request_payload_json: Mapped[dict[str, JSONValue]] = mapped_column(JSON, default=dict)
  21. response_payload_json: Mapped[dict[str, JSONValue] | None] = mapped_column(JSON, nullable=True)
  22. due_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, index=True)
  23. claimed_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
  24. completed_time: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)