@wu529778790/open-im 1.11.3-beta.5 → 1.11.4-beta.0

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/index.js CHANGED
@@ -209,17 +209,9 @@ function buildNotification(opts) {
209
209
  return lines.join("\n\n");
210
210
  }
211
211
  function buildStartupMessage(platform, appVersion, aiCommand, defaultWorkDir, sessionManager) {
212
- let sessionDir;
213
- // Telegram 私聊、企业微信当前实现里,活跃 chatId 可直接对应到 session userId。
214
- if (platform === "telegram" || platform === "wework") {
215
- const activeChatId = getActiveChatId(platform);
216
- if (activeChatId) {
217
- sessionDir = sessionManager.getWorkDir(activeChatId);
218
- }
219
- }
220
212
  const platformName = PLATFORM_DISPLAY_NAMES[platform] ?? platform;
221
213
  const toolName = getAIToolDisplayName(aiCommand);
222
- const dir = escapePathForMarkdown(sessionDir || defaultWorkDir);
214
+ const dir = escapePathForMarkdown(sessionManager.getMostRecentWorkDir());
223
215
  return buildNotification({
224
216
  emoji: "✅",
225
217
  title: `open-im v${appVersion} 已就绪`,
@@ -17,6 +17,11 @@ export declare class SessionManager {
17
17
  getSessionIdForThread(_userId: string, _threadId: string, _toolId: ToolId): string | undefined;
18
18
  setSessionIdForThread(userId: string, threadId: string, toolId: ToolId, sessionId: string): void;
19
19
  getWorkDir(userId: string): string;
20
+ /**
21
+ * 获取最近活跃的 session 的工作目录
22
+ * 如果没有 session,返回默认工作目录
23
+ */
24
+ getMostRecentWorkDir(): string;
20
25
  hasUserSession(userId: string): boolean;
21
26
  getConvId(userId: string): string;
22
27
  setWorkDir(userId: string, workDir: string): Promise<{
@@ -84,7 +84,27 @@ export class SessionManager {
84
84
  this.save();
85
85
  }
86
86
  getWorkDir(userId) {
87
- return this.sessions.get(userId)?.workDir ?? this.defaultWorkDir;
87
+ const s = this.sessions.get(userId);
88
+ if (s) {
89
+ s.lastActiveAt = Date.now();
90
+ return s.workDir;
91
+ }
92
+ return this.defaultWorkDir;
93
+ }
94
+ /**
95
+ * 获取最近活跃的 session 的工作目录
96
+ * 如果没有 session,返回默认工作目录
97
+ */
98
+ getMostRecentWorkDir() {
99
+ let mostRecent;
100
+ let latestTime = 0;
101
+ for (const [, session] of this.sessions) {
102
+ if (session.lastActiveAt && session.lastActiveAt > latestTime) {
103
+ latestTime = session.lastActiveAt;
104
+ mostRecent = session.workDir;
105
+ }
106
+ }
107
+ return mostRecent ?? this.defaultWorkDir;
88
108
  }
89
109
  hasUserSession(userId) {
90
110
  return this.sessions.has(userId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.11.3-beta.5",
3
+ "version": "1.11.4-beta.0",
4
4
  "description": "Your AI coding assistant, in every chat app. Multi-platform IM bridge for Claude Code, Codex, and CodeBuddy.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",