重构仓库目录为统一的 runtime 分层并清理历史 openclaw 残留。

本次迁移将网关/通道/工具/技能/脚本与协议资源集中到新结构,统一路径常量与脚本转发机制,减少顶层噪音并保证运行与测试行为一致。

Made-with: Cursor
This commit is contained in:
oliver 2026-04-25 01:24:23 +08:00
parent ba3836f00f
commit 4a23b715a2
498 changed files with 2760 additions and 2200 deletions

View file

@ -0,0 +1,40 @@
from __future__ import annotations
from typing import Any
def error_shape(code: str, message: str, data: dict[str, Any] | None = None) -> dict[str, Any]:
out: dict[str, Any] = {"code": str(code or "UNKNOWN"), "message": str(message or "")}
if isinstance(data, dict) and data:
out["data"] = data
return out
def assert_valid_params(
params: Any,
validator: Any,
method: str,
respond: Any,
) -> bool:
"""Validate request params and respond with a standardized error on failure."""
try:
ok = bool(validator(params)) if callable(validator) else True
except Exception as exc:
ok = False
err = error_shape("INVALID_REQUEST", f"param validator raised: {type(exc).__name__}")
try:
respond(False, None, err, None)
except Exception:
pass
return False
if ok:
return True
err = error_shape("INVALID_REQUEST", f"invalid params for {str(method or '').strip() or 'unknown'}")
try:
respond(False, None, err, None)
except Exception:
pass
return False
__all__ = ["assert_valid_params", "error_shape"]