@fefeding/aicmd 0.1.16 → 1.0.3

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.
package/electron/main.js CHANGED
@@ -110,6 +110,27 @@ function setupApiIPC() {
110
110
  return { ret: 500, msg: err.message || 'Internal error' };
111
111
  }
112
112
  });
113
+
114
+ // 文件上传 IPC 处理(app:// 协议下 fetch 不可用)
115
+ ipcMain.handle('file:upload', async (_event, payload) => {
116
+ const services = getServices();
117
+ if (!services) {
118
+ return { success: false, error: 'Services not available' };
119
+ }
120
+ try {
121
+ const { sessionId, fileName, fileData } = payload;
122
+ if (!sessionId || !fileName || !fileData) {
123
+ return { success: false, error: 'Missing sessionId, fileName, or fileData' };
124
+ }
125
+ console.log(`[IPC] File upload: session=${sessionId}, file=${fileName}, size=${fileData.byteLength || fileData.length}`);
126
+ const buffer = Buffer.from(fileData);
127
+ const bytes = await services.sshService.uploadFileViaSftp(sessionId, fileName, buffer);
128
+ return { success: true, bytes, fileName };
129
+ } catch (err) {
130
+ console.error('[IPC] File upload error:', err);
131
+ return { success: false, error: err.message };
132
+ }
133
+ });
113
134
  }
114
135
 
115
136
  // ========== 终端 IPC 处理(替代 WebSocket) ==========
@@ -424,8 +445,6 @@ function setupMenu() {
424
445
  submenu: [
425
446
  { label: 'About AICmd', click: () => shell.openExternal('https://aigcwhere.com/opensource/aicmd') },
426
447
  { type: 'separator' },
427
- { role: 'services' },
428
- { type: 'separator' },
429
448
  { role: 'hide' },
430
449
  { role: 'hideOthers' },
431
450
  { role: 'unhide' },
@@ -51,6 +51,15 @@ const api = {
51
51
  request(pathname, body) {
52
52
  return ipcRenderer.invoke('api:request', { pathname, body });
53
53
  },
54
+ /**
55
+ * 文件上传(app:// 协议下 fetch 不可用,通过 IPC 上传到主进程)
56
+ * @param {string} sessionId
57
+ * @param {string} fileName
58
+ * @param {ArrayBuffer|Uint8Array} fileData
59
+ */
60
+ uploadFile(sessionId, fileName, fileData) {
61
+ return ipcRenderer.invoke('file:upload', { sessionId, fileName, fileData });
62
+ },
54
63
  };
55
64
 
56
65
  // 剪贴板操作(contextIsolation 下渲染进程无法直接访问 navigator.clipboard)
@@ -17,6 +17,7 @@ const { BrowserWindow, ipcMain, app } = require('electron');
17
17
  let updateAvailable = null;
18
18
  let updateDownloaded = false;
19
19
  let downloadProgress = null;
20
+ let lastProgressBroadcast = 0; // 进度广播节流
20
21
 
21
22
  /**
22
23
  * 向所有窗口广播更新事件
@@ -82,8 +83,10 @@ function initAutoUpdater(options = {}) {
82
83
  transferred: progress.transferred,
83
84
  total: progress.total,
84
85
  };
85
- // 每 10% 广播一次,避免过于频繁
86
- if (downloadProgress.percent % 10 === 0) {
86
+ // 节流:至少间隔 1 秒广播一次
87
+ const now = Date.now();
88
+ if (now - lastProgressBroadcast >= 1000 || downloadProgress.percent >= 100) {
89
+ lastProgressBroadcast = now;
87
90
  broadcastUpdate('progress', downloadProgress);
88
91
  }
89
92
  });
@@ -103,10 +106,7 @@ function initAutoUpdater(options = {}) {
103
106
  updateAvailable = null;
104
107
  updateDownloaded = false;
105
108
  downloadProgress = null;
106
- // 静默处理网络错误,不打扰用户
107
- if (!error.message.includes('net::') && !error.message.includes('ENOTFOUND')) {
108
- broadcastUpdate('error', { message: error.message });
109
- }
109
+ broadcastUpdate('error', { message: error.message });
110
110
  });
111
111
 
112
112
  // 注册 IPC 处理器
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fefeding/aicmd",
3
- "version": "0.1.16",
3
+ "version": "1.0.3",
4
4
  "private": false,
5
5
  "type": "commonjs",
6
6
  "description": "AI-powered web SSH terminal with autonomous agent, skills, and file transfer",
@@ -38,8 +38,8 @@
38
38
  "electron:build:linux": "node scripts/electron-build.js --platform=linux"
39
39
  },
40
40
  "dependencies": {
41
+ "@cicctencent/agent-core": "^0.1.4",
41
42
  "axios": "^1.16.1",
42
- "cpu-features": "^0.0.10",
43
43
  "dayjs": "^1.11.21",
44
44
  "dotenv": "^17.4.2",
45
45
  "electron-updater": "^6.8.3",
@@ -50,6 +50,9 @@
50
50
  "vue-i18n": "^11.4.4",
51
51
  "ws": "^8.21.0"
52
52
  },
53
+ "optionalDependencies": {
54
+ "cpu-features": "^0.0.10"
55
+ },
53
56
  "devDependencies": {
54
57
  "@codemirror/commands": "^6.10.3",
55
58
  "@codemirror/language": "^6.12.3",