@fefeding/aicmd 0.1.16 → 1.0.4
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/dist/public/index.css +139 -37
- package/dist/public/index.js +464 -34
- package/dist/public/views.css +156 -156
- package/dist/public/views.js +69 -41
- package/dist/public/vue.js +1 -1
- package/dist/server/service/ai.service.d.ts +20 -128
- package/dist/server/service/ai.service.d.ts.map +1 -1
- package/dist/server/service/ai.service.js +359 -649
- package/dist/server/service/ai.service.js.map +1 -1
- package/dist/server/service/ai.service.ts +404 -833
- package/electron/main.js +21 -2
- package/electron/preload.js +9 -0
- package/electron/updater.js +6 -6
- package/package.json +5 -2
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' },
|
package/electron/preload.js
CHANGED
|
@@ -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)
|
package/electron/updater.js
CHANGED
|
@@ -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
|
-
//
|
|
86
|
-
|
|
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.
|
|
3
|
+
"version": "1.0.4",
|
|
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.24",
|
|
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",
|