sync update from LAN repo (source dhk-1 @ 3e87be55)
This commit is contained in:
1 parent
ab6068a7c1
commit
42f2a26fa8
1482 files changed
+227759
-9584
No files matched your search
+46
-3
@@ -30,19 +30,62 @@ EXCLUDED_SYSTEM_THREAD_TYPES = frozenset(
|
||||
"deep_research",
|
||||
"writing_setup",
|
||||
"report_structure_setup",
|
||||
"task-analysis",
|
||||
"task-analysis-qa",
|
||||
"task_deeplink",
|
||||
}
|
||||
)
|
||||
|
||||
# 这些系统线程 id 只存在于编排内部,不进「最近的对话」;loopback 派活必须能跨
|
||||
# 「点击触发的 HTTP 用户」和「绑定 created_by 签发的 JWT」读写,否则会 404 not accessible。
|
||||
SHARED_ACCESS_THREAD_TYPES = frozenset(
|
||||
{
|
||||
"roundtable",
|
||||
"task-analysis",
|
||||
"task-analysis-qa",
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def is_excluded_system_thread(metadata: dict[str, Any] | None) -> bool:
|
||||
"""Return True when a thread should be hidden from user conversation lists."""
|
||||
md = metadata or {}
|
||||
if md.get("system"):
|
||||
"""Return True when a thread should be hidden from user conversation lists.
|
||||
|
||||
Task-analysis seat runs created before ``thread_type`` was stamped still
|
||||
carry ``task_analysis_seat``. Those rows stay in the execution record and
|
||||
out of recent chats.
|
||||
"""
|
||||
md = metadata or {}
|
||||
if md.get("system"):
|
||||
return True
|
||||
# Task-analysis keeps its user-facing history in task_analysis_runs /
|
||||
# task_analysis_run_messages. The underlying LangGraph threads are runtime
|
||||
# implementation details; recognise their task markers as a defensive
|
||||
# fallback in case a legacy caller omitted ``system`` or ``thread_type``.
|
||||
if any(
|
||||
isinstance(md.get(key), str) and md[key].strip()
|
||||
for key in (
|
||||
"task_analysis_task_id",
|
||||
"task_analysis_source_task_id",
|
||||
"task_analysis_run_id",
|
||||
)
|
||||
):
|
||||
return True
|
||||
seat = md.get("task_analysis_seat")
|
||||
if isinstance(seat, str) and seat.strip():
|
||||
return True
|
||||
thread_type = md.get("thread_type")
|
||||
return isinstance(thread_type, str) and thread_type in EXCLUDED_SYSTEM_THREAD_TYPES
|
||||
|
||||
|
||||
def is_shared_access_thread(metadata: dict[str, Any] | None) -> bool:
|
||||
"""Return True when any authenticated caller may read/write this thread."""
|
||||
md = metadata or {}
|
||||
if md.get("taskId"):
|
||||
return True
|
||||
thread_type = md.get("thread_type")
|
||||
return isinstance(thread_type, str) and thread_type in SHARED_ACCESS_THREAD_TYPES
|
||||
|
||||
|
||||
class ThreadMetaStore(abc.ABC):
|
||||
@abc.abstractmethod
|
||||
async def create(
|
||||
|
||||
Reference in new issue
Block a user