@myassis/gateway 1.0.4 → 1.0.6
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/middleware/auth.js +1 -1
- package/dist/routes/agent.js +6 -6
- package/dist/routes/upload.js +3 -3
- package/dist/services/TaskSchedulerService.js +1 -1
- package/dist/services/TaskService.js +1 -1
- package/dist/services/agent/AgentManager.js +2 -2
- package/dist/services/llm/LLMClient.js +1 -1
- package/dist/services/memory/MemoryManager.js +2 -2
- package/dist/services/session/Session.js +6 -6
- package/dist/services/session/SessionManager.js +1 -1
- package/dist/services/systemPrompt.js +1 -1
- package/dist/services/tools/keyboard.js +63 -61
- package/dist/services/tools/model.js +1 -1
- package/dist/services/tools/mouse.js +67 -45
- package/dist/services/tools/skill.js +1 -1
- package/dist/services/tools/task.js +1 -1
- package/package.json +6 -5
- package/scripts/fix-all-aliases.js +112 -0
package/dist/middleware/auth.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 从请求头 Authorization: Bearer <token> 解码 JWT,提取 userId
|
|
4
4
|
* 同时保留原始 token 供路由转发给 Server
|
|
5
5
|
*/
|
|
6
|
-
import { authStore } from '
|
|
6
|
+
import { authStore } from '@/stores';
|
|
7
7
|
import { getLogger } from '@myassis/shared';
|
|
8
8
|
const logger = getLogger('middleware/auth');
|
|
9
9
|
const JWT_SECRET = process.env.JWT_SECRET || 'your-secret-key-change-in-production';
|
package/dist/routes/agent.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
|
-
import { requireAuth } from '
|
|
3
|
-
import { runWithToken } from '
|
|
4
|
-
import { getSessionManager } from '
|
|
5
|
-
import { initAgentManager, agentManagerMap } from '
|
|
6
|
-
import { AgentStore } from '
|
|
2
|
+
import { requireAuth } from '@/middleware/auth.js';
|
|
3
|
+
import { runWithToken } from '@/api/index.js';
|
|
4
|
+
import { getSessionManager } from '@/services/session';
|
|
5
|
+
import { initAgentManager, agentManagerMap } from '@/services/agent/AgentManager';
|
|
6
|
+
import { AgentStore } from '@/services/agent/AgentStore';
|
|
7
7
|
import { getLogger } from '@myassis/shared';
|
|
8
8
|
const logger = getLogger('AgentRoutes');
|
|
9
|
-
import { sessionStore } from '
|
|
9
|
+
import { sessionStore } from '@/services/session/SessionStore';
|
|
10
10
|
const router = Router();
|
|
11
11
|
// 所有路由需要认证
|
|
12
12
|
router.use(requireAuth, (req, _res, next) => {
|
package/dist/routes/upload.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import multer from 'multer';
|
|
3
|
-
import { appConfig } from '
|
|
4
|
-
import { requireAuth } from '
|
|
5
|
-
import { runWithToken } from '
|
|
3
|
+
import { appConfig } from '@/config/index.js';
|
|
4
|
+
import { requireAuth } from '@/middleware/auth.js';
|
|
5
|
+
import { runWithToken } from '@/api/index.js';
|
|
6
6
|
import { getLogger } from '@myassis/shared';
|
|
7
7
|
const logger = getLogger('UploadRoutes');
|
|
8
8
|
const router = Router();
|
|
@@ -8,7 +8,7 @@ import { webSocketService } from './WebSocketService';
|
|
|
8
8
|
import { getSessionManager } from './session';
|
|
9
9
|
import { getLogger, getUTCTimeKey, formatUTCForLog, holidayService } from '@myassis/shared';
|
|
10
10
|
import { tasksService } from './dataService';
|
|
11
|
-
import { authStore } from '
|
|
11
|
+
import { authStore } from '@/stores';
|
|
12
12
|
const logger = getLogger('TaskSchedulerService');
|
|
13
13
|
const EXPIRED_THRESHOLD = 60 * 60 * 1000; // 1小时
|
|
14
14
|
const CHECK_INTERVAL = 60 * 1000; // 1分钟
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* - platformApply === currentPlatform → 本地 SQLite 存储(localTaskService)
|
|
8
8
|
* - platformApply !== currentPlatform → 服务器 API(tasksApi)
|
|
9
9
|
*/
|
|
10
|
-
import { authStore } from '
|
|
10
|
+
import { authStore } from '@/stores';
|
|
11
11
|
import { tasksApi } from '../api';
|
|
12
12
|
import { localTaskService } from './LocalTaskService';
|
|
13
13
|
import { getLogger } from '@myassis/shared';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { Agent } from './Agent';
|
|
3
3
|
import { getSessionManager } from '../session/SessionManager';
|
|
4
|
-
import { authStore } from '
|
|
4
|
+
import { authStore } from '@/stores/authStore';
|
|
5
5
|
import { getLogger } from '@myassis/shared';
|
|
6
|
-
import appConfig from '
|
|
6
|
+
import appConfig from '@/config';
|
|
7
7
|
const logger = getLogger('AgentManager');
|
|
8
8
|
/**
|
|
9
9
|
* AgentManager - Business logic layer
|
|
@@ -2,9 +2,9 @@ import { getLogger } from '@myassis/shared';
|
|
|
2
2
|
const logger = getLogger('MemoryManager');
|
|
3
3
|
import { toModel } from '../models';
|
|
4
4
|
import { modelsService } from '../dataService';
|
|
5
|
-
import { authStore } from '
|
|
5
|
+
import { authStore } from '@/stores';
|
|
6
6
|
import { LLMClient } from '../llm/LLMClient';
|
|
7
|
-
import { appConfig } from '
|
|
7
|
+
import { appConfig } from '@/config';
|
|
8
8
|
const DEFAULT_CONFIG = {
|
|
9
9
|
summaryThreshold: 10,
|
|
10
10
|
enabled: true,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { getLogger } from '@myassis/shared';
|
|
3
3
|
import { SessionStore } from './SessionStore';
|
|
4
|
-
import { AgentStore } from '
|
|
5
|
-
import { authStore } from '
|
|
6
|
-
import { toModel } from '
|
|
7
|
-
import { executeTool, getToolDefinitions } from '
|
|
4
|
+
import { AgentStore } from '@/services/agent/AgentStore';
|
|
5
|
+
import { authStore } from '@/stores/authStore';
|
|
6
|
+
import { toModel } from '@/services/models';
|
|
7
|
+
import { executeTool, getToolDefinitions } from '@/services/tools';
|
|
8
8
|
import { getSystemPromptAsync } from '../systemPrompt';
|
|
9
9
|
import { LLMClient, parseAruments } from '../llm/LLMClient';
|
|
10
|
-
import { modelsService, settingsService } from '
|
|
10
|
+
import { modelsService, settingsService } from '@/services/dataService';
|
|
11
11
|
import { MemoryManager } from '../memory/MemoryManager';
|
|
12
|
-
import { appConfig } from '
|
|
12
|
+
import { appConfig } from '@/config';
|
|
13
13
|
import { getSessionManager } from './SessionManager';
|
|
14
14
|
const logger = getLogger('Session');
|
|
15
15
|
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
@@ -2,7 +2,7 @@ import { v4 as uuidv4 } from 'uuid';
|
|
|
2
2
|
import { getLogger } from '@myassis/shared';
|
|
3
3
|
const logger = getLogger('SessionManager');
|
|
4
4
|
import { sessionStore } from './SessionStore';
|
|
5
|
-
import { authStore } from '
|
|
5
|
+
import { authStore } from '@/stores/authStore';
|
|
6
6
|
import { Session } from './Session';
|
|
7
7
|
/**
|
|
8
8
|
* SessionManager - Business logic layer
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { keyboard, Key } from '@nut-tree/nut-js';
|
|
2
|
-
//
|
|
1
|
+
import { keyboard, Key } from '@nut-tree-fork/nut-js';
|
|
2
|
+
// 鍙墦鍗?ASCII 瀛楃鑼冨洿锛堢┖鏍煎埌 ~锛?
|
|
3
3
|
const PRINTABLE_ASCII_START = 32;
|
|
4
4
|
const PRINTABLE_ASCII_END = 126;
|
|
5
|
-
//
|
|
5
|
+
// 鏍¢獙鏂囨湰涓殑鎵€鏈夊瓧绗︽槸鍚﹂兘鏄敭鐩樺彲杈撳叆鐨勫瓧绗?
|
|
6
6
|
function validateText(text) {
|
|
7
7
|
for (let i = 0; i < text.length; i++) {
|
|
8
8
|
const charCode = text.charCodeAt(i);
|
|
9
|
-
//
|
|
9
|
+
// 妫€鏌ユ槸鍚﹀湪鍙墦鍗?ASCII 鑼冨洿鍐?
|
|
10
10
|
if (charCode < PRINTABLE_ASCII_START || charCode > PRINTABLE_ASCII_END) {
|
|
11
11
|
return { valid: false, invalidChar: text[i], charCode };
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
return { valid: true };
|
|
15
15
|
}
|
|
16
|
-
//
|
|
16
|
+
// 鎸夐敭鍚嶇О鍒?nut-js Key 鐨勬槧灏?
|
|
17
17
|
const keyMap = {
|
|
18
|
-
//
|
|
18
|
+
// 甯哥敤閿?
|
|
19
19
|
enter: Key.Enter,
|
|
20
20
|
return: Key.Enter,
|
|
21
21
|
escape: Key.Escape,
|
|
@@ -25,12 +25,12 @@ const keyMap = {
|
|
|
25
25
|
backspace: Key.Backspace,
|
|
26
26
|
delete: Key.Delete,
|
|
27
27
|
del: Key.Delete,
|
|
28
|
-
//
|
|
28
|
+
// 鏂瑰悜閿?
|
|
29
29
|
up: Key.Up,
|
|
30
30
|
down: Key.Down,
|
|
31
31
|
left: Key.Left,
|
|
32
32
|
right: Key.Right,
|
|
33
|
-
//
|
|
33
|
+
// 鍔熻兘閿?
|
|
34
34
|
f1: Key.F1,
|
|
35
35
|
f2: Key.F2,
|
|
36
36
|
f3: Key.F3,
|
|
@@ -43,7 +43,7 @@ const keyMap = {
|
|
|
43
43
|
f10: Key.F10,
|
|
44
44
|
f11: Key.F11,
|
|
45
45
|
f12: Key.F12,
|
|
46
|
-
//
|
|
46
|
+
// 淇グ閿?
|
|
47
47
|
ctrl: Key.LeftControl,
|
|
48
48
|
control: Key.LeftControl,
|
|
49
49
|
alt: Key.LeftAlt,
|
|
@@ -53,7 +53,7 @@ const keyMap = {
|
|
|
53
53
|
cmd: Key.LeftSuper,
|
|
54
54
|
command: Key.LeftSuper,
|
|
55
55
|
};
|
|
56
|
-
//
|
|
56
|
+
// 瑙f瀽缁勫悎閿紝濡?"Ctrl+C" 鎴?"Alt+Shift+F4"
|
|
57
57
|
function parseHotkey(keysStr) {
|
|
58
58
|
const parts = keysStr.split(/[+\-]/).map(s => s.trim().toLowerCase());
|
|
59
59
|
const keys = [];
|
|
@@ -63,7 +63,7 @@ function parseHotkey(keysStr) {
|
|
|
63
63
|
keys.push(mappedKey);
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
|
-
//
|
|
66
|
+
// 澶勭悊鍗曚釜瀛楃
|
|
67
67
|
if (part.length === 1) {
|
|
68
68
|
keys.push(part);
|
|
69
69
|
}
|
|
@@ -71,75 +71,77 @@ function parseHotkey(keysStr) {
|
|
|
71
71
|
}
|
|
72
72
|
return keys;
|
|
73
73
|
}
|
|
74
|
-
//
|
|
74
|
+
// 瑙f瀽鍗曚釜鎸夐敭
|
|
75
75
|
function parseKey(keyStr) {
|
|
76
76
|
const lowerKey = keyStr.toLowerCase();
|
|
77
77
|
if (keyMap[lowerKey]) {
|
|
78
78
|
return keyMap[lowerKey];
|
|
79
79
|
}
|
|
80
|
-
//
|
|
80
|
+
// 鍗曚釜瀛楃鐩存帴杩斿洖
|
|
81
81
|
if (keyStr.length === 1) {
|
|
82
82
|
return keyStr;
|
|
83
83
|
}
|
|
84
|
-
throw new Error(
|
|
84
|
+
throw new Error(`鏈煡鎸夐敭: ${keyStr}`);
|
|
85
85
|
}
|
|
86
86
|
export const keyboardTool = {
|
|
87
87
|
name: 'keyboard',
|
|
88
|
-
description: '
|
|
88
|
+
description: '鎺у埗閿洏杈撳叆鍜屾寜閿搷浣?,,
|
|
89
89
|
parameters: {
|
|
90
90
|
type: 'object',
|
|
91
91
|
properties: {
|
|
92
92
|
action: {
|
|
93
93
|
type: 'string',
|
|
94
|
-
description: '
|
|
94
|
+
description: '鎿嶄綔绫诲瀷锛歵ype锛堣緭鍏ユ枃鏈級銆乸ress锛堟寜鍘嬮敭锛夈€乭otkey锛堢粍鍚堥敭锛?,,
|
|
95
95
|
enum: ['type', 'press', 'hotkey'],
|
|
96
96
|
},
|
|
97
|
-
text: { type: 'string', description: '
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
text: { type: 'string', description: '瑕佽緭鍏ョ殑鏂囨湰锛坱ype 蹇呭~锛? },,
|
|
98
|
+
key: { type: 'string', description: '鎸夐敭鍚嶇О锛坧ress 蹇呭~锛夛紝濡?Enter銆丒scape銆乀ab' },
|
|
99
|
+
keys: {
|
|
100
|
+
type: 'string',
|
|
101
|
+
description: '缁勫悎閿紝濡?Ctrl+C銆丄lt+F4锛坔otkey 蹇呭~锛?,
|
|
102
|
+
},
|
|
102
103
|
},
|
|
104
|
+
required: ['action'],
|
|
103
105
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
106
|
+
handler: async (args) => {
|
|
107
|
+
try {
|
|
108
|
+
const { action, text, key, keys } = args;
|
|
109
|
+
switch (action) {
|
|
110
|
+
case 'type':
|
|
111
|
+
if (typeof text !== 'string') {
|
|
112
|
+
return { success: false, errorMessage: 'type 鎿嶄綔闇€瑕?text 鍙傛暟' };
|
|
113
|
+
}
|
|
114
|
+
const validation = validateText(text);
|
|
115
|
+
if (!validation.valid) {
|
|
116
|
+
return { success: false, errorMessage: `鏂囨湰鍖呭惈涓嶅彲杈撳叆瀛楃: "${validation.invalidChar}" (瀛楃鐮? ${validation.charCode})` };
|
|
117
|
+
}
|
|
118
|
+
await keyboard.type(text);
|
|
119
|
+
return { success: true, output: `宸茶緭鍏ユ枃鏈? "${text}"` };
|
|
120
|
+
case 'press':
|
|
121
|
+
if (typeof key !== 'string') {
|
|
122
|
+
return { success: false, errorMessage: 'press 鎿嶄綔闇€瑕?key 鍙傛暟' };
|
|
123
|
+
}
|
|
124
|
+
const parsedKey = parseKey(key);
|
|
125
|
+
await keyboard.pressKey(parsedKey);
|
|
126
|
+
return { success: true, output: `宸叉寜涓嬫寜閿? ${key}` };
|
|
127
|
+
case 'hotkey':
|
|
128
|
+
if (typeof keys !== 'string') {
|
|
129
|
+
return { success: false, errorMessage: 'hotkey 鎿嶄綔闇€瑕?keys 鍙傛暟' };
|
|
130
|
+
}
|
|
131
|
+
const hotkeys = parseHotkey(keys);
|
|
132
|
+
if (hotkeys.length === 0) {
|
|
133
|
+
return { success: false, errorMessage: '鏃犳硶瑙f瀽缁勫悎閿? };
|
|
134
|
+
};
|
|
135
|
+
await keyboard.pressKey(...hotkeys);
|
|
136
|
+
return { success: true, output: `宸叉墽琛岀粍鍚堥敭: ${keys}` };
|
|
137
|
+
}
|
|
138
|
+
default:
|
|
139
|
+
return { success: false, errorMessage: `鏈煡鐨勯敭鐩樻搷浣? ${action}` };
|
|
140
|
+
}
|
|
139
141
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
return { success: false, errorMessage: `閿洏鎿嶄綔澶辫触: ${error?.message || error}` };
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
}
|
|
145
147
|
};
|
|
@@ -1,55 +1,77 @@
|
|
|
1
|
-
import { mouse, Button } from '@nut-tree/nut-js';
|
|
1
|
+
import { mouse, Button } from '@nut-tree-fork/nut-js';
|
|
2
2
|
export const mouseTool = {
|
|
3
3
|
name: 'mouse',
|
|
4
|
-
description: '
|
|
4
|
+
description: '鎺у埗榧犳爣绉诲姩銆佺偣鍑诲拰婊氳疆鎿嶄綔',
|
|
5
5
|
parameters: {
|
|
6
6
|
type: 'object',
|
|
7
7
|
properties: {
|
|
8
8
|
action: {
|
|
9
9
|
type: 'string',
|
|
10
|
-
description: '
|
|
10
|
+
description: '榧犳爣鎿嶄綔绫诲瀷锛歮ove銆乧lick銆乺ightClick銆乨oubleClick銆乻croll銆乸osition',
|
|
11
11
|
},
|
|
12
|
-
x: { type: 'number', description: '
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
12
|
+
x: { type: 'number', description: '鐩爣 X 鍧愭爣锛坢ove 蹇呭~锛? },,
|
|
13
|
+
y: { type: 'number', description: '鐩爣 Y 鍧愭爣锛坢ove 蹇呭~锛? },,
|
|
14
|
+
button: { type: 'string', description: '榧犳爣鎸夐挳锛歭eft銆乺ight銆乵iddle锛岄粯璁?left', default: 'left' },
|
|
15
|
+
scrollX: { type: 'number', description: '姘村钩婊氬姩閲?, default: 0 },,
|
|
16
|
+
scrollY: { type: 'number', description: '鍨傜洿婊氬姩閲?, default: 0 },
|
|
17
|
+
},
|
|
18
|
+
required: ['action'],
|
|
19
|
+
},
|
|
20
|
+
handler: async (args) => {
|
|
21
|
+
try {
|
|
22
|
+
const { action, x, y, button = 'left', scrollX = 0, scrollY = 0 } = args;
|
|
23
|
+
switch (action) {
|
|
24
|
+
case 'move':
|
|
25
|
+
if (typeof x !== 'number' || typeof y !== 'number') {
|
|
26
|
+
return { success: false, errorMessage: 'move 鎿嶄綔闇€瑕?x 鍜?y 鍧愭爣' };
|
|
27
|
+
}
|
|
28
|
+
await mouse.setPosition({ x, y });
|
|
29
|
+
return { success: true, output: `榧犳爣绉诲姩鍒?(${x}, ${y})` };
|
|
30
|
+
case 'click':
|
|
31
|
+
case 'rightClick':
|
|
32
|
+
case 'doubleClick':
|
|
33
|
+
if (action === 'doubleClick') {
|
|
34
|
+
await mouse.click(Button.LEFT);
|
|
35
|
+
await new Promise(r => setTimeout(r, 100));
|
|
36
|
+
}
|
|
37
|
+
const btn = button === 'right' ? Button.RIGHT : button === 'middle' ? Button.MIDDLE : Button.LEFT;
|
|
38
|
+
await mouse.click(btn);
|
|
39
|
+
return { success: true, output: `${button} 閿?{action === 'doubleClick' ? '鍙? : ''}鍑绘垚鍔焋 };
|
|
40
|
+
|
|
41
|
+
case 'scroll':
|
|
42
|
+
await mouse.scrollDown(scrollY);
|
|
43
|
+
await mouse.scrollRight(scrollX);
|
|
44
|
+
return { success: true, output: `, 婊氬姩($, { scrollX }, $, { scrollY }) { } } ` };
|
|
45
|
+
|
|
46
|
+
case 'position':
|
|
47
|
+
const pos = await mouse.getPosition();
|
|
48
|
+
return { success: true, output: `;
|
|
49
|
+
褰撳墠榧犳爣浣嶇疆($, { pos, : .x }, $, { pos, : .y }) ` };
|
|
50
|
+
|
|
51
|
+
default:
|
|
52
|
+
return { success: false, errorMessage: `;
|
|
53
|
+
鏈;
|
|
54
|
+
煡鐨勯紶鏍囨搷浣 ? $ : ;
|
|
55
|
+
{
|
|
56
|
+
action;
|
|
57
|
+
}
|
|
58
|
+
` };
|
|
59
|
+
}
|
|
60
|
+
} catch (error: any) {
|
|
61
|
+
return { success: false, errorMessage: `;
|
|
62
|
+
榧犳爣鎿嶄綔澶辫触: $;
|
|
63
|
+
{
|
|
64
|
+
error?.message || error;
|
|
65
|
+
}
|
|
66
|
+
` };
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
finally { }
|
|
74
|
+
} } }
|
|
50
75
|
}
|
|
51
|
-
|
|
52
|
-
return { success: false, errorMessage: `鼠标操作失败: ${error?.message || error}` };
|
|
53
|
-
}
|
|
54
|
-
},
|
|
76
|
+
}
|
|
55
77
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { skillsService, skillHubService } from '../dataService';
|
|
2
|
-
import { authStore, persistStore } from '
|
|
2
|
+
import { authStore, persistStore } from '@/stores';
|
|
3
3
|
import { getLogger } from '@myassis/shared';
|
|
4
4
|
const logger = getLogger('skill');
|
|
5
5
|
export const skillTool = {
|
|
@@ -63,7 +63,7 @@ export const taskTool = {
|
|
|
63
63
|
return { success: true, output: JSON.stringify({ task: response.data }) };
|
|
64
64
|
}
|
|
65
65
|
case 'list': {
|
|
66
|
-
const response = await tasksService.list({ status });
|
|
66
|
+
const response = await tasksService.list(userId, { status });
|
|
67
67
|
if (!response.success)
|
|
68
68
|
return { success: false, errorMessage: '获取任务列表失败' };
|
|
69
69
|
const tasks = response.data || [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myassis/gateway",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "我的助手 Gateway Service - 本地 AI 网关服务,支持认证、WebSocket 实时通信和任务调度",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"dev": "tsx watch src/index.ts",
|
|
25
25
|
"start": "node dist/index.js",
|
|
26
|
-
"build": "tsc",
|
|
27
|
-
"postbuild": "node
|
|
26
|
+
"build": "tsc --skipLibCheck",
|
|
27
|
+
"postbuild": "node -e \"const fs = require('fs'); const path = require('path'); const filePath = path.join(__dirname, 'dist', 'index.js'); let content = fs.readFileSync(filePath, 'utf8'); if (!content.startsWith('#!')) { content = '#!/usr/bin/env node\n' + content; fs.writeFileSync(filePath, content, 'utf8'); console.log('✅ Added shebang to dist/index.js'); } else { console.log('ℹ️ Shebang already exists in dist/index.js'); }\" && npx tsc-alias",
|
|
28
28
|
"pkg:win": "pkg . --targets node18-win-x64 --output myassis-gateway-win.exe",
|
|
29
29
|
"pkg:linux": "pkg . --targets node18-linux-x64 --output myassis-gateway-linux",
|
|
30
30
|
"pkg:all": "npm run pkg:win && npm run pkg:linux",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"url": "git+https://github.com/myassis/myassis.git"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@nut-tree
|
|
49
|
+
"@nut-tree/nut-js": "^4.2.0",
|
|
50
50
|
"@myassis/shared": "latest",
|
|
51
51
|
"axios": "^1.15.2",
|
|
52
52
|
"bcryptjs": "^2.4.3",
|
|
@@ -79,7 +79,8 @@
|
|
|
79
79
|
"@types/ws": "^8.5.10",
|
|
80
80
|
"pkg": "^5.8.1",
|
|
81
81
|
"tsx": "^4.7.0",
|
|
82
|
-
"typescript": "^5.3.3"
|
|
82
|
+
"typescript": "^5.3.3",
|
|
83
|
+
"tsc-alias": "^1.8.10"
|
|
83
84
|
},
|
|
84
85
|
"pkg": {
|
|
85
86
|
"scripts": [
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* 最终修复脚本:将所有 @/ 路径别名替换为相对路径
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import fs from 'fs';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
import { fileURLToPath } from 'url';
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = path.dirname(__filename);
|
|
12
|
+
|
|
13
|
+
const srcDir = path.join(__dirname, '..', 'src');
|
|
14
|
+
|
|
15
|
+
// 计算两个路径之间的相对路径
|
|
16
|
+
function getRelativePath(fromFile, toModule) {
|
|
17
|
+
// toModule: @/services/session -> src/services/session
|
|
18
|
+
const targetPath = toModule.replace(/^@\//, '');
|
|
19
|
+
const targetFullPath = path.resolve(srcDir, targetPath);
|
|
20
|
+
|
|
21
|
+
// 计算相对路径
|
|
22
|
+
let relativePath = path.relative(path.dirname(fromFile), targetFullPath);
|
|
23
|
+
|
|
24
|
+
// Windows 路径转换为 Unix 风格
|
|
25
|
+
relativePath = relativePath.replace(/\\/g, '/');
|
|
26
|
+
|
|
27
|
+
// 确保以 ./ 或 ../ 开头
|
|
28
|
+
if (!relativePath.startsWith('.')) {
|
|
29
|
+
relativePath = './' + relativePath;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// 添加 .js 扩展名(ES Module 要求)
|
|
33
|
+
if (!relativePath.endsWith('.js') && !relativePath.endsWith('.ts')) {
|
|
34
|
+
relativePath += '.js';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return relativePath;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// 修复文件内容
|
|
41
|
+
function fixFileContent(filePath, content) {
|
|
42
|
+
let modified = false;
|
|
43
|
+
|
|
44
|
+
// 匹配 import ... from '@/...' 或 export ... from '@/...'
|
|
45
|
+
const importRegex = /(import|export)\s+([\s\S]+?)\s+from\s+['"]@\/([^'"]+)['"]/g;
|
|
46
|
+
|
|
47
|
+
const newContent = content.replace(importRegex, (match, keyword, imports, modulePath) => {
|
|
48
|
+
const relativePath = getRelativePath(filePath, '@/' + modulePath);
|
|
49
|
+
modified = true;
|
|
50
|
+
return `${keyword} ${imports} from '${relativePath}'`;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return { content: newContent, modified };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// 处理单个文件
|
|
57
|
+
function processFile(filePath) {
|
|
58
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
59
|
+
const { content: newContent, modified } = fixFileContent(filePath, content);
|
|
60
|
+
|
|
61
|
+
if (modified) {
|
|
62
|
+
fs.writeFileSync(filePath, newContent, 'utf8');
|
|
63
|
+
console.log(`✓ ${path.relative(process.cwd(), filePath)}`);
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// 递归处理目录
|
|
71
|
+
function processDirectory(dir) {
|
|
72
|
+
let fixedCount = 0;
|
|
73
|
+
|
|
74
|
+
const items = fs.readdirSync(dir, { withFileTypes: true });
|
|
75
|
+
|
|
76
|
+
for (const item of items) {
|
|
77
|
+
const itemPath = path.join(dir, item.name);
|
|
78
|
+
|
|
79
|
+
if (item.isDirectory()) {
|
|
80
|
+
// 跳过特定目录
|
|
81
|
+
if (!['node_modules', 'dist', '.git', 'coverage'].includes(item.name)) {
|
|
82
|
+
fixedCount += processDirectory(itemPath);
|
|
83
|
+
}
|
|
84
|
+
} else if (item.name.endsWith('.ts') && !item.name.endsWith('.d.ts')) {
|
|
85
|
+
if (processFile(itemPath)) {
|
|
86
|
+
fixedCount++;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return fixedCount;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 主函数
|
|
95
|
+
function main() {
|
|
96
|
+
console.log('🔧 将 @/ 路径别名替换为相对路径...\n');
|
|
97
|
+
|
|
98
|
+
if (!fs.existsSync(srcDir)) {
|
|
99
|
+
console.error('❌ src 目录不存在!');
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const fixedCount = processDirectory(srcDir);
|
|
104
|
+
|
|
105
|
+
console.log(`\n✅ 完成!修复了 ${fixedCount} 个文件`);
|
|
106
|
+
console.log('\n⚠️ 重要提示:');
|
|
107
|
+
console.log(' 1. 请检查修改是否正确');
|
|
108
|
+
console.log(' 2. 运行 npm run build 验证编译');
|
|
109
|
+
console.log(' 3. 提交代码更改');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
main();
|