openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.58 kB
JavaScript
import{r as defaultRuntime}from"./runtime-DIcLIHcp.mjs";import{r as terminalText}from"./safe-text-B_QTgn0s.mjs";import{r as theme}from"./theme-DS2CtI9X.mjs";import{t as createChannelIngressQueue}from"./ingress-queue-Bz4FEPVr.mjs";import{n as formatDurationHuman}from"./format-duration-CDAHVcL7.mjs";import{n as throwExpectedCliError}from"./expected-cli-error-oDVmXYil.mjs";import{t as parseLogsPositiveInt}from"./logs-cli.options-B6kx8bea.mjs";
//!src/commands/channels/dead-letters.ts
function resolveScope(e){const t=e.channel?.trim();if(!t)throwExpectedCliError(`--channel is required.`);const n=e.account?.trim()??`default`;if(!n)throwExpectedCliError(`--account must not be blank`);return{channelId:t,accountId:n}}async function channelsDeadLettersListCommand(e){const{channelId:t,accountId:n}=resolveScope(e);const r=createChannelIngressQueue({channelId:t,accountId:n});if(!r.listFailed)throw new Error(`This runtime does not support channel ingress dead-letter inspection.`);const i=await r.listFailed({limit:parseLogsPositiveInt(e.limit,100,`--limit`)});if(e.json){defaultRuntime.writeJson({channelId:t,accountId:n,deadLetters:i});return}defaultRuntime.log(theme.heading(terminalText`Channel ingress dead letters (${t}/${n})`));if(i.length===0){defaultRuntime.log(theme.muted(`No dead-lettered ingress events.`));return}const a=Date.now();for(const e of i){const t=formatDurationHuman(Math.max(0,a-e.failedAt));defaultRuntime.log(terminalText`- ${e.id}: ${e.reason}; attempts=${e.attempts}; failed ${t} ago`)}}async function channelsDeadLettersResubmitCommand(e,t){const{channelId:n,accountId:r}=resolveScope(t);const i=createChannelIngressQueue({channelId:n,accountId:r});if(!i.resubmit)throw new Error(`This runtime does not support channel ingress dead-letter resubmission.`);const a=await i.resubmit(e);if(a.kind===`resubmitted`){if(t.json)defaultRuntime.writeJson({channelId:n,accountId:r,eventId:e,result:a});else defaultRuntime.log(`${theme.success(`Resubmitted`)} ${terminalText`channel ingress event ${e} (${n}/${r}). The running channel retries it within 5 minutes by default (longer if configured).`}`);return}let o;switch(a.kind){case`completed`:o=`Ingress event ${e} is completed and cannot be resubmitted.`;break;case`active`:o=`Ingress event ${e} is already ${a.status}.`;break;case`unrecoverable`:o=`Ingress event ${e} has no retained payload and cannot be resubmitted.`;break;default:o=`Ingress event ${e} was not found for ${n}/${r}.`}throw new Error(t.json?o:terminalText`${o}`)}export{channelsDeadLettersListCommand,channelsDeadLettersResubmitCommand};