@agentvault/agentvault 0.23.3 → 0.23.4

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.
@@ -18,9 +18,24 @@ declare function _parseMentions(text: string): string[];
18
18
  * with 2min cooldown), so we no longer gate on senderIsAgent. All messages
19
19
  * are processed unless they @mention a *different* agent specifically.
20
20
  */
21
- declare function _shouldProcessRoomMessage(plaintext: string, agentName: string, accountId: string, senderIsAgent?: boolean, roomDisplayName?: string): boolean;
21
+ declare function _shouldProcessRoomMessage(plaintext: string, agentName: string, accountId: string, senderIsAgent?: boolean, roomDisplayName?: string, ownDisplayName?: string, selfResolved?: boolean): boolean;
22
22
  /** Strip the matching @mention prefix from plaintext so the agent sees clean text. */
23
- declare function _stripMentions(text: string, agentName: string, accountId: string, roomDisplayName?: string): string;
23
+ declare function _stripMentions(text: string, agentName: string, accountId: string, roomDisplayName?: string, ownDisplayName?: string): string;
24
+ /** Strip <think>…</think> reasoning blocks (and bare "think" lines) from model
25
+ * output, returning the trimmed remainder. Used to RECOVER a real answer from a
26
+ * turn whose blocks were all filtered as reasoning (regression 2026-07-08): a
27
+ * reasoning-heavy model (deepseek) can emit `<think>…</think>answer` as one block
28
+ * that the reply filter drops wholesale because it STARTS with `<think`, so the
29
+ * room got silence. Returns "" when nothing substantive remains (genuinely no
30
+ * answer — surface a warning rather than post noise). */
31
+ declare function _stripThinkBlocks(text: string): string;
32
+ /** True when a block looks like leaked chain-of-thought or an OpenClaw directive
33
+ * rather than a real reply: a "Reasoning:/Thinking:/Let me…/I need to/Let me
34
+ * check:" preamble, a <think> XML block or bare "think" line, or a [[directive]]
35
+ * tag. Single source of truth used BOTH to filter reply blocks AND to gate the
36
+ * Fix-B recovery stash — so a recovered fallback can never itself be raw reasoning
37
+ * noise, and the two checks can never drift (code-review 2026-07-08). */
38
+ declare function _looksLikeReasoningLeak(text: string): boolean;
24
39
  /** Resolve this agent's AgentVault room display_name (its own roster entry) +
25
40
  * build the compact identity+roster preamble surfaced to the LLM, so the agent
26
41
  * knows who it is in the room and who else is present (BUG-20260604-002).
@@ -113,7 +128,7 @@ declare function _emitHierarchicalSpans(channel: any, opts: {
113
128
  status: "ok" | "error";
114
129
  statusMessage?: string;
115
130
  }): void;
116
- export { _parseMentions, _shouldProcessRoomMessage, _stripMentions, _emitHierarchicalSpans, _resolveRoomIdentity, _buildRoomSenderId, _buildRoomTo };
131
+ export { _parseMentions, _shouldProcessRoomMessage, _stripMentions, _stripThinkBlocks, _looksLikeReasoningLeak, _emitHierarchicalSpans, _resolveRoomIdentity, _buildRoomSenderId, _buildRoomTo };
117
132
  declare const _default: {
118
133
  id: string;
119
134
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"openclaw-entry.d.ts","sourceRoot":"","sources":["../src/openclaw-entry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,OAAO,KAAK,EACV,iBAAiB,EASlB,MAAM,qBAAqB,CAAC;AA4D7B,gFAAgF;AAChF,eAAO,IAAI,oBAAoB,SAAQ,CAAC;AA0FxC,uEAAuE;AACvE,iBAAS,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAS9C;AAED;;;;;GAKG;AACH,iBAAS,yBAAyB,CAChC,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,aAAa,CAAC,EAAE,OAAO,EACvB,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAgBT;AAuBD,sFAAsF;AACtF,iBAAS,cAAc,CACrB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,eAAe,CAAC,EAAE,MAAM,GACvB,MAAM,CAeR;AAED;;;;cAIc;AACd,iBAAS,oBAAoB,CAC3B,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,YAAY,EAAE,MAAM,GACnB;IAAE,QAAQ,EAAE,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xF,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,IAAI,CA8DP;AAogBD,OAAO,EAAE,cAAc,EAAE,yBAAyB,EAAE,cAAc,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,YAAY,EAAE,CAAC;;;;;kBAQjL,iBAAiB;;AAJjC,wBA0ZE"}
@@ -49616,15 +49616,16 @@ function _parseMentions(text) {
49616
49616
  }
49617
49617
  return mentions;
49618
49618
  }
49619
- function _shouldProcessRoomMessage(plaintext, agentName, accountId, senderIsAgent, roomDisplayName) {
49619
+ function _shouldProcessRoomMessage(plaintext, agentName, accountId, senderIsAgent, roomDisplayName, ownDisplayName, selfResolved = true) {
49620
49620
  const mentions = _parseMentions(plaintext);
49621
49621
  if (mentions.length === 0) return true;
49622
49622
  if (mentions.includes("all") || mentions.includes("everyone")) return true;
49623
- const ownNames = _ownRoomNames(agentName, accountId, roomDisplayName);
49623
+ const ownNames = _ownRoomNames(agentName, accountId, roomDisplayName, ownDisplayName);
49624
49624
  if (mentions.some((m2) => ownNames.has(m2))) return true;
49625
+ if (!selfResolved) return true;
49625
49626
  return false;
49626
49627
  }
49627
- function _ownRoomNames(agentName, accountId, roomDisplayName) {
49628
+ function _ownRoomNames(agentName, accountId, roomDisplayName, ownDisplayName) {
49628
49629
  const names = /* @__PURE__ */ new Set();
