@ascegu/teamily 1.0.13 → 1.0.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ascegu/teamily",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "OpenClaw Teamily channel plugin - Team instant messaging server integration",
5
5
  "keywords": [
6
6
  "channel",
package/src/channel.ts CHANGED
@@ -26,7 +26,7 @@ import { normalizeTeamilyTarget, normalizeTeamilyAllowEntry } from "./normalize.
26
26
  import { probeTeamily } from "./probe.js";
27
27
  import { getTeamilyRuntime } from "./runtime.js";
28
28
  import type { ResolvedTeamilyAccount } from "./types.js";
29
- import { SESSION_TYPES } from "./types.js";
29
+ import { isGroupSession } from "./types.js";
30
30
 
31
31
  const meta = {
32
32
  id: "teamily",
@@ -243,11 +243,17 @@ export const teamilyPlugin: ChannelPlugin<ResolvedTeamilyAccount> = {
243
243
  const rt = getTeamilyRuntime();
244
244
  const currentCfg = rt.config.loadConfig();
245
245
 
246
- const isGroup = message.sessionType === SESSION_TYPES.GROUP;
246
+ const isGroup = isGroupSession(message.sessionType);
247
247
  const from = message.sendID;
248
248
 
249
- // In group chats, only respond when the bot is @-mentioned
250
- if (isGroup && !message.isAtSelf) return;
249
+ log?.info?.(
250
+ `[${accountId}] Incoming message: sessionType=${message.sessionType}, isGroup=${isGroup}, ` +
251
+ `from=${from}, recvID=${message.recvID}, isAtSelf=${message.isAtSelf ?? false}`,
252
+ );
253
+
254
+ // In group chats, all messages are dispatched to the agent for context,
255
+ // but only @-mentioned messages trigger a reply.
256
+ const shouldReply = !isGroup || !!message.isAtSelf;
251
257
 
252
258
  const text = message.content?.text || "";
253
259
  const sessionKey = isGroup ? `teamily:group:${message.recvID}` : `teamily:${from}`;
@@ -281,14 +287,17 @@ export const teamilyPlugin: ChannelPlugin<ResolvedTeamilyAccount> = {
281
287
  }
282
288
  }
283
289
 
290
+ const replyTarget = isGroup ? `group:${message.recvID}` : from;
284
291
  const msgCtx = {
285
292
  Body: text,
286
293
  From: from,
287
294
  To: account.userID,
288
295
  SessionKey: sessionKey,
289
296
  AccountId: accountId,
297
+ Provider: "teamily" as const,
298
+ Surface: "teamily" as const,
290
299
  OriginatingChannel: "teamily" as const,
291
- OriginatingTo: from,
300
+ OriginatingTo: replyTarget,
292
301
  ChatType: isGroup ? "group" : "direct",
293
302
  MediaUrl: mediaUrl,
294
303
  MediaPath: mediaPath,
@@ -300,12 +309,13 @@ export const teamilyPlugin: ChannelPlugin<ResolvedTeamilyAccount> = {
300
309
  cfg: currentCfg,
301
310
  dispatcherOptions: {
302
311
  deliver: async (payload: { text?: string; body?: string }) => {
312
+ if (!shouldReply) return;
303
313
  const replyText = payload?.text ?? payload?.body;
304
314
  if (replyText) {
305
315
  const monitor = getTeamilyMonitor(accountId);
306
316
  if (!monitor) throw new Error(`Teamily monitor not running for account ${accountId}`);
307
- const replyTo = isGroup ? `group:${message.recvID}` : from;
308
- const target = normalizeTeamilyTarget(replyTo);
317
+ log?.info?.(`[${accountId}] Sending reply to: ${replyTarget} (isGroup=${isGroup})`);
318
+ const target = normalizeTeamilyTarget(replyTarget);
309
319
  await monitor.sendText(target, replyText);
310
320
  }
311
321
  },
package/src/monitor.ts CHANGED
@@ -6,7 +6,7 @@ import type {
6
6
  TeamilyVideoContent,
7
7
  TeamilyAudioContent,
8
8
  } from "./types.js";
9
- import { CONTENT_TYPES, SESSION_TYPES } from "./types.js";
9
+ import { CONTENT_TYPES, SESSION_TYPES, isGroupSession } from "./types.js";
10
10
 
11
11
  export type TeamilyMessageHandler = (message: TeamilyMessage) => Promise<void> | void;
12
12
  export type TeamilyConnectionState = "connecting" | "connected" | "disconnected" | "error";
@@ -241,7 +241,7 @@ function convertSdkMessage(msg: MessageItem, selfUserID: string): TeamilyMessage
241
241
  return {
242
242
  serverMsgID: msg.serverMsgID || msg.clientMsgID || `${Date.now()}_${Math.random()}`,
243
243
  sendID: msg.sendID || "unknown",
244
- recvID: sessionType === SESSION_TYPES.GROUP ? (msg.groupID || "") : (msg.recvID || selfUserID),
244
+ recvID: isGroupSession(sessionType) ? (msg.groupID || "") : (msg.recvID || selfUserID),
245
245
  content,
246
246
  contentType,
247
247
  sessionType,
package/src/types.ts CHANGED
@@ -121,6 +121,12 @@ export const CONTENT_TYPES = {
121
121
  // Session type constants
122
122
  export const SESSION_TYPES = {
123
123
  SINGLE: 1,
124
+ SUPER_GROUP: 2,
124
125
  GROUP: 3,
125
126
  NOTIFICATION: 4,
126
127
  } as const;
128
+
129
+ /** Returns true when the session type represents any kind of group chat. */
130
+ export function isGroupSession(sessionType: number): boolean {
131
+ return sessionType === SESSION_TYPES.GROUP || sessionType === SESSION_TYPES.SUPER_GROUP;
132
+ }