UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

5 lines โ€ข 6.84 kB
import{c as normalizeOptionalLowercaseString}from"./string-coerce-CpTFcSwY.mjs";import"./identity-C2YDObs7.mjs";import{i as shouldAckReaction}from"./ack-reactions-Bo6otmMc.mjs";import"./logging-B6XiK4pi.mjs"; //!src/channels/status-reactions.ts const TOOL_REACTION_EMOJIS=/* @__PURE__ */ new Map([[`bash`,`๐Ÿ› ๏ธ`],[`computer`,`๐Ÿ–ฑ๏ธ`],[`mobile_ui`,`๐Ÿ“ฑ`],[`screen`,`๐Ÿ–ฅ๏ธ`],[`theme`,`๐ŸŽจ`],[`terminal`,`โŒจ๏ธ`],[`portal`,`๐ŸŒ`],[`process`,`๐Ÿงฐ`],[`gateway_process`,`๐Ÿงฐ`],[`read`,`๐Ÿ“–`],[`write`,`โœ๏ธ`],[`edit`,`๐Ÿ“`],[`personal_instructions`,`๐Ÿ“`],[`presence`,`๐Ÿงฉ`],[`attach`,`๐Ÿ“Ž`],[`api`,`๐ŸŒ`],[`browser`,`๐ŸŒ`],[`canvas`,`๐Ÿ–ผ๏ธ`],[`dashboard`,`๐Ÿ“‹`],[`nodes`,`๐Ÿ“ฑ`],[`cron`,`โฐ`],[`get_goal`,`๐ŸŽฏ`],[`create_goal`,`๐ŸŽฏ`],[`update_goal`,`๐ŸŽฏ`],[`progress_card`,`๐Ÿ—บ๏ธ`],[`ask_user`,`โ“`],[`secrets`,`๐Ÿ”‘`],[`suggest_task`,`โœจ`],[`dismiss_task`,`๐Ÿ—‘๏ธ`],[`skill_workshop`,`๐Ÿงฐ`],[`skill_library`,`๐Ÿงฐ`],[`openclaw`,`๐Ÿฆ€`],[`gateway`,`๐Ÿ”Œ`],[`plugins`,`๐Ÿงฉ`],[`exec`,`๐Ÿ› ๏ธ`],[`tool_call`,`๐Ÿงฐ`],[`dispatch_action`,`๐Ÿงฐ`],[`tool_call_update`,`๐Ÿงฐ`],[`session_status`,`๐Ÿ“Š`],[`github_publish`,`๐Ÿ”€`],[`github_identity_status`,`๐Ÿ”`],[`sessions`,`๐Ÿ—‚๏ธ`],[`sessions_list`,`๐Ÿ—‚๏ธ`],[`conversations_list`,`๐Ÿ’ฌ`],[`conversations_send`,`๐Ÿ“จ`],[`conversations_turn`,`โ†”๏ธ`],[`sessions_send`,`๐Ÿ“จ`],[`sessions_history`,`๐Ÿงพ`],[`sessions_search`,`๐Ÿ”Ž`],[`transcripts`,`๐ŸŽ™๏ธ`],[`sessions_spawn`,`๐Ÿง‘โ€๐Ÿ”ง`],[`agents_wait`,`โณ`],[`structured_output`,`๐Ÿงพ`],[`subagents`,`๐Ÿค–`],[`agents_list`,`๐Ÿงญ`],[`memory_search`,`๐Ÿง `],[`memory_get`,`๐Ÿ““`],[`skills_search`,`๐Ÿ”`],[`skills_read`,`๐Ÿ“–`],[`web_search`,`๐Ÿ”Ž`],[`web_fetch`,`๐Ÿ“„`],[`code_execution`,`๐Ÿงฎ`],[`decision_evaluate`,`โš–๏ธ`],[`message`,`โœ‰๏ธ`],[`apply_patch`,`๐Ÿฉน`],[`image`,`๐Ÿ–ผ๏ธ`],[`view_image`,`๐Ÿ–ผ๏ธ`],[`image_generate`,`๐ŸŽจ`],[`music_generate`,`๐ŸŽต`],[`video_generate`,`๐ŸŽฌ`],[`pdf`,`๐Ÿ“‘`],[`sessions_yield`,`โธ๏ธ`],[`tts`,`๐Ÿ”Š`]]);const DEFAULT_EMOJIS={queued:`๐Ÿ‘€`,thinking:`๐Ÿง `,tool:`๐Ÿ› ๏ธ`,coding:`๐Ÿ’ป`,web:`๐ŸŒ`,deploy:`๐Ÿ›ซ`,build:`๐Ÿ—๏ธ`,concierge:`๐Ÿ’`,done:`โœ…`,error:`โŒ`,stallSoft:`โณ`,stallHard:`โš ๏ธ`,compacting:`๐Ÿ—œ๏ธ`};const DEFAULT_TIMING={debounceMs:700,stallSoftMs:1e4,stallHardMs:3e4,doneHoldMs:1500,errorHoldMs:2500};const CODING_TOOL_TOKENS=[`exec`,`process`,`read`,`write`,`edit`,`session_status`,`bash`];const WEB_TOOL_TOKENS=[`web_search`,`web-search`,`web_fetch`,`web-fetch`,`browser`];const DEPLOY_TOOL_TOKENS=[`fastlane`,`deploy`,`upload`,`testflight`,`ship`,`release`,`publish`,`distribute`];const BUILD_TOOL_TOKENS=[`build`,`compile`,`xcode`,`swift`,`gradle`,`cargo`,`make`,`cmake`,`webpack`,`vite`,`tsc`,`lint`];const CONCIERGE_TOOL_TOKENS=[`navigate`,`click`,`fill`,`screenshot`,`scroll`,`page`,`form`,`puppeteer`,`playwright`,`selenium`,`chromedp`];function resolveToolEmoji(e,t,n){const r=normalizeOptionalLowercaseString(e)??``;if(!r)return t.tool;const i=DEPLOY_TOOL_TOKENS.some(e=>r.includes(e))?`deploy`:BUILD_TOOL_TOKENS.some(e=>r.includes(e))?`build`:CONCIERGE_TOOL_TOKENS.some(e=>r.includes(e))?`concierge`:WEB_TOOL_TOKENS.some(e=>r.includes(e))?`web`:CODING_TOOL_TOKENS.some(e=>r.includes(e))?`coding`:`tool`;if(n?.[i]!==void 0)return t[i];return TOOL_REACTION_EMOJIS.get(r)??t[i]}function createStatusReactionController(e){const{enabled:t,adapter:n,initialEmoji:r,onError:i}=e;const a=e.presentation!==`acknowledgement`;const o={...DEFAULT_EMOJIS,queued:e.emojis?.queued??r,...e.emojis};const s={...DEFAULT_TIMING,...e.timing};let c=``;let l=``;let u=null;let d=[];let f=null;let p=0;let m=false;let h=Promise.resolve();const g=/* @__PURE__ */ new Set;function enqueue(e){h=h.then(e,e);return h}function clearActivityTimers(){clearDebounceTimer();clearStallTimers()}function clearStallTimers(){for(const e of d)clearTimeout(e);d=[]}function cancelTerminalHold(){p+=1;const e=f;if(!e)return;f=null;clearTimeout(e.timer);e.resolve()}function waitForTerminalHold(e,t){if(e<=0||t!==p)return Promise.resolve();return new Promise(t=>{f={timer:setTimeout(()=>{f=null;t()},e),resolve:t}})}function clearDebounceTimer(){if(u){clearTimeout(u);u=null}}function resetStallTimers(){if(!a)return;clearStallTimers();d=[`stallSoft`,`stallHard`].map(e=>setTimeout(()=>{scheduleEmoji(o[e],{immediate:true,skipStallReset:true})},s[`${e}Ms`]))}async function removeActiveEmojis(e={}){if(!n.removeReaction)return;for(const t of g){if(t===e.keepEmoji)continue;try{await n.removeReaction(t)}catch(e){i?.(e)}finally{g.delete(t)}}}async function applyEmoji(e){try{if(!n.removeReaction||!g.has(e))await n.setReaction(e);g.add(e);c=e}catch(e){i?.(e)}}function scheduleEmoji(e,n={}){if(!t||m)return;const i=a?e:r;if(i===c||i===l){if(!n.skipStallReset)resetStallTimers();return}l=i;clearDebounceTimer();const applyPendingEmoji=async()=>{await applyEmoji(i);l=``};if(n.immediate)enqueue(applyPendingEmoji);else u=setTimeout(()=>{u=null;enqueue(applyPendingEmoji)},s.debounceMs);if(!n.skipStallReset)resetStallTimers()}function finishWithEmoji(e,n){if(!t)return Promise.resolve();m=true;clearActivityTimers();const r=p;return enqueue(async()=>{await applyEmoji(e);await removeActiveEmojis({keepEmoji:e});l=``;await waitForTerminalHold(n,r)})}async function clear(){if(!t)return;clearActivityTimers();cancelTerminalHold();m=true;await enqueue(async()=>{if(n.clearReaction)try{await n.clearReaction()}catch(e){i?.(e)}finally{g.clear()}else await removeActiveEmojis();c=``;l=``})}async function restoreInitial(){if(!t)return;const e=c===r;const n=l;const i=u!==null;const a=g.size>(g.has(r)?1:0);clearActivityTimers();if(!m&&e&&(!n||i)&&!a){l=``;return}if(!m&&n===r&&!i){await h;return}await enqueue(async()=>{await applyEmoji(r);await removeActiveEmojis({keepEmoji:r});l=``})}return{setQueued:()=>scheduleEmoji(o.queued,{immediate:true}),setThinking:()=>scheduleEmoji(o.thinking),setTool:t=>scheduleEmoji(resolveToolEmoji(t,o,e.emojis)),setCompacting:()=>scheduleEmoji(o.compacting),cancelPending(){clearDebounceTimer();l=``},setDone:()=>a?finishWithEmoji(o.done,s.doneHoldMs):finishWithEmoji(r,0),setError:()=>finishWithEmoji(o.error,s.errorHoldMs),clear,restoreInitial}} //!src/plugin-sdk/channel-feedback.ts function shouldAckReactionForWhatsApp(e){if(!e.emoji)return false;if(e.isDirect)return e.directEnabled;if(!e.isGroup||e.groupMode===`never`)return false;if(e.groupMode===`always`)return true;return shouldAckReaction({scope:`group-mentions`,isDirect:false,isGroup:true,isMentionableGroup:true,canDetectMention:true,effectiveWasMentioned:e.wasMentioned,shouldBypassMention:e.groupActivated})}export{DEFAULT_EMOJIS as a,WEB_TOOL_TOKENS as c,CONCIERGE_TOOL_TOKENS as i,createStatusReactionController as l,BUILD_TOOL_TOKENS as n,DEFAULT_TIMING as o,CODING_TOOL_TOKENS as r,DEPLOY_TOOL_TOKENS as s,shouldAckReactionForWhatsApp as t,resolveToolEmoji as u};