@myassis/gateway 1.0.7 → 1.0.10
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/services/LocalTaskService.js +1 -1
- package/dist/services/NotificationService.js +3 -3
- package/dist/services/TaskSchedulerService.js +4 -4
- package/dist/services/TaskService.js +1 -1
- package/dist/services/agent/AgentManager.js +1 -1
- package/dist/services/dataService.js +1 -1
- package/dist/services/index.js +9 -9
- package/dist/services/model/index.js +1 -1
- package/dist/services/session/Session.js +2 -2
- package/dist/services/session/SessionManager.js +2 -2
- package/dist/services/session/SessionStore.js +1 -1
- package/dist/services/session/index.js +2 -2
- package/dist/services/systemPrompt.js +1 -1
- package/dist/services/tools/index.js +15 -15
- package/dist/stores/index.js +3 -3
- package/package.json +2 -2
- package/scripts/fix-esm-imports.js +72 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 使用 SQLite 数据库存储任务
|
|
6
6
|
*/
|
|
7
7
|
import { v4 as uuidv4 } from 'uuid';
|
|
8
|
-
import { TaskStore } from './task/TaskStore';
|
|
8
|
+
import { TaskStore } from './task/TaskStore.js';
|
|
9
9
|
import { getLogger, sharedTaskService, formatUTCForLog } from '@myassis/shared';
|
|
10
10
|
const logger = getLogger('LocalTaskService');
|
|
11
11
|
class LocalTaskService {
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
* 负责发送任务通知
|
|
4
4
|
* 优先级:WebSocket > HMS Push (华为) / Expo Push (其他)
|
|
5
5
|
*/
|
|
6
|
-
import { PushTokenStore } from './task/PushTokenStore';
|
|
7
|
-
import { webSocketService } from './WebSocketService';
|
|
8
|
-
import { hmsPushService } from './HMSPushService';
|
|
6
|
+
import { PushTokenStore } from './task/PushTokenStore.js';
|
|
7
|
+
import { webSocketService } from './WebSocketService.js';
|
|
8
|
+
import { hmsPushService } from './HMSPushService.js';
|
|
9
9
|
import { getLogger } from '@myassis/shared';
|
|
10
10
|
const logger = getLogger('NotificationService');
|
|
11
11
|
const log = logger;
|
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
* 基于 SQLite 数据库的任务调度
|
|
4
4
|
* 每分钟检查待执行任务并发送通知
|
|
5
5
|
*/
|
|
6
|
-
import { taskStore } from './task/TaskStore';
|
|
7
|
-
import { webSocketService } from './WebSocketService';
|
|
8
|
-
import { getSessionManager } from './session';
|
|
6
|
+
import { taskStore } from './task/TaskStore.js';
|
|
7
|
+
import { webSocketService } from './WebSocketService.js';
|
|
8
|
+
import { getSessionManager } from './session.js';
|
|
9
9
|
import { getLogger, getUTCTimeKey, formatUTCForLog, holidayService } from '@myassis/shared';
|
|
10
|
-
import { tasksService } from './dataService';
|
|
10
|
+
import { tasksService } from './dataService.js';
|
|
11
11
|
import { authStore } from '../stores';
|
|
12
12
|
const logger = getLogger('TaskSchedulerService');
|
|
13
13
|
const EXPIRED_THRESHOLD = 60 * 60 * 1000; // 1小时
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { authStore } from '../stores';
|
|
11
11
|
import { tasksApi } from '../api';
|
|
12
|
-
import { localTaskService } from './LocalTaskService';
|
|
12
|
+
import { localTaskService } from './LocalTaskService.js';
|
|
13
13
|
import { getLogger } from '@myassis/shared';
|
|
14
14
|
import { getPlatform } from '@myassis/shared/dist/utils/system.js';
|
|
15
15
|
// 当前网关平台标识
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { Agent } from './Agent';
|
|
2
|
+
import { Agent } from './Agent.js';
|
|
3
3
|
import { getSessionManager } from '../session/SessionManager';
|
|
4
4
|
import { authStore } from '../../stores/authStore';
|
|
5
5
|
import { getLogger } from '@myassis/shared';
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { authApi, skillsApi, skillHubApi, modelsApi, settingsApi } from '../api';
|
|
11
11
|
import { authStore, memoryStore, persistStore } from '../stores';
|
|
12
|
-
import { taskService } from './TaskService';
|
|
12
|
+
import { taskService } from './TaskService.js';
|
|
13
13
|
import { getLogger } from '@myassis/shared';
|
|
14
14
|
const logger = getLogger('DataService');
|
|
15
15
|
// ============ 认证服务 ============
|
package/dist/services/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// Re-export all services from dataService
|
|
2
|
-
export { authService, skillsService, skillHubService, modelsService, settingsService, } from './dataService';
|
|
2
|
+
export { authService, skillsService, skillHubService, modelsService, settingsService, } from './dataService.js';
|
|
3
3
|
// Re-export tasksService from dataService (server-only tasks)
|
|
4
|
-
export { tasksService } from './dataService';
|
|
4
|
+
export { tasksService } from './dataService.js';
|
|
5
5
|
// Re-export session manager
|
|
6
|
-
export { getSessionManager } from './session';
|
|
6
|
+
export { getSessionManager } from './session/index.js';
|
|
7
7
|
// Re-export task services
|
|
8
|
-
export { taskSchedulerService } from './TaskSchedulerService';
|
|
9
|
-
export { taskService } from './TaskService';
|
|
10
|
-
export { localTaskService } from './LocalTaskService';
|
|
8
|
+
export { taskSchedulerService } from './TaskSchedulerService.js';
|
|
9
|
+
export { taskService } from './TaskService.js';
|
|
10
|
+
export { localTaskService } from './LocalTaskService.js';
|
|
11
11
|
// Re-export notification and holiday services
|
|
12
|
-
export { notificationService } from './NotificationService';
|
|
12
|
+
export { notificationService } from './NotificationService.js';
|
|
13
13
|
// Re-export task stores
|
|
14
|
-
export { TaskStore } from './task/TaskStore';
|
|
15
|
-
export { PushTokenStore } from './task/PushTokenStore';
|
|
14
|
+
export { TaskStore } from './task/TaskStore.js';
|
|
15
|
+
export { PushTokenStore } from './task/PushTokenStore.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { getLogger } from '@myassis/shared';
|
|
3
|
-
import { SessionStore } from './SessionStore';
|
|
3
|
+
import { SessionStore } from './SessionStore.js';
|
|
4
4
|
import { AgentStore } from '../../services/agent/AgentStore';
|
|
5
5
|
import { authStore } from '../../stores/authStore';
|
|
6
6
|
import { toModel } from '../../services/models';
|
|
@@ -10,7 +10,7 @@ import { LLMClient, parseAruments } from '../llm/LLMClient';
|
|
|
10
10
|
import { modelsService, settingsService } from '../../services/dataService';
|
|
11
11
|
import { MemoryManager } from '../memory/MemoryManager';
|
|
12
12
|
import { appConfig } from '../../config';
|
|
13
|
-
import { getSessionManager } from './SessionManager';
|
|
13
|
+
import { getSessionManager } from './SessionManager.js';
|
|
14
14
|
const logger = getLogger('Session');
|
|
15
15
|
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
16
16
|
// AgentStore 单例 - 需要通过 SessionStore 获取数据库实例
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { getLogger } from '@myassis/shared';
|
|
3
3
|
const logger = getLogger('SessionManager');
|
|
4
|
-
import { sessionStore } from './SessionStore';
|
|
4
|
+
import { sessionStore } from './SessionStore.js';
|
|
5
5
|
import { authStore } from '../../stores/authStore';
|
|
6
|
-
import { Session } from './Session';
|
|
6
|
+
import { Session } from './Session.js';
|
|
7
7
|
/**
|
|
8
8
|
* SessionManager - Business logic layer
|
|
9
9
|
* Manages sessions in memory
|
|
@@ -2,7 +2,7 @@ import Database from 'better-sqlite3';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fs from 'fs';
|
|
4
4
|
import { getLogger } from '@myassis/shared';
|
|
5
|
-
import { MigrationManager } from './MigrationManager';
|
|
5
|
+
import { MigrationManager } from './MigrationManager.js';
|
|
6
6
|
const logger = getLogger('SessionStore');
|
|
7
7
|
/**
|
|
8
8
|
* SessionStore - Data access layer
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// 导出 SessionManager(业务逻辑层)
|
|
2
|
-
export { SessionManager, getSessionManager } from './SessionManager';
|
|
3
|
-
export { Session } from './Session';
|
|
2
|
+
export { SessionManager, getSessionManager } from './SessionManager.js';
|
|
3
|
+
export { Session } from './Session.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { authStore } from '../stores';
|
|
2
2
|
import os from 'os';
|
|
3
|
-
import { settingsService, skillsService } from './dataService';
|
|
3
|
+
import { settingsService, skillsService } from './dataService.js';
|
|
4
4
|
import { getLogger } from '@myassis/shared';
|
|
5
5
|
const logger = getLogger('SystemPrompt');
|
|
6
6
|
// 预设的对话风格模板
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 工具定义集合
|
|
3
3
|
*/
|
|
4
|
-
export * from './types';
|
|
5
|
-
import { searchTool } from './search';
|
|
6
|
-
import { calculatorTool } from './calculator';
|
|
7
|
-
import { screenshotTool } from './screenshot';
|
|
8
|
-
import { keyboardTool } from './keyboard';
|
|
9
|
-
import { mouseTool } from './mouse';
|
|
10
|
-
import { fetchTool } from './fetch';
|
|
11
|
-
import { skillTool } from './skill';
|
|
12
|
-
import { execTool } from './exec';
|
|
13
|
-
import { fileTool } from './file';
|
|
14
|
-
import { taskTool } from './task';
|
|
15
|
-
import { modelTool } from './model';
|
|
16
|
-
import { editTool } from './edit';
|
|
17
|
-
import { webFetchTool } from './webFetch';
|
|
18
|
-
import { sessionsSpawnTool } from './sessionsSpawn';
|
|
4
|
+
export * from './types.js';
|
|
5
|
+
import { searchTool } from './search.js';
|
|
6
|
+
import { calculatorTool } from './calculator.js';
|
|
7
|
+
import { screenshotTool } from './screenshot.js';
|
|
8
|
+
import { keyboardTool } from './keyboard.js';
|
|
9
|
+
import { mouseTool } from './mouse.js';
|
|
10
|
+
import { fetchTool } from './fetch.js';
|
|
11
|
+
import { skillTool } from './skill.js';
|
|
12
|
+
import { execTool } from './exec.js';
|
|
13
|
+
import { fileTool } from './file.js';
|
|
14
|
+
import { taskTool } from './task.js';
|
|
15
|
+
import { modelTool } from './model.js';
|
|
16
|
+
import { editTool } from './edit.js';
|
|
17
|
+
import { webFetchTool } from './webFetch.js';
|
|
18
|
+
import { sessionsSpawnTool } from './sessionsSpawn.js';
|
|
19
19
|
export const tools = [
|
|
20
20
|
searchTool, calculatorTool, screenshotTool, keyboardTool, mouseTool,
|
|
21
21
|
skillTool, execTool, taskTool, modelTool, fetchTool,
|
package/dist/stores/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Gateway Stores 统一导出
|
|
3
3
|
*/
|
|
4
|
-
export { memoryStore } from './memoryStore';
|
|
5
|
-
export { persistStore } from './persistStore';
|
|
6
|
-
export { authStore } from './authStore';
|
|
4
|
+
export { memoryStore } from './memoryStore.js';
|
|
5
|
+
export { persistStore } from './persistStore.js';
|
|
6
|
+
export { authStore } from './authStore.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myassis/gateway",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "我的助手 Gateway Service - 本地 AI 网关服务,支持认证、WebSocket 实时通信和任务调度",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dev": "tsx watch src/index.ts",
|
|
25
25
|
"start": "node dist/index.js",
|
|
26
26
|
"build": "tsc --skipLibCheck",
|
|
27
|
-
"postbuild": "node scripts/add-shebang.js && npx tsc-alias",
|
|
27
|
+
"postbuild": "node scripts/add-shebang.js && node scripts/fix-esm-imports.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",
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
import { promisify } from 'util';
|
|
6
|
+
import { readdir, readFile, writeFile, stat } from 'fs/promises';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = path.dirname(__filename);
|
|
10
|
+
|
|
11
|
+
// 匹配相对导入的正则:import ... from './xxx' 或 import ... from '../xxx'
|
|
12
|
+
const relativeImportRegex = /from\s+['"](\.\/[^'"]*|\\.\\.\/[^'"]*)['"]/g;
|
|
13
|
+
const dynamicImportRegex = /import\s*\(\s*['"](\.\/[^'"]*|\\.\\.\/[^'"]*)['"]\s*\)/g;
|
|
14
|
+
|
|
15
|
+
async function addJsExtensionToImports(filePath) {
|
|
16
|
+
let content = await readFile(filePath, 'utf8');
|
|
17
|
+
let modified = false;
|
|
18
|
+
|
|
19
|
+
// 替换静态导入
|
|
20
|
+
content = content.replace(relativeImportRegex, (match, importPath) => {
|
|
21
|
+
// 如果已经有扩展名,跳过
|
|
22
|
+
if (importPath.endsWith('.js') || importPath.endsWith('.json') || importPath.endsWith('.ts')) {
|
|
23
|
+
return match;
|
|
24
|
+
}
|
|
25
|
+
modified = true;
|
|
26
|
+
return `from '${importPath}.js'`;
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// 替换动态导入
|
|
30
|
+
content = content.replace(dynamicImportRegex, (match, importPath) => {
|
|
31
|
+
if (importPath.endsWith('.js') || importPath.endsWith('.json') || importPath.endsWith('.ts')) {
|
|
32
|
+
return match;
|
|
33
|
+
}
|
|
34
|
+
modified = true;
|
|
35
|
+
return `import('${importPath}.js')`;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
if (modified) {
|
|
39
|
+
await writeFile(filePath, content, 'utf8');
|
|
40
|
+
console.log(`✅ Fixed imports in: ${path.relative(__dirname + '/..', filePath)}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function processDirectory(dirPath) {
|
|
45
|
+
const entries = await readdir(dirPath);
|
|
46
|
+
|
|
47
|
+
for (const entry of entries) {
|
|
48
|
+
const fullPath = path.join(dirPath, entry);
|
|
49
|
+
const stats = await stat(fullPath);
|
|
50
|
+
|
|
51
|
+
if (stats.isDirectory()) {
|
|
52
|
+
await processDirectory(fullPath);
|
|
53
|
+
} else if (entry.endsWith('.js')) {
|
|
54
|
+
await addJsExtensionToImports(fullPath);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function main() {
|
|
60
|
+
const distPath = path.join(__dirname, '..', 'dist');
|
|
61
|
+
|
|
62
|
+
if (!fs.existsSync(distPath)) {
|
|
63
|
+
console.error('❌ dist directory not found!');
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
console.log('🔧 Adding .js extensions to relative imports...');
|
|
68
|
+
await processDirectory(distPath);
|
|
69
|
+
console.log('✅ Done!');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
main().catch(console.error);
|