@openclawcity/become 1.0.26 → 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/cli.cjs +100 -13
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +100 -13
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +100 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +100 -13
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -681,16 +681,50 @@ function injectSkillsIntoMessages(messages, skillText) {
|
|
|
681
681
|
}
|
|
682
682
|
|
|
683
683
|
// src/proxy/detector.ts
|
|
684
|
-
var
|
|
685
|
-
var
|
|
686
|
-
var
|
|
684
|
+
var OCC_DM_PATTERN = /^\[DM from ([^\]]+)\]:/m;
|
|
685
|
+
var OCC_MENTION_PATTERN = /^\[([^\]]+) mentioned you in building chat\]:/m;
|
|
686
|
+
var OCC_ZONE_CHAT_PATTERN = /^\[([^\]]+) in zone chat\]:/m;
|
|
687
|
+
var OCC_PROPOSAL_PATTERN = /^\[([^\]]+) (?:sent you a proposal|accepted your proposal)\]:/m;
|
|
688
|
+
var OCC_CONVERSATION_REQUEST = /^\[([^\]]+) wants to start a conversation with you\]:/m;
|
|
689
|
+
var GENERIC_CHANNEL_PATTERN = /^\[([^\]]+)\s+says?\]:\s*/m;
|
|
690
|
+
var GENERIC_DM_PATTERN = /^DM\s+from\s+([^:]+):\s*/m;
|
|
691
|
+
var BUILDING_PATTERN = /^([a-zA-Z0-9]+[-_][a-zA-Z0-9_.-]+)\s+in\s+[^:]+:\s*/m;
|
|
687
692
|
var REVIEW_KEYWORDS = ["strengths:", "weaknesses:", "verdict:", "assessment:", "suggestions:"];
|
|
693
|
+
var SKIP_PATTERNS = [
|
|
694
|
+
/^\[Your human owner says\]:/m,
|
|
695
|
+
/^\[Your human set a new mission/m,
|
|
696
|
+
/^\[HEARTBEAT/m,
|
|
697
|
+
/^\[Someone left you a voice message\]/m
|
|
698
|
+
];
|
|
699
|
+
var OPENCLAW_SENDER_PATTERN = /"sender_id":\s*"([^"]+)".*?"sender":\s*"([^"]+)"/s;
|
|
700
|
+
var OPENCLAW_SKIP_SENDERS = /* @__PURE__ */ new Set(["city", "owner", "system"]);
|
|
688
701
|
function detectAgentConversation(messages) {
|
|
689
702
|
const negative = { isAgentToAgent: false };
|
|
690
703
|
if (!messages || messages.length === 0) return negative;
|
|
691
704
|
for (const msg of messages) {
|
|
692
705
|
if (msg.role !== "user" && msg.role !== "assistant") continue;
|
|
693
|
-
const content =
|
|
706
|
+
const content = contentToString(msg.content);
|
|
707
|
+
if (!content) continue;
|
|
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
|
+
}
|
|
694
728
|
if (msg.name && msg.role === "user") {
|
|
695
729
|
return {
|
|
696
730
|
isAgentToAgent: true,
|
|
@@ -698,7 +732,47 @@ function detectAgentConversation(messages) {
|
|
|
698
732
|
exchangeType: "chat"
|
|
699
733
|
};
|
|
700
734
|
}
|
|
701
|
-
const
|
|
735
|
+
const dmMatch = content.match(OCC_DM_PATTERN);
|
|
736
|
+
if (dmMatch) {
|
|
737
|
+
return {
|
|
738
|
+
isAgentToAgent: true,
|
|
739
|
+
otherAgentId: dmMatch[1].trim(),
|
|
740
|
+
exchangeType: "dm"
|
|
741
|
+
};
|
|
742
|
+
}
|
|
743
|
+
const mentionMatch = content.match(OCC_MENTION_PATTERN);
|
|
744
|
+
if (mentionMatch) {
|
|
745
|
+
return {
|
|
746
|
+
isAgentToAgent: true,
|
|
747
|
+
otherAgentId: mentionMatch[1].trim(),
|
|
748
|
+
exchangeType: "mention"
|
|
749
|
+
};
|
|
750
|
+
}
|
|
751
|
+
const zoneMatch = content.match(OCC_ZONE_CHAT_PATTERN);
|
|
752
|
+
if (zoneMatch) {
|
|
753
|
+
return {
|
|
754
|
+
isAgentToAgent: true,
|
|
755
|
+
otherAgentId: zoneMatch[1].trim(),
|
|
756
|
+
exchangeType: "chat"
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
const proposalMatch = content.match(OCC_PROPOSAL_PATTERN);
|
|
760
|
+
if (proposalMatch) {
|
|
761
|
+
return {
|
|
762
|
+
isAgentToAgent: true,
|
|
763
|
+
otherAgentId: proposalMatch[1].trim(),
|
|
764
|
+
exchangeType: "proposal"
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
const convMatch = content.match(OCC_CONVERSATION_REQUEST);
|
|
768
|
+
if (convMatch) {
|
|
769
|
+
return {
|
|
770
|
+
isAgentToAgent: true,
|
|
771
|
+
otherAgentId: convMatch[1].trim(),
|
|
772
|
+
exchangeType: "dm"
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
const channelMatch = content.match(GENERIC_CHANNEL_PATTERN);
|
|
702
776
|
if (channelMatch) {
|
|
703
777
|
return {
|
|
704
778
|
isAgentToAgent: true,
|
|
@@ -706,11 +780,11 @@ function detectAgentConversation(messages) {
|
|
|
706
780
|
exchangeType: "channel"
|
|
707
781
|
};
|
|
708
782
|
}
|
|
709
|
-
const
|
|
710
|
-
if (
|
|
783
|
+
const genericDmMatch = content.match(GENERIC_DM_PATTERN);
|
|
784
|
+
if (genericDmMatch) {
|
|
711
785
|
return {
|
|
712
786
|
isAgentToAgent: true,
|
|
713
|
-
otherAgentId:
|
|
787
|
+
otherAgentId: genericDmMatch[1].trim(),
|
|
714
788
|
exchangeType: "dm"
|
|
715
789
|
};
|
|
716
790
|
}
|
|
@@ -737,10 +811,17 @@ function detectAgentConversation(messages) {
|
|
|
737
811
|
function extractExchangeText(messages) {
|
|
738
812
|
return messages.filter((m) => m.role === "user" || m.role === "assistant").map((m) => {
|
|
739
813
|
const speaker = m.name ?? m.role;
|
|
740
|
-
const content =
|
|
814
|
+
const content = contentToString(m.content);
|
|
741
815
|
return `[${speaker}]: ${content}`;
|
|
742
816
|
}).join("\n").slice(0, 6e3);
|
|
743
817
|
}
|
|
818
|
+
function contentToString(content) {
|
|
819
|
+
if (typeof content === "string") return content;
|
|
820
|
+
if (Array.isArray(content)) {
|
|
821
|
+
return content.filter((c) => c.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
822
|
+
}
|
|
823
|
+
return "";
|
|
824
|
+
}
|
|
744
825
|
|
|
745
826
|
// src/proxy/extractor.ts
|
|
746
827
|
var LessonExtractor = class {
|
|
@@ -865,8 +946,9 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
|
|
|
865
946
|
if (Array.isArray(messages)) {
|
|
866
947
|
for (const m of messages) {
|
|
867
948
|
if (m.role === "user" || m.role === "system") {
|
|
868
|
-
const
|
|
869
|
-
|
|
949
|
+
const text = extractText(m.content);
|
|
950
|
+
const preview = text.slice(0, 300).replace(/\n/g, "\\n");
|
|
951
|
+
console.log(`[become] msg ${m.role}${m.name ? ` name=${m.name}` : ""}: ${preview}`);
|
|
870
952
|
}
|
|
871
953
|
}
|
|
872
954
|
}
|
|
@@ -914,7 +996,6 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
|
|
|
914
996
|
}
|
|
915
997
|
if (config.auto_extract && extractor && Array.isArray(messages)) {
|
|
916
998
|
extractor.extract(messages).then(() => {
|
|
917
|
-
stats.lessons_extracted++;
|
|
918
999
|
}).catch(() => {
|
|
919
1000
|
});
|
|
920
1001
|
}
|
|
@@ -923,7 +1004,6 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
|
|
|
923
1004
|
res.end(Buffer.from(responseBuffer));
|
|
924
1005
|
if (config.auto_extract && extractor && Array.isArray(messages)) {
|
|
925
1006
|
extractor.extract(messages).then(() => {
|
|
926
|
-
stats.lessons_extracted++;
|
|
927
1007
|
}).catch(() => {
|
|
928
1008
|
});
|
|
929
1009
|
}
|
|
@@ -991,6 +1071,13 @@ function buildUpstreamHeaders(config, incomingHeaders) {
|
|
|
991
1071
|
if (typeof accept === "string") headers["Accept"] = accept;
|
|
992
1072
|
return headers;
|
|
993
1073
|
}
|
|
1074
|
+
function extractText(content) {
|
|
1075
|
+
if (typeof content === "string") return content;
|
|
1076
|
+
if (Array.isArray(content)) {
|
|
1077
|
+
return content.filter((c) => c.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
1078
|
+
}
|
|
1079
|
+
return "";
|
|
1080
|
+
}
|
|
994
1081
|
|
|
995
1082
|
// src/dashboard/server.ts
|
|
996
1083
|
var import_node_http2 = require("http");
|