mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-16 19:47:55 +00:00
* Reply: add Slack interactive directive parser * Reply: wire Slack directives into normalization * Reply: cover Slack directive parsing * Reply: test Slack directive normalization * Slack: hint interactive reply directives * Config: add Slack interactive reply capability type * Config: validate Slack interactive reply capability * Reply: gate Slack directives behind capability * Slack: gate interactive reply hints by capability * Tests: cover Slack interactive reply capability gating * Changelog: note opt-in Slack interactive replies * Slack: fix interactive reply review findings * Slack: harden interactive reply routing and limits * Slack: harden interactive reply trust and validation
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import type { OpenClawConfig } from "../config/config.js";
|
|
import { listSlackAccountIds, resolveSlackAccount } from "./accounts.js";
|
|
|
|
function resolveInteractiveRepliesFromCapabilities(capabilities: unknown): boolean {
|
|
if (!capabilities) {
|
|
return false;
|
|
}
|
|
if (Array.isArray(capabilities)) {
|
|
return capabilities.some(
|
|
(entry) => String(entry).trim().toLowerCase() === "interactivereplies",
|
|
);
|
|
}
|
|
if (typeof capabilities === "object") {
|
|
return (capabilities as { interactiveReplies?: unknown }).interactiveReplies === true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
export function isSlackInteractiveRepliesEnabled(params: {
|
|
cfg: OpenClawConfig;
|
|
accountId?: string | null;
|
|
}): boolean {
|
|
if (params.accountId) {
|
|
const account = resolveSlackAccount({ cfg: params.cfg, accountId: params.accountId });
|
|
return resolveInteractiveRepliesFromCapabilities(account.config.capabilities);
|
|
}
|
|
const accountIds = listSlackAccountIds(params.cfg);
|
|
if (accountIds.length === 0) {
|
|
return resolveInteractiveRepliesFromCapabilities(params.cfg.channels?.slack?.capabilities);
|
|
}
|
|
if (accountIds.length > 1) {
|
|
return false;
|
|
}
|
|
const account = resolveSlackAccount({ cfg: params.cfg, accountId: accountIds[0] });
|
|
return resolveInteractiveRepliesFromCapabilities(account.config.capabilities);
|
|
}
|