@openclawcity/become 1.0.25 → 1.0.28
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 +85 -9
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +85 -9
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +85 -9
- 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 +85 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -642,16 +642,29 @@ function injectSkillsIntoMessages(messages, skillText) {
|
|
|
642
642
|
}
|
|
643
643
|
|
|
644
644
|
// src/proxy/detector.ts
|
|
645
|
-
var
|
|
646
|
-
var
|
|
647
|
-
var
|
|
645
|
+
var OCC_DM_PATTERN = /^\[DM from ([^\]]+)\]:/m;
|
|
646
|
+
var OCC_MENTION_PATTERN = /^\[([^\]]+) mentioned you in building chat\]:/m;
|
|
647
|
+
var OCC_ZONE_CHAT_PATTERN = /^\[([^\]]+) in zone chat\]:/m;
|
|
648
|
+
var OCC_PROPOSAL_PATTERN = /^\[([^\]]+) (?:sent you a proposal|accepted your proposal)\]:/m;
|
|
649
|
+
var OCC_CONVERSATION_REQUEST = /^\[([^\]]+) wants to start a conversation with you\]:/m;
|
|
650
|
+
var GENERIC_CHANNEL_PATTERN = /^\[([^\]]+)\s+says?\]:\s*/m;
|
|
651
|
+
var GENERIC_DM_PATTERN = /^DM\s+from\s+([^:]+):\s*/m;
|
|
652
|
+
var BUILDING_PATTERN = /^([a-zA-Z0-9]+[-_][a-zA-Z0-9_.-]+)\s+in\s+[^:]+:\s*/m;
|
|
648
653
|
var REVIEW_KEYWORDS = ["strengths:", "weaknesses:", "verdict:", "assessment:", "suggestions:"];
|
|
654
|
+
var SKIP_PATTERNS = [
|
|
655
|
+
/^\[Your human owner says\]:/m,
|
|
656
|
+
/^\[Your human set a new mission/m,
|
|
657
|
+
/^\[HEARTBEAT/m,
|
|
658
|
+
/^\[Someone left you a voice message\]/m
|
|
659
|
+
];
|
|
649
660
|
function detectAgentConversation(messages) {
|
|
650
661
|
const negative = { isAgentToAgent: false };
|
|
651
662
|
if (!messages || messages.length === 0) return negative;
|
|
652
663
|
for (const msg of messages) {
|
|
653
664
|
if (msg.role !== "user" && msg.role !== "assistant") continue;
|
|
654
|
-
const content =
|
|
665
|
+
const content = contentToString(msg.content);
|
|
666
|
+
if (!content) continue;
|
|
667
|
+
if (SKIP_PATTERNS.some((p) => p.test(content))) continue;
|
|
655
668
|
if (msg.name && msg.role === "user") {
|
|
656
669
|
return {
|
|
657
670
|
isAgentToAgent: true,
|
|
@@ -659,7 +672,47 @@ function detectAgentConversation(messages) {
|
|
|
659
672
|
exchangeType: "chat"
|
|
660
673
|
};
|
|
661
674
|
}
|
|
662
|
-
const
|
|
675
|
+
const dmMatch = content.match(OCC_DM_PATTERN);
|
|
676
|
+
if (dmMatch) {
|
|
677
|
+
return {
|
|
678
|
+
isAgentToAgent: true,
|
|
679
|
+
otherAgentId: dmMatch[1].trim(),
|
|
680
|
+
exchangeType: "dm"
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
const mentionMatch = content.match(OCC_MENTION_PATTERN);
|
|
684
|
+
if (mentionMatch) {
|
|
685
|
+
return {
|
|
686
|
+
isAgentToAgent: true,
|
|
687
|
+
otherAgentId: mentionMatch[1].trim(),
|
|
688
|
+
exchangeType: "mention"
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
const zoneMatch = content.match(OCC_ZONE_CHAT_PATTERN);
|
|
692
|
+
if (zoneMatch) {
|
|
693
|
+
return {
|
|
694
|
+
isAgentToAgent: true,
|
|
695
|
+
otherAgentId: zoneMatch[1].trim(),
|
|
696
|
+
exchangeType: "chat"
|
|
697
|
+
};
|
|
698
|
+
}
|
|
699
|
+
const proposalMatch = content.match(OCC_PROPOSAL_PATTERN);
|
|
700
|
+
if (proposalMatch) {
|
|
701
|
+
return {
|
|
702
|
+
isAgentToAgent: true,
|
|
703
|
+
otherAgentId: proposalMatch[1].trim(),
|
|
704
|
+
exchangeType: "proposal"
|
|
705
|
+
};
|
|
706
|
+
}
|
|
707
|
+
const convMatch = content.match(OCC_CONVERSATION_REQUEST);
|
|
708
|
+
if (convMatch) {
|
|
709
|
+
return {
|
|
710
|
+
isAgentToAgent: true,
|
|
711
|
+
otherAgentId: convMatch[1].trim(),
|
|
712
|
+
exchangeType: "dm"
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
const channelMatch = content.match(GENERIC_CHANNEL_PATTERN);
|
|
663
716
|
if (channelMatch) {
|
|
664
717
|
return {
|
|
665
718
|
isAgentToAgent: true,
|
|
@@ -667,11 +720,11 @@ function detectAgentConversation(messages) {
|
|
|
667
720
|
exchangeType: "channel"
|
|
668
721
|
};
|
|
669
722
|
}
|
|
670
|
-
const
|
|
671
|
-
if (
|
|
723
|
+
const genericDmMatch = content.match(GENERIC_DM_PATTERN);
|
|
724
|
+
if (genericDmMatch) {
|
|
672
725
|
return {
|
|
673
726
|
isAgentToAgent: true,
|
|
674
|
-
otherAgentId:
|
|
727
|
+
otherAgentId: genericDmMatch[1].trim(),
|
|
675
728
|
exchangeType: "dm"
|
|
676
729
|
};
|
|
677
730
|
}
|
|
@@ -698,10 +751,17 @@ function detectAgentConversation(messages) {
|
|
|
698
751
|
function extractExchangeText(messages) {
|
|
699
752
|
return messages.filter((m) => m.role === "user" || m.role === "assistant").map((m) => {
|
|
700
753
|
const speaker = m.name ?? m.role;
|
|
701
|
-
const content =
|
|
754
|
+
const content = contentToString(m.content);
|
|
702
755
|
return `[${speaker}]: ${content}`;
|
|
703
756
|
}).join("\n").slice(0, 6e3);
|
|
704
757
|
}
|
|
758
|
+
function contentToString(content) {
|
|
759
|
+
if (typeof content === "string") return content;
|
|
760
|
+
if (Array.isArray(content)) {
|
|
761
|
+
return content.filter((c) => c.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
762
|
+
}
|
|
763
|
+
return "";
|
|
764
|
+
}
|
|
705
765
|
|
|
706
766
|
// src/proxy/extractor.ts
|
|
707
767
|
var LessonExtractor = class {
|
|
@@ -823,6 +883,15 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
|
|
|
823
883
|
const rawBody = await readBody(req);
|
|
824
884
|
const body = JSON.parse(rawBody);
|
|
825
885
|
const messages = body.messages;
|
|
886
|
+
if (Array.isArray(messages)) {
|
|
887
|
+
for (const m of messages) {
|
|
888
|
+
if (m.role === "user" || m.role === "system") {
|
|
889
|
+
const text = extractText(m.content);
|
|
890
|
+
const preview = text.slice(0, 300).replace(/\n/g, "\\n");
|
|
891
|
+
console.log(`[become] msg ${m.role}${m.name ? ` name=${m.name}` : ""}: ${preview}`);
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
}
|
|
826
895
|
if (Array.isArray(messages)) {
|
|
827
896
|
const skills = getSkills().slice(0, config.max_skills_per_call);
|
|
828
897
|
if (skills.length > 0) {
|
|
@@ -944,6 +1013,13 @@ function buildUpstreamHeaders(config, incomingHeaders) {
|
|
|
944
1013
|
if (typeof accept === "string") headers["Accept"] = accept;
|
|
945
1014
|
return headers;
|
|
946
1015
|
}
|
|
1016
|
+
function extractText(content) {
|
|
1017
|
+
if (typeof content === "string") return content;
|
|
1018
|
+
if (Array.isArray(content)) {
|
|
1019
|
+
return content.filter((c) => c.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
1020
|
+
}
|
|
1021
|
+
return "";
|
|
1022
|
+
}
|
|
947
1023
|
|
|
948
1024
|
// src/dashboard/server.ts
|
|
949
1025
|
import { createServer as createServer2 } from "http";
|