49629
49630
  const add2 = (n2) => {
49630
49631
  if (!n2) return;
@@ -49635,10 +49636,11 @@ function _ownRoomNames(agentName, accountId, roomDisplayName) {
49635
49636
  add2(agentName);
49636
49637
  add2(accountId);
49637
49638
  add2(roomDisplayName);
49639
+ add2(ownDisplayName);
49638
49640
  return names;
49639
49641
  }
49640
- function _stripMentions(text, agentName, accountId, roomDisplayName) {
49641
- const ownNames = _ownRoomNames(agentName, accountId, roomDisplayName);
49642
+ function _stripMentions(text, agentName, accountId, roomDisplayName, ownDisplayName) {
49643
+ const ownNames = _ownRoomNames(agentName, accountId, roomDisplayName, ownDisplayName);
49642
49644
  return text.replace(/@(\w[\w]*)/gi, (full, name) => {
49643
49645
  const lower = name.toLowerCase();
49644
49646
  if (ownNames.has(lower)) {
@@ -49648,6 +49650,12 @@ function _stripMentions(text, agentName, accountId, roomDisplayName) {
49648
49650
  return full;
49649
49651
  }).replace(/^\s+/, "").trim();
49650
49652
  }
49653
+ function _stripThinkBlocks(text) {
49654
+ return (text ?? "").replace(/<think>[\s\S]*?<\/think>/gi, " ").replace(/^\s*think\s*$/gim, " ").trim();
49655
+ }
49656
+ function _looksLikeReasoningLeak(text) {
49657
+ return /^(Reasoning|Thinking|Let me think|I need to|Let me check):/i.test(text) || /^<think[\s>]/i.test(text) || /^think$/im.test(text) || /^\[\[[\w_]+\]\]/.test(text) || /^<think>[\s\S]*<\/think>$/i.test(text);
49658
+ }
49651
49659
  function _resolveRoomIdentity(channel, roomId, fallbackName) {
49652
49660
  const fallback = { selfName: fallbackName, preamble: "" };
49653
49661
  if (!roomId) return fallback;
@@ -49745,12 +49753,15 @@ async function handleInbound(params) {
49745
49753
  const isRoomMessage = Boolean(metadata.roomId);
49746
49754
  const isA2AMessage = Boolean(metadata.a2aChannelId);
49747
49755
  const roomIdentity = isRoomMessage ? _resolveRoomIdentity(channel, metadata.roomId, account.agentName ?? "") : { selfName: account.agentName ?? "", preamble: "" };
49756
+ const ownDisplayName = channel.ownDisplayName ?? "";
49757
+ const genericAgentName = !account.agentName || account.agentName.toLowerCase() === "default";
49758
+ const selfResolved = !!ownDisplayName || !!roomIdentity.selfName && roomIdentity.selfName !== (account.agentName ?? "") || !genericAgentName;
49748
49759
  if (isRoomMessage) {
49749
- if (!_shouldProcessRoomMessage(rawPlaintext, account.agentName ?? "", account.accountId ?? "", metadata.senderIsAgent, roomIdentity.selfName)) {
49760
+ if (!_shouldProcessRoomMessage(rawPlaintext, account.agentName ?? "", account.accountId ?? "", metadata.senderIsAgent, roomIdentity.selfName, ownDisplayName, selfResolved)) {
49750
49761
  return;
49751
49762
  }
49752
49763
  }
49753
- let plaintext = isRoomMessage ? _stripMentions(rawPlaintext, account.agentName ?? "", account.accountId ?? "", roomIdentity.selfName) : rawPlaintext;
49764
+ let plaintext = isRoomMessage ? _stripMentions(rawPlaintext, account.agentName ?? "", account.accountId ?? "", roomIdentity.selfName, ownDisplayName) : rawPlaintext;
49754
49765
  if (isRoomMessage || isA2AMessage) {
49755
49766
  try {
49756
49767
  const woke = await requestHeartbeatNow({ reason: `AgentVault ${isRoomMessage ? "room" : "A2A"} message received` });
@@ -49915,6 +49926,7 @@ async function handleInbound(params) {
49915
49926
  let totalReplyChars = 0;
49916
49927
  let firstReplyTime = null;
49917
49928
  const replySpans = [];
49929
+ let lastFilteredText = "";
49918
49930
  _emitChildSpan(channel, {
49919
49931
  traceId,
49920
49932
  parentSpanId: rootSpanId,
@@ -50099,10 +50111,11 @@ ${contextBody}`;
50099
50111
  if (payload.kind === "thinking" || payload.kind === "reasoning") return;
50100
50112
  const text = (payload.text ?? "").trim();
50101
50113
  if (!text) return;
50102
- if (/^(Reasoning|Thinking|Let me think|I need to|Let me check):/i.test(text)) return;
50103
- if (/^<think[\s>]/i.test(text) || /^think$/im.test(text)) return;
50104
- if (/^\[\[[\w_]+\]\]/.test(text)) return;
50105
- if (/^<think>[\s\S]*<\/think>$/i.test(text)) return;
50114
+ {
50115
+ const recoverable = _stripThinkBlocks(text);
50116
+ if (recoverable && !_looksLikeReasoningLeak(recoverable)) lastFilteredText = recoverable;
50117
+ }
50118
+ if (_looksLikeReasoningLeak(text)) return;
50106
50119
  const replyStart = Date.now();
50107
50120
  replyCount++;
50108
50121
  totalReplyChars += text.length;
@@ -50145,6 +50158,30 @@ ${contextBody}`;
50145
50158
  replyOptions: {}
50146
50159
  })
50147
50160
  );
50161
+ if (replyCount === 0 && lastFilteredText) {
50162
+ const canReply = isA2AMessage ? _a2aCanReply(metadata.a2aChannelId) : isRoomMessage ? _roomCanReply(metadata.roomId) : true;
50163
+ if (canReply) {
50164
+ const replyTarget = isA2AMessage ? { kind: "a2a", hubAddress: metadata.fromHubAddress } : isRoomMessage ? { kind: "room", roomId: metadata.roomId } : { kind: "owner" };
50165
+ console.warn(
50166
+ `[AgentVault] all reply blocks filtered as reasoning \u2014 delivering recovered fallback (${lastFilteredText.length} chars)`
50167
+ );
50168
+ await channel.deliver(replyTarget, { type: "text", text: lastFilteredText }, {
50169
+ conversationId: metadata.conversationId,
50170
+ topicId: metadata.topicId,
50171
+ parentSpanId: inferenceSpanId,
50172
+ metadata: isRoomMessage ? { content_length: lastFilteredText.length } : void 0
50173
+ });
50174
+ replyCount++;
50175
+ totalReplyChars += lastFilteredText.length;
50176
+ if (!firstReplyTime) firstReplyTime = Date.now();
50177
+ if (isA2AMessage) _a2aRecordReply(metadata.a2aChannelId);
50178
+ else if (isRoomMessage) _roomRecordReply(metadata.roomId);
50179
+ } else {
50180
+ console.warn("[AgentVault] reply blocks all filtered AND rate-limited \u2014 no fallback delivered");
50181
+ }
50182
+ } else if (replyCount === 0) {
50183
+ console.warn("[AgentVault] turn produced no deliverable reply (all blocks empty/filtered, nothing recoverable)");
50184
+ }
50148
50185
  const endTime = Date.now();
50149
50186
  _emitHierarchicalSpans(channel, {
50150
50187
  traceId,
@@ -51107,11 +51144,13 @@ export {
51107
51144
  _buildRoomSenderId,
51108
51145
  _buildRoomTo,
51109
51146
  _emitHierarchicalSpans,
51147
+ _looksLikeReasoningLeak,
51110
51148
  _parseMentions,
51111
51149
  _resolveRoomIdentity,
51112
51150
  _selectInboundPreamble,
51113
51151
  _shouldProcessRoomMessage,
51114
51152
  _stripMentions,
51153
+ _stripThinkBlocks,
51115
51154
  openclaw_entry_default as default,
51116
51155
  isUsingManagedRoutes
51117
51156
  };