mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 18:10:45 +00:00
refactor: drop provider reconnect shim
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user