@wu529778790/open-im 1.11.4-beta.0 → 1.11.4-beta.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.
|
@@ -378,9 +378,9 @@ export class ClaudeSDKAdapter {
|
|
|
378
378
|
let actualSessionId;
|
|
379
379
|
let hadSessionInvalid = false;
|
|
380
380
|
try {
|
|
381
|
-
// 先尝试自动恢复 CLI 的最新 session(如果用户没有指定 sessionId)
|
|
381
|
+
// 先尝试自动恢复 CLI 的最新 session(如果用户没有指定 sessionId,且不是 /new 后的新 session)
|
|
382
382
|
let resumeId = sessionId;
|
|
383
|
-
if (!resumeId) {
|
|
383
|
+
if (!resumeId && !options?.skipAutoResume) {
|
|
384
384
|
const latest = await findLatestClaudeSession(workDir);
|
|
385
385
|
if (latest) {
|
|
386
386
|
const cliActive = isCliSessionActive(latest.sessionId, latest.filePath);
|
|
@@ -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 是否是 /new 后的新 session
|
|
22
|
+
* 如果是,不应该自动恢复 CLI session
|
|
23
|
+
*/
|
|
24
|
+
isFreshSession(userId: string): boolean;
|
|
20
25
|
/**
|
|
21
26
|
* 获取最近活跃的 session 的工作目录
|
|
22
27
|
* 如果没有 session,返回默认工作目录
|
|
@@ -87,10 +87,20 @@ export class SessionManager {
|
|
|
87
87
|
const s = this.sessions.get(userId);
|
|
88
88
|
if (s) {
|
|
89
89
|
s.lastActiveAt = Date.now();
|
|
90
|
+
// 首次访问后清除 freshSession 标记(允许后续消息恢复 CLI session)
|
|
91
|
+
if (s.freshSession)
|
|
92
|
+
s.freshSession = false;
|
|
90
93
|
return s.workDir;
|
|
91
94
|
}
|
|
92
95
|
return this.defaultWorkDir;
|
|
93
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* 检查 session 是否是 /new 后的新 session
|
|
99
|
+
* 如果是,不应该自动恢复 CLI session
|
|
100
|
+
*/
|
|
101
|
+
isFreshSession(userId) {
|
|
102
|
+
return this.sessions.get(userId)?.freshSession === true;
|
|
103
|
+
}
|
|
94
104
|
/**
|
|
95
105
|
* 获取最近活跃的 session 的工作目录
|
|
96
106
|
* 如果没有 session,返回默认工作目录
|
|
@@ -158,6 +168,7 @@ export class SessionManager {
|
|
|
158
168
|
s.sessionIds = {};
|
|
159
169
|
s.activeConvId = randomBytes(4).toString('hex');
|
|
160
170
|
s.totalTurns = 0;
|
|
171
|
+
s.freshSession = true; // 标记为新 session,阻止自动恢复 CLI session
|
|
161
172
|
this.flushSync();
|
|
162
173
|
log.info(`New session for user ${userId}: oldConvId=${oldConvId}, oldSessionIds=${JSON.stringify(oldSessionIds)}, newConvId=${s.activeConvId}, sessionIds={}`);
|
|
163
174
|
return true;
|
package/dist/shared/ai-task.js
CHANGED
|
@@ -294,6 +294,8 @@ export function runAITask(deps, ctx, prompt, toolAdapter, platformAdapter) {
|
|
|
294
294
|
chatId: ctx.chatId,
|
|
295
295
|
// 默认跳过权限确认,保持全自动执行(可通过 config 或环境变量关闭)
|
|
296
296
|
skipPermissions: config.skipPermissions ?? true,
|
|
297
|
+
// /new 后跳过自动恢复 CLI session
|
|
298
|
+
skipAutoResume: sessionManager.isFreshSession(ctx.userId),
|
|
297
299
|
...(aiCommand === 'codex' && config.codexProxy ? { proxy: config.codexProxy } : {}),
|
|
298
300
|
});
|
|
299
301
|
return activeHandle;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wu529778790/open-im",
|
|
3
|
-
"version": "1.11.4-beta.
|
|
3
|
+
"version": "1.11.4-beta.1",
|
|
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",
|