@jerryliang122/openclaw-qqbot 1.0.6 → 1.0.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jerryliang122/openclaw-qqbot",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "QQ Bot channel plugin for OpenClaw (independently maintained fork)",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -89,7 +89,26 @@ export function buildCtxPayload(params: CtxPayloadParams): any {
89
89
  },
90
90
  reply: {
91
91
  to: envelope.targetId,
92
- replyToId: envelope.messageId,
92
+ /**
93
+ * ReplyToId 契约语义 = 当前消息回复(引用)的那条消息的 ID —— 对齐
94
+ * telegram 原生通道(replyHead?.messageId ?? visibleReplyTarget?.id),
95
+ * 无引用时必须为 undefined。框架将其渲染为模型可见 Conversation info
96
+ * 的 reply_to_id 字段。
97
+ *
98
+ * 历史版本误填 envelope.messageId(消息自身 ID),导致每条消息都呈现
99
+ * message_id == reply_to_id —— 被上层 agent 的 AGENTS 规则判为「内部
100
+ * 回灌、非新指令」而拒绝响应(2026-09-22 事故)。
101
+ *
102
+ * QQ 被动回复锚点不依赖此字段:deliverCtx.replyToId / msgid-cache 兜底
103
+ * (resolvePassiveFirstReplyToId)/ attachMsgIdWithQuota 均独立取值,
104
+ * threading resolveReplyToMode='off' 阻断框架隐式回复线程。
105
+ *
106
+ * 防御守卫:即使上游异常传入当前消息 ID(自引用),也强制置空——
107
+ * 「reply_to_id == message_id」这一假回灌签名在任何路径都不允许再现。
108
+ */
109
+ replyToId: envelope.quote?.messageId && envelope.quote.messageId !== envelope.messageId
110
+ ? envelope.quote.messageId
111
+ : undefined,
93
112
  originatingTo: envelope.targetId,
94
113
  },
95
114
  access: {
@@ -100,8 +119,17 @@ export function buildCtxPayload(params: CtxPayloadParams): any {
100
119
  : undefined,
101
120
  media: mediaFacts.length > 0 ? mediaFacts : undefined,
102
121
  supplemental: {
122
+ // quote.id 同样必须是「被引用消息」的真实 ID(ref-index 命中时),
123
+ // 而非当前消息 ID——框架经 applySupplementalContext 映射为
124
+ // ctx.ReplyToId / "Reply target of current user message"。
103
125
  quote: envelope.quote
104
- ? { id: envelope.messageId, body: envelope.quote.content, sender: envelope.quote.senderId }
126
+ ? {
127
+ ...(envelope.quote.messageId && envelope.quote.messageId !== envelope.messageId
128
+ ? { id: envelope.quote.messageId }
129
+ : {}),
130
+ body: envelope.quote.content,
131
+ sender: envelope.quote.senderId,
132
+ }
105
133
  : undefined,
106
134
  groupSystemPrompt: envelope.systemPrompt,
107
135
  },
@@ -20,7 +20,7 @@ export interface OpenClawInboundMessage {
20
20
  messageId: string;
21
21
  content: string;
22
22
  history?: Array<{ role: string; content: string; senderId?: string; senderName?: string }>;
23
- quote?: { content: string; senderId: string; attachments?: unknown[] };
23
+ quote?: { content: string; senderId: string; messageId?: string; attachments?: unknown[] };
24
24
  attachments?: unknown[];
25
25
  /** 入站图片 URL 列表(从附件中提取) */
26
26
  imageUrls?: string[];
@@ -44,7 +44,11 @@ function mapHistory(
44
44
  }
45
45
 
46
46
  /**
47
- * 将 ResolvedQuote 转换为 OpenClaw quote 格式
47
+ * 将 ResolvedQuote 转换为 OpenClaw quote 格式。
48
+ *
49
+ * messageId 为被引用消息的真实平台消息 ID:仅 ref-index store 命中
50
+ * (quote.source === 'store',entry 存在)时可取;msg_elements 兜底
51
+ * 解析拿不到 id,保持 undefined —— 此时框架不渲染 reply_to_id。
48
52
  */
49
53
  function mapQuote(
50
54
  quote: ResolvedQuote | undefined,
@@ -53,6 +57,7 @@ function mapQuote(
53
57
  return {
54
58
  content: quote.text,
55
59
  senderId: quote.entry?.senderId ?? '',
60
+ messageId: quote.entry?.messageId,
56
61
  attachments: quote.attachments as unknown[],
57
62
  };
58
63
  }