@myassis/gateway 1.0.106 → 1.0.107

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.
@@ -9,7 +9,7 @@ exports.requireAuth = void 0;
9
9
  * 注:Gateway 不自行验证 JWT 签名,而是比对 authStore 中由 Server 下发并本地持久化的 token。
10
10
  * 因此无需也不应持有 JWT_SECRET,避免密钥在末端多处散落。
11
11
  */
12
- const authStore_js_1 = require("../stores/authStore.js");
12
+ const authStore_js_1 = require("@/stores/authStore.js");
13
13
  const shared_1 = require("@myassis/shared");
14
14
  const logger = (0, shared_1.getLogger)('middleware/auth');
15
15
  /**
@@ -18,7 +18,7 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.broadcastDataChanges = void 0;
20
20
  const shared_1 = require("@myassis/shared");
21
- const WebSocketService_js_1 = require("../services/WebSocketService.js");
21
+ const WebSocketService_js_1 = require("@/services/WebSocketService.js");
22
22
  const logger = (0, shared_1.getLogger)('middleware/broadcast');
23
23
  /**
24
24
  * 路由前缀 -> 资源类型。
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const express_1 = require("express");
4
- const auth_js_1 = require("../middleware/auth.js");
5
- const index_js_1 = require("../api/index.js");
6
- const index_js_2 = require("../services/session/index.js");
7
- const AgentManager_js_1 = require("../services/agent/AgentManager.js");
8
- const AgentStore_js_1 = require("../services/agent/AgentStore.js");
4
+ const auth_js_1 = require("@/middleware/auth.js");
5
+ const index_js_1 = require("@/api/index.js");
6
+ const index_js_2 = require("@/services/session/index.js");
7
+ const AgentManager_js_1 = require("@/services/agent/AgentManager.js");
8
+ const AgentStore_js_1 = require("@/services/agent/AgentStore.js");
9
9
  const shared_1 = require("@myassis/shared");
10
10
  const logger = (0, shared_1.getLogger)('AgentRoutes');
11
- const SessionStore_js_1 = require("../services/session/SessionStore.js");
11
+ const SessionStore_js_1 = require("@/services/session/SessionStore.js");
12
12
  const router = (0, express_1.Router)();
13
13
  // 所有路由需要认证
14
14
  router.use(auth_js_1.requireAuth, (req, _res, next) => {
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.deleteFile = void 0;
7
7
  const express_1 = require("express");
8
8
  const multer_1 = __importDefault(require("multer"));
9
- const index_js_1 = require("../config/index.js");
10
- const auth_js_1 = require("../middleware/auth.js");
11
- const index_js_2 = require("../api/index.js");
9
+ const index_js_1 = require("@/config/index.js");
10
+ const auth_js_1 = require("@/middleware/auth.js");
11
+ const index_js_2 = require("@/api/index.js");
12
12
  const shared_1 = require("@myassis/shared");
13
13
  const logger = (0, shared_1.getLogger)('UploadRoutes');
14
14
  const router = (0, express_1.Router)();
@@ -11,7 +11,7 @@ const WebSocketService_js_1 = require("./WebSocketService.js");
11
11
  const index_js_1 = require("./session/index.js");
12
12
  const shared_1 = require("@myassis/shared");
13
13
  const dataService_js_1 = require("./dataService.js");
14
- const authStore_js_1 = require("../stores/authStore.js");
14
+ const authStore_js_1 = require("@/stores/authStore.js");
15
15
  const logger = (0, shared_1.getLogger)('TaskSchedulerService');
16
16
  const EXPIRED_THRESHOLD = 60 * 60 * 1000; // 1小时
17
17
  const CHECK_INTERVAL = 60 * 1000; // 1分钟
@@ -10,7 +10,7 @@
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.taskService = void 0;
13
- const index_js_1 = require("../stores/index.js");
13
+ const index_js_1 = require("@/stores/index.js");
14
14
  const index_js_2 = require("../api/index.js");
15
15
  const LocalTaskService_js_1 = require("./LocalTaskService.js");
16
16
  const shared_1 = require("@myassis/shared");
@@ -7,9 +7,9 @@ exports.initAgentManager = exports.agentManagerMap = exports.AgentManager = void
7
7
  const uuid_1 = require("uuid");
8
8
  const Agent_js_1 = require("./Agent.js");
9
9
  const SessionManager_js_1 = require("../session/SessionManager.js");
10
- const authStore_js_1 = require("../../stores/authStore.js");
10
+ const authStore_js_1 = require("@/stores/authStore.js");
11
11
  const shared_1 = require("@myassis/shared");
12
- const index_js_1 = __importDefault(require("../../config/index.js"));
12
+ const index_js_1 = __importDefault(require("@/config/index.js"));
13
13
  const logger = (0, shared_1.getLogger)('AgentManager');
14
14
  /**
15
15
  * AgentManager - Business logic layer
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getGlobalModelSelector = exports.parseAruments = exports.LLMClient = void 0;
7
- const index_js_1 = require("../../stores/index.js");
7
+ const index_js_1 = require("@/stores/index.js");
8
8
  const shared_1 = require("@myassis/shared");
9
9
  const promises_1 = __importDefault(require("fs/promises"));
10
- const index_js_2 = require("../../config/index.js");
10
+ const index_js_2 = require("@/config/index.js");
11
11
  const logger = (0, shared_1.getLogger)('LLMClient');
12
12
  /** 历史工具输出在上下文中的最大保留长度 */
