refactor: route bundled channel setup helpers through private sdk bridges

This commit is contained in:
Peter Steinberger 2026-03-16 18:35:13 -07:00
parent 6c1433a3c0
commit e554eee541
No known key found for this signature in database
30 changed files with 343 additions and 196 deletions

View File

@ -3,10 +3,12 @@ import type {
DiscordAccountConfig,
DiscordActionConfig,
} from "openclaw/plugin-sdk/discord";
import { createAccountActionGate } from "../../../src/channels/plugins/account-action-gate.js";
import { createAccountListHelpers } from "../../../src/channels/plugins/account-helpers.js";
import { resolveAccountEntry } from "../../../src/routing/account-lookup.js";
import { normalizeAccountId } from "../../../src/routing/session-key.js";
import {
createAccountActionGate,
createAccountListHelpers,
normalizeAccountId,
resolveAccountEntry,
} from "../../../src/plugin-sdk-internal/accounts.js";
import { resolveDiscordToken } from "./token.js";
export type ResolvedDiscordAccount = {

View File

@ -1,5 +1,5 @@
import { resolveTextChunkLimit } from "../../../src/auto-reply/chunk.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { type OpenClawConfig } from "../../../src/config/config.js";
import { resolveAccountEntry } from "../../../src/routing/account-lookup.js";
import { normalizeAccountId } from "../../../src/routing/session-key.js";
import { DISCORD_TEXT_CHUNK_LIMIT } from "./outbound-adapter.js";

View File

@ -1,22 +1,23 @@
import type { DiscordGuildEntry } from "../../../src/config/types.discord.js";
import {
applyAccountNameToChannelSection,
DEFAULT_ACCOUNT_ID,
formatDocsLink,
migrateBaseNameToDefaultAccount,
} from "../../../src/channels/plugins/setup-helpers.js";
import {
normalizeAccountId,
noteChannelLookupFailure,
noteChannelLookupSummary,
parseMentionOrPrefixedId,
patchChannelConfigForAccount,
setLegacyChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelSetupDmPolicy } from "../../../src/channels/plugins/setup-wizard-types.js";
import type { ChannelSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
import type { ChannelSetupAdapter } from "../../../src/channels/plugins/types.adapters.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import type { DiscordGuildEntry } from "../../../src/config/types.discord.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
type OpenClawConfig,
} from "../../../src/plugin-sdk-internal/setup.js";
import {
type ChannelSetupAdapter,
type ChannelSetupDmPolicy,
type ChannelSetupWizard,
} from "../../../src/plugin-sdk-internal/setup.js";
import { inspectDiscordAccount } from "./account-inspect.js";
import { listDiscordAccountIds, resolveDiscordAccount } from "./accounts.js";

View File

@ -1,19 +1,21 @@
import {
DEFAULT_ACCOUNT_ID,
formatDocsLink,
noteChannelLookupFailure,
noteChannelLookupSummary,
type OpenClawConfig,
parseMentionOrPrefixedId,
patchChannelConfigForAccount,
promptLegacyChannelAllowFrom,
resolveSetupAccountId,
setLegacyChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelSetupDmPolicy } from "../../../src/channels/plugins/setup-wizard-types.js";
import type { ChannelSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { DEFAULT_ACCOUNT_ID } from "../../../src/routing/session-key.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import type { WizardPrompter } from "../../../src/wizard/prompts.js";
type WizardPrompter,
} from "../../../src/plugin-sdk-internal/setup.js";
import {
type ChannelSetupDmPolicy,
type ChannelSetupWizard,
} from "../../../src/plugin-sdk-internal/setup.js";
import { inspectDiscordAccount } from "./account-inspect.js";
import {
listDiscordAccountIds,

View File

@ -1,4 +1,4 @@
import type { BaseTokenResolution } from "../../../src/channels/plugins/types.js";
import type { BaseTokenResolution } from "../../../src/channels/plugins/types.core.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { normalizeResolvedSecretInputString } from "../../../src/config/types.secrets.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";

View File

@ -1,7 +1,10 @@
import { normalizeAccountId, type IMessageAccountConfig } from "openclaw/plugin-sdk/imessage";
import { createAccountListHelpers } from "../../../src/channels/plugins/account-helpers.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { resolveAccountEntry } from "../../../src/routing/account-lookup.js";
import type { IMessageAccountConfig } from "openclaw/plugin-sdk/imessage";
import {
type OpenClawConfig,
createAccountListHelpers,
normalizeAccountId,
resolveAccountEntry,
} from "../../../src/plugin-sdk-internal/accounts.js";
export type ResolvedIMessageAccount = {
accountId: string;

View File

@ -1,36 +1,29 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import * as onboardHelpers from "../../../src/commands/onboard-helpers.js";
import * as execModule from "../../../src/process/exec.js";
import * as clientModule from "./client.js";
import { probeIMessage } from "./probe.js";
const detectBinaryMock = vi.hoisted(() => vi.fn());
const runCommandWithTimeoutMock = vi.hoisted(() => vi.fn());
const createIMessageRpcClientMock = vi.hoisted(() => vi.fn());
vi.mock("../../../src/commands/onboard-helpers.js", () => ({
detectBinary: (...args: unknown[]) => detectBinaryMock(...args),
}));
vi.mock("../../../src/process/exec.js", () => ({
runCommandWithTimeout: (...args: unknown[]) => runCommandWithTimeoutMock(...args),
}));
vi.mock("./client.js", () => ({
createIMessageRpcClient: (...args: unknown[]) => createIMessageRpcClientMock(...args),
}));
beforeEach(() => {
detectBinaryMock.mockClear().mockResolvedValue(true);
runCommandWithTimeoutMock.mockClear().mockResolvedValue({
vi.restoreAllMocks();
vi.spyOn(onboardHelpers, "detectBinary").mockResolvedValue(true);
vi.spyOn(execModule, "runCommandWithTimeout").mockResolvedValue({
stdout: "",
stderr: 'unknown command "rpc" for "imsg"',
code: 1,
signal: null,
killed: false,
});
createIMessageRpcClientMock.mockClear();
});
describe("probeIMessage", () => {
it("marks unknown rpc subcommand as fatal", async () => {
const createIMessageRpcClientMock = vi
.spyOn(clientModule, "createIMessageRpcClient")
.mockResolvedValue({
request: vi.fn(),
stop: vi.fn(),
} as unknown as Awaited<ReturnType<typeof clientModule.createIMessageRpcClient>>);
const result = await probeIMessage(1000, { cliPath: "imsg" });
expect(result.ok).toBe(false);
expect(result.fatal).toBe(true);

View File

@ -1,20 +1,21 @@
import {
applyAccountNameToChannelSection,
DEFAULT_ACCOUNT_ID,
formatDocsLink,
migrateBaseNameToDefaultAccount,
} from "../../../src/channels/plugins/setup-helpers.js";
import {
normalizeAccountId,
parseSetupEntriesAllowingWildcard,
promptParsedAllowFromForScopedChannel,
setChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelSetupDmPolicy } from "../../../src/channels/plugins/setup-wizard-types.js";
import { type ChannelSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
import type { ChannelSetupAdapter } from "../../../src/channels/plugins/types.adapters.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import type { WizardPrompter } from "../../../src/wizard/prompts.js";
type OpenClawConfig,
type WizardPrompter,
} from "../../../src/plugin-sdk-internal/setup.js";
import type {
ChannelSetupAdapter,
ChannelSetupDmPolicy,
ChannelSetupWizard,
} from "../../../src/plugin-sdk-internal/setup.js";
import {
listIMessageAccountIds,
resolveDefaultIMessageAccountId,

View File

@ -1,16 +1,18 @@
import {
DEFAULT_ACCOUNT_ID,
detectBinary,
formatDocsLink,
type OpenClawConfig,
parseSetupEntriesAllowingWildcard,
promptParsedAllowFromForScopedChannel,
setChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelSetupDmPolicy } from "../../../src/channels/plugins/setup-wizard-types.js";
import { type ChannelSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
import { detectBinary } from "../../../src/commands/onboard-helpers.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { DEFAULT_ACCOUNT_ID } from "../../../src/routing/session-key.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import type { WizardPrompter } from "../../../src/wizard/prompts.js";
type WizardPrompter,
} from "../../../src/plugin-sdk-internal/setup.js";
import type {
ChannelSetupDmPolicy,
ChannelSetupWizard,
} from "../../../src/plugin-sdk-internal/setup.js";
import {
listIMessageAccountIds,
resolveDefaultIMessageAccountId,

View File

@ -1,7 +1,10 @@
import { normalizeAccountId, type SignalAccountConfig } from "openclaw/plugin-sdk/signal";
import { createAccountListHelpers } from "../../../src/channels/plugins/account-helpers.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { resolveAccountEntry } from "../../../src/routing/account-lookup.js";
import type { SignalAccountConfig } from "openclaw/plugin-sdk/signal";
import {
type OpenClawConfig,
createAccountListHelpers,
normalizeAccountId,
resolveAccountEntry,
} from "../../../src/plugin-sdk-internal/accounts.js";
export type ResolvedSignalAccount = {
accountId: string;

View File

@ -1,27 +1,20 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import * as clientModule from "./client.js";
import { classifySignalCliLogLine } from "./daemon.js";
import { probeSignal } from "./probe.js";
const signalCheckMock = vi.fn();
const signalRpcRequestMock = vi.fn();
vi.mock("./client.js", () => ({
signalCheck: (...args: unknown[]) => signalCheckMock(...args),
signalRpcRequest: (...args: unknown[]) => signalRpcRequestMock(...args),
}));
describe("probeSignal", () => {
beforeEach(() => {
vi.clearAllMocks();
vi.restoreAllMocks();
});
it("extracts version from {version} result", async () => {
signalCheckMock.mockResolvedValueOnce({
vi.spyOn(clientModule, "signalCheck").mockResolvedValueOnce({
ok: true,
status: 200,
error: null,
});
signalRpcRequestMock.mockResolvedValueOnce({ version: "0.13.22" });
vi.spyOn(clientModule, "signalRpcRequest").mockResolvedValueOnce({ version: "0.13.22" });
const res = await probeSignal("http://127.0.0.1:8080", 1000);
@ -31,7 +24,7 @@ describe("probeSignal", () => {
});
it("returns ok=false when /check fails", async () => {
signalCheckMock.mockResolvedValueOnce({
vi.spyOn(clientModule, "signalCheck").mockResolvedValueOnce({
ok: false,
status: 503,
error: "HTTP 503",

View File

@ -1,22 +1,23 @@
import {
applyAccountNameToChannelSection,
DEFAULT_ACCOUNT_ID,
formatCliCommand,
formatDocsLink,
migrateBaseNameToDefaultAccount,
} from "../../../src/channels/plugins/setup-helpers.js";
import {
normalizeAccountId,
normalizeE164,
parseSetupEntriesAllowingWildcard,
promptParsedAllowFromForScopedChannel,
setChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelSetupDmPolicy } from "../../../src/channels/plugins/setup-wizard-types.js";
import type { ChannelSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
import type { ChannelSetupAdapter } from "../../../src/channels/plugins/types.adapters.js";
import { formatCliCommand } from "../../../src/cli/command-format.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import { normalizeE164 } from "../../../src/utils.js";
import type { WizardPrompter } from "../../../src/wizard/prompts.js";
type OpenClawConfig,
type WizardPrompter,
} from "../../../src/plugin-sdk-internal/setup.js";
import type {
ChannelSetupAdapter,
ChannelSetupDmPolicy,
ChannelSetupWizard,
} from "../../../src/plugin-sdk-internal/setup.js";
import {
listSignalAccountIds,
resolveDefaultSignalAccountId,

View File

@ -1,18 +1,20 @@
import {
DEFAULT_ACCOUNT_ID,
detectBinary,
formatCliCommand,
formatDocsLink,
installSignalCli,
type OpenClawConfig,
parseSetupEntriesAllowingWildcard,
promptParsedAllowFromForScopedChannel,
setChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelSetupDmPolicy } from "../../../src/channels/plugins/setup-wizard-types.js";
import { type ChannelSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
import { formatCliCommand } from "../../../src/cli/command-format.js";
import { detectBinary } from "../../../src/commands/onboard-helpers.js";
import { installSignalCli } from "../../../src/commands/signal-install.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { DEFAULT_ACCOUNT_ID } from "../../../src/routing/session-key.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import type { WizardPrompter } from "../../../src/wizard/prompts.js";
type WizardPrompter,
} from "../../../src/plugin-sdk-internal/setup.js";
import type {
ChannelSetupDmPolicy,
ChannelSetupWizard,
} from "../../../src/plugin-sdk-internal/setup.js";
import {
listSignalAccountIds,
resolveDefaultSignalAccountId,

View File

@ -1,9 +1,12 @@
import { normalizeChatType } from "../../../src/channels/chat-type.js";
import { createAccountListHelpers } from "../../../src/channels/plugins/account-helpers.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import type { SlackAccountConfig } from "../../../src/config/types.js";
import { resolveAccountEntry } from "../../../src/routing/account-lookup.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";
import type { SlackAccountConfig } from "openclaw/plugin-sdk/slack";
import {
type OpenClawConfig,
createAccountListHelpers,
DEFAULT_ACCOUNT_ID,
normalizeAccountId,
normalizeChatType,
resolveAccountEntry,
} from "../../../src/plugin-sdk-internal/accounts.js";
import type { SlackAccountSurfaceFields } from "./account-surface-fields.js";
import { resolveSlackAppToken, resolveSlackBotToken, resolveSlackUserToken } from "./token.js";

View File

@ -1,8 +1,11 @@
import {
applyAccountNameToChannelSection,
DEFAULT_ACCOUNT_ID,
formatDocsLink,
hasConfiguredSecretInput,
migrateBaseNameToDefaultAccount,
} from "../../../src/channels/plugins/setup-helpers.js";
import {
normalizeAccountId,
type OpenClawConfig,
noteChannelLookupFailure,
noteChannelLookupSummary,
parseMentionOrPrefixedId,
@ -10,17 +13,13 @@ import {
setAccountGroupPolicyForChannel,
setLegacyChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelSetupDmPolicy } from "../../../src/channels/plugins/setup-wizard-types.js";
import type {
ChannelSetupWizard,
ChannelSetupWizardAllowFromEntry,
} from "../../../src/channels/plugins/setup-wizard.js";
import type { ChannelSetupAdapter } from "../../../src/channels/plugins/types.adapters.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { hasConfiguredSecretInput } from "../../../src/config/types.secrets.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
} from "../../../src/plugin-sdk-internal/setup.js";
import {
type ChannelSetupAdapter,
type ChannelSetupDmPolicy,
type ChannelSetupWizard,
type ChannelSetupWizardAllowFromEntry,
} from "../../../src/plugin-sdk-internal/setup.js";
import { inspectSlackAccount } from "./account-inspect.js";
import { listSlackAccountIds, resolveSlackAccount, type ResolvedSlackAccount } from "./accounts.js";

View File

@ -1,6 +1,11 @@
import {
DEFAULT_ACCOUNT_ID,
formatDocsLink,
hasConfiguredSecretInput,
noteChannelLookupFailure,
noteChannelLookupSummary,
normalizeAccountId,
type OpenClawConfig,
parseMentionOrPrefixedId,
patchChannelConfigForAccount,
promptLegacyChannelAllowFrom,
@ -8,17 +13,13 @@ import {
setAccountGroupPolicyForChannel,
setLegacyChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelSetupDmPolicy } from "../../../src/channels/plugins/setup-wizard-types.js";
type WizardPrompter,
} from "../../../src/plugin-sdk-internal/setup.js";
import type {
ChannelSetupDmPolicy,
ChannelSetupWizard,
ChannelSetupWizardAllowFromEntry,
} from "../../../src/channels/plugins/setup-wizard.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { hasConfiguredSecretInput } from "../../../src/config/types.secrets.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import type { WizardPrompter } from "../../../src/wizard/prompts.js";
} from "../../../src/plugin-sdk-internal/setup.js";
import { inspectSlackAccount } from "./account-inspect.js";
import {
listSlackAccountIds,

View File

@ -1,5 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { OpenClawConfig } from "../../../src/config/config.js";
import * as subsystemModule from "../../../src/logging/subsystem.js";
import { withEnv } from "../../../src/test-utils/env.js";
import {
listTelegramAccountIds,
@ -29,15 +30,16 @@ function resolveAccountWithEnv(
return withEnv(env, () => resolveTelegramAccount({ cfg, ...(accountId ? { accountId } : {}) }));
}
vi.mock("../../../src/logging/subsystem.js", () => ({
createSubsystemLogger: () => {
beforeEach(() => {
vi.restoreAllMocks();
vi.spyOn(subsystemModule, "createSubsystemLogger").mockImplementation(() => {
const logger = {
warn: warnMock,
child: () => logger,
};
return logger;
},
}));
return logger as ReturnType<typeof subsystemModule.createSubsystemLogger>;
});
});
describe("resolveTelegramAccount", () => {
afterEach(() => {

View File

@ -21,7 +21,14 @@ import {
} from "../../../src/routing/session-key.js";
import { resolveTelegramToken } from "./token.js";
const log = createSubsystemLogger("telegram/accounts");
let log: ReturnType<typeof createSubsystemLogger> | null = null;
function getLog() {
if (!log) {
log = createSubsystemLogger("telegram/accounts");
}
return log;
}
function formatDebugArg(value: unknown): string {
if (typeof value === "string") {
@ -36,7 +43,7 @@ function formatDebugArg(value: unknown): string {
const debugAccounts = (...args: unknown[]) => {
if (isTruthyEnvValue(process.env.OPENCLAW_DEBUG_TELEGRAM_ACCOUNTS)) {
const parts = args.map((arg) => formatDebugArg(arg));
log.warn(parts.join(" ").trim());
getLog().warn(parts.join(" ").trim());
}
};
@ -92,7 +99,7 @@ export function resolveDefaultTelegramAccountId(cfg: OpenClawConfig): string {
}
if (ids.length > 1 && !emittedMissingDefaultWarn) {
emittedMissingDefaultWarn = true;
log.warn(
getLog().warn(
`channels.telegram: accounts.default is missing; falling back to "${ids[0]}". ` +
`${formatSetExplicitDefaultInstruction("telegram")} to avoid routing surprises in multi-account setups.`,
);

View File

@ -1,5 +1,5 @@
import { resolveTextChunkLimit } from "../../../src/auto-reply/chunk.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { type OpenClawConfig } from "../../../src/config/config.js";
import { resolveAccountEntry } from "../../../src/routing/account-lookup.js";
import { normalizeAccountId } from "../../../src/routing/session-key.js";
import { TELEGRAM_TEXT_CHUNK_LIMIT } from "./outbound-adapter.js";

View File

@ -1,5 +1,5 @@
import type { TelegramNetworkConfig } from "openclaw/plugin-sdk/telegram";
import type { BaseProbeResult } from "../../../src/channels/plugins/types.js";
import type { TelegramNetworkConfig } from "../../../src/config/types.telegram.js";
import { fetchWithTimeout } from "../../../src/utils/fetch-timeout.js";
import { resolveTelegramFetch } from "./fetch.js";
import { makeProxyFetch } from "./proxy.js";

View File

@ -1,16 +1,20 @@
import {
applyAccountNameToChannelSection,
DEFAULT_ACCOUNT_ID,
formatCliCommand,
formatDocsLink,
migrateBaseNameToDefaultAccount,
} from "../../../src/channels/plugins/setup-helpers.js";
import {
normalizeAccountId,
patchChannelConfigForAccount,
promptResolvedAllowFrom,
splitSetupEntries,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelSetupAdapter } from "../../../src/channels/plugins/types.adapters.js";
import { formatCliCommand } from "../../../src/cli/command-format.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
type OpenClawConfig,
type WizardPrompter,
} from "../../../src/plugin-sdk-internal/setup.js";
import type {
ChannelSetupAdapter,
ChannelSetupDmPolicy,
} from "../../../src/plugin-sdk-internal/setup.js";
import { resolveDefaultTelegramAccountId, resolveTelegramAccount } from "./accounts.js";
import { fetchTelegramChatId } from "./api-fetch.js";
@ -71,11 +75,7 @@ export async function resolveTelegramAllowFromEntries(params: {
export async function promptTelegramAllowFromForAccount(params: {
cfg: OpenClawConfig;
prompter: Parameters<
NonNullable<
import("../../../src/channels/plugins/setup-wizard-types.js").ChannelSetupDmPolicy["promptAllowFrom"]
>
>[0]["prompter"];
prompter: WizardPrompter;
accountId?: string;
}) {
const accountId = params.accountId ?? resolveDefaultTelegramAccountId(params.cfg);
@ -87,8 +87,6 @@ export async function promptTelegramAllowFromForAccount(params: {
"Telegram",
);
}
const { promptResolvedAllowFrom } =
await import("../../../src/channels/plugins/setup-wizard-helpers.runtime.js");
const unique = await promptResolvedAllowFrom({
prompter: params.prompter,
existing: resolved.config.allowFrom ?? [],

View File

@ -1,14 +1,16 @@
import {
DEFAULT_ACCOUNT_ID,
hasConfiguredSecretInput,
type OpenClawConfig,
patchChannelConfigForAccount,
setChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
splitSetupEntries,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import { type ChannelSetupDmPolicy } from "../../../src/channels/plugins/setup-wizard-types.js";
import { type ChannelSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { hasConfiguredSecretInput } from "../../../src/config/types.secrets.js";
import { DEFAULT_ACCOUNT_ID } from "../../../src/routing/session-key.js";
} from "../../../src/plugin-sdk-internal/setup.js";
import type {
ChannelSetupDmPolicy,
ChannelSetupWizard,
} from "../../../src/plugin-sdk-internal/setup.js";
import { inspectTelegramAccount } from "./account-inspect.js";
import { listTelegramAccountIds, resolveTelegramAccount } from "./accounts.js";
import {

View File

@ -1,7 +1,7 @@
import type { BaseTokenResolution } from "../../../src/channels/plugins/types.js";
import type { TelegramAccountConfig } from "openclaw/plugin-sdk/telegram";
import type { BaseTokenResolution } from "../../../src/channels/plugins/types.core.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { normalizeResolvedSecretInputString } from "../../../src/config/types.secrets.js";
import type { TelegramAccountConfig } from "../../../src/config/types.telegram.js";
import { tryReadSecretFileSync } from "../../../src/infra/secret-file.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";

View File

@ -1,16 +1,15 @@
import fs from "node:fs";
import path from "node:path";
import type {
DmPolicy,
GroupPolicy,
OpenClawConfig,
WhatsAppAccountConfig,
} from "openclaw/plugin-sdk/whatsapp";
import { createAccountListHelpers } from "../../../src/channels/plugins/account-helpers.js";
import type { DmPolicy, GroupPolicy, WhatsAppAccountConfig } from "openclaw/plugin-sdk/whatsapp";
import { resolveOAuthDir } from "../../../src/config/paths.js";
import { resolveAccountEntry } from "../../../src/routing/account-lookup.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";
import { resolveUserPath } from "../../../src/utils.js";
import {
type OpenClawConfig,
createAccountListHelpers,
DEFAULT_ACCOUNT_ID,
normalizeAccountId,
resolveAccountEntry,
resolveUserPath,
} from "../../../src/plugin-sdk-internal/accounts.js";
import { hasWebCredsSync } from "./auth-store.js";
export type ResolvedWhatsAppAccount = {

View File

@ -1,9 +1,9 @@
import {
applyAccountNameToChannelSection,
type ChannelSetupAdapter,
migrateBaseNameToDefaultAccount,
} from "../../../src/channels/plugins/setup-helpers.js";
import type { ChannelSetupAdapter } from "../../../src/channels/plugins/types.adapters.js";
import { normalizeAccountId } from "../../../src/routing/session-key.js";
normalizeAccountId,
} from "../../../src/plugin-sdk-internal/setup.js";
const channel = "whatsapp" as const;

View File

@ -1,23 +1,48 @@
import path from "node:path";
import { loginWeb } from "../../../src/channel-web.js";
import {
DEFAULT_ACCOUNT_ID,
type DmPolicy,
formatCliCommand,
formatDocsLink,
normalizeAccountId,
normalizeAllowFromEntries,
normalizeE164,
pathExists,
splitSetupEntries,
} from "../../../src/channels/plugins/setup-wizard-helpers.js";
import { setSetupChannelEnabled } from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
import { formatCliCommand } from "../../../src/cli/command-format.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { mergeWhatsAppConfig } from "../../../src/config/merge-config.js";
import type { DmPolicy } from "../../../src/config/types.js";
import { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../../../src/routing/session-key.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import { normalizeE164, pathExists } from "../../../src/utils.js";
setSetupChannelEnabled,
type OpenClawConfig,
} from "../../../src/plugin-sdk-internal/setup.js";
import type { ChannelSetupWizard } from "../../../src/plugin-sdk-internal/setup.js";
import { listWhatsAppAccountIds, resolveWhatsAppAuthDir } from "./accounts.js";
import { loginWeb } from "./login.js";
import { whatsappSetupAdapter } from "./setup-core.js";
const channel = "whatsapp" as const;
function mergeWhatsAppConfig(
cfg: OpenClawConfig,
patch: Partial<NonNullable<OpenClawConfig["channels"]>["whatsapp"]>,
options?: { unsetOnUndefined?: string[] },
): OpenClawConfig {
const base = { ...(cfg.channels?.whatsapp ?? {}) } as Record<string, unknown>;
for (const [key, value] of Object.entries(patch)) {
if (value === undefined) {
if (options?.unsetOnUndefined?.includes(key)) {
delete base[key];
}
continue;
}
base[key] = value;
}
return {
...cfg,
channels: {
...cfg.channels,
whatsapp: base,
},
};
}
function setWhatsAppDmPolicy(cfg: OpenClawConfig, dmPolicy: DmPolicy): OpenClawConfig {
return mergeWhatsAppConfig(cfg, { dmPolicy });
}

View File

@ -0,0 +1,8 @@
export type { OpenClawConfig } from "../config/config.js";
export { createAccountActionGate } from "../channels/plugins/account-action-gate.js";
export { createAccountListHelpers } from "../channels/plugins/account-helpers.js";
export { normalizeChatType } from "../channels/chat-type.js";
export { resolveAccountEntry } from "../routing/account-lookup.js";
export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
export { normalizeE164, pathExists, resolveUserPath } from "../utils.js";

View File

@ -0,0 +1,37 @@
export type { OpenClawConfig } from "../config/config.js";
export type { WizardPrompter } from "../wizard/prompts.js";
export type { ChannelSetupAdapter } from "../channels/plugins/types.adapters.js";
export type { ChannelSetupDmPolicy } from "../channels/plugins/setup-wizard-types.js";
export type {
ChannelSetupWizard,
ChannelSetupWizardAllowFromEntry,
} from "../channels/plugins/setup-wizard.js";
export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
export {
applyAccountNameToChannelSection,
migrateBaseNameToDefaultAccount,
} from "../channels/plugins/setup-helpers.js";
export {
normalizeAllowFromEntries,
noteChannelLookupFailure,
noteChannelLookupSummary,
parseMentionOrPrefixedId,
parseSetupEntriesAllowingWildcard,
patchChannelConfigForAccount,
promptLegacyChannelAllowFrom,
promptParsedAllowFromForScopedChannel,
promptResolvedAllowFrom,
resolveSetupAccountId,
setAccountGroupPolicyForChannel,
setChannelDmPolicyWithAllowFrom,
setLegacyChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
splitSetupEntries,
} from "../channels/plugins/setup-wizard-helpers.js";
export { detectBinary } from "../commands/onboard-helpers.js";
export { installSignalCli } from "../commands/signal-install.js";
export { formatCliCommand } from "../cli/command-format.js";
export { formatDocsLink } from "../terminal/links.js";
export { hasConfiguredSecretInput } from "../config/types.secrets.js";
export { normalizeE164, pathExists } from "../utils.js";

View File

@ -1,4 +1,5 @@
export { createAccountListHelpers } from "../channels/plugins/account-helpers.js";
export { createAccountActionGate } from "../channels/plugins/account-action-gate.js";
export { CHANNEL_MESSAGE_ACTION_NAMES } from "../channels/plugins/message-action-names.js";
export {
BLUEBUBBLES_ACTIONS,
@ -61,6 +62,27 @@ export type {
BaseTokenResolution,
} from "../channels/plugins/types.js";
export type { ChannelConfigSchema, ChannelPlugin } from "../channels/plugins/types.plugin.js";
export type {
ChannelSetupConfigureContext,
ChannelSetupDmPolicy,
ChannelSetupInteractiveContext,
ChannelSetupPlugin,
ChannelSetupResult,
ChannelSetupStatus,
ChannelSetupStatusContext,
ChannelSetupWizardAdapter,
} from "../channels/plugins/setup-wizard-types.js";
export type {
ChannelSetupWizard,
ChannelSetupWizardAllowFromEntry,
ChannelSetupWizardCredential,
ChannelSetupWizardCredentialState,
ChannelSetupWizardFinalize,
ChannelSetupWizardGroupAccess,
ChannelSetupWizardPrepare,
ChannelSetupWizardStatus,
ChannelSetupWizardTextInput,
} from "../channels/plugins/setup-wizard.js";
export type {
AcpRuntimeCapabilities,
AcpRuntimeControl,
@ -222,6 +244,21 @@ export {
createDefaultChannelRuntimeState,
} from "./status-helpers.js";
export {
normalizeAllowFromEntries,
noteChannelLookupFailure,
noteChannelLookupSummary,
parseMentionOrPrefixedId,
parseSetupEntriesAllowingWildcard,
patchChannelConfigForAccount,
promptLegacyChannelAllowFrom,
promptParsedAllowFromForScopedChannel,
promptResolvedAllowFrom,
resolveSetupAccountId,
setAccountGroupPolicyForChannel,
setChannelDmPolicyWithAllowFrom,
setLegacyChannelDmPolicyWithAllowFrom,
setSetupChannelEnabled,
splitSetupEntries,
promptSingleChannelSecretInput,
type SingleChannelSecretInputPromptResult,
} from "../channels/plugins/setup-wizard-helpers.js";
@ -356,6 +393,7 @@ export {
listConfiguredAccountIds,
resolveAccountWithDefaultFallback,
} from "./account-resolution.js";
export { resolveAccountEntry } from "../routing/account-lookup.js";
export { issuePairingChallenge } from "../pairing/pairing-challenge.js";
export { handleSlackMessageAction } from "./slack-message-actions.js";
export { extractToolSend } from "./tool-send.js";
@ -385,7 +423,10 @@ export {
resolveRuntimeEnv,
resolveRuntimeEnvWithUnavailableExit,
} from "./runtime.js";
export { detectBinary } from "../commands/onboard-helpers.js";
export { installSignalCli } from "../commands/signal-install.js";
export { chunkTextForOutbound } from "./text-chunking.js";
export { resolveTextChunkLimit } from "../auto-reply/chunk.js";
export { readBooleanParam } from "./boolean-param.js";
export { readJsonFileWithFallback, writeJsonFileAtomically } from "./json-store.js";
export { generatePkceVerifierChallenge, toFormUrlEncoded } from "./oauth-utils.js";
@ -420,6 +461,7 @@ export type {
TailscaleStatusCommandRunner,
} from "../shared/tailscale-status.js";
export type { ChatType } from "../channels/chat-type.js";
export { normalizeChatType } from "../channels/chat-type.js";
/** @deprecated Use ChatType instead */
export type { RoutePeerKind } from "../routing/resolve-route.js";
export { resolveAckReaction } from "../agents/identity.js";
@ -453,6 +495,7 @@ export type {
PersistentDedupeOptions,
} from "./persistent-dedupe.js";
export { formatErrorMessage } from "../infra/errors.js";
export { resolveFetch } from "../infra/fetch.js";
export {
formatUtcTimestamp,
formatZonedTimestamp,
@ -619,6 +662,7 @@ export {
readStringParam,
} from "../agents/tools/common.js";
export { formatDocsLink } from "../terminal/links.js";
export { formatCliCommand } from "../cli/command-format.js";
export {
DM_GROUP_ACCESS_REASON,
readStoreAllowFromForDmPolicy,
@ -630,7 +674,23 @@ export {
} from "../security/dm-policy-shared.js";
export type { DmGroupAccessReasonCode } from "../security/dm-policy-shared.js";
export type { HookEntry } from "../hooks/types.js";
export { clamp, escapeRegExp, normalizeE164, safeParseJson, sleep } from "../utils.js";
export {
clamp,
escapeRegExp,
isRecord,
normalizeE164,
pathExists,
resolveUserPath,
safeParseJson,
sleep,
} from "../utils.js";
export { fetchWithTimeout } from "../utils/fetch-timeout.js";
export {
DEFAULT_SECRET_FILE_MAX_BYTES,
loadSecretFileSync,
readSecretFileSync,
tryReadSecretFileSync,
} from "../infra/secret-file.js";
export { stripAnsi } from "../terminal/ansi.js";
export { missingTargetError } from "../infra/outbound/target-errors.js";
export { registerLogTransport } from "../logging/logger.js";
@ -656,6 +716,8 @@ export type {
DiagnosticWebhookProcessedEvent,
DiagnosticWebhookReceivedEvent,
} from "../infra/diagnostic-events.js";
export { loadConfig } from "../config/config.js";
export { runCommandWithTimeout } from "../process/exec.js";
export { detectMime, extensionForMime, getFileExtension } from "../media/mime.js";
export { extractOriginalFilename } from "../media/store.js";
export { listSkillCommandsForAgents } from "../auto-reply/skill-commands.js";

View File

@ -4,24 +4,25 @@ export type {
ChannelMessageActionAdapter,
} from "../channels/plugins/types.js";
export type { OpenClawConfig } from "../config/config.js";
export type { TelegramAccountConfig, TelegramActionConfig } from "../config/types.js";
export type { PluginRuntime } from "../plugins/runtime/types.js";
export type { OpenClawPluginApi } from "../plugins/types.js";
export type {
ChannelMessageActionContext,
ChannelPlugin,
OpenClawPluginApi,
PluginRuntime,
} from "./channel-plugin-common.js";
TelegramAccountConfig,
TelegramActionConfig,
TelegramNetworkConfig,
} from "../config/types.js";
export { emptyPluginConfigSchema } from "../plugins/config-schema.js";
export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
export {
DEFAULT_ACCOUNT_ID,
PAIRING_APPROVED_MESSAGE,
applyAccountNameToChannelSection,
buildChannelConfigSchema,
deleteAccountFromConfigSection,
emptyPluginConfigSchema,
formatPairingApproveHint,
getChatChannelMeta,
migrateBaseNameToDefaultAccount,
normalizeAccountId,
setAccountEnabledInConfigSection,
} from "./channel-plugin-common.js";