From 4b5487ee8594d84290a7da4700da3e86bbff0490 Mon Sep 17 00:00:00 2001 From: darkamenosa Date: Thu, 19 Mar 2026 01:27:21 +0700 Subject: [PATCH] LINE: avoid runtime lookup during onboarding (#49960) --- extensions/line/src/config-adapter.ts | 23 ++++++++++---------- src/commands/onboard-channels.e2e.test.ts | 26 +++++++++++++++++++++++ 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/extensions/line/src/config-adapter.ts b/extensions/line/src/config-adapter.ts index 118159f16b2..1b10989b45c 100644 --- a/extensions/line/src/config-adapter.ts +++ b/extensions/line/src/config-adapter.ts @@ -1,13 +1,11 @@ import { createScopedChannelConfigAdapter } from "openclaw/plugin-sdk/channel-config-helpers"; -import type { OpenClawConfig, ResolvedLineAccount } from "../api.js"; -import { getLineRuntime } from "./runtime.js"; - -function resolveLineRuntimeAccount(cfg: OpenClawConfig, accountId?: string | null) { - return getLineRuntime().channel.line.resolveLineAccount({ - cfg, - accountId: accountId ?? undefined, - }); -} +import { + listLineAccountIds, + resolveDefaultLineAccountId, + resolveLineAccount, + type OpenClawConfig, + type ResolvedLineAccount, +} from "../runtime-api.js"; export function normalizeLineAllowFrom(entry: string): string { return entry.replace(/^line:(?:user:)?/i, ""); @@ -19,9 +17,10 @@ export const lineConfigAdapter = createScopedChannelConfigAdapter< OpenClawConfig >({ sectionKey: "line", - listAccountIds: (cfg) => getLineRuntime().channel.line.listLineAccountIds(cfg), - resolveAccount: (cfg, accountId) => resolveLineRuntimeAccount(cfg, accountId), - defaultAccountId: (cfg) => getLineRuntime().channel.line.resolveDefaultLineAccountId(cfg), + listAccountIds: listLineAccountIds, + resolveAccount: (cfg, accountId) => + resolveLineAccount({ cfg, accountId: accountId ?? undefined }), + defaultAccountId: resolveDefaultLineAccountId, clearBaseFields: ["channelSecret", "tokenFile", "secretFile"], resolveAllowFrom: (account) => account.config.allowFrom, formatAllowFrom: (allowFrom) => diff --git a/src/commands/onboard-channels.e2e.test.ts b/src/commands/onboard-channels.e2e.test.ts index 7d64a4d120f..4934d3674ff 100644 --- a/src/commands/onboard-channels.e2e.test.ts +++ b/src/commands/onboard-channels.e2e.test.ts @@ -277,6 +277,32 @@ describe("setupChannels", () => { expect(multiselect).not.toHaveBeenCalled(); }); + it("renders the QuickStart channel picker without requiring the LINE runtime", async () => { + const select = vi.fn(async ({ message }: { message: string }) => { + if (message === "Select channel (QuickStart)") { + return "__skip__"; + } + return "__done__"; + }); + const { multiselect, text } = createUnexpectedPromptGuards(); + const prompter = createPrompter({ + select: select as unknown as WizardPrompter["select"], + multiselect, + text, + }); + + await expect( + runSetupChannels({} as OpenClawConfig, prompter, { + quickstartDefaults: true, + }), + ).resolves.toEqual({} as OpenClawConfig); + + expect(select).toHaveBeenCalledWith( + expect.objectContaining({ message: "Select channel (QuickStart)" }), + ); + expect(multiselect).not.toHaveBeenCalled(); + }); + it("continues Telegram setup when the plugin registry is empty", async () => { // Simulate missing registry entries (the scenario reported in #25545). setActivePluginRegistry(createEmptyPluginRegistry());