@gonzih/cc-discord 0.2.44 → 0.2.45

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.
@@ -242,6 +242,38 @@ function wireStdoutToRedis(proc, ns, wire) {
242
242
  content: "", event: "done", timestamp: new Date().toISOString(), chatId: 0,
243
243
  })).catch(() => { });
244
244
  }
245
+ else if (type === "rate_limit_event") {
246
+ const rl = parsed.rate_limit_info;
247
+ structuredEvent = parsed;
248
+ // Throttled: five-hour window exhausted and no overage credits.
249
+ // Claude will hang on API calls until the window resets — notify Discord immediately
250
+ // and signal done so the live message finalizes, rather than silently timing out.
251
+ if (rl?.overageStatus === "rejected") {
252
+ const resetsAt = rl.resetsAt ? new Date(rl.resetsAt * 1000).toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit", timeZoneName: "short" }) : "soon";
253
+ const alertMsg = {
254
+ id: crypto.randomUUID(),
255
+ source: "claude",
256
+ role: "assistant",
257
+ content: `⏳ Rate limited — five-hour window exhausted. Resets at **${resetsAt}**. Session paused; send any message after reset to resume.`,
258
+ timestamp: new Date().toISOString(),
259
+ chatId: 0,
260
+ };
261
+ wire.discord.publishOutgoing(ns, alertMsg).catch(() => { });
262
+ // Fire done so notifier finalizes the live message
263
+ rawRedis.publish(discordChatOutgoing(ns), JSON.stringify({
264
+ id: crypto.randomUUID(), source: "claude", role: "assistant",
265
+ content: "", event: "done", timestamp: new Date().toISOString(), chatId: 0,
266
+ })).catch(() => { });
267
+ // Kill the process — API calls will hang until reset anyway
268
+ setTimeout(() => {
269
+ try {
270
+ proc.stdin.end();
271
+ proc.kill("SIGTERM");
272
+ }
273
+ catch { /* ignore */ }
274
+ }, 500);
275
+ }
276
+ }
245
277
  else {
246
278
  structuredEvent = parsed;
247
279
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-discord",
3
- "version": "0.2.44",
3
+ "version": "0.2.45",
4
4
  "description": "Claude Code Discord bot — chat with Claude Code via Discord",
5
5
  "type": "module",
6
6
  "bin": {