Files
zhaoxi 4aa1dab283 feat: 清理 control_node + 引入 task 一等公民
- control_node 标注 DEPRECATED:保留目录壳子供未来远程探针节点复用,删除调用路径与相关测试
- 新增 task 表:极简元数据持久化 regulatory_node 完成的短任务(出报告/写文件/查询整理)
- regulatory_node 自标注:MessageResponse 扩展 task_action/title/summary,_run 末尾非阻塞落库
- query_task_list 改查 task 表,符合用户对"任务列表"的直觉,与 workflow 体系解耦
- 新增 /api/v1/task/list|/{id} 只读 API(task 由 regulatory 内部触发,不开放对外创建)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-17 16:30:19 +00:00

55 lines
2.0 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Copyright 2026 zhaoxi826
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
"""Task:管控节点(regulatory_node)完成的短任务记录。
与 workflow 不同,task 是上下文内能完成的轻量任务(写文件/查询/出报告等),
表里只存最终元数据 + 结果摘要 + 关联 artifact,不入库执行过程。
"""
from sqlalchemy import String, DateTime, Text, func
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy.dialects.postgresql import JSONB
from .base import BaseDataModel
class Task(BaseDataModel):
__tablename__ = "task"
task_id: Mapped[str] = mapped_column(
String(64), primary_key=True, comment="任务唯一 IDUUID"
)
user_id: Mapped[str] = mapped_column(
String(64), index=True, comment="所属用户 ID"
)
chat_id: Mapped[str | None] = mapped_column(
String(64), index=True, nullable=True, comment="所属对话(如有)"
)
command: Mapped[str] = mapped_column(
Text, comment="用户原始指令"
)
title: Mapped[str] = mapped_column(
String(255), comment="任务简短标题(LLM 生成)"
)
status: Mapped[str] = mapped_column(
String(20), index=True, default="completed",
comment="running / completed / failed",
)
result_summary: Mapped[str | None] = mapped_column(
Text, nullable=True, comment="完成后的结果摘要"
)
artifact_refs: Mapped[list | None] = mapped_column(
JSONB, nullable=True, comment="关联的 artifact url 列表"
)
created_at: Mapped[str] = mapped_column(
DateTime(timezone=True), server_default=func.now(), index=True
)
updated_at: Mapped[str] = mapped_column(
DateTime(timezone=True), server_default=func.now(), onupdate=func.now()
)