sync update from LAN repo (source master @ ca48c4ec)

This commit is contained in:
gozeros committed 2026-11-05 10:53:54 +08:00
1 parent 8bc8b0e082
commit ea9dcff9c0
873 files changed
+107866 -14011

No files matched your search

@@ -4,7 +4,7 @@ from __future__ import annotations
from datetime import UTC, datetime
from sqlalchemy import BigInteger, Boolean, Index, Integer, String, UniqueConstraint
from sqlalchemy import BigInteger, Boolean, Index, Integer, String, UniqueConstraint, text
from sqlalchemy.orm import Mapped, mapped_column
from deerflow.persistence.base import Base
@@ -13,6 +13,13 @@ from deerflow.persistence.types import BeijingDateTime, PortableJSON
class AgentRow(Base):
__tablename__ = "agents"
# Composite indexes for the gallery tabs. Single-column indexes cannot
# serve "广场" (hidden + private + square) or "我的" (owner + hidden)
# without a wide scan once the catalog grows.
__table_args__ = (
Index("ix_agents_catalog_square", "hidden", "is_private", "square_id", "created_at"),
Index("ix_agents_owner_hidden", "user_id", "hidden", "created_at"),
)
# Stored as a plain string so the same id can be used as the filesystem
# directory name under {base_dir}/agents/{id}/.
@@ -27,6 +34,14 @@ class AgentRow(Base):
# visible to its owner in the "我的" tab, and visible to anyone in the
# private-square listing once the password has been verified.
is_private: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, index=True)
# When True the agent is hidden from every non-admin listing surface
# (gallery / 我的 / 广场 / homepage selector / private square). Only the
# admin agents console (?admin=true) still lists it. Purely a catalog
# switch: single-record access (detail / chat / run) keeps working, so
# existing conversations with a hidden agent are unaffected.
# server_default keeps the startup ORM-column sweep able to ADD COLUMN
# on existing deployments (NOT NULL needs a default).
hidden: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, server_default=text("0"), index=True)
# Publish square (发布广场) this agent is filed under. A pure organizational
# category with no access control — independent of ``published`` /
# ``is_private``. Empty string = "not assigned" → the listing layer treats
@@ -124,4 +139,8 @@ class AgentExtrasRow(Base):
# list[str] | None — the agent's tool_groups whitelist from config.yaml.
tool_groups: Mapped[list | None] = mapped_column(PortableJSON(), nullable=True, default=None)
model: Mapped[str | None] = mapped_column(String(191), nullable=True, default=None)
# Gallery 「对话」 jump target mirrored from config.yaml so the list endpoint
# can redirect without reading every agent file. Nullable JSON so existing
# databases pick the column up on the startup ORM sweep.
chat_link: Mapped[dict | None] = mapped_column(PortableJSON(), nullable=True, default=None)
skills_synced_at: Mapped[datetime] = mapped_column(BeijingDateTime(), nullable=False, default=lambda: datetime.now(UTC), onupdate=lambda: datetime.now(UTC))