UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

3 lines (2 loc) • 1.43 kB
const TELEGRAM_AUTHORIZATION_CALLBACK_PREFIX=`eve_auth:`;function renderTelegramAuthorizationPrompt(e){let t=formatTelegramAuthorizationDisplayName(e.name,e.authorization?.displayName),n=e.authorization?.url;return{reply_markup:n===void 0?void 0:{inline_keyboard:[[{text:`Sign in with ${t}`,url:n}]]},text:[`Authorization required for ${t}.`,e.authorization?.instructions,e.authorization?.userCode===void 0?void 0:`Code: ${e.authorization.userCode}`].filter(e=>e!==void 0&&e.length>0).join(` `)}}function renderTelegramAuthorizationStatus(e){let t=e.requesterUserId===void 0||e.requesterUserId===null?void 0:`${TELEGRAM_AUTHORIZATION_CALLBACK_PREFIX}${e.requesterUserId}`;return{reply_markup:t===void 0?void 0:{inline_keyboard:[[{callback_data:t,text:`Authorize`}]]},text:`Authorization required for ${e.displayName}. The requester must sign in to resume.`}}function formatTelegramAuthorizationDisplayName(e,t){return t===void 0?e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1):t}function renderTelegramAuthorizationCompleted(e){if(e.outcome===`authorized`)return`${e.displayName} connected.`;let t=e.reason===void 0?``:` (${e.reason})`,n=e.outcome===`timed-out`?`timed out`:e.outcome;return`${e.displayName} authorization ${n}${t}.`}export{TELEGRAM_AUTHORIZATION_CALLBACK_PREFIX,formatTelegramAuthorizationDisplayName,renderTelegramAuthorizationCompleted,renderTelegramAuthorizationPrompt,renderTelegramAuthorizationStatus};