aicq-chat-plugin 2.6.5 → 2.6.7

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "id": "aicq-chat",
3
3
  "name": "AICQ Encrypted Chat",
4
- "version": "2.6.5",
4
+ "version": "2.6.7",
5
5
  "description": "End-to-end encrypted chat plugin for OpenClaw agents — Node.js implementation with full UI",
6
6
  "entry": "index.js",
7
7
  "activation": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicq-chat-plugin",
3
- "version": "2.6.5",
3
+ "version": "2.6.7",
4
4
  "description": "AICQ End-to-end Encrypted Chat Plugin for OpenClaw — Full UI with friend management, group chat, file transfer, and AI agent communication",
5
5
  "main": "index.js",
6
6
  "bin": {
package/public/index.html CHANGED
@@ -419,11 +419,24 @@ let pendingDeleteMsgId = null;
419
419
  const API = '';
420
420
 
421
421
  // ─── API Helper ─────────────────────────────────────────────────────
422
+ function errMsg(err) {
423
+ if (!err) return '未知错误';
424
+ if (typeof err === 'string') return err;
425
+ if (err.message) return err.message;
426
+ if (err.error && typeof err.error === 'string') return err.error;
427
+ if (err.error && typeof err.error === 'object') return errMsg(err.error);
428
+ try { return JSON.stringify(err); } catch { return '未知错误'; }
429
+ }
430
+
422
431
  async function api(method, path, body = null) {
423
432
  const opts = { method, headers: { 'Content-Type': 'application/json' } };
424
433
  if (body) opts.body = JSON.stringify(body);
425
434
  const resp = await fetch(API + path, opts);
426
- return resp.json();
435
+ const data = await resp.json();
436
+ if (!resp.ok && !data.success) {
437
+ throw new Error(errMsg(data.error) || `HTTP ${resp.status}`);
438
+ }
439
+ return data;
427
440
  }
428
441
 
429
442
  // ─── Agents ─────────────────────────────────────────────────────────
@@ -791,7 +804,7 @@ async function uploadFile(input, type) {
791
804
  if (data.success) {
792
805
  await loadMessages();
793
806
  } else {
794
- alert('上传失败: ' + (data.error || '未知错误'));
807
+ alert('上传失败: ' + errMsg(data.error));
795
808
  }
796
809
  } catch (e) {
797
810
  alert('上传失败: ' + e.message);
@@ -882,7 +895,7 @@ async function addFriendByCode() {
882
895
  document.getElementById('friendCodeInput').value = '';
883
896
  await loadFriends();
884
897
  } else {
885
- alert('添加失败: ' + (result.error || '未知错误'));
898
+ alert('添加失败: ' + errMsg(result.error));
886
899
  }
887
900
  } catch (e) {
888
901
  alert('添加失败: ' + e.message);
@@ -1041,7 +1054,7 @@ async function handlePluginAvatarUpload(input) {
1041
1054
  }
1042
1055
  alert('头像已更新');
1043
1056
  } else {
1044
- alert('上传失败: ' + (data.error || '未知错误'));
1057
+ alert('上传失败: ' + errMsg(data.error));
1045
1058
  }
1046
1059
  } catch (e) {
1047
1060
  alert('头像上传失败: ' + e.message);