实现shell_env支持

This commit is contained in:
朱潮 2026-03-16 13:56:24 +08:00
parent 5d10ed275e
commit da1352550f
3 changed files with 8 additions and 1 deletions

View File

@ -279,6 +279,7 @@ class AgentConfig:
enable_memori=enable_memori,
memori_semantic_search_top_k=bot_config.get("memori_semantic_search_top_k", MEM0_SEMANTIC_SEARCH_TOP_K),
trace_id=trace_id,
shell_env=bot_config.get("shell_env") or {},
)
# 在创建 config 时尽早准备 checkpoint 消息

View File

@ -637,6 +637,7 @@ class BotSettingsUpdate(BaseModel):
tool_response: Optional[bool] = None
skills: Optional[str] = None
is_published: Optional[bool] = None # 是否发布到广场
shell_env: Optional[dict] = None # 自定义 shell 环境变量
class ModelInfo(BaseModel):
@ -674,6 +675,7 @@ class BotSettingsResponse(BaseModel):
enable_thinking: bool
tool_response: bool
skills: Optional[str]
shell_env: Optional[dict] = None # 自定义 shell 环境变量
is_published: bool = False # 是否发布到广场
is_owner: bool = True # 是否是所有者
copied_from: Optional[str] = None # 复制来源的bot id
@ -1816,6 +1818,7 @@ async def get_bot_settings(bot_uuid: str, authorization: Optional[str] = Header(
enable_thinking=settings.get('enable_thinking', False),
tool_response=settings.get('tool_response', False),
skills=settings.get('skills'),
shell_env=settings.get('shell_env'),
is_published=is_published if is_published else False,
is_owner=is_owner,
copied_from=str(copied_from) if copied_from else None,
@ -1891,6 +1894,8 @@ async def update_bot_settings(
update_json['tool_response'] = request.tool_response
if request.skills is not None:
update_json['skills'] = request.skills
if request.shell_env is not None:
update_json['shell_env'] = request.shell_env
# is_published 是表字段,不在 settings JSON 中
need_update_published = request.is_published is not None

View File

@ -530,7 +530,8 @@ async def fetch_bot_config_from_db(bot_user_id: str, user_identifier: Optional[s
"enable_thinking": settings_data.get("enable_thinking", False),
"skills": settings_data.get("skills", []),
"description": settings_data.get("description", ""),
"suggestions": settings_data.get("suggestions", [])
"suggestions": settings_data.get("suggestions", []),
"shell_env": settings_data.get("shell_env") or {},
}
# 处理 dataset_ids