@openclawcity/become 1.0.26 → 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 +79 -11
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +79 -11
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +79 -11
- 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 +79 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3254,16 +3254,29 @@ function injectSkillsIntoMessages(messages, skillText) {
|
|
|
3254
3254
|
}
|
|
3255
3255
|
|
|
3256
3256
|
// src/proxy/detector.ts
|
|
3257
|
-
var
|
|
3258
|
-
var
|
|
3259
|
-
var
|
|
3257
|
+
var OCC_DM_PATTERN = /^\[DM from ([^\]]+)\]:/m;
|
|
3258
|
+
var OCC_MENTION_PATTERN = /^\[([^\]]+) mentioned you in building chat\]:/m;
|
|
3259
|
+
var OCC_ZONE_CHAT_PATTERN = /^\[([^\]]+) in zone chat\]:/m;
|
|
3260
|
+
var OCC_PROPOSAL_PATTERN = /^\[([^\]]+) (?:sent you a proposal|accepted your proposal)\]:/m;
|
|
3261
|
+
var OCC_CONVERSATION_REQUEST = /^\[([^\]]+) wants to start a conversation with you\]:/m;
|
|
3262
|
+
var GENERIC_CHANNEL_PATTERN = /^\[([^\]]+)\s+says?\]:\s*/m;
|
|
3263
|
+
var GENERIC_DM_PATTERN = /^DM\s+from\s+([^:]+):\s*/m;
|
|
3264
|
+
var BUILDING_PATTERN = /^([a-zA-Z0-9]+[-_][a-zA-Z0-9_.-]+)\s+in\s+[^:]+:\s*/m;
|
|
3260
3265
|
var REVIEW_KEYWORDS = ["strengths:", "weaknesses:", "verdict:", "assessment:", "suggestions:"];
|
|
3266
|
+
var SKIP_PATTERNS = [
|
|
3267
|
+
/^\[Your human owner says\]:/m,
|
|
3268
|
+
/^\[Your human set a new mission/m,
|
|
3269
|
+
/^\[HEARTBEAT/m,
|
|
3270
|
+
/^\[Someone left you a voice message\]/m
|
|
3271
|
+
];
|
|
3261
3272
|
function detectAgentConversation(messages) {
|
|
3262
3273
|
const negative = { isAgentToAgent: false };
|
|
3263
3274
|
if (!messages || messages.length === 0) return negative;
|
|
3264
3275
|
for (const msg of messages) {
|
|
3265
3276
|
if (msg.role !== "user" && msg.role !== "assistant") continue;
|
|
3266
|
-
const content =
|
|
3277
|
+
const content = contentToString(msg.content);
|
|
3278
|
+
if (!content) continue;
|
|
3279
|
+
if (SKIP_PATTERNS.some((p) => p.test(content))) continue;
|
|
3267
3280
|
if (msg.name && msg.role === "user") {
|
|
3268
3281
|
return {
|
|
3269
3282
|
isAgentToAgent: true,
|
|
@@ -3271,7 +3284,47 @@ function detectAgentConversation(messages) {
|
|
|
3271
3284
|
exchangeType: "chat"
|
|
3272
3285
|
};
|
|
3273
3286
|
}
|
|
3274
|
-
const
|
|
3287
|
+
const dmMatch = content.match(OCC_DM_PATTERN);
|
|
3288
|
+
if (dmMatch) {
|
|
3289
|
+
return {
|
|
3290
|
+
isAgentToAgent: true,
|
|
3291
|
+
otherAgentId: dmMatch[1].trim(),
|
|
3292
|
+
exchangeType: "dm"
|
|
3293
|
+
};
|
|
3294
|
+
}
|
|
3295
|
+
const mentionMatch = content.match(OCC_MENTION_PATTERN);
|
|
3296
|
+
if (mentionMatch) {
|
|
3297
|
+
return {
|
|
3298
|
+
isAgentToAgent: true,
|
|
3299
|
+
otherAgentId: mentionMatch[1].trim(),
|
|
3300
|
+
exchangeType: "mention"
|
|
3301
|
+
};
|
|
3302
|
+
}
|
|
3303
|
+
const zoneMatch = content.match(OCC_ZONE_CHAT_PATTERN);
|
|
3304
|
+
if (zoneMatch) {
|
|
3305
|
+
return {
|
|
3306
|
+
isAgentToAgent: true,
|
|
3307
|
+
otherAgentId: zoneMatch[1].trim(),
|
|
3308
|
+
exchangeType: "chat"
|
|
3309
|
+
};
|
|
3310
|
+
}
|
|
3311
|
+
const proposalMatch = content.match(OCC_PROPOSAL_PATTERN);
|
|
3312
|
+
if (proposalMatch) {
|
|
3313
|
+
return {
|
|
3314
|
+
isAgentToAgent: true,
|
|
3315
|
+
otherAgentId: proposalMatch[1].trim(),
|
|
3316
|
+
exchangeType: "proposal"
|
|
3317
|
+
};
|
|
3318
|
+
}
|
|
3319
|
+
const convMatch = content.match(OCC_CONVERSATION_REQUEST);
|
|
3320
|
+
if (convMatch) {
|
|
3321
|
+
return {
|
|
3322
|
+
isAgentToAgent: true,
|
|
3323
|
+
otherAgentId: convMatch[1].trim(),
|
|
3324
|
+
exchangeType: "dm"
|
|
3325
|
+
};
|
|
3326
|
+
}
|
|
3327
|
+
const channelMatch = content.match(GENERIC_CHANNEL_PATTERN);
|
|
3275
3328
|
if (channelMatch) {
|
|
3276
3329
|
return {
|
|
3277
3330
|
isAgentToAgent: true,
|
|
@@ -3279,11 +3332,11 @@ function detectAgentConversation(messages) {
|
|
|
3279
3332
|
exchangeType: "channel"
|
|
3280
3333
|
};
|
|
3281
3334
|
}
|
|
3282
|
-
const
|
|
3283
|
-
if (
|
|
3335
|
+
const genericDmMatch = content.match(GENERIC_DM_PATTERN);
|
|
3336
|
+
if (genericDmMatch) {
|
|
3284
3337
|
return {
|
|
3285
3338
|
isAgentToAgent: true,
|
|
3286
|
-
otherAgentId:
|
|
3339
|
+
otherAgentId: genericDmMatch[1].trim(),
|
|
3287
3340
|
exchangeType: "dm"
|
|
3288
3341
|
};
|
|
3289
3342
|
}
|
|
@@ -3310,10 +3363,17 @@ function detectAgentConversation(messages) {
|
|
|
3310
3363
|
function extractExchangeText(messages) {
|
|
3311
3364
|
return messages.filter((m) => m.role === "user" || m.role === "assistant").map((m) => {
|
|
3312
3365
|
const speaker = m.name ?? m.role;
|
|
3313
|
-
const content =
|
|
3366
|
+
const content = contentToString(m.content);
|
|
3314
3367
|
return `[${speaker}]: ${content}`;
|
|
3315
3368
|
}).join("\n").slice(0, 6e3);
|
|
3316
3369
|
}
|
|
3370
|
+
function contentToString(content) {
|
|
3371
|
+
if (typeof content === "string") return content;
|
|
3372
|
+
if (Array.isArray(content)) {
|
|
3373
|
+
return content.filter((c) => c.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
3374
|
+
}
|
|
3375
|
+
return "";
|
|
3376
|
+
}
|
|
3317
3377
|
|
|
3318
3378
|
// src/proxy/extractor.ts
|
|
3319
3379
|
var LessonExtractor = class {
|
|
@@ -3438,8 +3498,9 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
|
|
|
3438
3498
|
if (Array.isArray(messages)) {
|
|
3439
3499
|
for (const m of messages) {
|
|
3440
3500
|
if (m.role === "user" || m.role === "system") {
|
|
3441
|
-
const
|
|
3442
|
-
|
|
3501
|
+
const text = extractText(m.content);
|
|
3502
|
+
const preview = text.slice(0, 300).replace(/\n/g, "\\n");
|
|
3503
|
+
console.log(`[become] msg ${m.role}${m.name ? ` name=${m.name}` : ""}: ${preview}`);
|
|
3443
3504
|
}
|
|
3444
3505
|
}
|
|
3445
3506
|
}
|
|
@@ -3564,6 +3625,13 @@ function buildUpstreamHeaders(config, incomingHeaders) {
|
|
|
3564
3625
|
if (typeof accept === "string") headers["Accept"] = accept;
|
|
3565
3626
|
return headers;
|
|
3566
3627
|
}
|
|
3628
|
+
function extractText(content) {
|
|
3629
|
+
if (typeof content === "string") return content;
|
|
3630
|
+
if (Array.isArray(content)) {
|
|
3631
|
+
return content.filter((c) => c.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
|
|
3632
|
+
}
|
|
3633
|
+
return "";
|
|
3634
|
+
}
|
|
3567
3635
|
|
|
3568
3636
|
// src/integrations/openclawcity.ts
|
|
3569
3637
|
function emptySkillEvidence() {
|