JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix(agentos): repair Web/TUI token auth switch and connect hooks
yechenzhencd443b07b0c6
diff --git a/deploy/yuanrong/.env.example b/deploy/yuanrong/.env.exampleindex bf7c37fb98..8a2aaf8f30 100644--- a/deploy/yuanrong/.env.example+++ b/deploy/yuanrong/.env.example@@ -95,6 +95,10 @@ WEB_PORT=""# 默认 600;<=0 禁用回收。未设置时使用 yaml 配置。SANDBOX_IDLE_TIMEOUT_SECONDS=""+# AgentOS IAM 鉴权(gateway.agentos.auth_enabled=true 时生效)+AGENTOS_AUTH_SERVICE_URL="http://iam-agentos:8080"+AGENTOS_AUTH_TIMEOUT="10"+# 函数ID(单独部署 gateway 时需要指定,由 openYuanrong 注册函数后返回)FUNCTION_ID=""diff --git a/deploy/yuanrong/conf/gateway-config-yuanrong.template.yaml b/deploy/yuanrong/conf/gateway-config-yuanrong.template.yamlindex ccd2afe57a..3fded6e7d9 100644--- a/deploy/yuanrong/conf/gateway-config-yuanrong.template.yaml+++ b/deploy/yuanrong/conf/gateway-config-yuanrong.template.yaml@@ -500,7 +500,8 @@ gateway:connect_timeout_s: 30auth_service_url: ${AGENTOS_AUTH_SERVICE_URL:-http://iam-agentos:8080}timeout: ${AGENTOS_AUTH_TIMEOUT:-10}- auth_enabled: bool = True+ # Web/TUI token 鉴权总开关;默认关闭。true 时创建 AgentOSAuthenticator 校验连接。+ auth_enabled: falseheartbeat:# 心跳间隔(秒),默认 3600diff --git a/jiuwenswarm/extensions/agentos/agentos_router/config.py b/jiuwenswarm/extensions/agentos/agentos_router/config.pyindex e59b26dcfa..2320252300 100644--- a/jiuwenswarm/extensions/agentos/agentos_router/config.py+++ b/jiuwenswarm/extensions/agentos/agentos_router/config.py@@ -49,7 +49,7 @@ class RouterConfig:ssh_channel: SshChannelEndpoint | None = Noneauth_service_url: str = ""timeout: float = 10.0- auth_enabled: bool = True+ auth_enabled: bool = Falsedef agentos_router_selected(config: dict[str, Any]) -> bool:@@ -133,7 +133,7 @@ def load_router_config(config: dict[str, Any]) -> RouterConfig:auth_service_url = str(agentos.get("auth_service_url") or "").strip()timeout = float(agentos.get("timeout") or 10)- auth_enabled = str(agentos.get("auth_enabled", "true")).strip().lower() in ("true", "1", "yes")+ auth_enabled = str(agentos.get("auth_enabled", "false")).strip().lower() in ("true", "1", "yes")# Env wins over yaml (incl. explicit 0 to disable), same as vibeskill.idle_timeout_env = _read_float_env(SANDBOX_IDLE_TIMEOUT_ENV)diff --git a/jiuwenswarm/gateway/app_gateway.py b/jiuwenswarm/gateway/app_gateway.pyindex 50d0d33596..e6c8ec0688 100644--- a/jiuwenswarm/gateway/app_gateway.py+++ b/jiuwenswarm/gateway/app_gateway.py@@ -1910,10 +1910,6 @@ async def _run_with_telemetry(# 回填引用:MessageHandler 实例化早于 ChannelManager,广播全局事件时需经它取 web channel。message_handler.set_channel_manager(channel_manager)- # 装配 AgentOSRouterClient 订阅 Channel 连接事件- subscribe_fn = getattr(client, "set_channel_manager", None)- if callable(subscribe_fn):- subscribe_fn(channel_manager)updater_service = UpdaterService()prewarm_sync_debounce_task: asyncio.Task[None] | None = Noneprewarm_sync_task: asyncio.Task[None] | None = None@@ -2175,6 +2171,11 @@ async def _run_with_telemetry()channel_manager.register_channel_with_inbound(tui_channel, tui_norm_and_forward)+ # Web/TUI 注册后再订阅连接钩子,否则 get_channel 拿不到 channel。+ subscribe_fn = getattr(client, "set_channel_manager", None)+ if callable(subscribe_fn):+ subscribe_fn(channel_manager)+acp_inbound_server = _InboundGatewayServer(lambda msg: _normalize_and_forward_message(msg, channel_manager))diff --git a/jiuwenswarm/resources/config.yaml b/jiuwenswarm/resources/config.yamlindex ed7e3563ce..104a67531e 100644--- a/jiuwenswarm/resources/config.yaml+++ b/jiuwenswarm/resources/config.yaml@@ -952,7 +952,8 @@ gateway:client_keys_dir: "/root/.ssh"auth_service_url: ${AGENTOS_AUTH_SERVICE_URL:-http://iam-agentos:8080}timeout: ${AGENTOS_AUTH_TIMEOUT:-10}- auth_enabled: bool = True+ # Web/TUI token 鉴权总开关;默认关闭。true 时创建 AgentOSAuthenticator 校验连接。+ auth_enabled: falseheartbeat:# 心跳间隔(秒),默认 3600