openclaw-lark-multi-agent 1.4.11 → 1.4.13

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/README.md CHANGED
@@ -306,14 +306,22 @@ By default, a bot responds when:
306
306
 
307
307
  - it is directly mentioned;
308
308
  - `@all` / `@_all` appears in the message;
309
- - this bot's Free mode is enabled and the message is a plain human message with no targeted mentions.
309
+ - a Chairman is set for this group, and this bot's Free mode is enabled for a plain human message with no mentions;
310
+ - a Chairman is set, no bot is Free, and this bot is the Chairman (even if muted).
310
311
 
311
312
  Free mode is intentionally per-bot and conservative:
312
313
 
313
- - Free mode lets a bot reply to ordinary human messages without being mentioned.
314
+ - Free mode lets a bot reply to ordinary unmentioned human messages **only while this group has a Chairman**.
314
315
  - If a human message mentions another bot, only that bot may respond. Other Free-mode bots stay silent.
315
316
  - If a human message mentions a regular person, Free-mode bots stay silent.
316
- - `@all` remains a broadcast trigger and may activate every eligible bot.
317
+ - `@all` remains a broadcast trigger and may activate every eligible bot. If the message also targets somebody else but not this bot, target exclusivity wins.
318
+ - These rules apply equally to one-bot and multi-bot groups, including local commands such as `/help` and `/free`: no coordinator or single-bot fallback may answer a mention addressed elsewhere.
319
+ - Mention identity requires a matching configured `app_id` or an already probed bot `open_id`. Known conflicting app/open IDs veto a match; neither wins by order. An unprobed open ID cannot establish identity (a matching app ID still can). Display names, including exact names and parenthesized suffixes, never establish identity. Message metadata never updates probed identities.
320
+ - Structured rich-post `at` nodes can supply an already known open ID when mention metadata is absent; they cannot override conflicting metadata. Missing/unresolved mentions or standalone `@name`/platform placeholders fail closed. Embedded `@` in email addresses or ordinary text is not a command or identity signal.
321
+
322
+ **Clearing Chairman is not mute.** `/chairman off` (also `clear` / `none`) atomically clears the canonical group Chairman and persists Discuss off, stops not-yet-started discussion turns, and blocks **new unmentioned group model triggers**, including Free bots and stale Discuss-on state after reopening the database. It does not abort an executing agent, change an existing queue task's identity, or suppress its eventual result. Explicit verified self/multi-target mentions, standalone `@all`, and private chats retain their normal behavior. Free/mute settings are not reset.
323
+
324
+ Local management commands are evaluated before the ordinary-chat gate. Use `/chairman <exact configured bot name>` without mentions, or a verified `/chairman @Bot`, to restore the group; Free/Chairman fallback then works again. `/discuss on` still requires a Chairman and must be enabled again after off. Bare group help/settings retain their existing single-coordinator routing; bare `/chairman` shows usage, not status (use `/status`).
317
325
 
318
326
  Mention-only routing is supported. If a user first sends content and then sends only a bot mention, for example:
319
327
 
