@gonzih/cc-discord 0.1.14 → 0.1.16

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/bot.d.ts CHANGED
@@ -48,6 +48,12 @@ export declare class CcDiscordBot {
48
48
  * channelNamespaceMap + routedChannelIds. Call once on startup after the notifier is ready.
49
49
  */
50
50
  loadChannelMappings(): Promise<void>;
51
+ /** Typing intervals for meta-agent routed channels — keyed by channelId. */
52
+ private metaAgentTypingTimers;
53
+ /** Start (or reset) the typing indicator for a meta-agent–routed channel. */
54
+ private startMetaAgentTyping;
55
+ /** Stop the typing indicator for a meta-agent–routed channel. Called by the notifier on flush. */
56
+ stopMetaAgentTyping(channelId: string): void;
51
57
  /** Session key: "channelId" or "channelId:threadId" for threads */
52
58
  private sessionKey;
53
59
  /** Get the channel/thread for sending messages */
package/dist/bot.js CHANGED
@@ -226,6 +226,22 @@ export class CcDiscordBot {
226
226
  }
227
227
  }
228
228
  }
229
+ /** Typing intervals for meta-agent routed channels — keyed by channelId. */
230
+ metaAgentTypingTimers = new Map();
231
+ /** Start (or reset) the typing indicator for a meta-agent–routed channel. */
232
+ startMetaAgentTyping(channelId, channel) {
233
+ this.stopMetaAgentTyping(channelId);
234
+ channel.sendTyping().catch(() => { });
235
+ this.metaAgentTypingTimers.set(channelId, setInterval(() => { channel.sendTyping().catch(() => { }); }, TYPING_INTERVAL_MS));
236
+ }
237
+ /** Stop the typing indicator for a meta-agent–routed channel. Called by the notifier on flush. */
238
+ stopMetaAgentTyping(channelId) {
239
+ const timer = this.metaAgentTypingTimers.get(channelId);
240
+ if (timer) {
241
+ clearInterval(timer);
242
+ this.metaAgentTypingTimers.delete(channelId);
243
+ }
244
+ }
229
245
  /** Session key: "channelId" or "channelId:threadId" for threads */
230
246
  sessionKey(channelId, threadId) {
231
247
  return threadId ? `${channelId}:${threadId}` : channelId;
@@ -363,6 +379,7 @@ export class CcDiscordBot {
363
379
  this.writeChatMessage("user", "discord", text, effectiveChannelId, mappedNs.namespace);
364
380
  this.opts.registerRoutedChannelId?.(mappedNs.namespace, effectiveChannelId);
365
381
  this.persistChannelMapping(effectiveChannelId, mappedNs.namespace, mappedNs.repoUrl);
382
+ this.startMetaAgentTyping(effectiveChannelId, msg.channel);
366
383
  const username = msg.member?.displayName ?? msg.author.username;
367
384
  try {
368
385
  await routeToMetaAgent(mappedNs.namespace, stampPrompt(text, username, msg.createdAt), this.redis);
@@ -411,6 +428,7 @@ export class CcDiscordBot {
411
428
  this.writeChatMessage("user", "discord", fullText, channelId, mappedNs.namespace);
412
429
  this.opts.registerRoutedChannelId?.(mappedNs.namespace, channelId);
413
430
  this.persistChannelMapping(channelId, mappedNs.namespace, mappedNs.repoUrl);
431
+ this.startMetaAgentTyping(channelId, channel);
414
432
  try {
415
433
  await routeToMetaAgent(mappedNs.namespace, prompt, this.redis);
416
434
  }
@@ -460,6 +478,7 @@ export class CcDiscordBot {
460
478
  this.writeChatMessage("user", "discord", fullText, channelId, mappedNs.namespace);
461
479
  this.opts.registerRoutedChannelId?.(mappedNs.namespace, channelId);
462
480
  this.persistChannelMapping(channelId, mappedNs.namespace, mappedNs.repoUrl);
481
+ this.startMetaAgentTyping(channelId, channel);
463
482
  try {
464
483
  await routeToMetaAgent(mappedNs.namespace, prompt, this.redis);
465
484
  }
@@ -502,6 +521,7 @@ export class CcDiscordBot {
502
521
  this.writeChatMessage("user", "discord", fullText, channelId, mappedNs.namespace);
503
522
  this.opts.registerRoutedChannelId?.(mappedNs.namespace, channelId);
504
523
  this.persistChannelMapping(channelId, mappedNs.namespace, mappedNs.repoUrl);
524
+ this.startMetaAgentTyping(channelId, channel);
505
525
  try {
506
526
  await routeToMetaAgent(mappedNs.namespace, prompt, this.redis);
507
527
  }
@@ -1031,6 +1051,9 @@ export class CcDiscordBot {
1031
1051
  session.claude.kill();
1032
1052
  this.sessions.delete(key);
1033
1053
  }
1054
+ for (const [channelId] of this.metaAgentTypingTimers) {
1055
+ this.stopMetaAgentTyping(channelId);
1056
+ }
1034
1057
  void this.client.destroy();
1035
1058
  }
1036
1059
  }
package/dist/notifier.js CHANGED
@@ -174,6 +174,7 @@ export function startNotifier(bot, notifyChannelId, namespace, redis, handleUser
174
174
  const META_AGENT_FLUSH_DELAY_MS = 1500;
175
175
  const metaAgentBuffers = new Map();
176
176
  function flushMetaAgentBuffer(ns, targetChannelId) {
177
+ bot.stopMetaAgentTyping(targetChannelId);
177
178
  const buf = metaAgentBuffers.get(ns);
178
179
  if (!buf || !buf.text.trim())
179
180
  return;
@@ -202,9 +203,11 @@ export function startNotifier(bot, notifyChannelId, namespace, redis, handleUser
202
203
  const content = parsed.content;
203
204
  if (!content)
204
205
  return;
205
- // Only forward to Discord for explicitly routed namespaces.
206
- // Primary namespace (money-brain) chat output belongs to Telegram cc-tg handles that.
207
- const targetChannelId = routedChannelIds.get(ns);
206
+ // For the primary namespace: deliver to the primary Discord channel (DISCORD_NOTIFY_CHANNEL_ID
207
+ // or the last-active channel). Responses go to BOTH Telegram (via cc-tg) AND Discord.
208
+ // For other (routed) namespaces: only deliver to explicitly registered channelIds.
209
+ const targetChannelId = routedChannelIds.get(ns) ??
210
+ (ns === namespace ? (notifyChannelId ?? getActiveChannelId?.()) : undefined);
208
211
  if (targetChannelId == null) {
209
212
  log("warn", `meta-agent output: no channelId for namespace=${ns}, dropping line`);
210
213
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-discord",
3
- "version": "0.1.14",
3
+ "version": "0.1.16",
4
4
  "description": "Claude Code Discord bot — chat with Claude Code via Discord",
5
5
  "type": "module",
6
6
  "bin": {