"""ORM model for custom agents.""" from __future__ import annotations from datetime import UTC, datetime from sqlalchemy import Boolean, DateTime, String from sqlalchemy.orm import Mapped, mapped_column from deerflow.persistence.base import Base class AgentRow(Base): __tablename__ = "agents" # Stored as a plain string so the same id can be used as the filesystem # directory name under {base_dir}/agents/{id}/. id: Mapped[str] = mapped_column(String(64), primary_key=True) name: Mapped[str] = mapped_column(String(256), nullable=False, index=True) description: Mapped[str] = mapped_column(String(1024), nullable=False, default="") user_id: Mapped[str | None] = mapped_column(String(64), nullable=True, index=True) published: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, index=True) created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, default=lambda: datetime.now(UTC)) updated_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False, default=lambda: datetime.now(UTC), onupdate=lambda: datetime.now(UTC))