openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.44 kB
JavaScript
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import"./session-key-BPgKfU2m.mjs";import{n as normalizeAccountId}from"./account-id-3yqrEsRn.mjs";import{n as normalizeMessageChannel}from"./message-channel-core-D_hPOadj.mjs";import{t as isDeliverableMessageChannel}from"./message-channel-normalize-hDAO6_JQ.mjs";import"./message-channel-514k57tV.mjs";
//!src/cli/message-secret-scope.ts
function resolveScopedChannelCandidate(e){if(typeof e!==`string`)return;const t=normalizeMessageChannel(e);if(!t||!isDeliverableMessageChannel(t))return;return t}function resolveChannelFromTargetValue(e){const t=normalizeOptionalString(e);if(!t)return;const n=t.indexOf(`:`);if(n<=0)return;return resolveScopedChannelCandidate(t.slice(0,n))}function resolveChannelFromTargets(e){if(!Array.isArray(e))return;const t=new Set(e.map(resolveChannelFromTargetValue).filter(e=>e!==void 0));return t.size===1?[...t][0]:void 0}function resolveScopedAccountId(e){const t=normalizeOptionalString(e);if(!t)return;return normalizeAccountId(t)}function resolveMessageSecretScope(e){const t=resolveScopedChannelCandidate(e.channel)??resolveChannelFromTargetValue(e.target)??resolveChannelFromTargets(e.targets)??resolveScopedChannelCandidate(e.fallbackChannel);const n=resolveScopedAccountId(e.accountId)??resolveScopedAccountId(e.fallbackAccountId??void 0);return{...t?{channel:t}:{},...n?{accountId:n}:{}}}export{resolveMessageSecretScope as t};