From c09031f15a382231847de5291fbf1e56028b65bb Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 13 Apr 2026 08:23:26 -0700 Subject: [PATCH] fix: tighten inbound replay typing --- .../nextcloud-talk/src/monitor.replay.test.ts | 3 +- extensions/whatsapp/src/inbound/monitor.ts | 10 ++--- src/wizard/setup.ts | 37 +++++++++---------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/extensions/nextcloud-talk/src/monitor.replay.test.ts b/extensions/nextcloud-talk/src/monitor.replay.test.ts index 63325e2fcc1..923a0971224 100644 --- a/extensions/nextcloud-talk/src/monitor.replay.test.ts +++ b/extensions/nextcloud-talk/src/monitor.replay.test.ts @@ -99,13 +99,14 @@ describe("createNextcloudTalkWebhookServer replay handling", () => { stateDir: params.stateDir, }); - return async (message: NextcloudTalkInboundMessage) => + return async (message: NextcloudTalkInboundMessage): Promise => { await processNextcloudTalkReplayGuardedMessage({ replayGuard, accountId: params.accountId ?? "acct", message, handleMessage: () => params.handleMessage(message), }); + }; } it("acknowledges replayed requests and skips onMessage side effects", async () => { diff --git a/extensions/whatsapp/src/inbound/monitor.ts b/extensions/whatsapp/src/inbound/monitor.ts index 992812fb9b9..f7e2517b467 100644 --- a/extensions/whatsapp/src/inbound/monitor.ts +++ b/extensions/whatsapp/src/inbound/monitor.ts @@ -46,6 +46,10 @@ function shouldClearSocketRefAfterSendFailure(err: unknown): boolean { return /closed|reset|disconnect|no active socket/i.test(formatError(err)); } +function isNonEmptyString(value: string | undefined): value is string { + return Boolean(value); +} + export type MonitorWebInboxOptions = { verbose: boolean; accountId: string; @@ -132,11 +136,7 @@ export async function attachWebInboxToSocket( error?: unknown, ): Promise => { const dedupeKeys = [ - ...new Set( - entries - .map((entry) => entry.dedupeKey) - .filter((dedupeKey): dedupeKey is string => Boolean(dedupeKey)), - ), + ...new Set(entries.map((entry) => entry.dedupeKey).filter(isNonEmptyString)), ]; if (dedupeKeys.length === 0) { return; diff --git a/src/wizard/setup.ts b/src/wizard/setup.ts index d80b98686b6..e4698071beb 100644 --- a/src/wizard/setup.ts +++ b/src/wizard/setup.ts @@ -1,5 +1,6 @@ import { formatCliCommand } from "../cli/command-format.js"; import type { + AuthChoice, GatewayAuthChoice, OnboardMode, OnboardOptions, @@ -484,25 +485,23 @@ export async function runSetupWizard( let nextConfig: OpenClawConfig = applyLocalSetupWorkspaceConfig(baseConfig, workspaceDir); const authChoiceFromPrompt = opts.authChoice === undefined; - const promptedAuthChoice = authChoiceFromPrompt - ? await (async () => { - const { ensureAuthProfileStore } = await import("../agents/auth-profiles.runtime.js"); - const { promptAuthChoiceGrouped } = await import("../commands/auth-choice-prompt.js"); - const authStore = ensureAuthProfileStore(undefined, { - allowKeychainPrompt: false, - }); - return await promptAuthChoiceGrouped({ - prompter, - store: authStore, - includeSkip: true, - config: nextConfig, - workspaceDir, - }); - })() - : undefined; - const authChoice = opts.authChoice ?? promptedAuthChoice; - if (!authChoice) { - throw new Error("Failed to resolve auth choice."); + let authChoice: AuthChoice | undefined = opts.authChoice; + if (authChoiceFromPrompt) { + const { ensureAuthProfileStore } = await import("../agents/auth-profiles.runtime.js"); + const { promptAuthChoiceGrouped } = await import("../commands/auth-choice-prompt.js"); + const authStore = ensureAuthProfileStore(undefined, { + allowKeychainPrompt: false, + }); + authChoice = await promptAuthChoiceGrouped({ + prompter, + store: authStore, + includeSkip: true, + config: nextConfig, + workspaceDir, + }); + } + if (authChoice === undefined) { + throw new WizardCancelledError("auth choice is required"); } if (authChoice === "custom-api-key") {