@gonzih/cc-discord 0.2.11 → 0.2.13

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
@@ -54,10 +54,6 @@ export declare class CcDiscordBot {
54
54
  loadChannelMappings(): Promise<void>;
55
55
  /** Typing intervals for meta-agent routed channels — keyed by channelId. */
56
56
  private metaAgentTypingTimers;
57
- /** Per-channel debounce state for guild channel → meta-agent routing. */
58
- private messageBuffer;
59
- /** Debounce window in ms — multiple messages within this window are coalesced into one prompt. */
60
- private static readonly MESSAGE_DEBOUNCE_MS;
61
57
  /** Start (or reset) the typing indicator for a meta-agent–routed channel. */
62
58
  private startMetaAgentTyping;
63
59
  /** Stop the typing indicator for a meta-agent–routed channel. Called by the notifier on flush. */
package/dist/bot.js CHANGED
@@ -227,10 +227,6 @@ export class CcDiscordBot {
227
227
  }
228
228
  /** Typing intervals for meta-agent routed channels — keyed by channelId. */
229
229
  metaAgentTypingTimers = new Map();
230
- /** Per-channel debounce state for guild channel → meta-agent routing. */
231
- messageBuffer = new Map();
232
- /** Debounce window in ms — multiple messages within this window are coalesced into one prompt. */
233
- static MESSAGE_DEBOUNCE_MS = 2500;
234
230
  /** Start (or reset) the typing indicator for a meta-agent–routed channel. */
235
231
  startMetaAgentTyping(channelId, channel) {
236
232
  this.stopMetaAgentTyping(channelId);
@@ -470,41 +466,20 @@ export class CcDiscordBot {
470
466
  this.writeChatMessage("user", "discord", text, effectiveChannelId, mappedNs.namespace);
471
467
  this.opts.registerRoutedChannelId?.(mappedNs.namespace, effectiveChannelId);
472
468
  this.persistChannelMapping(effectiveChannelId, mappedNs.namespace, mappedNs.repoUrl);
473
- // Detect goal messages → create a thread for loop tracking (before debounce so thread is created promptly)
469
+ this.startMetaAgentTyping(effectiveChannelId, msg.channel);
470
+ // Detect goal messages → create a thread for loop tracking
474
471
  if (this.loopManager && msg.guild && !msg.channel.isThread()) {
475
472
  if (isGoalMessage(text)) {
476
473
  await this.createLoopThread(msg, effectiveChannelId, mappedNs.namespace, text);
477
474
  }
478
475
  }
479
476
  const username = msg.member?.displayName ?? msg.author.username;
480
- const stamped = stampPrompt(text, username, msg.createdAt);
481
- // Capture for use inside async callback (this.redis is guaranteed non-null by the outer guard)
482
- const redis = this.redis;
483
- const nsName = mappedNs.namespace;
484
- const sendChannel = msg.channel;
485
- // Debounce: buffer messages arriving within MESSAGE_DEBOUNCE_MS and route once
486
- const existing = this.messageBuffer.get(effectiveChannelId);
487
- if (existing) {
488
- // Another message already queued — append and reset timer
489
- clearTimeout(existing.timer);
490
- existing.messages.push(stamped);
477
+ try {
478
+ await routeToMetaAgent(mappedNs.namespace, stampPrompt(text, username, msg.createdAt), this.redis);
491
479
  }
492
- else {
493
- // First message in the window start typing indicator immediately so user sees feedback
494
- this.startMetaAgentTyping(effectiveChannelId, msg.channel);
495
- this.messageBuffer.set(effectiveChannelId, { timer: undefined, messages: [stamped] });
480
+ catch (err) {
481
+ await msg.channel.send(`Failed to route to ${mappedNs.namespace}: ${err.message}`).catch(() => { });
496
482
  }
497
- const buf = this.messageBuffer.get(effectiveChannelId);
498
- buf.timer = setTimeout(async () => {
499
- this.messageBuffer.delete(effectiveChannelId);
500
- const combined = buf.messages.join('\n\n');
501
- try {
502
- await routeToMetaAgent(nsName, combined, redis);
503
- }
504
- catch (err) {
505
- await sendChannel.send(`Failed to route to ${nsName}: ${err.message}`).catch(() => { });
506
- }
507
- }, CcDiscordBot.MESSAGE_DEBOUNCE_MS);
508
483
  return;
509
484
  }
510
485
  // Unknown guild channel — reject rather than silently start a local session with wrong context
package/dist/notifier.js CHANGED
@@ -51,6 +51,8 @@ export function parseNotification(raw) {
51
51
  if (parsed.routing && parsed.routing.length > 0 && !parsed.routing.includes("discord")) {
52
52
  return null;
53
53
  }
54
+ if (parsed.is_cron === true)
55
+ return null;
54
56
  if (parsed.text)
55
57
  text = parsed.text;
56
58
  driver = parsed.driver;
@@ -209,6 +211,11 @@ export function startNotifier(bot, notifyChannelId, namespace, redis, handleUser
209
211
  if (!buf || !buf.text.trim())
210
212
  return;
211
213
  const text = `← [${ns}] ` + stripAnsi(buf.text.trim());
214
+ if (text.length < 30) {
215
+ buf.text = "";
216
+ buf.timer = null;
217
+ return;
218
+ }
212
219
  buf.text = "";
213
220
  buf.timer = null;
214
221
  // During an active loop, route meta-agent output to the thread rather than main channel
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-discord",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "Claude Code Discord bot — chat with Claude Code via Discord",
5
5
  "type": "module",
6
6
  "bin": {