UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 4.21 kB
import{a as resolveApprovalApprovers}from"./approval-auth-helpers-Bk50jUzG.mjs";import{t as matchesApprovalRequestFilters}from"./approval-request-filters-Dj8ITkL-.mjs";import{i as isChannelExecApprovalTargetRecipient,n as createChannelExecApprovalProfileAsync,r as isChannelExecApprovalClientEnabledFromConfig}from"./approval-client-helpers-BDe9Rzfs.mjs";import"./approval-client-runtime-8i3vc795.mjs";import{o as doesApprovalRequestSelectChannelAccountAsync}from"./approval-request-account-binding-DFLDpifZ.mjs";import"./approval-native-runtime-JvOQgEkA.mjs";import{i as resolveTelegramAccount,r as resolveDefaultTelegramAccountId}from"./accounts-CHjEWHkL.mjs";import{c as normalizeTelegramChatId,f as resolveTelegramTargetChatType}from"./topic-conversation-C3o7-j7e.mjs"; //!extensions/telegram/src/exec-approvals.ts function normalizeTelegramDirectApproverId(e){const t=normalizeTelegramChatId(String(e));return t&&!t.startsWith(`-`)?t:void 0}function resolveTelegramExecApprovalConfig(e){const t=resolveTelegramAccount(e);const n=t.config.execApprovals;const r=t.enabled&&t.tokenSource!==`none`?n?.enabled??`auto`:false;return{...n,enabled:r}}function getTelegramExecApprovalApprovers(e){return resolveApprovalApprovers({explicit:resolveTelegramExecApprovalConfig(e)?.approvers,allowFrom:Array.isArray(e.cfg.commands?.ownerAllowFrom)?e.cfg.commands.ownerAllowFrom:[],normalizeApprover:normalizeTelegramDirectApproverId})}function isTelegramExecApprovalTargetRecipient(e){return isChannelExecApprovalTargetRecipient({...e,channel:`telegram`,matchTarget:({target:e,normalizedSenderId:t})=>{const n=e.to?normalizeTelegramDirectApproverId(e.to):void 0;return n!==void 0&&n===t}})}function isTelegramExecApprovalAccountEligible(e){const t=resolveTelegramAccount(e);if(!t.enabled||t.tokenSource===`none`)return false;const n=resolveTelegramExecApprovalConfig(e);return isChannelExecApprovalClientEnabledFromConfig({enabled:n?.enabled,approverCount:getTelegramExecApprovalApprovers(e).length})&&matchesApprovalRequestFilters({request:e.request.request,agentFilter:n?.agentFilter,sessionFilter:n?.sessionFilter,fallbackAgentIdFromSessionKey:true})}async function matchesTelegramRequestAccount(e){const t=e.accountId??resolveDefaultTelegramAccountId(e.cfg);return doesApprovalRequestSelectChannelAccountAsync({...e,channel:`telegram`,defaultAccountId:resolveDefaultTelegramAccountId(e.cfg),eligibleAccountIds:isTelegramExecApprovalAccountEligible({...e,accountId:t})?[t]:[]})}const telegramExecApprovalProfile=createChannelExecApprovalProfileAsync({resolveConfig:resolveTelegramExecApprovalConfig,resolveApprovers:getTelegramExecApprovalApprovers,isTargetRecipient:isTelegramExecApprovalTargetRecipient,matchesRequestAccount:matchesTelegramRequestAccount,fallbackAgentIdFromSessionKey:true,requireClientEnabledForLocalPromptSuppression:false});const isTelegramExecApprovalClientEnabled=telegramExecApprovalProfile.isClientEnabled;const isTelegramExecApprovalApprover=telegramExecApprovalProfile.isApprover;const isTelegramExecApprovalAuthorizedSender=telegramExecApprovalProfile.isAuthorizedSender;const resolveTelegramExecApprovalTarget=telegramExecApprovalProfile.resolveTarget;const shouldHandleTelegramExecApprovalRequest=telegramExecApprovalProfile.shouldHandleRequest;function shouldInjectTelegramExecApprovalButtons(e){if(!isTelegramExecApprovalClientEnabled(e))return false;const t=resolveTelegramExecApprovalTarget(e);const n=resolveTelegramTargetChatType(e.to);return t===`both`||n===`direct`&&t===`dm`||n===`group`&&t===`channel`}const shouldSuppressLocalTelegramExecApprovalPrompt=telegramExecApprovalProfile.shouldSuppressLocalPrompt;const isTelegramExecApprovalHandlerConfigured=telegramExecApprovalProfile.isClientEnabled;export{isTelegramExecApprovalHandlerConfigured as a,resolveTelegramExecApprovalTarget as c,shouldSuppressLocalTelegramExecApprovalPrompt as d,isTelegramExecApprovalClientEnabled as i,shouldHandleTelegramExecApprovalRequest as l,isTelegramExecApprovalApprover as n,isTelegramExecApprovalTargetRecipient as o,isTelegramExecApprovalAuthorizedSender as r,resolveTelegramExecApprovalConfig as s,getTelegramExecApprovalApprovers as t,shouldInjectTelegramExecApprovalButtons as u};