feat(tools): add OpenClaw remote agent tool integration
- Detect x-openclaw flag in OpenAPI schema and init dedicated config - Implement multimodal input/output (image download, compress, base64) - Add OpenClaw connection test and status validation in tool service - Fix auth_config token check to support both api_key and bearer_token - Inject runtime context (user_id, conversation_id, files) in chat services
This commit is contained in:
@@ -640,7 +640,18 @@ class AgentRunService:
|
||||
multimodal_service = MultimodalService(self.db, model_info)
|
||||
processed_files = await multimodal_service.process_files(files)
|
||||
logger.info(f"处理了 {len(processed_files)} 个文件,provider={provider}")
|
||||
|
||||
#================= 为 OpenClaw 工具注入运行时上下文==========
|
||||
for t in tools:
|
||||
logger.info(f"检查工具: {type(t).__name__}, has_tool_instance={hasattr(t, 'tool_instance')}, is_openclaw={getattr(getattr(t, 'tool_instance', None), '_is_openclaw', 'N/A')}")
|
||||
if hasattr(t, 'tool_instance') and hasattr(t.tool_instance, '_is_openclaw'):
|
||||
if t.tool_instance._is_openclaw:
|
||||
t.tool_instance._user_id = user_id or "anonymous"
|
||||
t.tool_instance._conversation_id = (
|
||||
str(conversation_id) if conversation_id else None)
|
||||
if processed_files:
|
||||
t.tool_instance._uploaded_files = processed_files
|
||||
logger.info(f"已注入 _uploaded_files, 数量: {len(processed_files)}")
|
||||
#================= 为 OpenClaw 工具注入运行时上下文结束==========
|
||||
# 7. 知识库检索
|
||||
context = None
|
||||
|
||||
@@ -890,7 +901,18 @@ class AgentRunService:
|
||||
multimodal_service = MultimodalService(self.db, model_info)
|
||||
processed_files = await multimodal_service.process_files(files)
|
||||
logger.info(f"处理了 {len(processed_files)} 个文件,provider={provider}")
|
||||
|
||||
#============为 OpenClaw 工具注入会话session======
|
||||
# 为 OpenClaw 工具注入运行时上下文
|
||||
for t in tools:
|
||||
if hasattr(t, 'tool_instance') and hasattr(t.tool_instance, '_is_openclaw'):
|
||||
if t.tool_instance._is_openclaw:
|
||||
t.tool_instance._user_id = user_id or "anonymous"
|
||||
t.tool_instance._conversation_id = (
|
||||
str(conversation_id) if conversation_id else None)
|
||||
# 注入用户上传的文件
|
||||
if processed_files:
|
||||
t.tool_instance._uploaded_files = processed_files
|
||||
#============为 OpenClaw 工具注入会话session======
|
||||
# 7. 知识库检索
|
||||
context = None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user