refactor!: rename chat providers to channels

This commit is contained in:
Peter Steinberger
2026-01-13 06:16:43 +00:00
parent 0cd632ba84
commit 90342a4f3a
393 changed files with 8004 additions and 6737 deletions

View File

@@ -0,0 +1,41 @@
import type { AgentToolResult } from "@mariozechner/pi-agent-core";
import type { ClawdbotConfig } from "../../config/config.js";
import { getChannelPlugin, listChannelPlugins } from "./index.js";
import type {
ChannelMessageActionContext,
ChannelMessageActionName,
} from "./types.js";
export function listChannelMessageActions(
cfg: ClawdbotConfig,
): ChannelMessageActionName[] {
const actions = new Set<ChannelMessageActionName>(["send"]);
for (const plugin of listChannelPlugins()) {
const list = plugin.actions?.listActions?.({ cfg });
if (!list) continue;
for (const action of list) actions.add(action);
}
return Array.from(actions);
}
export function supportsChannelMessageButtons(cfg: ClawdbotConfig): boolean {
for (const plugin of listChannelPlugins()) {
if (plugin.actions?.supportsButtons?.({ cfg })) return true;
}
return false;
}
export async function dispatchChannelMessageAction(
ctx: ChannelMessageActionContext,
): Promise<AgentToolResult<unknown> | null> {
const plugin = getChannelPlugin(ctx.channel);
if (!plugin?.actions?.handleAction) return null;
if (
plugin.actions.supportsAction &&
!plugin.actions.supportsAction({ action: ctx.action })
) {
return null;
}
return await plugin.actions.handleAction(ctx);
}