@@ -344,7 +352,7 @@ Persistent constraints (such as "do not call Feishu send tools directly" and the
344
352
 
345
353
  `/discuss` is an explicit group-level multi-agent discussion scheduler. It is separate from Free mode:
346
354
 
347
- - `/free` controls whether a single bot may answer plain human messages.
355
+ - `/free` controls whether a single bot may answer plain human messages in a group with a Chairman.
348
356
  - `/discuss on` requires a chairman to be set first (`/chairman @Bot`). It lets one coordinator take over plain human messages and run all non-muted bots plus the chairman in barrier-style rounds. Free mode is ignored inside discussion: every bot that is not muted participates regardless of its Free setting.
349
357
  - Targeted mentions still fall through to normal routing, so `@GPT hello` works even while discuss mode is enabled.
350
358
  - Each participant receives the same round prompt and does not see other participants' replies from the current round until the next round.
@@ -373,11 +381,11 @@ Each group can have exactly one chairman, set with `/chairman @Bot`. Setting a n
373
381
 
374
382
  ```text
375
383
  /chairman @Bot set the chairman
376
- /chairman show the current chairman
384
+ /chairman show usage (use /status for current chairman)
377
385
  /chairman off clear the chairman
378
386
  ```
379
387
 
380
- `/chairman` is a group-level command handled by one coordinator bot, so it produces a single reply.
388
+ `/chairman` is a group-level command: the verified target handles targeted setup, and the coordinator handles untargeted management. Multiple-target errors belong to the first verified target, never an unmentioned coordinator.
381
389
 
382
390
  ### `/locale`
383
391
 
package/README.zh-CN.md CHANGED
@@ -236,7 +236,7 @@ openclaw-lark-multi-agent install-windows-service
236
236
  - `/mute` — 开关当前 bot 在当前群聊里的 mute 模式
237
237
  - `/mode` — 查看当前 bot 在当前聊天里的模式
238
238
  - `/discuss on|off|status|stop|rounds N` — 控制群级多 bot 讨论模式(需先设置 Chairman;默认 10 轮)
239
- - `/chairman [@Bot|off]` — 设置/查看/清除本群唯一 Chairman
239
+ - `/chairman [@Bot|配置名|off]` — 设置/切换/清除本群唯一 Chairman
240
240
  - `/locale [zh|en]` — 设置/查看当前群语言
241
241
 
242
242
  如果你想把 slash command 直接发给 OpenClaw,可以用双斜杠转义:
@@ -284,14 +284,22 @@ openclaw-lark-multi-agent install-windows-service
284
284
 
285
285
  - 被直接 @;
286
286
  - 消息里出现 `@all` / `@_all`;
287
- - 当前 bot 开启了 Free 模式,并且这是一条没有定向 @ 的普通人类消息。
287
+ - 本群已设置 Chairman、当前 bot 开启了 Free 模式,且这是一条无 @ 的普通人类消息;
288
+ - 本群已设置 Chairman、没有 Free bot,由 Chairman 兜底(即使 Chairman 是 mute)。
288
289
 
289
290
  Free 模式是 per-bot 且保守的:
290
291
 
291
- - Free 模式允许 bot 在没有被 @ 时回复普通人类消息。
292
+ - Free 模式**仅在本群已设置 Chairman 时**允许 bot 回复无 @ 的普通人类消息。
292
293
  - 如果人类消息 @ 了另一个 bot,只有被 @ 的 bot 可以回复,其他 Free 模式 bot 保持静默。
293
294
  - 如果人类消息 @ 了普通人,Free 模式 bot 保持静默。
294
- - `@all` 仍然是广播触发,可激活所有符合条件的 bot。
295
+ - `@all` 仍然是广播触发,可激活所有符合条件的 bot;但同时定向 @ 其他人/bot 且没有 @ 当前 bot 时,定向排他优先。
296
+ - 单 bot 和多 bot 群、Free/Chairman/Discuss、`/help`、`/free` 等本地命令统一遵循定向排他规则;coordinator 或单 bot 不能兜底抢答。
297
+ - 点名身份仅由匹配的配置 `app_id` 或启动探测已确认的 bot `open_id` 确定。已知 app/open ID 冲突时拒绝匹配,不按顺序让其中一个优先;尚未探测的 open ID 不能独立确认身份,但匹配的 app ID 仍可确认。名字、同名人/外部机器人、括号后缀不构成身份依据,消息元数据不会覆盖已探测身份。
298
+ - 富文本结构化 `at` 节点只在缺少 mention 元数据时可按已知 open ID 确认目标,不能覆盖冲突元数据。缺元数据的 `@name` / 平台占位符及无法确认的目标保持安静;邮箱或普通文字内嵌的 `@` 不当作指令或身份信号。
299
+
300
+ **Chairman off 不是 mute,但禁止无 @ 的普通新消息触发模型。** `/chairman off`(也支持 `clear` / `none`)原子持久化清空群 Chairman 并关闭 Discuss,停止尚未开始的讨论轮次;即使 bot 原来 Free 或数据库遗留 Discuss on,无 Chairman 时普通新消息也不会触发。不会 abort 已执行 agent、改变旧队列任务身份或阻止其最终结果回传;明确 @ 自己/多目标含自己、单独 `@all`、私聊仍按原规则,Free/mute 设置不清除。
301
+
302
+ 本地管理命令先于普通聊天门禁处理。可无 @ 发送 `/chairman 精确配置名`,或通过可靠点名 `/chairman @Bot` 恢复;之后 Free/Chairman 兜底恢复原行为。Discuss 需重新 `/discuss on` 且必须已有 Chairman。无目标管理命令保留原 coordinator 规则;裸 `/chairman` 返回用法,查看状态用 `/status`。
295
303
 
296
304
  支持“纯 @ 触发”。例如用户先发:
297
305
 
@@ -323,8 +331,8 @@ catch-up 上下文是 bot 随当前消息一起拿到的群里未看到的发言
323
331
 
324
332
  `/discuss` 是显式的群级多智能体讨论调度器,和 Free 模式分工不同:
325
333
 
326
- - `/free` 控制单个 bot 是否可以响应普通人类消息。
327
- - `/discuss on` 需先设置 Chairman(`/chairman @Bot`)。它让一个 coordinator 接管普通人类消息,并按 barrier-style round 调度所有 Free 模式 bot 加上 Chairman。
334
+ - `/free` 控制单个 bot 是否可以在已设 Chairman 的群响应普通人类消息。
335
+ - `/discuss on` 需先设置 Chairman(`/chairman @Bot`)。它让一个 coordinator 接管普通人类消息,并按 barrier-style round 调度所有非 mute bot 加上 Chairman,忽略 Free 开关。
328
336
  - 定向 @ 仍然走普通路由,所以 discuss 开启时 `@GPT hello` 仍会只触发 GPT。
329
337
  - 每个参与 bot 在同一轮拿到相同 prompt,本轮内看不到其他 bot 的回复,下一轮才会看到上一轮结果。
330
338
  - Chairman 每轮最后发言:先给出自己的观点,质疑薄弱点,调停分歧,并决定继续还是总结。
@@ -352,11 +360,11 @@ catch-up 上下文是 bot 随当前消息一起拿到的群里未看到的发言
352
360
 
353
361
  ```text
354
362
  /chairman @Bot 设置 Chairman
355
- /chairman 查看当前 Chairman
363
+ /chairman 显示设置用法;查看状态请用 /status
356
364
  /chairman off 清除 Chairman
357
365
  ```
358
366
 
359
- `/chairman` 是群级命令,由一个 coordinator bot 统一处理,只产生一条回复。
367
+ `/chairman` 是群级命令:定向设置由目标 bot 处理,无目标管理由 coordinator 处理;多目标错误由第一个可靠目标回复,未被点名的 coordinator 不抢答。
360
368
 
361
369
  ### `/locale` 语言
362
370
 
@@ -124,10 +124,17 @@ export class DiscussionManager {
124
124
  parts.push(`${errorNames.join("、")} ${t.error}`);
125
125
  await sendSystemMessage(t.discussionRoundNotice(current.currentRound, current.maxRounds, parts.join(current.locale === "zh" ? ";" : "; "))).catch(() => { });
126
126
  }
127
+ // stop/preemption may occur while a system notice is being delivered.
128
+ if (this.sessions.get(session.chatId)?.id !== sessionId || current.status !== "running")
129
+ return;
127
130
  const mustFinish = allNoReply || current.currentRound >= current.maxRounds;
128
131
  if (chairman) {
129
132
  const chairmanPrompt = this.buildChairmanPrompt(current, replies, mustFinish);
130
133
  const chairResult = await chairman.runDiscussionTurn(current.chatId, chairmanPrompt, { round: current.currentRound, maxRounds: current.maxRounds });
134
+ // An old in-flight Chairman may finish after stop or replacement. Its
135
+ // delivery belongs to that turn, but it must not mutate the new session.
136
+ if (this.sessions.get(session.chatId)?.id !== sessionId || current.status !== "running")
137
+ return;
131
138
  const chairText = (chairResult.text || "").trim();
132
139
  replies[chairman.name] = chairText;
133
140
  const latest = current.completedRounds[current.completedRounds.length - 1];
@@ -57,6 +57,8 @@ export declare class FeishuBot {
57
57
  * message falls back to a normal run, cancel these before submission so a
58
58
  * later identical steer cannot consume the stale observer/correlation. */
59
59
  private pendingSteerCleanups;
60
+ private errorNoticeTimers;
61
+ private errorNoticeChecks;
60
62
  private adminOpenId;
61
63
  private locale;
62
64
  private configPath?;
@@ -128,7 +130,6 @@ export declare class FeishuBot {
128
130
  private isAllMention;
129
131
  private isAllMentionItem;
130
132
  private mentionedBotName;
131
- private escapeRegExp;
132
133
  private resolveBotName;
133
134
  private resolveHumanName;
134
135
  private cleanMentions;
@@ -202,20 +203,15 @@ export declare class FeishuBot {
202
203
  private deliverySourceId;
203
204
  private sendSystemDelivery;
204
205
  private enqueueAndDispatchDelivery;
206
+ private inspectErrorNotice;
207
+ private deferErrorNotice;
208
+ private scheduleErrorNoticeCheck;
209
+ /** Bounded read-only diagnosis; known live tasks retain low-frequency observation. */
210
+ private reconcileErrorNotices;
205
211
  private scheduleDeliveryRetry;
206
212
  private dispatchPendingDeliveries;
207
213
  private hasFreeModeBot;
208
214
  private mentionedBotNames;
209
- private mentionedBotNamesFromChairmanText;
210
- /**
211
- * Resolve the target bot name(s) for a /chairman command using every signal
212
- * available, in priority order:
213
- * 1. Feishu mention metadata (app_id / open_id / name).
214
- * 2. Text fallback: "@Bot" or "Bot" written in the message body.
215
- *
216
- * This keeps /chairman working even when a Feishu client or bridge omits
217
- * mention metadata. Returns a de-duplicated, order-preserving list.
218
- */
219
215
  private resolveChairmanTargets;
220
216
  private isDiscussionCoordinator;
221
217
  private static markBotSeenInChat;
@@ -288,6 +284,7 @@ export declare class FeishuBot {
288
284
  /**
289
285
  * Send a proactive message to a chat (not a reply).
290
286
  */
287
+ private sendErrorNotice;
291
288
  private sendFinalMessage;
292
289
  private sendMessage;
293
290
  /**