mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 07:20:44 +08:00
重构仓库目录为统一的 runtime 分层并清理历史 openclaw 残留。
本次迁移将网关/通道/工具/技能/脚本与协议资源集中到新结构,统一路径常量与脚本转发机制,减少顶层噪音并保证运行与测试行为一致。 Made-with: Cursor
This commit is contained in:
parent
ba3836f00f
commit
4a23b715a2
498 changed files with 2760 additions and 2200 deletions
41
runtime/orchestration/session_mapping.py
Normal file
41
runtime/orchestration/session_mapping.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
||||
from oclaw.platform.persistence.sqlite_store import SqliteStore
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SessionMapResult:
|
||||
session_id: str
|
||||
scope: str # "group" | "dm"
|
||||
|
||||
|
||||
def get_or_create_session_for_wecom(
|
||||
store: SqliteStore,
|
||||
*,
|
||||
tenant_id: str,
|
||||
user_id: str,
|
||||
external_user_id: str,
|
||||
external_chat_id: str,
|
||||
is_group: bool,
|
||||
) -> SessionMapResult:
|
||||
"""Group: session per chat_id; DM: session per user_id.
|
||||
|
||||
We store mapping under (tenant, channel, external_chat_id, external_user_id) to keep it simple.
|
||||
"""
|
||||
scope = "group" if bool(is_group) else "dm"
|
||||
# For DM, external_chat_id is often contact id; we still keep it as provided.
|
||||
title = f"wecom:{scope}:{external_chat_id[:8]}"
|
||||
sid = store.get_or_create_channel_session(
|
||||
tenant_id=tenant_id,
|
||||
channel="wecom",
|
||||
external_chat_id=external_chat_id,
|
||||
external_user_id=external_user_id,
|
||||
session_title=title,
|
||||
)
|
||||
return SessionMapResult(session_id=sid, scope=scope)
|
||||
|
||||
|
||||
__all__ = ["SessionMapResult", "get_or_create_session_for_wecom"]
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue