@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/cli.cjs
CHANGED
|
@@ -696,6 +696,8 @@ var SKIP_PATTERNS = [
|
|
|
696
696
|
/^\[HEARTBEAT/m,
|
|
697
697
|
/^\[Someone left you a voice message\]/m
|
|
698
698
|
];
|
|
699
|
+
var OPENCLAW_SENDER_PATTERN = /"sender_id":\s*"([^"]+)".*?"sender":\s*"([^"]+)"/s;
|
|
700
|
+
var OPENCLAW_SKIP_SENDERS = /* @__PURE__ */ new Set(["city", "owner", "system"]);
|
|
699
701
|
function detectAgentConversation(messages) {
|
|
700
702
|
const negative = { isAgentToAgent: false };
|
|
701
703
|
if (!messages || messages.length === 0) return negative;
|
|
@@ -704,6 +706,25 @@ function detectAgentConversation(messages) {
|
|
|
704
706
|
const content = contentToString(msg.content);
|
|
705
707
|
if (!content) continue;
|
|
706
708
|
if (SKIP_PATTERNS.some((p) => p.test(content))) continue;
|
|
709
|
+
if (content.includes("untrusted metadata") || content.includes("sender_id")) {
|
|
710
|
+
const senderMatch = content.match(OPENCLAW_SENDER_PATTERN);
|
|
711
|
+
if (senderMatch) {
|
|
712
|
+
const [, senderId, senderName] = senderMatch;
|
|
713
|
+
if (!OPENCLAW_SKIP_SENDERS.has(senderId) && !OPENCLAW_SKIP_SENDERS.has(senderName.toLowerCase())) {
|
|
714
|
+
let exchangeType = "chat";
|
|
715
|
+
if (content.includes("[DM from")) exchangeType = "dm";
|
|
716
|
+
else if (content.includes("mentioned you")) exchangeType = "mention";
|
|
717
|
+
else if (content.includes("proposal")) exchangeType = "proposal";
|
|
718
|
+
else if (content.includes("zone chat")) exchangeType = "chat";
|
|
719
|
+
return {
|
|
720
|
+
isAgentToAgent: true,
|
|
721
|
+
otherAgentId: senderName,
|
|
722
|
+
exchangeType
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
continue;
|
|
727
|
+
}
|
|
707
728
|
if (msg.name && msg.role === "user") {
|
|
708
729
|
return {
|
|
709
730
|
isAgentToAgent: true,
|
|
@@ -787,8 +808,29 @@ function detectAgentConversation(messages) {
|
|
|
787
808
|
}
|
|
788
809
|
return negative;
|
|
789
810
|
}
|
|
790
|
-
function extractExchangeText(messages) {
|
|
791
|
-
|
|
811
|
+
function extractExchangeText(messages, otherAgentId) {
|
|
812
|
+
const relevant = messages.filter((m) => m.role === "user" || m.role === "assistant");
|
|
813
|
+
if (otherAgentId) {
|
|
814
|
+
let lastAgentMsgIndex = -1;
|
|
815
|
+
for (let i = relevant.length - 1; i >= 0; i--) {
|
|
816
|
+
const msg = relevant[i];
|
|
817
|
+
if (msg.role !== "user") continue;
|
|
818
|
+
const text = contentToString(msg.content);
|
|
819
|
+
if (msg.name === otherAgentId || text.includes(otherAgentId)) {
|
|
820
|
+
lastAgentMsgIndex = i;
|
|
821
|
+
break;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
if (lastAgentMsgIndex >= 0) {
|
|
825
|
+
const slice = relevant.slice(lastAgentMsgIndex, lastAgentMsgIndex + 2);
|
|
826
|
+
return slice.map((m) => {
|
|
827
|
+
const speaker = m.name ?? m.role;
|
|
828
|
+
const content = contentToString(m.content);
|
|
829
|
+
return `[${speaker}]: ${content}`;
|
|
830
|
+
}).join("\n").slice(0, 6e3);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
return relevant.map((m) => {
|
|
792
834
|
const speaker = m.name ?? m.role;
|
|
793
835
|
const content = contentToString(m.content);
|
|
794
836
|
return `[${speaker}]: ${content}`;
|
|
@@ -819,7 +861,7 @@ var LessonExtractor = class {
|
|
|
819
861
|
const trustLevel = this.trust.getLevel(agentId);
|
|
820
862
|
if (trustLevel === "blocked") return;
|
|
821
863
|
if (!this.trust.canLearn(agentId)) return;
|
|
822
|
-
const exchangeText = extractExchangeText(messages);
|
|
864
|
+
const exchangeText = extractExchangeText(messages, agentId !== "unknown-agent" ? agentId : void 0);
|
|
823
865
|
if (exchangeText.length < 20) return;
|
|
824
866
|
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.
|
|
825
867
|
|
|
@@ -975,7 +1017,6 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
|
|
|
975
1017
|
}
|
|
976
1018
|
if (config.auto_extract && extractor && Array.isArray(messages)) {
|
|
977
1019
|
extractor.extract(messages).then(() => {
|
|
978
|
-
stats.lessons_extracted++;
|
|
979
1020
|
}).catch(() => {
|
|
980
1021
|
});
|
|
981
1022
|
}
|
|
@@ -984,7 +1025,6 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
|
|
|
984
1025
|
res.end(Buffer.from(responseBuffer));
|
|
985
1026
|
if (config.auto_extract && extractor && Array.isArray(messages)) {
|
|
986
1027
|
extractor.extract(messages).then(() => {
|
|
987
|
-
stats.lessons_extracted++;
|
|
988
1028
|
}).catch(() => {
|
|
989
1029
|
});
|
|
990
1030
|
}
|