myagent-ai 1.23.30 → 1.23.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -281,8 +281,15 @@ class MainAgent(BaseAgent):
281
281
 
282
282
  logger.info(f"[{task_id}] 开始处理用户请求: {context.user_message[:100]}")
283
283
 
284
+ # [v1.23.30] 读取外部注入的 Agent 专属提示词(群聊、多Agent 场景使用)
285
+ # _try_model_chain_inner 通过此属性注入 group_context 等自定义提示词
286
+ _override_prompt = getattr(self, '_agent_override_prompt', None)
287
+
284
288
  try:
285
- return await self.process_v2(context)
289
+ return await self.process_v2(
290
+ context,
291
+ agent_override_prompt=_override_prompt,
292
+ )
286
293
  finally:
287
294
  # 移除活跃上下文
288
295
  self.active_contexts.pop(context.session_id, None)
@@ -182,7 +182,7 @@ class ToolDispatcher:
182
182
  )
183
183
  result = exec_result.to_dict()
184
184
 
185
- output = result.get("output", "")
185
+ output = result.get("stdout", "") or result.get("output", "")
186
186
  import re as _re
187
187
 
188
188
  # [v1.23.0] 检测 __SEND_FILE__ 标记 — CLI send-file 命令输出此标记
@@ -225,7 +225,8 @@ class ToolDispatcher:
225
225
  if not media_result.get("success"):
226
226
  result["output"] += f"\n[音频播放失败: {media_result.get('error', '')}]"
227
227
  if video_markers:
228
- clean_output = result.get("output", "")
228
+ # [v1.23.32] 修复: result 可能没有 output key(来自 to_dict 的 stdout)
229
+ clean_output = result.get("output", "") or clean_output
229
230
  clean_output = _re.sub(r'__EMBED_VIDEO__.+?__END__\n?', '', clean_output).strip()
230
231
  result["output"] = clean_output
231
232
  for media_url, media_title in video_markers:
@@ -261,6 +262,10 @@ class ToolDispatcher:
261
262
  except Exception:
262
263
  pass
263
264
 
265
+ # [v1.23.32] 确保 result 始终有 output 字段(to_dict 返回 stdout,V2 循环依赖 output)
266
+ if "output" not in result:
267
+ result["output"] = clean_output
268
+
264
269
  return result
265
270
 
266
271
  async def _exec_recall_memory(self, params: Dict, task_id: str) -> Dict:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myagent-ai",
3
- "version": "1.23.30",
3
+ "version": "1.23.32",
4
4
  "description": "本地桌面端执行型AI助手 - Open Interpreter 风格 | Local Desktop Execution-Oriented AI Assistant",
5
5
  "main": "main.py",
6
6
  "bin": {
@@ -811,6 +811,114 @@ function updateStreamingMessage(msgIdx) {
811
811
  }
812
812
  }
813
813
  }
