@wu529778790/open-im 1.9.4-beta.0 → 1.9.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.
@@ -2,5 +2,7 @@ export type EnqueueResult = 'running' | 'queued' | 'rejected';
2
2
  export declare class RequestQueue {
3
3
  private queues;
4
4
  enqueue(userId: string, convId: string, prompt: string, execute: (prompt: string) => Promise<void>): EnqueueResult;
5
+ /** 清除指定用户会话的所有排队任务(不中止正在运行的任务) */
6
+ clear(userId: string, convId: string): number;
5
7
  private run;
6
8
  }
@@ -21,6 +21,18 @@ export class RequestQueue {
21
21
  this.run(key, prompt, execute);
22
22
  return 'running';
23
23
  }
24
+ /** 清除指定用户会话的所有排队任务(不中止正在运行的任务) */
25
+ clear(userId, convId) {
26
+ const key = `${userId}:${convId}`;
27
+ const q = this.queues.get(key);
28
+ if (!q)
29
+ return 0;
30
+ const cleared = q.tasks.length;
31
+ q.tasks.length = 0;
32
+ if (cleared > 0)
33
+ log.info(`Cleared ${cleared} queued tasks for ${key}`);
34
+ return cleared;
35
+ }
24
36
  async run(key, prompt, execute) {
25
37
  try {
26
38
  await execute(prompt);
@@ -104,6 +104,18 @@ export function setupWorkBuddyHandlers(config, sessionManager) {
104
104
  try {
105
105
  const handled = await commandHandler.dispatch(text, chatId, userId, 'workbuddy', (u, c, p, w, conv, _r, m) => handleAIRequest(u, c, msgId, p, w, conv));
106
106
  if (handled) {
107
+ // /new 命令时,中止当前运行中的任务并清空队列
108
+ if (text === '/new') {
109
+ const runningTaskKey = taskKeyByChatId.get(chatId);
110
+ if (runningTaskKey) {
111
+ const state = runningTasks.get(runningTaskKey);
112
+ if (state) {
113
+ log.info(`Aborting running task ${runningTaskKey} due to /new command`);
114
+ state.handle.abort();
115
+ }
116
+ }
117
+ requestQueue.clear(userId, convId);
118
+ }
107
119
  log.info(`Command handled for message: ${text}`);
108
120
  return;
109
121
  }
@@ -123,7 +135,8 @@ export function setupWorkBuddyHandlers(config, sessionManager) {
123
135
  await sendErrorReply(null, chatId, 'Request queue is full. Please try again later.', msgId);
124
136
  }
125
137
  else if (enqueueResult === 'queued') {
126
- await sendTextReply(null, chatId, 'Your request is queued.', msgId);
138
+ // streaming 而非 end_turn,避免 CodeBuddy 平台显示 "✅ Local Agent task completed"
139
+ await sendStreamingReply(null, chatId, '⏳ 请求已排队,请稍候...', msgId);
127
140
  }
128
141
  }
129
142
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wu529778790/open-im",
3
- "version": "1.9.4-beta.0",
3
+ "version": "1.9.4-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",