@openclawcity/become 1.0.29 → 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 +24 -3
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +24 -3
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +24 -3
- 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 +24 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -769,8 +769,29 @@ function detectAgentConversation(messages) {
|
|
|
769
769
|
}
|
|
770
770
|
return negative;
|
|
771
771
|
}
|
|
772
|
-
function extractExchangeText(messages) {
|
|
773
|
-
|
|
772
|
+
function extractExchangeText(messages, otherAgentId) {
|
|
773
|
+
const relevant = messages.filter((m) => m.role === "user" || m.role === "assistant");
|
|
774
|
+
if (otherAgentId) {
|
|
775
|
+
let lastAgentMsgIndex = -1;
|
|
776
|
+
for (let i = relevant.length - 1; i >= 0; i--) {
|
|
777
|
+
const msg = relevant[i];
|
|
778
|
+
if (msg.role !== "user") continue;
|
|
779
|
+
const text = contentToString(msg.content);
|
|
780
|
+
if (msg.name === otherAgentId || text.includes(otherAgentId)) {
|
|
781
|
+
lastAgentMsgIndex = i;
|
|
782
|
+
break;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
if (lastAgentMsgIndex >= 0) {
|
|
786
|
+
const slice = relevant.slice(lastAgentMsgIndex, lastAgentMsgIndex + 2);
|
|
787
|
+
return slice.map((m) => {
|
|
788
|
+
const speaker = m.name ?? m.role;
|
|
789
|
+
const content = contentToString(m.content);
|
|
790
|
+
return `[${speaker}]: ${content}`;
|
|
791
|
+
}).join("\n").slice(0, 6e3);
|
|
792
|
+
}
|
|
793
|
+
}
|
|
794
|
+
return relevant.map((m) => {
|
|
774
795
|
const speaker = m.name ?? m.role;
|
|
775
796
|
const content = contentToString(m.content);
|
|
776
797
|
return `[${speaker}]: ${content}`;
|
|
@@ -801,7 +822,7 @@ var LessonExtractor = class {
|
|
|
801
822
|
const trustLevel = this.trust.getLevel(agentId);
|
|
802
823
|
if (trustLevel === "blocked") return;
|
|
803
824
|
if (!this.trust.canLearn(agentId)) return;
|
|
804
|
-
const exchangeText = extractExchangeText(messages);
|
|
825
|
+
const exchangeText = extractExchangeText(messages, agentId !== "unknown-agent" ? agentId : void 0);
|
|
805
826
|
if (exchangeText.length < 20) return;
|
|
806
827
|
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.
|
|
807
828
|
|