## 安全修复 (12项) - Webhook接口添加全局Token认证,过滤敏感请求头 - 修复JWT Base64 padding公式,防止签名验证绕过 - 数据库密码/飞书Token从源码移除,改为环境变量 - 工作流引擎添加路径遍历防护 (_resolve_safe_path) - eval()添加模板长度上限检查 - 审批API添加认证依赖 - 前端v-html增强XSS转义,console.log仅开发模式输出 - 500错误不再暴露内部异常详情 ## Agent运行时修复 (7项) - 删除_inject_knowledge_context中未定义db变量的finally块 - 工具执行添加try/except保护,异常不崩溃Agent - LLM重试计入budget计数器 - self_review异常时passed=False - max_iterations截断标记success=False - 工具参数JSON解析失败时记录警告日志 - run()开始时重置_llm_invocations计数器 ## 配置与基础设施 - DEBUG默认False,SQL_ECHO独立配置项 - init_db()补全13个缺失模型导入 - 新增WEBHOOK_AUTH_TOKEN/SQL_ECHO配置项 - 新增.env.example模板文件 ## 前端修复 (12项) - 登录改用URLSearchParams替代FormData - 401拦截器通过Pinia store统一清理状态 - SSE流超时从60s延长至300s - final/error事件时清除streamTimeout - localStorage聊天记录添加24h TTL - safeParseArgCount替代模板中裸JSON.parse - fetchUser 401时同时清除user对象 ## 新增模块 - 知识进化: knowledge_extractor/retriever/tasks - 数字孪生: shadow_executor/comparison模型 - 行为采集: behavior_middleware/collector/fingerprint_engine - 代码审查: code_review_agent/document_review_agent - 反馈学习: feedback_learner - 瓶颈检测/优化引擎/成本估算/需求估算 - 速率限制器 (rate_limiter) - Alembic迁移 015-020 ## 文档 - 商业化落地计划 - 8篇docs文档 (架构/API/部署/开发/贡献等) - Docker Compose生产配置 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
59 lines
3.4 KiB
Python
59 lines
3.4 KiB
Python
"""add agent_execution_logs table
|
|
|
|
Revision ID: 015_add_agent_execution_logs
|
|
Revises: 014_add_schedule_goal_fields
|
|
Create Date: 2026-05-10
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.dialects.mysql import CHAR
|
|
|
|
revision = "015_add_agent_execution_logs"
|
|
down_revision = "014_add_schedule_goal_fields"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"agent_execution_logs",
|
|
sa.Column("id", CHAR(36), primary_key=True, comment="日志ID"),
|
|
sa.Column("agent_id", sa.String(36), nullable=True, comment="Agent ID"),
|
|
sa.Column("agent_name", sa.String(200), nullable=True, comment="Agent 名称"),
|
|
sa.Column("goal_id", sa.String(36), nullable=True, comment="关联 Goal ID"),
|
|
sa.Column("task_id", sa.String(36), nullable=True, comment="关联 Task ID"),
|
|
sa.Column("user_id", sa.String(36), nullable=True, comment="用户 ID"),
|
|
sa.Column("session_id", sa.String(100), nullable=True, comment="会话标识"),
|
|
sa.Column("input_text", sa.Text, nullable=True, comment="用户输入文本"),
|
|
sa.Column("output_text", sa.Text, nullable=True, comment="Agent 输出文本"),
|
|
sa.Column("output_truncated", sa.Boolean, default=False, comment="输出是否被截断"),
|
|
sa.Column("success", sa.Boolean, default=True, comment="是否成功"),
|
|
sa.Column("error_message", sa.Text, nullable=True, comment="错误信息"),
|
|
sa.Column("latency_ms", sa.Integer, nullable=True, comment="总耗时(ms)"),
|
|
sa.Column("iterations_used", sa.Integer, default=0, comment="ReAct 迭代次数"),
|
|
sa.Column("tool_calls_made", sa.Integer, default=0, comment="工具调用总次数"),
|
|
sa.Column("tool_chain", sa.JSON, nullable=True, comment="工具调用链"),
|
|
sa.Column("llm_calls", sa.JSON, nullable=True, comment="LLM调用明细"),
|
|
sa.Column("steps", sa.JSON, nullable=True, comment="执行步骤详情"),
|
|
sa.Column("model", sa.String(100), nullable=True, comment="使用的模型"),
|
|
sa.Column("provider", sa.String(50), nullable=True, comment="模型提供商"),
|
|
sa.Column("user_rating", sa.Integer, nullable=True, comment="用户评分(1-5)"),
|
|
sa.Column("user_feedback", sa.Text, nullable=True, comment="用户反馈文本"),
|
|
sa.Column("knowledge_extracted", sa.Boolean, default=False, comment="是否已提取知识"),
|
|
sa.Column("created_at", sa.DateTime, comment="创建时间"),
|
|
)
|
|
op.create_index("ix_agent_exec_log_agent_id", "agent_execution_logs", ["agent_id"])
|
|
op.create_index("ix_agent_exec_log_goal_id", "agent_execution_logs", ["goal_id"])
|
|
op.create_index("ix_agent_exec_log_task_id", "agent_execution_logs", ["task_id"])
|
|
op.create_index("ix_agent_exec_log_user_id", "agent_execution_logs", ["user_id"])
|
|
op.create_index("ix_agent_exec_log_created_at", "agent_execution_logs", ["created_at"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_agent_exec_log_created_at", table_name="agent_execution_logs")
|
|
op.drop_index("ix_agent_exec_log_user_id", table_name="agent_execution_logs")
|
|
op.drop_index("ix_agent_exec_log_task_id", table_name="agent_execution_logs")
|
|
op.drop_index("ix_agent_exec_log_goal_id", table_name="agent_execution_logs")
|
|
op.drop_index("ix_agent_exec_log_agent_id", table_name="agent_execution_logs")
|
|
op.drop_table("agent_execution_logs")
|