Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(weixin): fix test file version reader
xcosmosbox2dce5e07c1db
diff --git a/nanobot/channels/weixin.py b/nanobot/channels/weixin.pyindex 4341f21d1..7f6c6abab 100644--- a/nanobot/channels/weixin.py+++ b/nanobot/channels/weixin.py@@ -54,19 +54,8 @@ MESSAGE_TYPE_BOT = 2MESSAGE_STATE_FINISH = 2WEIXIN_MAX_MESSAGE_LEN = 4000---def _read_reference_package_meta() -> dict[str, str]:- """Best-effort read of reference `package/package.json` metadata."""- try:- pkg_path = Path(__file__).resolve().parents[2] / "package" / "package.json"- data = json.loads(pkg_path.read_text(encoding="utf-8"))- return {- "version": str(data.get("version", "") or ""),- "ilink_appid": str(data.get("ilink_appid", "") or ""),- }- except Exception:- return {"version": "", "ilink_appid": ""}+WEIXIN_CHANNEL_VERSION = "2.1.1"+ILINK_APP_ID = "bot"def _build_client_version(version: str) -> int:@@ -84,11 +73,7 @@ def _build_client_version(version: str) -> int:patch = _as_int(2)return ((major & 0xFF) << 16) | ((minor & 0xFF) << 8) | (patch & 0xFF)--_PKG_META = _read_reference_package_meta()-WEIXIN_CHANNEL_VERSION = _PKG_META["version"] or "unknown"-ILINK_APP_ID = _PKG_META["ilink_appid"]-ILINK_APP_CLIENT_VERSION = _build_client_version(_PKG_META["version"] or "0.0.0")+ILINK_APP_CLIENT_VERSION = _build_client_version(WEIXIN_CHANNEL_VERSION)BASE_INFO: dict[str, str] = {"channel_version": WEIXIN_CHANNEL_VERSION}# Session-expired error codediff --git a/tests/channels/test_weixin_channel.py b/tests/channels/test_weixin_channel.pyindex c4e5cf552..f4d57a8b0 100644--- a/tests/channels/test_weixin_channel.py+++ b/tests/channels/test_weixin_channel.py@@ -52,8 +52,7 @@ def test_make_headers_includes_route_tag_when_configured() -> None:def test_channel_version_matches_reference_plugin_version() -> None:- pkg = json.loads(Path("package/package.json").read_text())- assert WEIXIN_CHANNEL_VERSION == pkg["version"]+ assert WEIXIN_CHANNEL_VERSION == "2.1.1"def test_save_and_load_state_persists_context_tokens(tmp_path) -> None: