@openclawcity/become 1.0.28 → 1.0.29

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/dist/index.js CHANGED
@@ -3196,6 +3196,8 @@ var SKIP_PATTERNS = [
3196
3196
  /^\[HEARTBEAT/m,
3197
3197
  /^\[Someone left you a voice message\]/m
3198
3198
  ];
3199
+ var OPENCLAW_SENDER_PATTERN = /"sender_id":\s*"([^"]+)".*?"sender":\s*"([^"]+)"/s;
3200
+ var OPENCLAW_SKIP_SENDERS = /* @__PURE__ */ new Set(["city", "owner", "system"]);
3199
3201
  function detectAgentConversation(messages) {
3200
3202
  const negative = { isAgentToAgent: false };
3201
3203
  if (!messages || messages.length === 0) return negative;
@@ -3204,6 +3206,25 @@ function detectAgentConversation(messages) {
3204
3206
  const content = contentToString(msg.content);
3205
3207
  if (!content) continue;
3206
3208
  if (SKIP_PATTERNS.some((p) => p.test(content))) continue;
3209
+ if (content.includes("untrusted metadata") || content.includes("sender_id")) {
3210
+ const senderMatch = content.match(OPENCLAW_SENDER_PATTERN);
3211
+ if (senderMatch) {
3212
+ const [, senderId, senderName] = senderMatch;
3213
+ if (!OPENCLAW_SKIP_SENDERS.has(senderId) && !OPENCLAW_SKIP_SENDERS.has(senderName.toLowerCase())) {
3214
+ let exchangeType = "chat";
3215
+ if (content.includes("[DM from")) exchangeType = "dm";
3216
+ else if (content.includes("mentioned you")) exchangeType = "mention";
3217
+ else if (content.includes("proposal")) exchangeType = "proposal";
3218
+ else if (content.includes("zone chat")) exchangeType = "chat";
3219
+ return {
3220
+ isAgentToAgent: true,
3221
+ otherAgentId: senderName,
3222
+ exchangeType
3223
+ };
3224
+ }
3225
+ }
3226
+ continue;
3227
+ }
3207
3228
  if (msg.name && msg.role === "user") {
3208
3229
  return {
3209
3230
  isAgentToAgent: true,
@@ -3475,7 +3496,6 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
3475
3496
  }
3476
3497
  if (config.auto_extract && extractor && Array.isArray(messages)) {
3477
3498
  extractor.extract(messages).then(() => {
3478
- stats.lessons_extracted++;
3479
3499
  }).catch(() => {
3480
3500
  });
3481
3501
  }
@@ -3484,7 +3504,6 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
3484
3504
  res.end(Buffer.from(responseBuffer));
3485
3505
  if (config.auto_extract && extractor && Array.isArray(messages)) {
3486
3506
  extractor.extract(messages).then(() => {
3487
- stats.lessons_extracted++;
3488
3507
  }).catch(() => {
3489
3508
  });
3490
3509
  }