UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 1.29 kB
import{o as writeRuntimeJson}from"./runtime-DIcLIHcp.mjs";import{n as sanitizeTerminalText}from"./safe-text-B_QTgn0s.mjs";import{t as formatCliCommand}from"./command-format-D7KhNLP0.mjs";import{t as ClawHubRequestError}from"./clawhub-client-BqChQ9oR.mjs";import{n as fetchClawHubPromotions}from"./clawhub-promotions-Bdm6-CpZ.mjs"; //!src/commands/promos/list.ts async function promosListCommand(e,t){let n;try{n=await fetchClawHubPromotions()}catch(n){if(!(n instanceof ClawHubRequestError)||n.status!==404)throw n;if(e.json)writeRuntimeJson(t,{promotions:[]});else t.log(`Promotions are not available from ClawHub yet.`);return}if(e.json){writeRuntimeJson(t,{promotions:n});return}if(n.length===0){t.log(`No active promotions right now.`);return}const r=sanitizeTerminalText;for(const e of n){const n=e.sponsor?` — ${r(e.sponsor)}`:``;const i=r(e.title);const a=Math.max(0,Math.floor((e.endsAt-Date.now())/864e5));const o=a===0?`ends today`:a===1?`1 day left`:`${a} days left`;t.log(`${i}${n} (${o})`);t.log(` ${r(e.blurb)}`);for(const n of e.models){const e=n.alias?` (${r(n.alias)})`:``;const i=n.suggestedDefault?` — suggested default`:``;t.log(` · ${r(n.modelRef)}${e}${i}`)}t.log(` Claim: ${formatCliCommand(`openclaw promos claim ${r(e.slug)}`)}`)}}export{promosListCommand};