feat: 添加swarms团队编排功能并优化agent委派系统
- 引入AgentTeamOrchestrator支持多agent协同任务执行 - 增加第三方swarms库依赖并配置git协议替换以改善包管理 - 扩展DelegationManager支持团队任务调度和进度跟踪 - 实现中文bigram分词算法提升中文任务检索准确性 - 调整A2AClient和DelegationManager超时时间从30秒增至600秒 - 优化AgentRunResult状态判断逻辑增加有意义摘要检测 - 修改Dockerfile配置npm仓库镜像地址和git协议映射 - 更新CLI命令行接口支持网关端口配置传递 - 调整提供者超时配置机制增强请求稳定性 - 移除过时的support_group字段简化agent描述符结构 - 增强错误处理和进度事件报告机制改进用户体验
This commit is contained in:
@ -21,6 +21,40 @@ require_file() {
|
||||
fi
|
||||
}
|
||||
|
||||
render_swarms_env_file() {
|
||||
local config_path="$1"
|
||||
local target_path="$2"
|
||||
|
||||
CONFIG_PATH="$config_path" TARGET_PATH="$target_path" python3 - <<'PY'
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
config_path = Path(os.environ["CONFIG_PATH"])
|
||||
target_path = Path(os.environ["TARGET_PATH"])
|
||||
|
||||
data = json.loads(config_path.read_text(encoding="utf-8"))
|
||||
model = str(data.get("agents", {}).get("defaults", {}).get("model") or "").strip()
|
||||
if model and "/" not in model:
|
||||
model = f"openai/{model}"
|
||||
provider_cfg = data.get("providers", {}).get("openai", {}) or {}
|
||||
api_key = str(provider_cfg.get("apiKey") or "").strip()
|
||||
api_base = str(provider_cfg.get("apiBase") or "").strip()
|
||||
|
||||
lines = [
|
||||
'# Generated from /root/.nanobot/config.json for vendored swarms runtime.',
|
||||
'WORKSPACE_DIR="/root/.nanobot/workspace"',
|
||||
'SWARMS_VERBOSE_GLOBAL="False"',
|
||||
'SWARMS_TELEMETRY_ON="false"',
|
||||
f'SWARMS_DEFAULT_MODEL="{model}"',
|
||||
f'OPENAI_API_KEY="{api_key}"',
|
||||
f'OPENAI_API_BASE="{api_base}"',
|
||||
f'OPENAI_BASE_URL="{api_base}"',
|
||||
]
|
||||
target_path.write_text("\n".join(lines) + "\n", encoding="utf-8")
|
||||
PY
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
local status=$?
|
||||
|
||||
@ -51,6 +85,14 @@ fi
|
||||
require_file "$NANOBOT_HOME/config.json" "Missing Boardware Genius config"
|
||||
require_file "$NANOBOT_AUTH_FILE" "Missing web auth users file"
|
||||
|
||||
SWARMS_ENV_FILE="/opt/app/backend/third_party/swarms/.env"
|
||||
render_swarms_env_file "$NANOBOT_HOME/config.json" "$SWARMS_ENV_FILE"
|
||||
if [[ -f "$SWARMS_ENV_FILE" ]]; then
|
||||
set -a
|
||||
. "$SWARMS_ENV_FILE"
|
||||
set +a
|
||||
fi
|
||||
|
||||
export NANOBOT_AUTH_FILE
|
||||
export NANOBOT_RUNTIME_ENV_FILE
|
||||
export PORT="$APP_FRONTEND_PORT"
|
||||
|
||||
Reference in New Issue
Block a user