mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-09 03:30:48 +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
|
|
@ -1,53 +0,0 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
|
||||
def _normalize_optional_string(value: Any) -> str | None:
|
||||
if not isinstance(value, str):
|
||||
return None
|
||||
s = value.strip()
|
||||
return s or None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RestartDeliveryContext:
|
||||
channel: str | None = None
|
||||
to: str | None = None
|
||||
account_id: str | None = None
|
||||
|
||||
|
||||
def _parse_restart_delivery_context(params: Any) -> tuple[RestartDeliveryContext | None, str | None]:
|
||||
raw = params.get("deliveryContext") if isinstance(params, dict) else None
|
||||
if not isinstance(raw, dict):
|
||||
return (None, None)
|
||||
channel = _normalize_optional_string(raw.get("channel"))
|
||||
to = _normalize_optional_string(raw.get("to"))
|
||||
account_id = _normalize_optional_string(raw.get("accountId"))
|
||||
ctx = RestartDeliveryContext(channel=channel, to=to, account_id=account_id)
|
||||
normalized_ctx = ctx if (channel or to or account_id) else None
|
||||
thread_id_raw = raw.get("threadId")
|
||||
if isinstance(thread_id_raw, (int, float)) and thread_id_raw == thread_id_raw:
|
||||
thread_id = str(int(thread_id_raw))
|
||||
else:
|
||||
thread_id = _normalize_optional_string(thread_id_raw)
|
||||
return (normalized_ctx, thread_id)
|
||||
|
||||
|
||||
def parse_restart_request_params(params: Any) -> dict[str, Any]:
|
||||
session_key = _normalize_optional_string(params.get("sessionKey") if isinstance(params, dict) else None)
|
||||
delivery_context, thread_id = _parse_restart_delivery_context(params)
|
||||
note = _normalize_optional_string(params.get("note") if isinstance(params, dict) else None)
|
||||
restart_delay_raw = params.get("restartDelayMs") if isinstance(params, dict) else None
|
||||
restart_delay_ms = None
|
||||
if isinstance(restart_delay_raw, (int, float)) and restart_delay_raw == restart_delay_raw:
|
||||
restart_delay_ms = max(0, int(restart_delay_raw))
|
||||
return {
|
||||
"sessionKey": session_key,
|
||||
"deliveryContext": delivery_context.__dict__ if delivery_context else None,
|
||||
"threadId": thread_id,
|
||||
"note": note,
|
||||
"restartDelayMs": restart_delay_ms,
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue