UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.8 kB
import{a as extractErrorCode}from"./error-coercion-DlKnt6w-.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{r as isPluginTrustRefusalError}from"./plugin-trust-5mL8edIh.mjs";import{n as isChannelIngressUnavailableError}from"./ingress-unavailable-CrpSg7MI.mjs"; //!src/gateway/channel-status-patches.ts function createConnectedChannelStatusPatch(e=Date.now()){return{connected:true,lastConnectedAt:e,lastEventAt:e}}function createTransportActivityStatusPatch(e=Date.now()){return{lastTransportActivityAt:e}}function channelReadyPatch(e={}){return{running:true,connected:true,lifecycle:`ready`,lastConnectedAt:Date.now(),lastError:null,terminalDisconnect:void 0,...e}}function channelBlockedPatch(e,t={}){return{lifecycle:`blocked`,terminalDisconnect:true,lastError:e,...t}}function channelStartFailurePatch(e){const t=formatErrorMessage(e);const n=isPluginTrustRefusalError(e);return{lastError:t,...extractErrorCode(e)===`AGENT_SELECTION_REQUIRED`||n?channelBlockedPatch(t,n?{healthState:`plugin-trust-refused`}:{}):{},...isChannelIngressUnavailableError(e)?{ingressUnavailable:true}:{}}}function channelStoppedPatch(e={}){return{running:false,connected:false,lifecycle:`stopped`,...e}}function sanitizeAbortedTaskStatusPatch(e,t){const n={...e};delete n.running;delete n.restartPending;delete n.reconnectAttempts;delete n.lastStartAt;delete n.lastStopAt;delete n.lifecycle;if(n.connected===true){delete n.connected;delete n.lastConnectedAt;delete n.lastEventAt;delete n.lastTransportActivityAt}if(n.lastError===null&&t.lastError)delete n.lastError;return n}export{createConnectedChannelStatusPatch as a,channelStoppedPatch as i,channelReadyPatch as n,createTransportActivityStatusPatch as o,channelStartFailurePatch as r,sanitizeAbortedTaskStatusPatch as s,channelBlockedPatch as t};