refactor: restore public sdk seams after rebase

This commit is contained in:
Peter Steinberger
2026-03-16 22:47:56 -07:00
parent f2bd76cd1a
commit 5dd2245094
31 changed files with 190 additions and 178 deletions

View File

@@ -1,13 +1,13 @@
import {
hasConfiguredSecretInput,
normalizeSecretInputString,
} from "openclaw/plugin-sdk/config-runtime";
import type { DiscordAccountConfig } from "../../../src/config/types.js";
import {
DEFAULT_ACCOUNT_ID,
normalizeAccountId,
type OpenClawConfig,
} from "../../../src/plugin-sdk-internal/accounts.js";
} from "openclaw/plugin-sdk/account-resolution";
import {
hasConfiguredSecretInput,
normalizeSecretInputString,
} from "openclaw/plugin-sdk/config-runtime";
import type { DiscordAccountConfig } from "openclaw/plugin-sdk/discord";
import {
mergeDiscordAccountConfig,
resolveDefaultDiscordAccountId,

View File

@@ -1,11 +1,11 @@
import type { OpenClawConfig } from "../../../src/config/config.js";
import type { DiscordAccountConfig, DiscordActionConfig } from "../../../src/config/types.js";
import {
createAccountActionGate,
createAccountListHelpers,
normalizeAccountId,
resolveAccountEntry,
} from "../../../src/plugin-sdk-internal/accounts.js";
type OpenClawConfig,
} from "openclaw/plugin-sdk/account-resolution";
import type { DiscordAccountConfig, DiscordActionConfig } from "openclaw/plugin-sdk/discord";
import { resolveDiscordToken } from "./token.js";
export type ResolvedDiscordAccount = {

View File

@@ -1,3 +1,4 @@
import type { MockFn } from "openclaw/plugin-sdk/test-utils";
import { expect, vi } from "vitest";
import type { OpenClawConfig } from "../../../../src/config/config.js";
import type { RuntimeEnv } from "../../../../src/runtime.js";
@@ -14,6 +15,34 @@ export type PluginCommandSpecMock = {
acceptsArgs: boolean;
};
type AnyMock = MockFn;
type ProviderMonitorTestMocks = {
clientHandleDeployRequestMock: AnyMock;
clientFetchUserMock: AnyMock;
clientGetPluginMock: AnyMock;
clientConstructorOptionsMock: AnyMock;
createDiscordAutoPresenceControllerMock: AnyMock;
createDiscordNativeCommandMock: AnyMock;
createDiscordMessageHandlerMock: AnyMock;
createNoopThreadBindingManagerMock: AnyMock;
createThreadBindingManagerMock: AnyMock;
reconcileAcpThreadBindingsOnStartupMock: AnyMock;
createdBindingManagers: Array<{ stop: ReturnType<typeof vi.fn> }>;
getAcpSessionStatusMock: AnyMock;
getPluginCommandSpecsMock: AnyMock;
listNativeCommandSpecsForConfigMock: AnyMock;
listSkillCommandsForAgentsMock: AnyMock;
monitorLifecycleMock: AnyMock;
resolveDiscordAccountMock: AnyMock;
resolveDiscordAllowlistConfigMock: AnyMock;
resolveNativeCommandsEnabledMock: AnyMock;
resolveNativeSkillsEnabledMock: AnyMock;
isVerboseMock: AnyMock;
shouldLogVerboseMock: AnyMock;
voiceRuntimeModuleLoadedMock: AnyMock;
};
export function baseDiscordAccountConfig() {
return {
commands: { native: true, nativeSkills: false },
@@ -23,7 +52,7 @@ export function baseDiscordAccountConfig() {
};
}
const providerMonitorTestMocks = vi.hoisted(() => {
const providerMonitorTestMocks: ProviderMonitorTestMocks = vi.hoisted(() => {
const createdBindingManagers: Array<{ stop: ReturnType<typeof vi.fn> }> = [];
const isVerboseMock = vi.fn(() => false);
const shouldLogVerboseMock = vi.fn(() => false);
@@ -123,7 +152,7 @@ const {
voiceRuntimeModuleLoadedMock,
} = providerMonitorTestMocks;
export function getProviderMonitorTestMocks() {
export function getProviderMonitorTestMocks(): typeof providerMonitorTestMocks {
return providerMonitorTestMocks;
}

View File

@@ -1,9 +1,9 @@
import type { OpenClawConfig } from "openclaw/plugin-sdk/account-resolution";
import { formatAllowFromLowercase } from "openclaw/plugin-sdk/allow-from";
import {
createScopedAccountConfigAccessors,
createScopedChannelConfigBase,
} from "openclaw/plugin-sdk/channel-config-helpers";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { inspectDiscordAccount } from "./account-inspect.js";
import {
listDiscordAccountIds,

View File

@@ -1,7 +1,9 @@
import type { DiscordGuildEntry } from "openclaw/plugin-sdk/config-runtime";
import {
applyAccountNameToChannelSection,
createPatchedAccountSetupAdapter,
DEFAULT_ACCOUNT_ID,
formatDocsLink,
migrateBaseNameToDefaultAccount,
normalizeAccountId,
noteChannelLookupFailure,
@@ -13,13 +15,11 @@ import {
type OpenClawConfig,
} from "openclaw/plugin-sdk/setup";
import {
createAllowlistSetupWizardProxy,
type ChannelSetupAdapter,
type ChannelSetupDmPolicy,
type ChannelSetupWizard,
} from "openclaw/plugin-sdk/setup";
import { createPatchedAccountSetupAdapter } from "../../../src/channels/plugins/setup-helpers.js";
import { createAllowlistSetupWizardProxy } from "../../../src/channels/plugins/setup-wizard-proxy.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import { inspectDiscordAccount } from "./account-inspect.js";
import { listDiscordAccountIds, resolveDiscordAccount } from "./accounts.js";
@@ -140,9 +140,15 @@ export const discordSetupAdapter: ChannelSetupAdapter = {
},
};
export function createDiscordSetupWizardProxy(
loadWizard: () => Promise<{ discordSetupWizard: ChannelSetupWizard }>,
) {
export function createDiscordSetupWizardBase(handlers: {
promptAllowFrom: NonNullable<ChannelSetupDmPolicy["promptAllowFrom"]>;
resolveAllowFromEntries: NonNullable<
NonNullable<ChannelSetupWizard["allowFrom"]>["resolveEntries"]
>;
resolveGroupAllowlist: NonNullable<
NonNullable<NonNullable<ChannelSetupWizard["groupAccess"]>["resolveAllowlist"]>
>;
}) {
const discordDmPolicy: ChannelSetupDmPolicy = {
label: "Discord",
channel,
@@ -156,13 +162,7 @@ export function createDiscordSetupWizardProxy(
channel,
dmPolicy: policy,
}),
promptAllowFrom: async ({ cfg, prompter, accountId }) => {
const wizard = (await loadWizard()).discordSetupWizard;
if (!wizard.dmPolicy?.promptAllowFrom) {
return cfg;
}
return await wizard.dmPolicy.promptAllowFrom({ cfg, prompter, accountId });
},
promptAllowFrom: handlers.promptAllowFrom,
};
return {
@@ -253,12 +253,8 @@ export function createDiscordSetupWizardProxy(
entries: string[];
prompter: { note: (message: string, title?: string) => Promise<void> };
}) => {
const wizard = (await loadWizard()).discordSetupWizard;
if (!wizard.groupAccess?.resolveAllowlist) {
return entries.map((input) => ({ input, resolved: false }));
}
try {
return await wizard.groupAccess.resolveAllowlist({
return await handlers.resolveGroupAllowlist({
cfg,
accountId,
credentialValues,
@@ -317,18 +313,7 @@ export function createDiscordSetupWizardProxy(
accountId: string;
credentialValues: { token?: string };
entries: string[];
}) => {
const wizard = (await loadWizard()).discordSetupWizard;
if (!wizard.allowFrom) {
return entries.map((input) => ({ input, resolved: false, id: null }));
}
return await wizard.allowFrom.resolveEntries({
cfg,
accountId,
credentialValues,
entries,
});
},
}) => await handlers.resolveAllowFromEntries({ cfg, accountId, credentialValues, entries }),
apply: async ({
cfg,
accountId,

View File

@@ -1,5 +1,6 @@
import {
DEFAULT_ACCOUNT_ID,
formatDocsLink,
noteChannelLookupFailure,
noteChannelLookupSummary,
type OpenClawConfig,
@@ -12,7 +13,6 @@ import {
type WizardPrompter,
} from "openclaw/plugin-sdk/setup";
import { type ChannelSetupDmPolicy, type ChannelSetupWizard } from "openclaw/plugin-sdk/setup";
import { formatDocsLink } from "../../../src/terminal/links.js";
import { inspectDiscordAccount } from "./account-inspect.js";
import {
listDiscordAccountIds,

View File

@@ -2,7 +2,7 @@ import type {
ProviderResolveDynamicModelContext,
ProviderRuntimeModel,
} from "openclaw/plugin-sdk/core";
import { cloneFirstTemplateModel } from "../../src/plugins/provider-model-helpers.js";
import { cloneFirstTemplateModel } from "openclaw/plugin-sdk/provider-models";
const GEMINI_3_1_PRO_PREFIX = "gemini-3.1-pro";
const GEMINI_3_1_FLASH_PREFIX = "gemini-3.1-flash";

View File

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

View File

@@ -1,6 +1,7 @@
import {
applyAccountNameToChannelSection,
DEFAULT_ACCOUNT_ID,
formatDocsLink,
migrateBaseNameToDefaultAccount,
normalizeAccountId,
parseSetupEntriesAllowingWildcard,
@@ -16,7 +17,6 @@ import type {
ChannelSetupWizard,
ChannelSetupWizardTextInput,
} from "openclaw/plugin-sdk/setup";
import { formatDocsLink } from "../../../src/terminal/links.js";
import {
listIMessageAccountIds,
resolveDefaultIMessageAccountId,

View File

@@ -1,6 +1,8 @@
import { setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
import type { ChannelSetupWizard } from "openclaw/plugin-sdk/setup";
import { detectBinary } from "../../../src/commands/onboard-helpers.js";
import {
detectBinary,
setSetupChannelEnabled,
type ChannelSetupWizard,
} from "openclaw/plugin-sdk/setup";
import { listIMessageAccountIds, resolveIMessageAccount } from "./accounts.js";
import {
createIMessageCliPathTextInput,

View File

@@ -3,19 +3,17 @@ import {
collectAllowlistProviderRestrictSendersWarnings,
} from "openclaw/plugin-sdk/channel-policy";
import {
buildChannelConfigSchema,
DEFAULT_ACCOUNT_ID,
deleteAccountFromConfigSection,
setAccountEnabledInConfigSection,
} from "../../../src/channels/plugins/config-helpers.js";
import { buildChannelConfigSchema } from "../../../src/channels/plugins/config-schema.js";
import type { ChannelPlugin } from "../../../src/channels/plugins/types.plugin.js";
import { getChatChannelMeta } from "../../../src/channels/registry.js";
import { IMessageConfigSchema } from "../../../src/config/zod-schema.providers-core.js";
import {
formatTrimmedAllowFromEntries,
getChatChannelMeta,
IMessageConfigSchema,
resolveIMessageConfigAllowFrom,
resolveIMessageConfigDefaultTo,
} from "../../../src/plugin-sdk/channel-config-helpers.js";
import { DEFAULT_ACCOUNT_ID } from "../../../src/routing/session-key.js";
setAccountEnabledInConfigSection,
type ChannelPlugin,
} from "openclaw/plugin-sdk/imessage";
import {
listIMessageAccountIds,
resolveDefaultIMessageAccountId,

View File

@@ -1,5 +1,5 @@
import { findCatalogTemplate } from "../../src/plugins/provider-catalog.js";
import { cloneFirstTemplateModel } from "../../src/plugins/provider-model-helpers.js";
import { findCatalogTemplate } from "openclaw/plugin-sdk/provider-catalog";
import { cloneFirstTemplateModel } from "openclaw/plugin-sdk/provider-models";
export const OPENAI_API_BASE_URL = "https://api.openai.com/v1";

View File

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

View File

@@ -1,6 +1,8 @@
import {
applyAccountNameToChannelSection,
DEFAULT_ACCOUNT_ID,
formatCliCommand,
formatDocsLink,
migrateBaseNameToDefaultAccount,
normalizeAccountId,
normalizeE164,
@@ -17,8 +19,6 @@ import type {
ChannelSetupWizard,
ChannelSetupWizardTextInput,
} from "openclaw/plugin-sdk/setup";
import { formatCliCommand } from "../../../src/cli/command-format.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import {
listSignalAccountIds,
resolveDefaultSignalAccountId,

View File

@@ -1,7 +1,9 @@
import { setSetupChannelEnabled } from "openclaw/plugin-sdk/setup";
import type { ChannelSetupWizard } from "openclaw/plugin-sdk/setup";
import { detectBinary } from "../../../src/commands/onboard-helpers.js";
import { installSignalCli } from "../../../src/commands/signal-install.js";
import {
detectBinary,
installSignalCli,
setSetupChannelEnabled,
type ChannelSetupWizard,
} from "openclaw/plugin-sdk/setup";
import { listSignalAccountIds, resolveSignalAccount } from "./accounts.js";
import {
createSignalCliPathTextInput,

View File

@@ -4,15 +4,15 @@ import {
collectAllowlistProviderRestrictSendersWarnings,
} from "openclaw/plugin-sdk/channel-policy";
import {
buildChannelConfigSchema,
DEFAULT_ACCOUNT_ID,
deleteAccountFromConfigSection,
getChatChannelMeta,
normalizeE164,
setAccountEnabledInConfigSection,
} from "../../../src/channels/plugins/config-helpers.js";
import { buildChannelConfigSchema } from "../../../src/channels/plugins/config-schema.js";
import type { ChannelPlugin } from "../../../src/channels/plugins/types.plugin.js";
import { getChatChannelMeta } from "../../../src/channels/registry.js";
import { SignalConfigSchema } from "../../../src/config/zod-schema.providers-core.js";
import { DEFAULT_ACCOUNT_ID } from "../../../src/routing/session-key.js";
import { normalizeE164 } from "../../../src/utils.js";
SignalConfigSchema,
type ChannelPlugin,
} from "openclaw/plugin-sdk/signal";
import {
listSignalAccountIds,
resolveDefaultSignalAccountId,

View File

@@ -1,13 +1,13 @@
import {
hasConfiguredSecretInput,
normalizeSecretInputString,
} from "../../../src/config/types.secrets.js";
import type { SlackAccountConfig } from "../../../src/config/types.slack.js";
import {
DEFAULT_ACCOUNT_ID,
normalizeAccountId,
type OpenClawConfig,
} from "../../../src/plugin-sdk-internal/accounts.js";
} from "openclaw/plugin-sdk/account-resolution";
import {
hasConfiguredSecretInput,
normalizeSecretInputString,
} from "openclaw/plugin-sdk/config-runtime";
import type { SlackAccountConfig } from "openclaw/plugin-sdk/slack";
import type { SlackAccountSurfaceFields } from "./account-surface-fields.js";
import {
mergeSlackAccountConfig,

View File

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

View File

@@ -1,6 +1,9 @@
import {
applyAccountNameToChannelSection,
createAllowlistSetupWizardProxy,
createPatchedAccountSetupAdapter,
DEFAULT_ACCOUNT_ID,
formatDocsLink,
hasConfiguredSecretInput,
migrateBaseNameToDefaultAccount,
normalizeAccountId,
@@ -19,9 +22,6 @@ import {
type ChannelSetupWizard,
type ChannelSetupWizardAllowFromEntry,
} from "openclaw/plugin-sdk/setup";
import { createPatchedAccountSetupAdapter } from "../../../src/channels/plugins/setup-helpers.js";
import { createAllowlistSetupWizardProxy } from "../../../src/channels/plugins/setup-wizard-proxy.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import { inspectSlackAccount } from "./account-inspect.js";
import { listSlackAccountIds, resolveSlackAccount, type ResolvedSlackAccount } from "./accounts.js";
import {
@@ -112,9 +112,15 @@ export const slackSetupAdapter: ChannelSetupAdapter = {
},
};
export function createSlackSetupWizardBase(
loadWizard: () => Promise<{ slackSetupWizard: ChannelSetupWizard }>,
) {
export function createSlackSetupWizardBase(handlers: {
promptAllowFrom: NonNullable<ChannelSetupDmPolicy["promptAllowFrom"]>;
resolveAllowFromEntries: NonNullable<
NonNullable<ChannelSetupWizard["allowFrom"]>["resolveEntries"]
>;
resolveGroupAllowlist: NonNullable<
NonNullable<NonNullable<ChannelSetupWizard["groupAccess"]>["resolveAllowlist"]>
>;
}) {
const slackDmPolicy: ChannelSetupDmPolicy = {
label: "Slack",
channel,
@@ -128,13 +134,7 @@ export function createSlackSetupWizardBase(
channel,
dmPolicy: policy,
}),
promptAllowFrom: async ({ cfg, prompter, accountId }) => {
const wizard = (await loadWizard()).slackSetupWizard;
if (!wizard.dmPolicy?.promptAllowFrom) {
return cfg;
}
return await wizard.dmPolicy.promptAllowFrom({ cfg, prompter, accountId });
},
promptAllowFrom: handlers.promptAllowFrom,
};
return {
@@ -285,18 +285,7 @@ export function createSlackSetupWizardBase(
accountId: string;
credentialValues: { botToken?: string };
entries: string[];
}) => {
const wizard = (await loadWizard()).slackSetupWizard;
if (!wizard.allowFrom) {
return entries.map((input) => ({ input, resolved: false, id: null }));
}
return await wizard.allowFrom.resolveEntries({
cfg,
accountId,
credentialValues,
entries,
});
},
}) => await handlers.resolveAllowFromEntries({ cfg, accountId, credentialValues, entries }),
apply: ({
cfg,
accountId,
@@ -353,11 +342,7 @@ export function createSlackSetupWizardBase(
prompter: { note: (message: string, title?: string) => Promise<void> };
}) => {
try {
const wizard = (await loadWizard()).slackSetupWizard;
if (!wizard.groupAccess?.resolveAllowlist) {
return entries;
}
return await wizard.groupAccess.resolveAllowlist({
return await handlers.resolveGroupAllowlist({
cfg,
accountId,
credentialValues,

View File

@@ -1,5 +1,6 @@
import {
DEFAULT_ACCOUNT_ID,
formatDocsLink,
hasConfiguredSecretInput,
noteChannelLookupFailure,
noteChannelLookupSummary,
@@ -19,7 +20,6 @@ import type {
ChannelSetupWizard,
ChannelSetupWizardAllowFromEntry,
} from "openclaw/plugin-sdk/setup";
import { formatDocsLink } from "../../../src/terminal/links.js";
import { inspectSlackAccount } from "./account-inspect.js";
import {
listSlackAccountIds,

View File

@@ -3,14 +3,18 @@ import {
createScopedAccountConfigAccessors,
createScopedChannelConfigBase,
} from "openclaw/plugin-sdk/channel-config-helpers";
import { buildChannelConfigSchema } from "../../../src/channels/plugins/config-schema.js";
import { patchChannelConfigForAccount } from "../../../src/channels/plugins/setup-wizard-helpers.js";
import type { ChannelPlugin } from "../../../src/channels/plugins/types.plugin.js";
import { getChatChannelMeta } from "../../../src/channels/registry.js";
import type { OpenClawConfig } from "../../../src/config/config.js";
import { hasConfiguredSecretInput } from "../../../src/config/types.secrets.js";
import { SlackConfigSchema } from "../../../src/config/zod-schema.providers-core.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import {
formatDocsLink,
hasConfiguredSecretInput,
patchChannelConfigForAccount,
} from "openclaw/plugin-sdk/setup";
import {
buildChannelConfigSchema,
getChatChannelMeta,
SlackConfigSchema,
type ChannelPlugin,
type OpenClawConfig,
} from "openclaw/plugin-sdk/slack";
import { inspectSlackAccount } from "./account-inspect.js";
import {
listSlackAccountIds,

View File

@@ -1,33 +1,27 @@
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
import type { OpenClawConfig, TelegramAccountConfig } from "openclaw/plugin-sdk/telegram";
import { vi } from "vitest";
import type { OpenClawConfig } from "../../../src/config/config.js";
import type { TelegramAccountConfig } from "../../../src/config/types.js";
import type { RuntimeEnv } from "../../../src/runtime.js";
type RegisterTelegramNativeCommandsParams = Parameters<
typeof import("./bot-native-commands.js").registerTelegramNativeCommands
>[0];
export type NativeCommandTestParams = {
bot: {
api: {
setMyCommands: ReturnType<typeof vi.fn>;
sendMessage: ReturnType<typeof vi.fn>;
};
command: ReturnType<typeof vi.fn>;
};
bot: RegisterTelegramNativeCommandsParams["bot"];
cfg: OpenClawConfig;
runtime: RuntimeEnv;
accountId: string;
telegramCfg: TelegramAccountConfig;
allowFrom: string[];
groupAllowFrom: string[];
replyToMode: string;
replyToMode: RegisterTelegramNativeCommandsParams["replyToMode"];
textLimit: number;
useAccessGroups: boolean;
nativeEnabled: boolean;
nativeSkillsEnabled: boolean;
nativeDisabledExplicit: boolean;
resolveGroupPolicy: () => { allowlistEnabled: boolean; allowed: boolean };
resolveTelegramGroupConfig: () => {
groupConfig: undefined;
topicConfig: undefined;
};
resolveTelegramGroupConfig: RegisterTelegramNativeCommandsParams["resolveTelegramGroupConfig"];
shouldSkipUpdate: () => boolean;
opts: { token: string };
};
@@ -53,9 +47,15 @@ export function createNativeCommandTestParams(
sendMessage: vi.fn().mockResolvedValue(undefined),
},
command: vi.fn(),
} as NativeCommandTestParams["bot"]),
} as unknown as NativeCommandTestParams["bot"]),
cfg: params.cfg ?? ({} as OpenClawConfig),
runtime: params.runtime ?? ({ log } as RuntimeEnv),
runtime:
params.runtime ??
({
log,
error: vi.fn(),
exit: vi.fn(),
} as unknown as RuntimeEnv),
accountId: params.accountId ?? "default",
telegramCfg: params.telegramCfg ?? ({} as TelegramAccountConfig),
allowFrom: params.allowFrom ?? [],

View File

@@ -1,6 +1,6 @@
import type { RuntimeEnv } from "openclaw/plugin-sdk";
import type { OpenClawConfig } from "openclaw/plugin-sdk/telegram";
import { expect, vi } from "vitest";
import type { OpenClawConfig } from "../../../src/config/config.js";
import type { RuntimeEnv } from "../../../src/runtime.js";
import {
createNativeCommandTestParams as createBaseNativeCommandTestParams,
createTelegramPrivateCommandContext,
@@ -12,6 +12,13 @@ type RegisteredCommand = {
description: string;
};
type CreateCommandBotResult = {
bot: RegisterTelegramNativeCommandsParams["bot"];
commandHandlers: Map<string, (ctx: unknown) => Promise<void>>;
sendMessage: ReturnType<typeof vi.fn>;
setMyCommands: ReturnType<typeof vi.fn>;
};
const skillCommandMocks = vi.hoisted(() => ({
listSkillCommandsForAgents: vi.fn(() => []),
}));
@@ -51,7 +58,7 @@ export function resetNativeCommandMenuMocks() {
deliverReplies.mockResolvedValue({ delivered: true });
}
export function createCommandBot() {
export function createCommandBot(): CreateCommandBotResult {
const commandHandlers = new Map<string, (ctx: unknown) => Promise<void>>();
const sendMessage = vi.fn().mockResolvedValue(undefined);
const setMyCommands = vi.fn().mockResolvedValue(undefined);

View File

@@ -1,6 +1,8 @@
import {
applyAccountNameToChannelSection,
DEFAULT_ACCOUNT_ID,
formatCliCommand,
formatDocsLink,
migrateBaseNameToDefaultAccount,
normalizeAccountId,
patchChannelConfigForAccount,
@@ -10,8 +12,6 @@ import {
type WizardPrompter,
} from "openclaw/plugin-sdk/setup";
import type { ChannelSetupAdapter, ChannelSetupDmPolicy } from "openclaw/plugin-sdk/setup";
import { formatCliCommand } from "../../../src/cli/command-format.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import { resolveDefaultTelegramAccountId, resolveTelegramAccount } from "./accounts.js";
import { fetchTelegramChatId } from "./api-fetch.js";

View File

@@ -8,7 +8,6 @@ import {
type ChannelSetupInput,
type ChannelSetupWizard,
type OpenClawConfig,
type WizardPrompter,
} from "openclaw/plugin-sdk/setup";
import { buildTlonAccountFields } from "./account-fields.js";
import { normalizeShip } from "./targets.js";
@@ -38,12 +37,7 @@ type TlonSetupWizardBaseParams = {
cfg: OpenClawConfig;
configured: boolean;
}) => string[] | Promise<string[]>;
finalize: (params: {
cfg: OpenClawConfig;
accountId: string;
prompter: WizardPrompter;
options?: Record<string, unknown>;
}) => Promise<{ cfg: OpenClawConfig }>;
finalize: NonNullable<ChannelSetupWizard["finalize"]>;
};
export function createTlonSetupWizardBase(params: TlonSetupWizardBaseParams): ChannelSetupWizard {

View File

@@ -166,13 +166,11 @@ export const whatsappPlugin: ChannelPlugin<ResolvedWhatsAppAccount> = {
},
auth: {
login: async ({ cfg, accountId, runtime, verbose }) => {
const resolvedAccountId = accountId?.trim() || whatsappPlugin.config.defaultAccountId(cfg);
await (await loadWhatsAppChannelRuntime()).loginWeb(
Boolean(verbose),
undefined,
runtime,
resolvedAccountId,
);
const resolvedAccountId =
accountId?.trim() || whatsappPlugin.config.defaultAccountId?.(cfg) || DEFAULT_ACCOUNT_ID;
await (
await loadWhatsAppChannelRuntime()
).loginWeb(Boolean(verbose), undefined, runtime, resolvedAccountId);
},
},
heartbeat: {
@@ -181,9 +179,9 @@ export const whatsappPlugin: ChannelPlugin<ResolvedWhatsAppAccount> = {
return { ok: false, reason: "whatsapp-disabled" };
}
const account = resolveWhatsAppAccount({ cfg, accountId });
const authExists = await (deps?.webAuthExists ?? (await loadWhatsAppChannelRuntime()).webAuthExists)(
account.authDir,
);
const authExists = await (
deps?.webAuthExists ?? (await loadWhatsAppChannelRuntime()).webAuthExists
)(account.authDir);
if (!authExists) {
return { ok: false, reason: "whatsapp-not-linked" };
}
@@ -219,9 +217,7 @@ export const whatsappPlugin: ChannelPlugin<ResolvedWhatsAppAccount> = {
? await (await loadWhatsAppChannelRuntime()).webAuthExists(authDir)
: false;
const authAgeMs =
linked && authDir
? (await loadWhatsAppChannelRuntime()).getWebAuthAgeMs(authDir)
: null;
linked && authDir ? (await loadWhatsAppChannelRuntime()).getWebAuthAgeMs(authDir) : null;
const self =
linked && authDir
? (await loadWhatsAppChannelRuntime()).readWebSelfId(authDir)
@@ -288,7 +284,9 @@ export const whatsappPlugin: ChannelPlugin<ResolvedWhatsAppAccount> = {
);
},
loginWithQrStart: async ({ accountId, force, timeoutMs, verbose }) =>
await (await loadWhatsAppChannelRuntime()).startWebLoginWithQr({
await (
await loadWhatsAppChannelRuntime()
).startWebLoginWithQr({
accountId,
force,
timeoutMs,
@@ -297,7 +295,9 @@ export const whatsappPlugin: ChannelPlugin<ResolvedWhatsAppAccount> = {
loginWithQrWait: async ({ accountId, timeoutMs }) =>
await (await loadWhatsAppChannelRuntime()).waitForWebLogin({ accountId, timeoutMs }),
logoutAccount: async ({ account, runtime }) => {
const cleared = await (await loadWhatsAppChannelRuntime()).logoutWeb({
const cleared = await (
await loadWhatsAppChannelRuntime()
).logoutWeb({
authDir: account.authDir,
isLegacyAuthDir: account.isLegacyAuthDir,
runtime,

View File

@@ -1,18 +1,18 @@
import path from "node:path";
import {
DEFAULT_ACCOUNT_ID,
formatCliCommand,
formatDocsLink,
normalizeAccountId,
normalizeAllowFromEntries,
normalizeE164,
pathExists,
splitSetupEntries,
setSetupChannelEnabled,
type DmPolicy,
type OpenClawConfig,
} from "openclaw/plugin-sdk/setup";
import type { ChannelSetupWizard } from "openclaw/plugin-sdk/setup";
import { formatCliCommand } from "../../../src/cli/command-format.js";
import type { DmPolicy } from "../../../src/config/types.js";
import { formatDocsLink } from "../../../src/terminal/links.js";
import { listWhatsAppAccountIds, resolveWhatsAppAuthDir } from "./accounts.js";
import { loginWeb } from "./login.js";
import { whatsappSetupAdapter } from "./setup-core.js";

View File

@@ -173,7 +173,7 @@ bundledChannelRuntimeSetters.setLineRuntime({
setMatrixRuntime({
state: {
resolveStateDir: (_env, homeDir) => (homeDir ?? (() => "/tmp"))(),
resolveStateDir: (_env: unknown, homeDir?: () => string) => (homeDir ?? (() => "/tmp"))(),
},
} as never);

View File

@@ -16,6 +16,7 @@ export type { ProviderPlugin } from "../plugins/types.js";
export { DEFAULT_CONTEXT_TOKENS } from "../agents/defaults.js";
export { normalizeModelCompat } from "../agents/model-compat.js";
export { normalizeProviderId } from "../agents/provider-id.js";
export { cloneFirstTemplateModel } from "../plugins/provider-model-helpers.js";
export {
applyGoogleGeminiModelDefault,

View File

@@ -7,8 +7,11 @@ export type { WizardPrompter } from "../wizard/prompts.js";
export type { ChannelSetupAdapter } from "../channels/plugins/types.adapters.js";
export type { ChannelSetupInput } from "../channels/plugins/types.core.js";
export type { ChannelSetupDmPolicy } from "../channels/plugins/setup-wizard-types.js";
export type { ChannelSetupWizardAllowFromEntry } from "../channels/plugins/setup-wizard.js";
export type { ChannelSetupWizard } from "../channels/plugins/setup-wizard.js";
export type {
ChannelSetupWizard,
ChannelSetupWizardAllowFromEntry,
ChannelSetupWizardTextInput,
} from "../channels/plugins/setup-wizard.js";
export { DEFAULT_ACCOUNT_ID, normalizeAccountId } from "../routing/session-key.js";
export { formatCliCommand } from "../cli/command-format.js";
@@ -52,5 +55,6 @@ export {
setTopLevelChannelGroupPolicy,
splitSetupEntries,
} from "../channels/plugins/setup-wizard-helpers.js";
export { createAllowlistSetupWizardProxy } from "../channels/plugins/setup-wizard-proxy.js";
export { formatResolvedUnresolvedNote } from "./resolution-notes.js";

View File

@@ -1,4 +1,7 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { clearRuntimeAuthProfileStoreSnapshots } from "../../agents/auth-profiles/store.js";
import type { AuthChoice } from "../../commands/onboard-types.js";
import { applyAuthChoiceLoadedPluginProvider } from "../../plugins/provider-auth-choice.js";
import {
createAuthTestLifecycle,
createExitThrowingRuntime,
@@ -7,8 +10,6 @@ import {
requireOpenClawAgentDir,
setupAuthTestEnv,
} from "../../commands/test-wizard-helpers.js";
import { clearRuntimeAuthProfileStoreSnapshots } from "../../agents/auth-profiles/store.js";
import { applyAuthChoiceLoadedPluginProvider } from "../../plugins/provider-auth-choice.js";
import { buildProviderPluginMethodChoice } from "../provider-wizard.js";
import { requireProviderContractProvider, uniqueProviderContractProviders } from "./registry.js";
import { registerProviders, requireProvider } from "./testkit.js";