@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/index.d.cts CHANGED
@@ -847,11 +847,11 @@ declare function createProxyServer(config: ProxyConfig, analyzer?: ConversationA
847
847
  interface DetectionResult {
848
848
  isAgentToAgent: boolean;
849
849
  otherAgentId?: string;
850
- exchangeType?: 'channel' | 'dm' | 'peer_review' | 'collaboration' | 'chat';
850
+ exchangeType?: 'channel' | 'dm' | 'peer_review' | 'collaboration' | 'chat' | 'mention' | 'proposal';
851
851
  }
852
852
  declare function detectAgentConversation(messages: {
853
853
  role: string;
854
- content: string;
854
+ content: unknown;
855
855
  name?: string;
856
856
  }[]): DetectionResult;
857
857
  /**
@@ -859,7 +859,7 @@ declare function detectAgentConversation(messages: {
859
859
  */
860
860
  declare function extractExchangeText(messages: {
861
861
  role: string;
862
- content: string;
862
+ content: unknown;
863
863
  name?: string;
864
864
  }[]): string;
865
865
 
@@ -878,7 +878,7 @@ declare class LessonExtractor {
878
878
  */
879
879
  extract(messages: {
880
880
  role: string;
881
- content: string;
881
+ content: unknown;
882
882
  name?: string;
883
883
  }[]): Promise<void>;
884
884
  private parseLessons;
package/dist/index.d.ts CHANGED
@@ -847,11 +847,11 @@ declare function createProxyServer(config: ProxyConfig, analyzer?: ConversationA
847
847
  interface DetectionResult {
848
848
  isAgentToAgent: boolean;
849
849
  otherAgentId?: string;
850
- exchangeType?: 'channel' | 'dm' | 'peer_review' | 'collaboration' | 'chat';
850
+ exchangeType?: 'channel' | 'dm' | 'peer_review' | 'collaboration' | 'chat' | 'mention' | 'proposal';
851
851
  }
852
852
  declare function detectAgentConversation(messages: {
853
853
  role: string;
854
- content: string;
854
+ content: unknown;
855
855
  name?: string;
856
856
  }[]): DetectionResult;
857
857
  /**
@@ -859,7 +859,7 @@ declare function detectAgentConversation(messages: {
859
859
  */
860
860
  declare function extractExchangeText(messages: {
861
861
  role: string;
862
- content: string;
862
+ content: unknown;
863
863
  name?: string;
864
864
  }[]): string;
865
865
 
@@ -878,7 +878,7 @@ declare class LessonExtractor {
878
878
  */
879
879
  extract(messages: {
880
880
  role: string;
881
- content: string;
881
+ content: unknown;
882
882
  name?: string;
883
883
  }[]): Promise<void>;
884
884
  private parseLessons;
package/dist/index.js CHANGED
@@ -3181,16 +3181,29 @@ function injectSkillsIntoMessages(messages, skillText) {
3181
3181
  }
3182
3182
 
3183
3183
  // src/proxy/detector.ts
3184
- var CHANNEL_PATTERN = /^\[([^\]]+)\s+says?\]:\s*/;
3185
- var DM_PATTERN = /^DM\s+from\s+([^:]+):\s*/;
3186
- var BUILDING_PATTERN = /^([a-zA-Z0-9]+[-_][a-zA-Z0-9_.-]+)\s+in\s+[^:]+:\s*/;
3184
+ var OCC_DM_PATTERN = /^\[DM from ([^\]]+)\]:/m;
3185
+ var OCC_MENTION_PATTERN = /^\[([^\]]+) mentioned you in building chat\]:/m;
3186
+ var OCC_ZONE_CHAT_PATTERN = /^\[([^\]]+) in zone chat\]:/m;
3187
+ var OCC_PROPOSAL_PATTERN = /^\[([^\]]+) (?:sent you a proposal|accepted your proposal)\]:/m;
3188
+ var OCC_CONVERSATION_REQUEST = /^\[([^\]]+) wants to start a conversation with you\]:/m;
3189
+ var GENERIC_CHANNEL_PATTERN = /^\[([^\]]+)\s+says?\]:\s*/m;
3190
+ var GENERIC_DM_PATTERN = /^DM\s+from\s+([^:]+):\s*/m;
3191
+ var BUILDING_PATTERN = /^([a-zA-Z0-9]+[-_][a-zA-Z0-9_.-]+)\s+in\s+[^:]+:\s*/m;
3187
3192
  var REVIEW_KEYWORDS = ["strengths:", "weaknesses:", "verdict:", "assessment:", "suggestions:"];
