@openclawcity/become 1.0.28 → 1.0.30
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/cli.cjs +45 -5
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +45 -5
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +45 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.js +45 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -856,12 +856,19 @@ declare function detectAgentConversation(messages: {
|
|
|
856
856
|
}[]): DetectionResult;
|
|
857
857
|
/**
|
|
858
858
|
* Extract agent-to-agent exchange text from messages for analysis.
|
|
859
|
+
*
|
|
860
|
+
* When `otherAgentId` is provided, only returns the last message from that
|
|
861
|
+
* agent and the assistant's reply — filtering out heartbeat instructions,
|
|
862
|
+
* city context, owner messages, and other noise that would confuse the LLM.
|
|
863
|
+
*
|
|
864
|
+
* Falls back to full conversation (capped at 6000 chars) when no agent ID
|
|
865
|
+
* is available (e.g. peer_review detection without a named sender).
|
|
859
866
|
*/
|
|
860
867
|
declare function extractExchangeText(messages: {
|
|
861
868
|
role: string;
|
|
862
869
|
content: unknown;
|
|
863
870
|
name?: string;
|
|
864
|
-
}[]): string;
|
|
871
|
+
}[], otherAgentId?: string): string;
|
|
865
872
|
|
|
866
873
|
/**
|
|
867
874
|
* Async lesson extractor. After the proxy forwards a response, this analyzes
|
package/dist/index.d.ts
CHANGED
|
@@ -856,12 +856,19 @@ declare function detectAgentConversation(messages: {
|
|
|
856
856
|
}[]): DetectionResult;
|
|
857
857
|
/**
|
|
858
858
|
* Extract agent-to-agent exchange text from messages for analysis.
|
|
859
|
+
*
|
|
860
|
+
* When `otherAgentId` is provided, only returns the last message from that
|
|
861
|
+
* agent and the assistant's reply — filtering out heartbeat instructions,
|
|
862
|
+
* city context, owner messages, and other noise that would confuse the LLM.
|
|
863
|
+
*
|
|
864
|
+
* Falls back to full conversation (capped at 6000 chars) when no agent ID
|
|
865
|
+
* is available (e.g. peer_review detection without a named sender).
|
|
859
866
|
*/
|
|
860
867
|
declare function extractExchangeText(messages: {
|
|
861
868
|
role: string;
|
|
862
869
|
content: unknown;
|
|
863
870
|
name?: string;
|
|
864
|
-
}[]): string;
|
|
871
|
+
}[], otherAgentId?: string): string;
|
|
865
872
|
|
|
866
873
|
/**
|
|
867
874
|
* Async lesson extractor. After the proxy forwards a response, this analyzes
|
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,
|
|
@@ -3287,8 +3308,29 @@ function detectAgentConversation(messages) {
|
|
|
3287
3308
|
}
|
|
3288
3309
|
return negative;
|
|
3289
3310
|
}
|
|
3290
|
-
function extractExchangeText(messages) {
|
|
3291
|
-
|
|
3311
|
+
function extractExchangeText(messages, otherAgentId) {
|
|
3312
|
+
const relevant = messages.filter((m) => m.role === "user" || m.role === "assistant");
|
|
3313
|
+
if (otherAgentId) {
|
|
3314
|
+
let lastAgentMsgIndex = -1;
|
|
3315
|
+
for (let i = relevant.length - 1; i >= 0; i--) {
|
|
3316
|
+
const msg = relevant[i];
|
|
3317
|
+
if (msg.role !== "user") continue;
|
|
3318
|
+
const text = contentToString(msg.content);
|
|
3319
|
+
if (msg.name === otherAgentId || text.includes(otherAgentId)) {
|
|
3320
|
+
lastAgentMsgIndex = i;
|
|
3321
|
+
break;
|
|
3322
|
+
}
|
|
3323
|
+
}
|
|
3324
|
+
if (lastAgentMsgIndex >= 0) {
|
|
3325
|
+
const slice = relevant.slice(lastAgentMsgIndex, lastAgentMsgIndex + 2);
|
|
3326
|
+
return slice.map((m) => {
|
|
3327
|
+
const speaker = m.name ?? m.role;
|
|
3328
|
+
const content = contentToString(m.content);
|
|
3329
|
+
return `[${speaker}]: ${content}`;
|
|
3330
|
+
}).join("\n").slice(0, 6e3);
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
return relevant.map((m) => {
|
|
3292
3334
|
const speaker = m.name ?? m.role;
|
|
3293
3335
|
const content = contentToString(m.content);
|
|
3294
3336
|
return `[${speaker}]: ${content}`;
|
|
@@ -3319,7 +3361,7 @@ var LessonExtractor = class {
|
|
|
3319
3361
|
const trustLevel = this.trust.getLevel(agentId);
|
|
3320
3362
|
if (trustLevel === "blocked") return;
|
|
3321
3363
|
if (!this.trust.canLearn(agentId)) return;
|
|
3322
|
-
const exchangeText = extractExchangeText(messages);
|
|
3364
|
+
const exchangeText = extractExchangeText(messages, agentId !== "unknown-agent" ? agentId : void 0);
|
|
3323
3365
|
if (exchangeText.length < 20) return;
|
|
3324
3366
|
const prompt = `Analyze this conversation between an AI agent and another agent. Extract concrete, actionable lessons that the first agent (the "assistant") can learn from the other agent.
|
|
3325
3367
|
|
|
@@ -3475,7 +3517,6 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
|
|
|
3475
3517
|
}
|
|
3476
3518
|
if (config.auto_extract && extractor && Array.isArray(messages)) {
|
|
3477
3519
|
extractor.extract(messages).then(() => {
|
|
3478
|
-
stats.lessons_extracted++;
|
|
3479
3520
|
}).catch(() => {
|
|
3480
3521
|
});
|
|
3481
3522
|
}
|
|
@@ -3484,7 +3525,6 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
|
|
|
3484
3525
|
res.end(Buffer.from(responseBuffer));
|
|
3485
3526
|
if (config.auto_extract && extractor && Array.isArray(messages)) {
|
|
3486
3527
|
extractor.extract(messages).then(() => {
|
|
3487
|
-
stats.lessons_extracted++;
|
|
3488
3528
|
}).catch(() => {
|
|
3489
3529
|
});
|
|
3490
3530
|
}
|