UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines • 7.34 kB
import"./number-coercion-B3CfI447.mjs";import"./types.secrets-UWdyCdE6.mjs";import"./paths-D_FOvGon.mjs";import{O as parseThreadSessionSuffix,f as resolveThreadSessionKeys,j as normalizeSessionKeyPreservingOpaquePeerIds}from"./session-key-BPgKfU2m.mjs";import"./subsystem-DLCDFvCH.mjs";import"./dedupe-CsfmSvUH.mjs";import{n as getChatChannelMeta,t as findChatChannelMeta}from"./chat-meta-CPf8a-2D.mjs";import"./keyed-async-queue-qBcorzrt.mjs";import"./secure-random-CDFMDkJP.mjs";import"./net-Bu4cO5Pq.mjs";import"./common-DIgvX97L.mjs";import"./resolve-route-DpjPYoyg.mjs";import{l as emptyChannelConfigSchema}from"./config-schema-BELT5_VZ.mjs";import"./typebox-pxCMyoM2.mjs";import"./tailscale-status-XuUK2SG6.mjs";import"./secret-file-DX9QP-Ug.mjs";import"./delegate-BVTRz_Yj.mjs";import{t as buildOutboundBaseSessionKey}from"./base-session-key-DDzuV0h2.mjs";import{t as normalizeOutboundThreadId}from"./thread-id-CvhPHt8h.mjs";import{t as buildAccountScopedDmSecurityPolicy}from"./helpers-1A2j6LGz.mjs";import{r as createTextPairingAdapter}from"./pairing-adapters-B8ppUwxs.mjs";import{r as createTopLevelChannelReplyToModeResolver,t as createScopedAccountReplyToModeResolver}from"./threading-helpers-CtIdPiTH.mjs";import{i as createAttachedChannelResultAdapter}from"./channel-send-result-liYbEKsH.mjs";import{t as createCachedLazyValueGetter}from"./lazy-value-BJJrSp6u.mjs";import"./config-schema-BQYgWf1D.mjs";import"./plugin-entry-DhKiQ4Uu.mjs";import"./config-helpers-D6BTBPzI.mjs";import"./setup-helpers-AzpIWWec.mjs";import"./persistent-bindings.resolve-CnWL2Osg.mjs";import"./chat-target-prefixes-D9B8D83t.mjs"; //!src/plugin-sdk/thread-aware-outbound-session-route.ts function buildChannelOutboundSessionRoute(e){const t=buildOutboundBaseSessionKey({cfg:e.cfg,agentId:e.agentId,channel:e.channel,accountId:e.accountId,peer:e.peer});return{sessionKey:t,baseSessionKey:t,...e.recipientSessionExact!==void 0?{recipientSessionExact:e.recipientSessionExact}:{},peer:e.peer,chatType:e.chatType,from:e.from,to:e.to,...e.threadId!==void 0?{threadId:e.threadId}:{}}}function recoverCurrentThreadSessionId(e){const t=parseThreadSessionSuffix(e.currentSessionKey);if(!t.baseSessionKey||!t.threadId)return;if(normalizeSessionKeyPreservingOpaquePeerIds(t.baseSessionKey)!==normalizeSessionKeyPreservingOpaquePeerIds(e.route.baseSessionKey))return;const n={route:e.route,currentBaseSessionKey:t.baseSessionKey,currentThreadId:t.threadId};if(e.canRecover&&!e.canRecover(n))return;return t.threadId}function buildThreadAwareOutboundSessionRoute(e){const t=recoverCurrentThreadSessionId({route:e.route,currentSessionKey:e.currentSessionKey,canRecover:e.canRecoverCurrentThread});const n={replyToId:resolveThreadAwareOutboundCandidate(e.replyToId),threadId:resolveThreadAwareOutboundCandidate(e.threadId),currentSession:resolveThreadAwareOutboundCandidate(t)};const r=(e.precedence??[`replyToId`,`threadId`,`currentSession`]).map(e=>n[e]).find(Boolean);const i=resolveThreadSessionKeys({baseSessionKey:e.route.baseSessionKey,threadId:r?.sessionThreadId,parentSessionKey:r?e.parentSessionKey:void 0,useSuffix:e.useSuffix,normalizeThreadId:e.normalizeThreadId});return{...e.route,sessionKey:i.sessionKey,...r!==void 0?{threadId:r.routeThreadId}:{}}}function resolveThreadAwareOutboundCandidate(e){const t=normalizeOutboundThreadId(e);if(t===void 0)return;return{routeThreadId:typeof e===`number`?e:t,sessionThreadId:t}} //!src/plugin-sdk/core.ts async function ensureConfiguredAcpBindingReady(e){return(await import(`./persistent-bindings.lifecycle-t_pPvz6a.mjs`)).ensureConfiguredAcpBindingReadyCore(e)}function getChatChannelMetaForSdk(e){return getChatChannelMeta(e)}function defineChannelPluginEntry({id:e,name:t,description:n,plugin:r,configSchema:i,setRuntime:a,registerCliMetadata:o,registerFull:s,registerCapabilities:c}){const l=createCachedLazyValueGetter(i??emptyChannelConfigSchema);return{id:e,name:t,description:n,get configSchema(){return l()},register(e){if(e.registrationMode===`cli-metadata`){o?.(e);return}if(e.registrationMode===`tool-discovery`){s?.(e);c?.(e);return}e.registerChannel({plugin:r});a?.(e.runtime);if(e.registrationMode===`discovery`){o?.(e);c?.(e);return}if(e.registrationMode!==`full`)return;o?.(e);s?.(e);c?.(e)},channelPlugin:r,...a?{setChannelRuntime:a}:{}}}function defineSetupPluginEntry(e){return{plugin:e}}function resolveChatChannelSecurity(e){if(!(`dm`in e))return e;return{resolveDmPolicy:({cfg:t,accountId:n,account:r})=>buildAccountScopedDmSecurityPolicy({cfg:t,channelKey:e.dm.channelKey,accountId:n,fallbackAccountId:e.dm.resolveFallbackAccountId?.(r)??r.accountId,policy:e.dm.resolvePolicy(r),allowFrom:e.dm.resolveAllowFrom(r)??[],defaultPolicy:e.dm.defaultPolicy,allowFromPathSuffix:e.dm.allowFromPathSuffix,policyPathSuffix:e.dm.policyPathSuffix,approveChannelId:e.dm.approveChannelId,approveHint:e.dm.approveHint,normalizeEntry:e.dm.normalizeEntry,classifyEntryAuthentication:e.dm.classifyEntryAuthentication,inheritSharedDefaultsFromDefaultAccount:e.dm.inheritSharedDefaultsFromDefaultAccount}),...e.dmRouting?{dmRouting:e.dmRouting}:{},...e.collectWarnings?{collectWarnings:e.collectWarnings}:{},...e.collectAuditFindings?{collectAuditFindings:e.collectAuditFindings}:{}}}function resolveChatChannelPairing(e){return`text`in e?createTextPairingAdapter(e.text):e}function resolveChatChannelThreading(e){if(!(`topLevelReplyToMode`in e)&&!(`scopedAccountReplyToMode`in e))return e;const t=`topLevelReplyToMode`in e?createTopLevelChannelReplyToModeResolver(e.topLevelReplyToMode):createScopedAccountReplyToModeResolver(e.scopedAccountReplyToMode);return{...e,resolveReplyToMode:t}}function resolveChatChannelOutbound(e){if(!(`attachedResults`in e))return e;return{...e.base,...createAttachedChannelResultAdapter(e.attachedResults)}}function createChatChannelPlugin(e){return{...e.base,capabilities:e.base.capabilities??{chatTypes:[`direct`]},conversationBindings:{supportsCurrentConversationBinding:true,...e.base.conversationBindings},...e.security?{security:resolveChatChannelSecurity(e.security)}:{},...e.pairing?{pairing:resolveChatChannelPairing(e.pairing)}:{},...e.threading?{threading:resolveChatChannelThreading(e.threading)}:{},...e.outbound?{outbound:resolveChatChannelOutbound(e.outbound)}:{}}}function createChannelPluginBase(e){return{id:e.id,meta:{...findChatChannelMeta(e.id),...e.meta,id:e.id},...e.setupWizard?{setupWizard:e.setupWizard}:{},...e.capabilities?{capabilities:e.capabilities}:{},...e.commands?{commands:e.commands}:{},...e.doctor?{doctor:e.doctor}:{},...e.agentPrompt?{agentPrompt:e.agentPrompt}:{},...e.streaming?{streaming:e.streaming}:{},...e.reload?{reload:e.reload}:{},...e.gatewayMethods?{gatewayMethods:e.gatewayMethods}:{},...e.gatewayMethodDescriptors?{gatewayMethodDescriptors:e.gatewayMethodDescriptors}:{},...e.configSchema?{configSchema:e.configSchema}:{},...e.config?{config:e.config}:{},...e.security?{security:e.security}:{},...e.groups?{groups:e.groups}:{},...e.setup?{setup:e.setup}:{},...e.setupContract?{setupContract:e.setupContract}:{}}}export{ensureConfiguredAcpBindingReady as a,buildThreadAwareOutboundSessionRoute as c,defineSetupPluginEntry as i,recoverCurrentThreadSessionId as l,createChatChannelPlugin as n,getChatChannelMetaForSdk as o,defineChannelPluginEntry as r,buildChannelOutboundSessionRoute as s,createChannelPluginBase as t};