refactor: drop provider reconnect shim

This commit is contained in:
Peter Steinberger
2026-04-22 06:21:08 +01:00
parent cb426b3b20
commit 4a9dd3fe49
2 changed files with 4 additions and 43 deletions

View File

@@ -38,8 +38,8 @@ beforeEach(() => {
describe("plugin-sdk drainPendingDeliveries", () => {
it("injects the lazy outbound deliver runtime when no deliver fn is provided", async () => {
await drainPendingDeliveries({
drainKey: "whatsapp:test",
logLabel: "WhatsApp reconnect drain",
drainKey: "demo:test",
logLabel: "Demo reconnect drain",
cfg: {},
log,
selectEntry: () => ({ match: false }),
@@ -56,8 +56,8 @@ describe("plugin-sdk drainPendingDeliveries", () => {
const deliver = vi.fn(async () => []);
await drainPendingDeliveries({
drainKey: "whatsapp:test",
logLabel: "WhatsApp reconnect drain",
drainKey: "demo:test",
logLabel: "Demo reconnect drain",
cfg: {},
log,
deliver,

View File

@@ -1,18 +1,10 @@
import type { OpenClawConfig } from "../config/types.openclaw.js";
import {
drainPendingDeliveries as coreDrainPendingDeliveries,
type DeliverFn,
type RecoveryLogger,
} from "../infra/outbound/delivery-queue.js";
// Public runtime/transport helpers for plugins that need shared infra behavior.
function normalizeWhatsAppReconnectAccountId(accountId?: string): string {
return (accountId ?? "").trim() || "default";
}
const WHATSAPP_NO_LISTENER_ERROR_RE = /No active WhatsApp Web listener/i;
type OutboundDeliverRuntimeModule = typeof import("../infra/outbound/deliver-runtime.js");
type DrainPendingDeliveriesOptions = Omit<
Parameters<typeof coreDrainPendingDeliveries>[0],
@@ -36,37 +28,6 @@ export async function drainPendingDeliveries(opts: DrainPendingDeliveriesOptions
});
}
/**
* @deprecated Prefer plugin-owned reconnect policy wired through
* `drainPendingDeliveries(...)`. This compatibility shim preserves the
* historical public SDK symbol for existing plugin callers.
*/
export async function drainReconnectQueue(opts: {
accountId: string;
cfg: OpenClawConfig;
log: RecoveryLogger;
stateDir?: string;
deliver?: DeliverFn;
}): Promise<void> {
const normalizedAccountId = normalizeWhatsAppReconnectAccountId(opts.accountId);
await drainPendingDeliveries({
drainKey: `whatsapp:${normalizedAccountId}`,
logLabel: "WhatsApp reconnect drain",
cfg: opts.cfg,
log: opts.log,
stateDir: opts.stateDir,
deliver: opts.deliver,
selectEntry: (entry) => ({
match:
entry.channel === "whatsapp" &&
normalizeWhatsAppReconnectAccountId(entry.accountId) === normalizedAccountId &&
typeof entry.lastError === "string" &&
WHATSAPP_NO_LISTENER_ERROR_RE.test(entry.lastError),
bypassBackoff: true,
}),
});
}
export * from "../infra/backoff.js";
export * from "../infra/channel-activity.js";
export * from "../infra/dedupe.js";