13
13
  const HISTORY_TOOL_OUTPUT_LIMIT = index_js_2.appConfig.oldToolContentLimit;
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nextTrimLevel = exports.planTurnCompaction = exports.buildContext = exports.estimateTokens = exports.estimateChars = exports.TrimLevel = exports.CHARS_PER_TOKEN = void 0;
4
4
  const shared_1 = require("@myassis/shared");
5
- const index_js_1 = require("../../config/index.js");
5
+ const index_js_1 = require("@/config/index.js");
6
6
  const ToolLedger_js_1 = require("./ToolLedger.js");
7
7
  const ToolCallArchive_js_1 = require("./ToolCallArchive.js");
8
8
  const logger = (0, shared_1.getLogger)('ContextBuilder');
@@ -200,6 +200,9 @@ function clipPair(messages, pair, limit, sessionId) {
200
200
  // 以避免在「未真正裁剪」时产生无提示可引用的孤儿存档。
201
201
  if (Array.isArray(head.tool_calls)) {
202
202
  for (const tc of head.tool_calls) {
203
+ const tcName = tc?.toolName || tc?.function?.name;
204
+ if (tcName === 'updatePlan')
205
+ continue;
203
206
  tc.input = clipJsonArguments(tc.input, limit);
204
207
  if (tc.function) {
205
208
  tc.function.arguments = clipJsonArguments(tc.function.arguments, limit);
@@ -210,6 +213,8 @@ function clipPair(messages, pair, limit, sessionId) {
210
213
  const msg = messages[i];
211
214
  if (!msg || typeof msg.content !== 'string')
212
215
  continue;
216
+ if (msg.tool_call_name === 'updatePlan')
217
+ continue; // plan state must stay intact
213
218
  const original = msg.content;
214
219
  if (original.length <= limit)
215
220
  continue; // 仅当真正被截断才归档 + 提示
@@ -319,6 +324,9 @@ function skeletonizePair(messages, pair, sessionId) {
319
324
  toolName: tc?.toolName || tc?.function?.name || 'unknown',
320
325
  });
321
326
  }
327
+ const tcName = tc?.toolName || tc?.function?.name;
328
+ if (tcName === 'updatePlan')
329
+ continue;
322
330
  tc.input = skeletonArguments(tc.input);
323
331
  if (tc.function) {
324
332
  tc.function.arguments = skeletonArguments(tc.function.arguments);
@@ -329,6 +337,8 @@ function skeletonizePair(messages, pair, sessionId) {
329
337
  const msg = messages[i];
330
338
  if (!msg)
331
339
  continue;
340
+ if (msg.tool_call_name === 'updatePlan')
341
+ continue;
332
342
  const original = typeof msg.content === 'string' ? msg.content : JSON.stringify(msg.content ?? '');
333
343
  // 骨架化总是有损,但仅在原文较长时值得归档 + 提示
334
344
  if (original.length <= SKELETON_OUTPUT_LIMIT) {
@@ -28,9 +28,9 @@ const shared_1 = require("@myassis/shared");
28
28
  const logger = (0, shared_1.getLogger)('MemoryManager');
29
29
  const models_js_1 = require("../models.js");
30
30
  const dataService_js_1 = require("../dataService.js");
31
- const index_js_1 = require("../../stores/index.js");
31
+ const index_js_1 = require("@/stores/index.js");
32
32
  const LLMClient_js_1 = require("../llm/LLMClient.js");
33
- const index_js_2 = require("../../config/index.js");
33
+ const index_js_2 = require("@/config/index.js");
34
34
  const ToolLedger_js_1 = require("./ToolLedger.js");
35
35
  const DEFAULT_CONFIG = {
36
36
  summaryThreshold: index_js_2.appConfig.summaryThreshold,
@@ -27,15 +27,15 @@ exports.Session = exports.handleApprovalResponse = exports.registerApprovalWaite
27
27
  const uuid_1 = require("uuid");
28
28
  const shared_1 = require("@myassis/shared");
29
29
  const SessionStore_js_1 = require("./SessionStore.js");
30
- const AgentStore_js_1 = require("../../services/agent/AgentStore.js");
31
- const authStore_js_1 = require("../../stores/authStore.js");
32
- const models_js_1 = require("../../services/models.js");
33
- const index_js_1 = require("../../services/tools/index.js");
30
+ const AgentStore_js_1 = require("@/services/agent/AgentStore.js");
31
+ const authStore_js_1 = require("@/stores/authStore.js");
32
+ const models_js_1 = require("@/services/models.js");
33
+ const index_js_1 = require("@/services/tools/index.js");
34
34
  const systemPrompt_js_1 = require("../systemPrompt.js");
35
35
  const LLMClient_js_1 = require("../llm/LLMClient.js");
36
- const dataService_js_1 = require("../../services/dataService.js");
36
+ const dataService_js_1 = require("@/services/dataService.js");
37
37
  const MemoryManager_js_1 = require("../memory/MemoryManager.js");
38
- const index_js_2 = require("../../config/index.js");
38
+ const index_js_2 = require("@/config/index.js");
39
39
  const ContextBuilder_js_1 = require("../memory/ContextBuilder.js");
40
40
  const SessionManager_js_1 = require("./SessionManager.js");
41
41
  const SessionNotificationService_js_1 = require("../SessionNotificationService.js");
@@ -1397,6 +1397,11 @@ class Session {
1397
1397
  };
1398
1398
  messages.push(toolResultMessage);
1399
1399
  }
1400
+ // 每轮注入简短计划状态,防止上下文裁剪导致模型丢失计划而重新创建
1401
+ if (this.plan.length > 0 && !this.isPlanCompleted()) {
1402
+ const planStatus = this.plan.map((s, i) => (i + 1) + '.' + s.step + '[' + s.status + ']').join('; ');
1403
+ messages.push({ role: 'user', content: '[计划状态] ' + planStatus, attachments: [] });
1404
+ }
1400
1405
  // 计划模式:模型常常只在开头和结尾调用 updatePlan,中间过程不同步进度。
1401
1406
  // 这里在已有计划且连续多轮未同步时,主动注入一条提醒,迫使模型推进计划状态。
1402
1407
  const reminder = this.buildPlanReminder(roundsSincePlanUpdate, forceFinalize);
@@ -5,7 +5,7 @@ const uuid_1 = require("uuid");
5
5
  const shared_1 = require("@myassis/shared");
6
6
  const logger = (0, shared_1.getLogger)('SessionManager');
7
7
  const SessionStore_js_1 = require("./SessionStore.js");
8
- const authStore_js_1 = require("../../stores/authStore.js");
8
+ const authStore_js_1 = require("@/stores/authStore.js");
9
9
  const Session_js_1 = require("./Session.js");
10
10
  const ToolCallArchive_js_1 = require("../memory/ToolCallArchive.js");
11
11
  /**
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getSystemPromptAsync = exports.LANGUAGES = exports.CHAT_STYLE_TEMPLATES = void 0;
7
- const index_js_1 = require("../stores/index.js");
7
+ const index_js_1 = require("@/stores/index.js");
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const dataService_js_1 = require("./dataService.js");
10
10
  const shared_1 = require("@myassis/shared");
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.modelTool = void 0;
4
4
  const dataService_js_1 = require("../dataService.js");
5
- const index_js_1 = require("../../stores/index.js");
5
+ const index_js_1 = require("@/stores/index.js");
6
6
  exports.modelTool = {
7
7
  name: 'model',
8
8
  description: '模型管理工具',
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.skillTool = void 0;
4
4
  const dataService_js_1 = require("../dataService.js");
5
- const index_js_1 = require("../../stores/index.js");
5
+ const index_js_1 = require("@/stores/index.js");
6
6
  const shared_1 = require("@myassis/shared");
7
7
  const logger = (0, shared_1.getLogger)('skill');
8
8
  exports.skillTool = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myassis/gateway",
3
- "version": "1.0.106",
3
+ "version": "1.0.107",
4
4
  "description": "我的助手 Gateway Service - 本地 AI 网关服务,支持认证、WebSocket 实时通信和任务调度",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/dist/.env DELETED
@@ -1,6 +0,0 @@
1
- # Gateway 环境配置
2
- # Server API 地址(desktop 端通过 gateway 访问 server)
3
- SERVER_BASE_URL=https://api.my-assis.com
4
- # 服务端口
5
- PORT=3001
6
- HTTP_PROXY=http://127.0.0.1:7890
@@ -1 +0,0 @@
1
- ok