@heylemon/lemonade 0.6.7 → 0.6.8

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.6.7",
3
- "commit": "2965fd60321e809102f7cf3b40bb4a8bb6e009cb",
4
- "builtAt": "2026-02-28T10:36:45.544Z"
2
+ "version": "0.6.8",
3
+ "commit": "5a980408e79cc336ae458564f5a0b54a7567804b",
4
+ "builtAt": "2026-02-28T11:10:23.426Z"
5
5
  }
@@ -16,7 +16,7 @@ import { resolveWhatsAppAccount } from "../accounts.js";
16
16
  import { setActiveWebListener } from "../active-listener.js";
17
17
  import { monitorWebInbox } from "../inbound.js";
18
18
  import { computeBackoff, newConnectionId, resolveHeartbeatSeconds, resolveReconnectPolicy, sleepWithAbort, } from "../reconnect.js";
19
- import { formatError, getStatusCode, getWebAuthAgeMs, readWebSelfId } from "../session.js";
19
+ import { formatError, getStatusCode, getWebAuthAgeMs, logoutWeb, readWebSelfId, } from "../session.js";
20
20
  import { DEFAULT_WEB_MEDIA_BYTES } from "./constants.js";
21
21
  import { whatsappHeartbeatLog, whatsappLog } from "./loggers.js";
22
22
  import { buildMentionConfig } from "./mentions.js";
@@ -210,7 +210,15 @@ export async function monitorWebChannel(verbose, listenerFactory = monitorWebInb
210
210
  reconnectAttempts,
211
211
  maxAttempts: reconnectPolicy.maxAttempts,
212
212
  }, "web reconnect: max attempts reached after connection failure");
213
- runtime.error(`WhatsApp Web reconnect: max attempts reached (${reconnectAttempts}/${reconnectPolicy.maxAttempts}). Stopping web monitoring.`);
213
+ // If 515 was seen, credentials are stale clear them so the next
214
+ // gateway restart or manual re-link starts fresh.
215
+ if (has515Retried) {
216
+ await logoutWeb({ authDir: account.authDir, runtime });
217
+ runtime.error("WhatsApp session invalidated (repeated 515). Cleared credentials — re-link via QR to restore.");
218
+ }
219
+ else {
220
+ runtime.error(`WhatsApp Web reconnect: max attempts reached (${reconnectAttempts}/${reconnectPolicy.maxAttempts}). Stopping web monitoring.`);
221
+ }
214
222
  break;
215
223
  }
216
224
  const delay = computeBackoff(reconnectPolicy, reconnectAttempts);
@@ -210,6 +210,18 @@ export async function waitForWebLogin(opts = {}) {
210
210
  if (restarted && isLoginFresh(login)) {
211
211
  continue;
212
212
  }
213
+ // 515 retry failed — credentials are stale. Clear them so the next
214
+ // pairing attempt starts completely fresh instead of reusing a
215
+ // broken session that WhatsApp's server has already invalidated.
216
+ await logoutWeb({
217
+ authDir: login.authDir,
218
+ isLegacyAuthDir: login.isLegacyAuthDir,
219
+ runtime,
220
+ });
221
+ const message = "WhatsApp pairing failed (code 515). Cleared session — please scan the QR code again.";
222
+ await resetActiveLogin(account.accountId, message);
223
+ runtime.log(danger(message));
224
+ return { connected: false, message };
213
225
  }
214
226
  const message = `WhatsApp login failed: ${login.error}`;
215
227
  await resetActiveLogin(account.accountId, message);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heylemon/lemonade",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "description": "AI gateway CLI for Lemon - local AI assistant with integrations",
5
5
  "publishConfig": {
6
6
  "access": "restricted"