@wu529778790/open-im 1.7.0-beta.0 → 1.7.0-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.
@@ -2,6 +2,7 @@
2
2
  * 共享 AI 任务执行层,支持多 ToolAdapter。
3
3
  */
4
4
  import { getPermissionMode } from '../permission-mode/session-mode.js';
5
+ import { resolvePlatformAiCommand } from '../config.js';
5
6
  import { formatToolStats, formatToolCallNotification, getContextWarning, getAIToolDisplayName, } from './utils.js';
6
7
  import { createLogger } from '../logger.js';
7
8
  const log = createLogger('AITask');
@@ -102,24 +103,27 @@ export function runAITask(deps, ctx, prompt, toolAdapter, platformAdapter) {
102
103
  : undefined)
103
104
  : undefined;
104
105
  }
106
+ // 使用 aiCommand 而不是 toolAdapter.toolId,确保 sessionId 的存储和查询使用相同的 key
107
+ const aiCommand = resolvePlatformAiCommand(config, ctx.platform);
105
108
  const toolId = toolAdapter.toolId;
106
- const timeoutMs = toolId === 'codex'
109
+ const timeoutMs = aiCommand === 'codex'
107
110
  ? config.codexTimeoutMs
108
- : toolId === 'codebuddy'
111
+ : aiCommand === 'codebuddy'
109
112
  ? config.codebuddyTimeoutMs
110
113
  : config.claudeTimeoutMs;
111
114
  const startRun = () => {
112
115
  activeHandle = toolAdapter.run(prompt, currentSessionId, ctx.workDir, {
113
116
  onSessionId: (id) => {
114
117
  currentSessionId = id;
118
+ // 使用 aiCommand 而不是 toolId,确保与查询时使用相同的 key
115
119
  if (ctx.threadId)
116
- sessionManager.setSessionIdForThread(ctx.userId, ctx.threadId, toolId, id);
120
+ sessionManager.setSessionIdForThread(ctx.userId, ctx.threadId, aiCommand, id);
117
121
  else if (ctx.convId)
118
- sessionManager.setSessionIdForConv(ctx.userId, ctx.convId, toolId, id);
122
+ sessionManager.setSessionIdForConv(ctx.userId, ctx.convId, aiCommand, id);
119
123
  },
120
124
  onSessionInvalid: () => {
121
125
  if (ctx.convId)
122
- sessionManager.clearSessionForConv(ctx.userId, ctx.convId, toolId);
126
+ sessionManager.clearSessionForConv(ctx.userId, ctx.convId, aiCommand);
123
127
  },
124
128
  onThinking: (t) => {
125
129
  if (!firstContentLogged) {
@@ -211,14 +215,14 @@ export function runAITask(deps, ctx, prompt, toolAdapter, platformAdapter) {
211
215
  }
212
216
  settled = true;
213
217
  log.error(`Task error for user ${ctx.userId}: ${error}`);
214
- if (toolId !== 'claude' && !isUsageLimitError(error)) {
218
+ if (aiCommand !== 'claude' && !isUsageLimitError(error)) {
215
219
  if (ctx.convId)
216
- sessionManager.clearSessionForConv(ctx.userId, ctx.convId, toolId);
220
+ sessionManager.clearSessionForConv(ctx.userId, ctx.convId, aiCommand);
217
221
  else
218
- sessionManager.clearActiveToolSession(ctx.userId, toolId);
219
- log.info(`Session reset for user ${ctx.userId} due to ${toolId} task error`);
222
+ sessionManager.clearActiveToolSession(ctx.userId, aiCommand);
223
+ log.info(`Session reset for user ${ctx.userId} due to ${aiCommand} task error`);
220
224
  }
221
- else if (toolId === 'codex' && isUsageLimitError(error)) {
225
+ else if (aiCommand === 'codex' && isUsageLimitError(error)) {
222
226
  log.info(`Keeping codex session for user ${ctx.userId} after usage limit error`);
223
227
  }
224
228
  try {
@@ -236,7 +240,7 @@ export function runAITask(deps, ctx, prompt, toolAdapter, platformAdapter) {
236
240
  timeoutMs,
237
241
  model: sessionManager.getModel(ctx.userId, ctx.threadId) ?? config.claudeModel,
238
242
  chatId: ctx.chatId,
239
- ...(toolId === 'codex' && config.codexProxy ? { proxy: config.codexProxy } : {}),
243
+ ...(aiCommand === 'codex' && config.codexProxy ? { proxy: config.codexProxy } : {}),
240
244
  });
241
245
  return activeHandle;
242
246
  };
@@ -251,7 +255,7 @@ export function runAITask(deps, ctx, prompt, toolAdapter, platformAdapter) {
251
255
  latestContent: '',
252
256
  settle,
253
257
  startedAt: Date.now(),
254
- toolId,
258
+ toolId: aiCommand,
255
259
  };
256
260
  startRun();
257
261
  platformAdapter.onTaskReady(taskState);
@@ -33,13 +33,28 @@ describe("runAITask", () => {
33
33
  const taskPromise = runAITask({
34
34
  config: {
35
35
  aiCommand: "codex",
36
+ platforms: {},
37
+ enabledPlatforms: [],
36
38
  defaultPermissionMode: "ask",
37
39
  codexTimeoutMs: 600000,
38
40
  claudeTimeoutMs: 600000,
41
+ codebuddyTimeoutMs: 600000,
39
42
  claudeSkipPermissions: false,
40
43
  claudeModel: "",
41
44
  hookPort: 35801,
42
45
  codexProxy: "",
46
+ wechatToken: "",
47
+ wechatGuid: "",
48
+ wechatUserId: "",
49
+ wechatAppId: "",
50
+ wechatAppSecret: "",
51
+ dingtalkClientId: "",
52
+ dingtalkClientSecret: "",
53
+ qqAppId: "",
54
+ qqSecret: "",
55
+ weworkCorpId: "",
56
+ weworkSecret: "",
57
+ telegramBotToken: "",
43
58
  },
44
59
  sessionManager: sessionManager,
45
60
  }, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.7.0-beta.0",
3
+ "version": "1.7.0-beta.1",
4
4
  "description": "Multi-platform IM bridge for AI CLI tools (Claude, Codex, CodeBuddy)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",