feat: v0.1.1 迭代——人设外键重构、Chat UI优化、意识节点防幻觉、日志双视图

1. 人设外键重构:persona_template 成为 system_prompt 唯一权威来源,
   agent/系统节点通过 persona_id FK 引用,含数据迁移脚本
2. Chat UI:去掉底部AI提示、加号改为弹出菜单、新建对话乐观跳转
3. 意识节点:无可用worker时禁止编造agent_id,只能自行完成或拒绝
4. 日志页面:双tab布局(系统日志 + 工作流日志列表选择)
5. 其他:SSE流式聊天、对话删除/重命名、standalone模式修复

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 06:18:47 +00:00
parent e3b8686d45
commit 6f1bc27101
39 changed files with 2904 additions and 524 deletions
@@ -0,0 +1,34 @@
"""simplify persona_template to name + system_prompt
Revision ID: 0006
Revises: 0005
Create Date: 2026-06-04
"""
from alembic import op
import sqlalchemy as sa
revision = "0006"
down_revision = "0005"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.drop_column("persona_template", "description")
op.drop_column("persona_template", "agent_type")
op.drop_column("persona_template", "provider_title")
op.drop_column("persona_template", "model_id")
op.drop_column("persona_template", "tools")
op.drop_column("persona_template", "tags")
op.drop_column("persona_template", "is_builtin")
def downgrade() -> None:
op.add_column("persona_template", sa.Column("description", sa.Text(), nullable=False, server_default=""))
op.add_column("persona_template", sa.Column("agent_type", sa.String(32), nullable=False, server_default="ordinary"))
op.add_column("persona_template", sa.Column("provider_title", sa.String(50), nullable=True))
op.add_column("persona_template", sa.Column("model_id", sa.String(100), nullable=True))
op.add_column("persona_template", sa.Column("tools", sa.JSON(), server_default="[]"))
op.add_column("persona_template", sa.Column("tags", sa.JSON(), server_default="[]"))
op.add_column("persona_template", sa.Column("is_builtin", sa.Boolean(), nullable=False, server_default="false"))
@@ -0,0 +1,82 @@
"""persona_id FK refactor: agents and system nodes reference persona_template
Revision ID: 0007
Revises: 0006
Create Date: 2026-06-05
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.sql import table, column
from ulid import ULID
revision = "0007"
down_revision = "0006"
branch_labels = None
depends_on = None
def upgrade() -> None:
# 1. Data migration: create persona records from existing system_prompts
conn = op.get_bind()
# Migrate base_individual.system_prompt → persona_template records
rows = conn.execute(
sa.text(
"SELECT agent_id, system_prompt, owner_id FROM base_individual "
"WHERE system_prompt IS NOT NULL AND system_prompt != ''"
)
).fetchall()
for row in rows:
template_id = str(ULID())
conn.execute(
sa.text(
"INSERT INTO persona_template (template_id, name, system_prompt, owner_id) "
"VALUES (:tid, :name, :prompt, :owner)"
),
{"tid": template_id, "name": f"auto_{row[0][:8]}", "prompt": row[1], "owner": row[2]},
)
conn.execute(
sa.text(
"UPDATE base_individual SET template_origin_id = :tid WHERE agent_id = :aid"
),
{"tid": template_id, "aid": row[0]},
)
# Migrate system_node_config.custom_system_prompt → persona_template
node_rows = conn.execute(
sa.text(
"SELECT node_name, custom_system_prompt FROM system_node_config "
"WHERE custom_system_prompt IS NOT NULL AND custom_system_prompt != ''"
)
).fetchall()
# Add persona_id column to system_node_config before populating
op.add_column(
"system_node_config",
sa.Column("persona_id", sa.String(64), sa.ForeignKey("persona_template.template_id", ondelete="SET NULL"), nullable=True),
)
for row in node_rows:
template_id = str(ULID())
conn.execute(
sa.text(
"INSERT INTO persona_template (template_id, name, system_prompt, owner_id) "
"VALUES (:tid, :name, :prompt, NULL)"
),
{"tid": template_id, "name": f"node_{row[0]}", "prompt": row[1]},
)
conn.execute(
sa.text(
"UPDATE system_node_config SET persona_id = :tid WHERE node_name = :nn"
),
{"tid": template_id, "nn": row[0]},
)
# 2. Rename template_origin_id → persona_id on base_individual
op.alter_column("base_individual", "template_origin_id", new_column_name="persona_id")
# 3. Drop old columns
op.drop_column("base_individual", "system_prompt")
op.drop_column("system_node_config", "custom_system_prompt")