eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.08 kB
JavaScript
import{select}from"../ask.js";function buildChatPreferenceOptions(e){let option=(e,t,n)=>({id:e,label:t,value:e,hint:n}),t=[];return e.availableChannels.includes(`web`)&&t.push(option(`web`,`Web chat`,`next.js`)),e.availableChannels.includes(`slack`)&&e.slackbotAttached&&t.push(option(`slack`,`Slack`,`open workspace`)),t.push(option(`repl`,`Terminal UI`)),t.push(option(`api`,`API`)),t.push(option(`skip`,`Skip and chat later`)),t}function pickInitialPreference(e){if(e.availableChannels.includes(`web`))return`web`;if(e.availableChannels.includes(`slack`)&&e.slackbotAttached)return`slack`}function selectChat(t){return{id:`select-chat`,async gather({state:n}){if(t.presetPreference!==void 0)return t.presetPreference;let r={availableChannels:[...n.channels],slackbotAttached:n.slackbotAttached};return t.asker.ask(select({key:`chat`,message:`Start a chat with your agent now`,options:buildChatPreferenceOptions(r),recommended:pickInitialPreference(r),required:!0}))},async perform({input:e}){return e},apply(e,t){return{...e,chat:t}}}}export{buildChatPreferenceOptions,selectChat};