UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 3.33 kB
import{c as normalizeOptionalLowercaseString}from"./string-coerce-CpTFcSwY.mjs";import{f as normalizeStringEntries}from"./string-normalization-D_oBUpO3.mjs";import{n as listBundledChannelCatalogEntries}from"./bundled-channel-catalog-read-CX1nvZIw.mjs";import{t as normalizeAnyChannelId}from"./registry-normalize-BP0gv89S.mjs";import"./registry-yecJKTDP.mjs";import{r as listChannelPlugins,t as getChannelPlugin}from"./registry-CpNh6QcT.mjs";import{r as setChannelAgentToolMeta}from"./channel-tool-metadata-u9xIQtTP.mjs";import{n as resolveChannelApprovalCapability}from"./plugins-DxOycUNJ.mjs";import{c as resolveMessageActionDiscoveryChannelId,o as resolveCurrentChannelMessageToolDiscoveryAdapter,t as createMessageActionDiscoveryContext}from"./message-action-discovery-rhv-hZtK.mjs"; //!src/channels/plugins/native-approval-prompt.ts const NATIVE_APPROVAL_PROMPT_RUNTIME_CAPABILITY=`nativeApprovals`;const NATIVE_APPROVAL_PROMPT_RUNTIME_CAPABILITY_NORMALIZED=`nativeapprovals`;function channelPluginHasNativeApprovalPromptUi(e){const t=resolveChannelApprovalCapability(e);return Boolean(t?.native||t?.nativeRuntime)}function isKnownNativeApprovalPromptChannel(e){const t=normalizeOptionalLowercaseString(e);return Boolean(t&&listBundledChannelCatalogEntries().some(e=>e.id===t&&e.channel.approvalFlags?.includes(`native`)))}function hasNativeApprovalPromptRuntimeCapability(e){return Boolean(e?.some(e=>normalizeOptionalLowercaseString(e)===NATIVE_APPROVAL_PROMPT_RUNTIME_CAPABILITY_NORMALIZED))} //!src/agents/channel-tools.ts function*listChannelSupportedActionsSteps(e){const t=resolveMessageActionDiscoveryChannelId(e.channel);if(!t)return[];const n=resolveCurrentChannelMessageToolDiscoveryAdapter(t,e.preparedMessageToolCatalog);if(!n?.actions)return[];return(yield{pluginId:n.pluginId,actions:n.actions,context:createMessageActionDiscoveryContext(e),includeActions:true}).actions}function listChannelAgentTools(e){const t=[];for(const n of listChannelPlugins()){const r=n.agentTools;if(!r)continue;const i=typeof r===`function`?r(e):r;if(Array.isArray(i)){for(const e of i)setChannelAgentToolMeta(e,{channelId:n.id});t.push(...i)}}return t}function resolveChannelMessageToolHints(e){const t=normalizeAnyChannelId(e.channel);if(!t)return[];const n=getChannelPlugin(t)?.agentPrompt?.messageToolHints;if(!n)return[];const r=e.cfg??{};return normalizeStringEntries(n({cfg:r,accountId:e.accountId}))}function resolveChannelPromptCapabilities(e){const t=normalizeAnyChannelId(e.channel);if(!t)return[];const n=getChannelPlugin(t);const r=e.cfg??{};const i=normalizeStringEntries(n?.agentPrompt?.messageToolCapabilities?.({cfg:r,accountId:e.accountId})??[]);if(channelPluginHasNativeApprovalPromptUi(n))i.push(NATIVE_APPROVAL_PROMPT_RUNTIME_CAPABILITY);return i}function resolveChannelReactionGuidance(e){const t=normalizeAnyChannelId(e.channel);if(!t)return;const n=getChannelPlugin(t)?.agentPrompt?.reactionGuidance;if(!n)return;const r=n({cfg:e.cfg??{},accountId:e.accountId});if(!r?.level)return;return{level:r.level,channel:r.channelLabel?.trim()||t}}export{resolveChannelReactionGuidance as a,resolveChannelPromptCapabilities as i,listChannelSupportedActionsSteps as n,hasNativeApprovalPromptRuntimeCapability as o,resolveChannelMessageToolHints as r,isKnownNativeApprovalPromptChannel as s,listChannelAgentTools as t};