814
+
815
+ // [v1.23.30] 文件卡片渲染(backward compat 路径 — 确保无 parts 时也能显示文件)
816
+ if (msg._files && msg._files.length > 0) {
817
+ var bcImageContainer = contentArea.querySelector(':scope > .msg-attachments-images');
818
+ var bcExistingFiles = contentArea.querySelectorAll(':scope > .msg-attachments-files');
819
+ var bcFileContainer = bcExistingFiles.length > 0 ? bcExistingFiles[0] : null;
820
+ var bcRenderedIds = (bcFileContainer ? bcFileContainer._renderedFileIds : []) || [];
821
+ var bcRenderedImageIds = (bcImageContainer ? bcImageContainer._renderedImageIds : []) || [];
822
+ for (var _bcFi = 0; _bcFi < msg._files.length; _bcFi++) {
823
+ var _bcF = msg._files[_bcFi];
824
+ var _bcFId = _bcF.id || _bcF.file_id || '';
825
+ if (bcRenderedIds.indexOf(_bcFId) >= 0 || bcRenderedImageIds.indexOf(_bcFId) >= 0) continue;
826
+ var _bcIsImg = _bcF.type && _bcF.type.indexOf('image/') === 0;
827
+ var _bcIsAud = _bcF.type && _bcF.type.indexOf('audio/') === 0;
828
+ var _bcIsVid = _bcF.type && _bcF.type.indexOf('video/') === 0;
829
+ if (_bcIsImg || _bcIsAud || _bcIsVid) {
830
+ if (!bcImageContainer) {
831
+ bcImageContainer = document.createElement('div');
832
+ bcImageContainer.className = 'msg-attachments msg-attachments-images';
833
+ bcImageContainer._renderedImageIds = [];
834
+ var bcBubble = contentArea.querySelector('.message-bubble');
835
+ if (bcBubble) {
836
+ contentArea.insertBefore(bcImageContainer, bcBubble);
837
+ } else {
838
+ contentArea.appendChild(bcImageContainer);
839
+ }
840
+ }
841
+ if (_bcIsImg && _bcFId) {
842
+ var _bcImgDiv = document.createElement('div');
843
+ _bcImgDiv.className = 'msg-image-wrapper agent-image';
844
+ _bcImgDiv.innerHTML = '<img src="/api/file/' + _bcFId + '" class="msg-image" loading="lazy" alt="' + escapeHtml(_bcF.name || 'image') + '" onclick="openFileViewer(\'' + _bcFId + '\', this.src, \'' + escapeHtml(_bcF.name) + '\')" />';
845
+ bcImageContainer.appendChild(_bcImgDiv);
846
+ } else if (_bcIsAud && _bcFId) {
847
+ var _bcAudDiv = document.createElement('div');
848
+ _bcAudDiv.className = 'msg-media-player';
849
+ _bcAudDiv.innerHTML = '<audio controls src="/api/file/' + _bcFId + '" style="width:100%;max-width:480px" preload="metadata"></audio><div class="msg-media-title">' + escapeHtml(_bcF.name || '音频') + '</div>';
850
+ bcImageContainer.appendChild(_bcAudDiv);
851
+ } else if (_bcIsVid && _bcFId) {
852
+ var _bcVidDiv = document.createElement('div');
853
+ _bcVidDiv.className = 'msg-media-player';
854
+ _bcVidDiv.innerHTML = '<video controls src="/api/file/' + _bcFId + '" style="width:100%;max-width:640px;border-radius:8px" preload="metadata"></video><div class="msg-media-title">' + escapeHtml(_bcF.name || '视频') + '</div>';
855
+ bcImageContainer.appendChild(_bcVidDiv);
856
+ }
857
+ bcImageContainer._renderedImageIds.push(_bcFId);
858
+ continue;
859
+ }
860
+ if (!bcFileContainer) {
861
+ bcFileContainer = document.createElement('div');
862
+ bcFileContainer.className = 'msg-attachments msg-attachments-files';
863
+ bcFileContainer._renderedFileIds = [];
864
+ var bcBubble2 = contentArea.querySelector('.message-bubble');
865
+ if (bcBubble2) {
866
+ bcBubble2.parentNode.insertBefore(bcFileContainer, bcBubble2.nextSibling);
867
+ } else {
868
+ contentArea.appendChild(bcFileContainer);
869
+ }
870
+ }
871
+ var _bcIcon = _getFileIcon(_bcF.name || _bcF.type || '');
872
+ var _bcSizeStr = _bcF.size ? formatFileSize(_bcF.size) : '';
873
+ var _bcFDiv = document.createElement('div');
874
+ _bcFDiv.className = 'msg-file-item agent-file';
875
+ _bcFDiv.title = '点击预览';
876
+ _bcFDiv.innerHTML = '<span class="msg-file-icon">' + _bcIcon + '</span>' +
877
+ '<span class="msg-file-info"><span class="msg-file-name">' + escapeHtml(_bcF.name) + '</span>' +
878
+ (_bcSizeStr ? '<span class="msg-file-size">' + _bcSizeStr + '</span>' : '') +
879
+ '</span>' +
880
+ '<span class="msg-file-actions">' +
881
+ '<a class="msg-file-download" href="/api/file/' + (_bcFId || '') + '?name=' + encodeURIComponent(_bcF.name || 'file') + '" download="' + escapeHtml(_bcF.name) + '" title="下载" onclick="event.stopPropagation()">⬇</a>' +
882
+ '</span>';
883
+ bcFileContainer.appendChild(_bcFDiv);
884
+ bcFileContainer._renderedFileIds.push(_bcFId);
885
+ }
886
+ }
887
+
888
+ // [v1.23.30] 在线媒体嵌入渲染(backward compat 路径)
889
+ if (msg._media && msg._media.length > 0) {
890
+ var bcExistingMedia = contentArea.querySelectorAll(':scope > .msg-attachments-media');
891
+ var bcMediaContainer = bcExistingMedia.length > 0 ? bcExistingMedia[0] : null;
892
+ if (!bcMediaContainer) {
893
+ bcMediaContainer = document.createElement('div');
894
+ bcMediaContainer.className = 'msg-attachments msg-attachments-media';
895
+ var bcBubble3 = contentArea.querySelector('.message-bubble');
896
+ if (bcBubble3) {
897
+ contentArea.insertBefore(bcMediaContainer, bcBubble3);
898
+ } else {
899
+ contentArea.appendChild(bcMediaContainer);
900
+ }
901
+ }
902
+ var bcRenderedMediaUrls = bcMediaContainer._renderedMediaUrls || [];
903
+ for (var _bcMi = 0; _bcMi < msg._media.length; _bcMi++) {
904
+ var _bcM = msg._media[_bcMi];
905
+ var _bcMUrl = _bcM.embed_url || _bcM.original_url || '';
906
+ if (!_bcMUrl || bcRenderedMediaUrls.indexOf(_bcMUrl) >= 0) continue;
907
+ var _bcMIsAud = _bcM.media_type === 'audio';
908
+ var _bcMTitle = _bcM.title || (_bcMIsAud ? '在线音乐' : '在线视频');
909
+ var _bcMDiv = document.createElement('div');
910
+ _bcMDiv.className = 'msg-media-embed' + (_bcMIsAud ? ' msg-media-audio' : ' msg-media-video');
911
+ if (_bcM.embed_url) {
912
+ _bcMDiv.innerHTML = '<div class="msg-media-header"><span class="msg-media-icon">' + (_bcMIsAud ? '🎵' : '🎬') + '</span><span class="msg-media-label">' + escapeHtml(_bcMTitle) + '</span></div><iframe src="' + escapeHtml(_bcMUrl) + '" style="width:100%;max-width:' + (_bcMIsAud ? '480' : '640') + 'px;height:' + (_bcMIsAud ? '80' : '360') + 'px;border:none;border-radius:8px" loading="lazy" allow="autoplay;encrypted-media;picture-in-picture" allowfullscreen></iframe>';
913
+ } else {
914
+ _bcMDiv.style.cssText = 'padding:10px 14px;border-radius:8px;background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.1);cursor:pointer';
915
+ _bcMDiv.innerHTML = '<div class="msg-media-header"><span class="msg-media-icon">' + (_bcMIsAud ? '🎵' : '🎬') + '</span><span class="msg-media-label">' + escapeHtml(_bcMTitle) + '</span></div>';
916
+ }
917
+ bcMediaContainer.appendChild(_bcMDiv);
918
+ bcRenderedMediaUrls.push(_bcMUrl);
919
+ }
920
+ bcMediaContainer._renderedMediaUrls = bcRenderedMediaUrls;
921
+ }
814
922
  }
815
923
 
816
924
  // Update streaming indicator