openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
7 lines • 5.9 kB
JavaScript
import{b as asNullableRecord,h as normalizeLowercaseStringOrEmpty}from"./global-singleton-CTnqrmaI.js";import{C as hasLegacyAccountStreamingAliases,T as normalizeChannelConfigEntries,c as stripRetiredChannelKeys,n as defineKeyMoveMigration,s as defineChannelAliasMigration}from"./runtime-doctor-migrations-D8alsOFs.js";import{t as asBoolean}from"./boolean-DATM0QjB.js";import"./string-coerce-runtime-DtNToPzY.js";
//!src/channels/streaming-config-readers.ts
function getChannelStreamingConfigObject(e){const t=asNullableRecord(e?.streaming);return t?t:void 0}function resolveChannelStreamingNativeTransport(e){return asBoolean(getChannelStreamingConfigObject(e)?.nativeTransport)}
//!extensions/slack/src/streaming-compat.ts
function resolveSlackStreamingMode(e={}){const t=normalizeLowercaseStringOrEmpty(getChannelStreamingConfigObject(e)?.mode??e.streaming);if(t===`off`||t===`partial`||t===`block`||t===`progress`)return t;switch(normalizeLowercaseStringOrEmpty(e.streamMode)){case`append`:return`block`;case`status_final`:return`progress`;case`replace`:return`partial`;default:return typeof e.streaming===`boolean`?e.streaming?`partial`:`off`:`progress`}}function resolveSlackNativeStreaming(e={}){return resolveChannelStreamingNativeTransport(e)??(typeof e.nativeStreaming===`boolean`?e.nativeStreaming:typeof e.streaming===`boolean`?e.streaming:true)}
//!extensions/slack/src/doctor-contract.ts
const streamingAliasMigration=defineChannelAliasMigration({channelId:`slack`,streaming:{defaultMode:`partial`,resolveMode:resolveSlackStreamingMode,resolveNativeTransport:resolveSlackNativeStreaming},dm:{root:true,accounts:true}});const dmReplyModeMigration=defineKeyMoveMigration({from:[`dm`,`replyToMode`],to:[`replyToModeByChatType`,`direct`]});const threadMentionPolicyMigration=defineKeyMoveMigration({from:[`thread`,`requireExplicitMention`],to:[`implicitMentions`,`threadParticipation`],map:e=>typeof e===`boolean`?{value:!e}:null,pruneEmptySource:true,movedMessage:({sourcePath:e,targetPath:t,mappedValue:n})=>`Moved ${e} → ${t} (${String(n)}).`});function hasInteractiveRepliesCapability(e){const t=asNullableRecord(e)?.capabilities;if(Array.isArray(t))return t.some(e=>typeof e===`string`&&e.trim().toLowerCase()===`interactivereplies`);const n=asNullableRecord(t);return Boolean(n&&(Object.keys(n).length===0||Object.hasOwn(n,`interactiveReplies`)))}function hasEnterpriseOrgInstall(e){return Object.hasOwn(asNullableRecord(e)??{},`enterpriseOrgInstall`)}const legacyConfigRules=[...streamingAliasMigration.legacyConfigRules,{path:[`channels`,`slack`,`enterpriseOrgInstall`],message:`channels.slack.enterpriseOrgInstall is retired; Slack now detects org-wide installations automatically. Run "openclaw doctor --fix".`},{path:[`channels`,`slack`,`accounts`],message:`channels.slack.accounts.<id>.enterpriseOrgInstall is retired; Slack now detects org-wide installations automatically. Run "openclaw doctor --fix".`,match:e=>hasLegacyAccountStreamingAliases(e,hasEnterpriseOrgInstall)},{path:[`channels`,`slack`],message:`channels.slack.capabilities.interactiveReplies is retired; use typed presentation actions instead. Run "openclaw doctor --fix".`,match:hasInteractiveRepliesCapability},{path:[`channels`,`slack`,`accounts`],message:`channels.slack.accounts.<id>.capabilities.interactiveReplies is retired; use typed presentation actions instead. Run "openclaw doctor --fix".`,match:e=>hasLegacyAccountStreamingAliases(e,hasInteractiveRepliesCapability)},{path:[`channels`,`slack`],message:`channels.slack.dm.replyToMode moved to replyToModeByChatType.direct. Run "openclaw doctor --fix".`,match:dmReplyModeMigration.hasLegacy},{path:[`channels`,`slack`,`accounts`],message:`channels.slack.accounts.<id>.dm.replyToMode moved to replyToModeByChatType.direct. Run "openclaw doctor --fix".`,match:e=>hasLegacyAccountStreamingAliases(e,dmReplyModeMigration.hasLegacy)},{path:[`channels`,`slack`],message:`channels.slack.thread.requireExplicitMention is legacy; use channels.slack.implicitMentions.threadParticipation instead. Run "openclaw doctor --fix".`,match:threadMentionPolicyMigration.hasLegacy},{path:[`channels`,`slack`,`accounts`],message:`channels.slack.accounts.<id>.thread.requireExplicitMention is legacy; use channels.slack.accounts.<id>.implicitMentions.threadParticipation instead. Run "openclaw doctor --fix".`,match:e=>hasLegacyAccountStreamingAliases(e,threadMentionPolicyMigration.hasLegacy)}];function normalizeCompatibilityConfig({cfg:e}){const t=[];const n=stripRetiredChannelKeys({cfg:e,channelId:`slack`,keys:/* @__PURE__ */ new Set([`enterpriseOrgInstall`]),scope:`root-and-accounts`,onRemove:({key:e,pathPrefix:n})=>t.push(`Removed retired ${n}.${e}; Slack detects org-wide installations automatically.`)});const r=streamingAliasMigration.normalizeChannelConfig({cfg:n.config,changes:t});return normalizeChannelConfigEntries({cfg:r.config,channelId:`slack`,changes:t,normalizeEntry:e=>{let{entry:t}=e;let n=false;const r=t.capabilities;let i;let a=false;if(Array.isArray(r)){const e=r.filter(e=>!(typeof e===`string`&&e.trim().toLowerCase()===`interactivereplies`));if(e.length!==r.length)i=e}else{const e=asNullableRecord(r);if(e&&(Object.keys(e).length===0||Object.hasOwn(e,`interactiveReplies`))){a=Object.keys(e).length===0;const{interactiveReplies:t,...n}=e;i=n}}if(i!==void 0){t={...t};if(Array.isArray(i)?i.length===0:Object.keys(i).length===0)delete t.capabilities;else t.capabilities=i;e.changes.push(a?`Removed retired empty ${e.pathPrefix}.capabilities object; use typed presentation actions instead.`:`Removed retired ${e.pathPrefix}.capabilities.interactiveReplies; use typed presentation actions instead.`);n=true}const o=dmReplyModeMigration.normalize({...e,entry:t});const s=threadMentionPolicyMigration.normalize({...e,entry:o.entry});return{entry:s.entry,changed:n||o.changed||s.changed}}})}export{legacyConfigRules,normalizeCompatibilityConfig};