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
feature(deploy): sync yuanrong gateway template with AgentOS SSH defaults
yechenzhen69c026a66132
diff --git a/deploy/yuanrong/.env.example b/deploy/yuanrong/.env.exampleindex b3975d7660..99cfba5f93 100644--- a/deploy/yuanrong/.env.example+++ b/deploy/yuanrong/.env.example@@ -72,6 +72,25 @@ MASTER_NODE_IP=""# 元戎Frontend端口(单独部署 gateway 时需要指定,默认8888)FRONTEND_PORT=""+# Agent OS 注册中心端口(单独部署 gateway 时可指定,默认4003)+REGISTRY_PORT=""++# SSH channel 监听端口(单独部署 gateway 时可指定,默认2223)+# 监听 IP 使用 MASTER_NODE_IP+SSH_PORT=""++# TUI GatewayServer 监听地址(/tui)+# HOST 不设置时部署脚本会自动填成 MASTER_NODE_IP+GATEWAY_HOST=""+# TUI 监听端口;空则 check_handler 填默认 19001+GATEWAY_PORT=""++# WebChannel 监听地址(/ws)+# HOST 不设置时部署脚本会自动填成 MASTER_NODE_IP+WEB_HOST=""+# WebChannel 监听端口;空则 check_handler 填默认 19000+WEB_PORT=""+# 函数ID(单独部署 gateway 时需要指定,由 openYuanrong 注册函数后返回)FUNCTION_ID=""diff --git a/deploy/yuanrong/check_handler.sh b/deploy/yuanrong/check_handler.shindex 43e2e0ab04..bd68001201 100755--- a/deploy/yuanrong/check_handler.sh+++ b/deploy/yuanrong/check_handler.sh@@ -103,6 +103,38 @@ check_gateway_up_dependency() {warning "FRONTEND_PORT not set, using default: 8888"fi+ if [ -z "${DEPLOY_VARS["REGISTRY_PORT"]:-}" ]; then+ DEPLOY_VARS["REGISTRY_PORT"]="4003"+ warning "REGISTRY_PORT not set, using default: 4003"+ fi++ if [ -z "${DEPLOY_VARS["SSH_PORT"]:-}" ]; then+ DEPLOY_VARS["SSH_PORT"]="2223"+ warning "SSH_PORT not set, using default: 2223"+ fi++ # TUI (/tui on GatewayServer) bind host defaults to master node IP.+ if [ -z "${DEPLOY_VARS["GATEWAY_HOST"]:-}" ]; then+ DEPLOY_VARS["GATEWAY_HOST"]="${DEPLOY_VARS["MASTER_NODE_IP"]}"+ info "GATEWAY_HOST not set, using MASTER_NODE_IP: ${DEPLOY_VARS["GATEWAY_HOST"]}"+ fi++ if [ -z "${DEPLOY_VARS["GATEWAY_PORT"]:-}" ]; then+ DEPLOY_VARS["GATEWAY_PORT"]="19001"+ warning "GATEWAY_PORT not set, using default: 19001"+ fi++ # WebChannel (/ws) bind host defaults to master node IP.+ if [ -z "${DEPLOY_VARS["WEB_HOST"]:-}" ]; then+ DEPLOY_VARS["WEB_HOST"]="${DEPLOY_VARS["MASTER_NODE_IP"]}"+ info "WEB_HOST not set, using MASTER_NODE_IP: ${DEPLOY_VARS["WEB_HOST"]}"+ fi++ if [ -z "${DEPLOY_VARS["WEB_PORT"]:-}" ]; then+ DEPLOY_VARS["WEB_PORT"]="19000"+ warning "WEB_PORT not set, using default: 19000"+ fi+if [ -z "${DEPLOY_VARS["FUNCTION_ID"]:-}" ]; thenerror "FUNCTION_ID is not set. Please deploy jiuwenswarm first or set FUNCTION_ID in .env.custom."fidiff --git a/deploy/yuanrong/conf/gateway-config-yuanrong.template.yaml b/deploy/yuanrong/conf/gateway-config-yuanrong.template.yamlindex 070c59b96b..84e51e6090 100644--- a/deploy/yuanrong/conf/gateway-config-yuanrong.template.yaml+++ b/deploy/yuanrong/conf/gateway-config-yuanrong.template.yaml@@ -478,15 +478,41 @@ gateway:# AgentClient 配置 - Gateway 连接到 AgentServer 的方式# type: websocket(默认) | yuanrong(直接函数调用) | agentos_router(AgentOS 扩展)agent_client:- type: yuanrong # websocket | yuanrong | agentos_router- # yuanrong 函数模式配置下面参数+ type: agentos_router # websocket | yuanrong | agentos_router+ # yuanrong / agentos_router 共用下面参数frontend_endpoint: http://<<MASTER_NODE_IP>>:<<FRONTEND_PORT>>function_version_urn: <<FUNCTION_ID>>concurrency: <<GATEWAY_CONCURRENCY>>invoke_timeout_s: <<GATEWAY_INVOKE_TIMEOUT>>+ # POST/DELETE /api/agent 超时(秒);create 含镜像拉取/容器启动,建议明显大于 invoke_timeout_sagent_timeout_s: 300+ # create 请求的 namespace,默认 defaultagent_namespace: default+ # AgentOS Router Extension 配置;agent_client.type=agentos_router 时生效。+ # 默认 agent_type=jiuwenswarm 直走 YuanRong URN invoke(与 type=yuanrong 对齐);+ # opencode/claude 走 registry launch-spec + create_sandbox。+ agentos:+ creating_timeout_seconds: 60+ # Agent 复用 key 字段,默认 user_id + agent_type。+ # 可选字段:user_id、agent_type、session_id(必须包含前两项)。+ agent_key_fields:+ - user_id+ - agent_type+ registry:+ # Agent OS 注册中心:host 来自 --hosts / CLUSTER_HOSTS 的 master IP+ endpoint: http://<<MASTER_NODE_IP>>:<<REGISTRY_PORT>>+ request_timeout_s: 10+ # 本机 nodeIP,供 POST /api/nodes/{node}/heartbeat+ node: <<MASTER_NODE_IP>>+ # SSH 南向接入 YuanRong 实例(配合 channels.ssh 北向使用):+ # ssh -p <port> 'yr:instance:<instance_id>'@<frontend-host>+ # 主机取自 agent_client.frontend_endpoint;<instance_id> 为 create agent 返回的实例 id。+ ssh:+ port: 2222+ user_template: "yr:instance:{instance}"+ connect_timeout_s: 30+heartbeat:# 心跳间隔(秒),默认 3600every: 3600@@ -644,6 +670,19 @@ channels:my_user_id: ""bot_name: ""enable_memory: false+ ssh:+ # SSH channel -> MessageHandler(北向);南向经 gateway.agent_client+ # (type=agentos_router 时由 AgentOS Router 创建 YuanRong 实例并+ # 以 yr:instance:<instance_id> 中继到 frontend)。+ # 启用前请安装可选依赖: pip install "jiuwenswarm[ssh]" 或 uv sync --extra ssh+ # 客户端: ssh -p <listen_port> user@<gateway-host>+ # 南向连接参数见 gateway.agentos.ssh;agent_type 跟随用户当前值(3rdagent.switch)。+ enabled: true+ # 监听 IP:host 来自 --hosts / CLUSTER_HOSTS 的 master IP+ listen_host: <<MASTER_NODE_IP>>+ listen_port: <<SSH_PORT>>+ host_key_path: ~/.jiuwenswarm/config/ssh_host_key+ relay_timeout_sec: 3600# ========== 细粒度权限管控(tiered_policy)==========#diff --git a/deploy/yuanrong/global_vars.sh b/deploy/yuanrong/global_vars.shindex c6529fc07a..5ed5dd459f 100755--- a/deploy/yuanrong/global_vars.sh+++ b/deploy/yuanrong/global_vars.sh@@ -47,6 +47,14 @@ declare -A DEPLOY_VARS=(["FRONTEND_PORT"]=""["FUNCTION_ID"]=""["MASTER_NODE_IP"]=""+ ["REGISTRY_PORT"]=""+ ["SSH_PORT"]=""+ # TUI GatewayServer bind host; empty → default to MASTER_NODE_IP at deploy check time+ ["GATEWAY_HOST"]=""+ ["GATEWAY_PORT"]=""+ # WebChannel bind host; empty → default to MASTER_NODE_IP at deploy check time+ ["WEB_HOST"]=""+ ["WEB_PORT"]=""["OS_TYPE"]=""["EXTENSION_DIRS"]="")diff --git a/jiuwenswarm/gateway/app_gateway.py b/jiuwenswarm/gateway/app_gateway.pyindex 10fe28daca..9fc7ed7da3 100644--- a/jiuwenswarm/gateway/app_gateway.py+++ b/jiuwenswarm/gateway/app_gateway.py@@ -2426,8 +2426,24 @@ async def _run(if isinstance(ssh_conf, dict):# 南向经 agent client(如 agentos_router -> yuanrong)动态解析。enabled, reason = _is_channel_enabled(ssh_conf, ["listen_port"])+ full_cfg = get_config()+ gateway_cfg = full_cfg.get("gateway") if isinstance(full_cfg, dict) else {}+ agent_client_cfg = (+ gateway_cfg.get("agent_client") if isinstance(gateway_cfg, dict) else {}+ )+ client_type = (+ str(agent_client_cfg.get("type") or "websocket").strip().lower()+ if isinstance(agent_client_cfg, dict)+ else "websocket"+ )if not enabled:logger.info("[App] channels.ssh.%s, SshChannel disabled", reason)+ elif client_type != "agentos_router":+ logger.warning(+ "[App] channels.ssh.enabled=true but gateway.agent_client.type=%s "+ "(require agentos_router); SshChannel will not start",+ client_type,+ )else:ssh_config = SshChannelConfig.from_dict({**ssh_conf, "enabled": True})ssh_channel = SshChannel(ssh_config, _DummyBus())