@myassis/gateway 1.0.10 → 1.0.11
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 +4 -4
- package/dist/services/TaskSchedulerService.js +2 -2
- package/dist/services/TaskService.js +2 -2
- package/dist/services/agent/Agent.js +1 -1
- package/dist/services/agent/AgentManager.js +3 -3
- package/dist/services/dataService.js +2 -2
- package/dist/services/llm/LLMClient.js +1 -1
- package/dist/services/memory/MemoryManager.js +5 -5
- package/dist/services/session/Session.js +9 -9
- package/dist/services/session/SessionManager.js +1 -1
- package/dist/services/systemPrompt.js +1 -1
- package/dist/services/task/PushTokenStore.js +1 -1
- package/dist/services/task/TaskStore.js +1 -1
- package/dist/services/tools/model.js +2 -2
- package/dist/services/tools/sessionsSpawn.js +1 -1
- package/dist/services/tools/skill.js +2 -2
- package/dist/services/tools/task.js +1 -1
- package/package.json +1 -1
- package/scripts/fix-esm-imports.js +16 -5
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 '../stores';
|
|
6
|
+
import { authStore } from '../stores/authStore.js';
|
|
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
2
|
import { requireAuth } from '../middleware/auth.js';
|
|
3
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';
|
|
4
|
+
import { getSessionManager } from '../services/session/index.js';
|
|
5
|
+
import { initAgentManager, agentManagerMap } from '../services/agent/AgentManager.js';
|
|
6
|
+
import { AgentStore } from '../services/agent/AgentStore.js';
|
|
7
7
|
import { getLogger } from '@myassis/shared';
|
|
8
8
|
const logger = getLogger('AgentRoutes');
|
|
9
|
-
import { sessionStore } from '../services/session/SessionStore';
|
|
9
|
+
import { sessionStore } from '../services/session/SessionStore.js';
|
|
10
10
|
const router = Router();
|
|
11
11
|
// 所有路由需要认证
|
|
12
12
|
router.use(requireAuth, (req, _res, next) => {
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { taskStore } from './task/TaskStore.js';
|
|
7
7
|
import { webSocketService } from './WebSocketService.js';
|
|
8
|
-
import { getSessionManager } from './session.js';
|
|
8
|
+
import { getSessionManager } from './session/index.js';
|
|
9
9
|
import { getLogger, getUTCTimeKey, formatUTCForLog, holidayService } from '@myassis/shared';
|
|
10
10
|
import { tasksService } from './dataService.js';
|
|
11
|
-
import { authStore } from '../stores';
|
|
11
|
+
import { authStore } from '../stores/authStore.js';
|
|
12
12
|
const logger = getLogger('TaskSchedulerService');
|
|
13
13
|
const EXPIRED_THRESHOLD = 60 * 60 * 1000; // 1小时
|
|
14
14
|
const CHECK_INTERVAL = 60 * 1000; // 1分钟
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* - platformApply === currentPlatform → 本地 SQLite 存储(localTaskService)
|
|
8
8
|
* - platformApply !== currentPlatform → 服务器 API(tasksApi)
|
|
9
9
|
*/
|
|
10
|
-
import { authStore } from '../stores';
|
|
11
|
-
import { tasksApi } from '../api';
|
|
10
|
+
import { authStore } from '../stores/index.js';
|
|
11
|
+
import { tasksApi } from '../api/index.js';
|
|
12
12
|
import { localTaskService } from './LocalTaskService.js';
|
|
13
13
|
import { getLogger } from '@myassis/shared';
|
|
14
14
|
import { getPlatform } from '@myassis/shared/dist/utils/system.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
-
import { getSessionManager } from '../session/SessionManager';
|
|
2
|
+
import { getSessionManager } from '../session/SessionManager.js';
|
|
3
3
|
/**
|
|
4
4
|
* Agent - Business logic entity
|
|
5
5
|
* Represents an AI agent with independent system prompt and multiple sessions
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { Agent } from './Agent.js';
|
|
3
|
-
import { getSessionManager } from '../session/SessionManager';
|
|
4
|
-
import { authStore } from '../../stores/authStore';
|
|
3
|
+
import { getSessionManager } from '../session/SessionManager.js';
|
|
4
|
+
import { authStore } from '../../stores/authStore.js';
|
|
5
5
|
import { getLogger } from '@myassis/shared';
|
|
6
|
-
import appConfig from '../../config';
|
|
6
|
+
import appConfig from '../../config/index.js';
|
|
7
7
|
const logger = getLogger('AgentManager');
|
|
8
8
|
/**
|
|
9
9
|
* AgentManager - Business logic layer
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* - /api/v1/data/* - 用户数据路由 (models, skills, tasks, settings)
|
|
8
8
|
* - /api/v1/skill-hubs/* - 技能库路由
|
|
9
9
|
*/
|
|
10
|
-
import { authApi, skillsApi, skillHubApi, modelsApi, settingsApi } from '../api';
|
|
11
|
-
import { authStore, memoryStore, persistStore } from '../stores';
|
|
10
|
+
import { authApi, skillsApi, skillHubApi, modelsApi, settingsApi } from '../api/index.js';
|
|
11
|
+
import { authStore, memoryStore, persistStore } from '../stores/index.js';
|
|
12
12
|
import { taskService } from './TaskService.js';
|
|
13
13
|
import { getLogger } from '@myassis/shared';
|
|
14
14
|
const logger = getLogger('DataService');
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getLogger } from '@myassis/shared';
|
|
2
2
|
const logger = getLogger('MemoryManager');
|
|
3
|
-
import { toModel } from '../models';
|
|
4
|
-
import { modelsService } from '../dataService';
|
|
5
|
-
import { authStore } from '../../stores';
|
|
6
|
-
import { LLMClient } from '../llm/LLMClient';
|
|
7
|
-
import { appConfig } from '../../config';
|
|
3
|
+
import { toModel } from '../models.js';
|
|
4
|
+
import { modelsService } from '../dataService.js';
|
|
5
|
+
import { authStore } from '../../stores/index.js';
|
|
6
|
+
import { LLMClient } from '../llm/LLMClient.js';
|
|
7
|
+
import { appConfig } from '../../config/index.js';
|
|
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.js';
|
|
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
|
-
import { getSystemPromptAsync } from '../systemPrompt';
|
|
9
|
-
import { LLMClient, parseAruments } from '../llm/LLMClient';
|
|
10
|
-
import { modelsService, settingsService } from '../../services/dataService';
|
|
11
|
-
import { MemoryManager } from '../memory/MemoryManager';
|
|
12
|
-
import { appConfig } from '../../config';
|
|
4
|
+
import { AgentStore } from '../../services/agent/AgentStore.js';
|
|
5
|
+
import { authStore } from '../../stores/authStore.js';
|
|
6
|
+
import { toModel } from '../../services/models.js';
|
|
7
|
+
import { executeTool, getToolDefinitions } from '../../services/tools/index.js';
|
|
8
|
+
import { getSystemPromptAsync } from '../systemPrompt.js';
|
|
9
|
+
import { LLMClient, parseAruments } from '../llm/LLMClient.js';
|
|
10
|
+
import { modelsService, settingsService } from '../../services/dataService.js';
|
|
11
|
+
import { MemoryManager } from '../memory/MemoryManager.js';
|
|
12
|
+
import { appConfig } from '../../config/index.js';
|
|
13
13
|
import { getSessionManager } from './SessionManager.js';
|
|
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.js';
|
|
5
|
-
import { authStore } from '../../stores/authStore';
|
|
5
|
+
import { authStore } from '../../stores/authStore.js';
|
|
6
6
|
import { Session } from './Session.js';
|
|
7
7
|
/**
|
|
8
8
|
* SessionManager - Business logic layer
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { getLogger } from '@myassis/shared';
|
|
6
6
|
const logger = getLogger('PushTokenStore');
|
|
7
|
-
import { sessionStore } from '../session/SessionStore';
|
|
7
|
+
import { sessionStore } from '../session/SessionStore.js';
|
|
8
8
|
export class PushTokenStore {
|
|
9
9
|
db;
|
|
10
10
|
constructor() {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* 操作 SQLite 数据库,与 AgentStore/SessionStore 共享同一个数据库实例
|
|
4
4
|
*/
|
|
5
5
|
import { getLogger } from '@myassis/shared';
|
|
6
|
-
import { sessionStore } from '../session/SessionStore';
|
|
6
|
+
import { sessionStore } from '../session/SessionStore.js';
|
|
7
7
|
const logger = getLogger('TaskStore');
|
|
8
8
|
function rowToTaskData(row) {
|
|
9
9
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { modelsService } from '../dataService';
|
|
2
|
-
import { authStore } from '../../stores';
|
|
1
|
+
import { modelsService } from '../dataService.js';
|
|
2
|
+
import { authStore } from '../../stores/index.js';
|
|
3
3
|
export const modelTool = {
|
|
4
4
|
name: 'model',
|
|
5
5
|
description: '模型管理工具',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { v4 as uuidv4 } from 'uuid';
|
|
2
2
|
import { getLogger } from '@myassis/shared';
|
|
3
|
-
import { getSessionManager } from '../session';
|
|
3
|
+
import { getSessionManager } from '../session/index.js';
|
|
4
4
|
const logger = getLogger('sessionsSpawn');
|
|
5
5
|
export const sessionsSpawnTool = {
|
|
6
6
|
name: 'sessions_spawn',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { skillsService, skillHubService } from '../dataService';
|
|
2
|
-
import { authStore, persistStore } from '../../stores';
|
|
1
|
+
import { skillsService, skillHubService } from '../dataService.js';
|
|
2
|
+
import { authStore, persistStore } from '../../stores/index.js';
|
|
3
3
|
import { getLogger } from '@myassis/shared';
|
|
4
4
|
const logger = getLogger('skill');
|
|
5
5
|
export const skillTool = {
|
package/package.json
CHANGED
|
@@ -16,14 +16,25 @@ async function addJsExtensionToImports(filePath) {
|
|
|
16
16
|
let content = await readFile(filePath, 'utf8');
|
|
17
17
|
let modified = false;
|
|
18
18
|
|
|
19
|
-
// 替换静态导入
|
|
20
|
-
content = content.replace(
|
|
19
|
+
// 替换静态导入 - 匹配各种相对路径
|
|
20
|
+
content = content.replace(/from\s+['"]([^'"\n]+)['"]/g, (match, importPath) => {
|
|
21
|
+
// 如果是 node_modules 或绝对路径,跳过
|
|
22
|
+
if (importPath.startsWith('@myassis/') || importPath.startsWith('/')) {
|
|
23
|
+
return match;
|
|
24
|
+
}
|
|
25
|
+
|
|
21
26
|
// 如果已经有扩展名,跳过
|
|
22
|
-
if (importPath.endsWith('.js') || importPath.endsWith('.json') || importPath.endsWith('.ts')) {
|
|
27
|
+
if (importPath.endsWith('.js') || importPath.endsWith('.json') || importPath.endsWith('.ts') || importPath.endsWith('.cjs') || importPath.endsWith('.mjs')) {
|
|
23
28
|
return match;
|
|
24
29
|
}
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
|
|
31
|
+
// 只处理相对路径 (./ 或 ../)
|
|
32
|
+
if (importPath.startsWith('.') || importPath.startsWith('..')) {
|
|
33
|
+
modified = true;
|
|
34
|
+
return `from '${importPath}.js'`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return match;
|
|
27
38
|
});
|
|
28
39
|
|
|
29
40
|
// 替换动态导入
|