aicodeswitch 5.2.0 → 5.2.1

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.
@@ -290,7 +290,11 @@ class KeyLogger {
290
290
  }
291
291
  try {
292
292
  const data = yield promises_1.default.readFile(this.getShardIndexPath(keyId), 'utf-8');
293
- const index = JSON.parse(data);
293
+ const parsed = JSON.parse(data);
294
+ // 防御性过滤:确保返回有效数组,剔除 null/undefined 或缺少 filename 的条目
295
+ const index = Array.isArray(parsed)
296
+ ? parsed.filter((s) => s != null && typeof s === 'object' && 'filename' in s)
297
+ : [];
294
298
  this.shardIndexCache.set(keyId, index);
295
299
  return index;
296
300
  }
@@ -3388,6 +3388,12 @@ const start = () => __awaiter(void 0, void 0, void 0, function* () {
3388
3388
  });
3389
3389
  process.on('SIGINT', () => { void shutdown('SIGINT'); });
3390
3390
  process.on('SIGTERM', () => { void shutdown('SIGTERM'); });
3391
+ // 优雅关闭端点(供 Tauri 等外部调用者触发服务端完整清理流程)
3392
+ // 放在 shutdown 定义之后注册,确保闭包可引用
3393
+ app.post('/api/shutdown', asyncHandler((_req, res) => __awaiter(void 0, void 0, void 0, function* () {
3394
+ res.json({ success: true });
3395
+ setImmediate(() => { void shutdown('HTTP_SHUTDOWN'); });
3396
+ })));
3391
3397
  });
3392
3398
  // 全局未捕获异常处理 - 防止服务崩溃
3393
3399
  process.on('uncaughtException', (error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aicodeswitch",
3
- "version": "5.2.0",
3
+ "version": "5.2.1",
4
4
  "description": "A tool to help you manage AI programming tools to access large language models locally. It allows your Claude Code, Codex and other tools to no longer be limited to official models.",
5
5
  "author": "tangshuang",
6
6
  "license": "GPL-3.0",