ForcePilot/backend/package/yuxi/channel/extensions/flock/threading.py

32 lines
874 B
Python
Raw Normal View History

from __future__ import annotations
from yuxi.channel.protocols import ReplyTransport
def extract_thread_id(msg) -> str | None:
if hasattr(msg, "message_thread_id"):
return msg.message_thread_id
if hasattr(msg, "raw_payload"):
raw = msg.raw_payload
if isinstance(raw, dict):
event = raw.get("event", {})
if isinstance(event, dict):
message = event.get("message", {})
if isinstance(message, dict):
return message.get("threadId")
return None
def resolve_reply_transport(msg, thread_id: str | None) -> ReplyTransport:
return ReplyTransport(mode="inline", thread_id=thread_id)
def resolve_auto_thread_id(
config: dict,
account_id: str,
to: str,
tool_context=None,
reply_to_id: str | None = None,
) -> str | None:
return reply_to_id