fix(actions): layer per-account gate fallback

This commit is contained in:
Sebastian
2026-02-16 20:59:23 -05:00
parent 616c0bd4c7
commit 2b3ecee7c5
10 changed files with 203 additions and 25 deletions

View File

@@ -1,16 +1,18 @@
import type { TelegramActionConfig } from "../../../config/types.telegram.js";
import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js";
import {
createActionGate,
readNumberParam,
readStringArrayParam,
readStringOrNumberParam,
readStringParam,
} from "../../../agents/tools/common.js";
import { handleTelegramAction } from "../../../agents/tools/telegram-actions.js";
import type { TelegramActionConfig } from "../../../config/types.telegram.js";
import { extractToolSend } from "../../../plugin-sdk/tool-send.js";
import { listEnabledTelegramAccounts } from "../../../telegram/accounts.js";
import {
createTelegramActionGate,
listEnabledTelegramAccounts,
} from "../../../telegram/accounts.js";
import { isTelegramInlineButtonsEnabled } from "../../../telegram/inline-buttons.js";
import type { ChannelMessageActionAdapter, ChannelMessageActionName } from "../types.js";
const providerId = "telegram";
@@ -48,7 +50,9 @@ export const telegramMessageActions: ChannelMessageActionAdapter = {
return [];
}
// Union of all accounts' action gates (any account enabling an action makes it available)
const gates = accounts.map((a) => createActionGate(a.config.actions));
const gates = accounts.map((account) =>
createTelegramActionGate({ cfg, accountId: account.accountId }),
);
const gate = (key: keyof TelegramActionConfig, defaultValue = true) =>
gates.some((g) => g(key, defaultValue));
const actions = new Set<ChannelMessageActionName>(["send"]);