@gonzih/cc-discord 0.2.47 → 0.2.48

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.
@@ -252,20 +252,20 @@ function wireStdoutToRedis(proc, ns, wire) {
252
252
  if (rl?.overageStatus === "rejected" && !rateLimitNotified) {
253
253
  rateLimitNotified = true;
254
254
  const resetsAt = rl.resetsAt ? new Date(rl.resetsAt * 1000).toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit", timeZoneName: "short" }) : "soon";
255
- const alertMsg = {
256
- id: crypto.randomUUID(),
257
- source: "claude",
258
- role: "assistant",
259
- content: `⏳ Rate limited — five-hour window exhausted. Resets at **${resetsAt}**. Session paused; send any message after reset to resume.`,
260
- timestamp: new Date().toISOString(),
261
- chatId: 0,
262
- };
263
- wire.discord.publishOutgoing(ns, alertMsg).catch(() => { });
264
- // Fire done so notifier finalizes the live message
255
+ const alertContent = `⏳ Rate limited — five-hour window exhausted. Resets at **${resetsAt}**. Session paused; send any message after reset to resume.`;
256
+ // 1. Close the current turn first — finalizes any real response text already in the live state.
257
+ // If this is a pure rate-limit turn (no preceding text), done is a no-op in the notifier.
265
258
  rawRedis.publish(discordChatOutgoing(ns), JSON.stringify({
266
259
  id: crypto.randomUUID(), source: "claude", role: "assistant",
267
260
  content: "", event: "done", timestamp: new Date().toISOString(), chatId: 0,
268
261
  })).catch(() => { });
262
+ // 2. Send alert tagged as "rate_limit" so the notifier delivers it as a standalone message,
263
+ // not accumulated into whatever text the current live state already holds.
264
+ rawRedis.publish(discordChatOutgoing(ns), JSON.stringify({
265
+ id: crypto.randomUUID(), source: "claude", role: "assistant",
266
+ content: alertContent, event: "rate_limit",
267
+ timestamp: new Date().toISOString(), chatId: 0,
268
+ })).catch(() => { });
269
269
  // Kill the process — API calls will hang until reset anyway
270
270
  setTimeout(() => {
271
271
  try {
package/dist/notifier.js CHANGED
@@ -352,6 +352,17 @@ export function startNotifier(bot, notifyChannelId, namespace, redis, handleUser
352
352
  scheduleFinal(ns, state);
353
353
  return;
354
354
  }
355
+ // rate_limit: delivered after the current turn's "done" — send as a standalone message,
356
+ // never accumulate into live state text (which already finalized above via "done").
357
+ if (event === "rate_limit") {
358
+ const alertContent = parsed.content ?? "";
359
+ if (alertContent) {
360
+ bot.sendToChannelById(deliverTo, `← [${ns}]\n${alertContent}`).catch((err) => {
361
+ log("warn", `rate_limit alert send failed (ns=${ns}):`, err.message);
362
+ });
363
+ }
364
+ return;
365
+ }
355
366
  // done: immediate finalization (fired by meta-agent-manager after result event)
356
367
  if (event === "done") {
357
368
  if (state.starting) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gonzih/cc-discord",
3
- "version": "0.2.47",
3
+ "version": "0.2.48",
4
4
  "description": "Claude Code Discord bot — chat with Claude Code via Discord",
5
5
  "type": "module",
6
6
  "bin": {