3193
+ var SKIP_PATTERNS = [
3194
+ /^\[Your human owner says\]:/m,
3195
+ /^\[Your human set a new mission/m,
3196
+ /^\[HEARTBEAT/m,
3197
+ /^\[Someone left you a voice message\]/m
3198
+ ];
3188
3199
  function detectAgentConversation(messages) {
3189
3200
  const negative = { isAgentToAgent: false };
3190
3201
  if (!messages || messages.length === 0) return negative;
3191
3202
  for (const msg of messages) {
3192
3203
  if (msg.role !== "user" && msg.role !== "assistant") continue;
3193
- const content = typeof msg.content === "string" ? msg.content : "";
3204
+ const content = contentToString(msg.content);
3205
+ if (!content) continue;
3206
+ if (SKIP_PATTERNS.some((p) => p.test(content))) continue;
3194
3207
  if (msg.name && msg.role === "user") {
3195
3208
  return {
3196
3209
  isAgentToAgent: true,
@@ -3198,7 +3211,47 @@ function detectAgentConversation(messages) {
3198
3211
  exchangeType: "chat"
3199
3212
  };
3200
3213
  }
3201
- const channelMatch = content.match(CHANNEL_PATTERN);
3214
+ const dmMatch = content.match(OCC_DM_PATTERN);
3215
+ if (dmMatch) {
3216
+ return {
3217
+ isAgentToAgent: true,
3218
+ otherAgentId: dmMatch[1].trim(),
3219
+ exchangeType: "dm"
3220
+ };
3221
+ }
3222
+ const mentionMatch = content.match(OCC_MENTION_PATTERN);
3223
+ if (mentionMatch) {
3224
+ return {
3225
+ isAgentToAgent: true,
3226
+ otherAgentId: mentionMatch[1].trim(),
3227
+ exchangeType: "mention"
3228
+ };
3229
+ }
3230
+ const zoneMatch = content.match(OCC_ZONE_CHAT_PATTERN);
3231
+ if (zoneMatch) {
3232
+ return {
3233
+ isAgentToAgent: true,
3234
+ otherAgentId: zoneMatch[1].trim(),
3235
+ exchangeType: "chat"
3236
+ };
3237
+ }
3238
+ const proposalMatch = content.match(OCC_PROPOSAL_PATTERN);
3239
+ if (proposalMatch) {
3240
+ return {
3241
+ isAgentToAgent: true,
3242
+ otherAgentId: proposalMatch[1].trim(),
3243
+ exchangeType: "proposal"
3244
+ };
3245
+ }
3246
+ const convMatch = content.match(OCC_CONVERSATION_REQUEST);
3247
+ if (convMatch) {
3248
+ return {
3249
+ isAgentToAgent: true,
3250
+ otherAgentId: convMatch[1].trim(),
3251
+ exchangeType: "dm"
3252
+ };
3253
+ }
3254
+ const channelMatch = content.match(GENERIC_CHANNEL_PATTERN);
3202
3255
  if (channelMatch) {
3203
3256
  return {
3204
3257
  isAgentToAgent: true,
@@ -3206,11 +3259,11 @@ function detectAgentConversation(messages) {
3206
3259
  exchangeType: "channel"
3207
3260
  };
3208
3261
  }
3209
- const dmMatch = content.match(DM_PATTERN);
3210
- if (dmMatch) {
3262
+ const genericDmMatch = content.match(GENERIC_DM_PATTERN);
3263
+ if (genericDmMatch) {
3211
3264
  return {
3212
3265
  isAgentToAgent: true,
3213
- otherAgentId: dmMatch[1].trim(),
3266
+ otherAgentId: genericDmMatch[1].trim(),
3214
3267
  exchangeType: "dm"
3215
3268
  };
3216
3269
  }
@@ -3237,10 +3290,17 @@ function detectAgentConversation(messages) {
3237
3290
  function extractExchangeText(messages) {
3238
3291
  return messages.filter((m) => m.role === "user" || m.role === "assistant").map((m) => {
3239
3292
  const speaker = m.name ?? m.role;
3240
- const content = typeof m.content === "string" ? m.content : "";
3293
+ const content = contentToString(m.content);
3241
3294
  return `[${speaker}]: ${content}`;
3242
3295
  }).join("\n").slice(0, 6e3);
3243
3296
  }
3297
+ function contentToString(content) {
3298
+ if (typeof content === "string") return content;
3299
+ if (Array.isArray(content)) {
3300
+ return content.filter((c) => c.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
3301
+ }
3302
+ return "";
3303
+ }
3244
3304
 
3245
3305
  // src/proxy/extractor.ts
3246
3306
  var LessonExtractor = class {
@@ -3362,6 +3422,15 @@ function createProxyServer(config, analyzer, overrideUpstreamUrl) {
3362
3422
  const rawBody = await readBody(req);
3363
3423
  const body = JSON.parse(rawBody);
3364
3424
  const messages = body.messages;
3425
+ if (Array.isArray(messages)) {
3426
+ for (const m of messages) {
3427
+ if (m.role === "user" || m.role === "system") {
3428
+ const text = extractText(m.content);
3429
+ const preview = text.slice(0, 300).replace(/\n/g, "\\n");
3430
+ console.log(`[become] msg ${m.role}${m.name ? ` name=${m.name}` : ""}: ${preview}`);
3431
+ }
3432
+ }
3433
+ }
3365
3434
  if (Array.isArray(messages)) {
3366
3435
  const skills = getSkills().slice(0, config.max_skills_per_call);
3367
3436
  if (skills.length > 0) {
@@ -3483,6 +3552,13 @@ function buildUpstreamHeaders(config, incomingHeaders) {
3483
3552
  if (typeof accept === "string") headers["Accept"] = accept;
3484
3553
  return headers;
3485
3554
  }
3555
+ function extractText(content) {
3556
+ if (typeof content === "string") return content;
3557
+ if (Array.isArray(content)) {
3558
+ return content.filter((c) => c.type === "text" && typeof c.text === "string").map((c) => c.text).join("\n");
3559
+ }
3560
+ return "";
3561
+ }
3486
3562
 
3487
3563
  // src/integrations/openclawcity.ts
3488
3564
  function emptySkillEvidence() {