refactor(channels): move bootstrap channel logic behind extension seams

This commit is contained in:
Peter Steinberger
2026-04-04 04:52:53 +01:00
parent fff7e610df
commit bc457fd1b8
25 changed files with 602 additions and 249 deletions

View File

@@ -1,6 +1,6 @@
import { getBundledChannelContractSurfaceModule } from "../channels/plugins/contract-surfaces.js";
import type { OpenClawConfig } from "../config/config.js";
import { resolveDmGroupAccessWithLists } from "../security/dm-policy-shared.js";
export { buildCommandsPaginationKeyboard } from "../../extensions/telegram/api.js";
export {
createPreCryptoDirectDmAuthorizer,
resolveInboundDirectDmAccessWithRuntime,
@@ -86,6 +86,37 @@ export {
buildHelpMessage,
} from "../auto-reply/status.js";
type TelegramCommandUiContract = {
buildCommandsPaginationKeyboard: (
currentPage: number,
totalPages: number,
agentId?: string,
) => Array<Array<{ text: string; callback_data: string }>>;
};
function loadTelegramCommandUiContract(): TelegramCommandUiContract {
const contract = getBundledChannelContractSurfaceModule<TelegramCommandUiContract>({
pluginId: "telegram",
preferredBasename: "contract-api.ts",
});
if (!contract) {
throw new Error("telegram command ui contract surface is unavailable");
}
return contract;
}
export function buildCommandsPaginationKeyboard(
currentPage: number,
totalPages: number,
agentId?: string,
): Array<Array<{ text: string; callback_data: string }>> {
return loadTelegramCommandUiContract().buildCommandsPaginationKeyboard(
currentPage,
totalPages,
agentId,
);
}
export type ResolveSenderCommandAuthorizationParams = {
cfg: OpenClawConfig;
rawBody: string;