openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.64 kB
JavaScript
import{r as modelKey}from"./provider-registry-index-fv5AHL27.mjs";
//!src/shared/fast-mode.ts
const DEFAULT_FAST_MODE_AUTO_ON_SECONDS=60;function normalizeFastModeAutoOnSeconds(e){return typeof e===`number`&&Number.isInteger(e)&&e>0?e:void 0}function resolveFastModeModelAutoOnSeconds(e){const t=e.modelParamSources??[e.cfg?.agents?.defaults?.models?.[modelKey(e.provider??``,e.model??``)]?.params];for(const e of t){const t=normalizeFastModeAutoOnSeconds(e?.fastAutoOnSeconds)??normalizeFastModeAutoOnSeconds(e?.fast_auto_on_seconds)??normalizeFastModeAutoOnSeconds(e?.fastSeconds)??normalizeFastModeAutoOnSeconds(e?.fast_seconds);if(t!==void 0)return t}return 60}function resolveFastModeForElapsed(e){const t=e.nowMs??Date.now();const n=Math.max(0,t-e.startedAtMs);const r=normalizeFastModeAutoOnSeconds(e.fastAutoOnSeconds)??60;const i=r*1e3;const a=e.mode===`auto`?n<=i:e.mode===true||e.mode===`ultrafast`;const o=Math.floor(n/1e3);return{mode:e.mode,enabled:a,elapsedSeconds:o,fastAutoOnSeconds:r}}function formatFastModeAutoProgressText(e){if(e.enabled)return`💨Fast: auto-on`;const t=normalizeFastModeAutoOnSeconds(e.fastAutoOnSeconds)??60;return`💨Fast: auto-off(${e.elapsedSeconds}s>=${t}s)`}function formatFastModeValue(e){return e===`auto`||e===`ultrafast`?e:e===true?`on`:`off`}function formatFastModeConfirmation(e){if(e===`ultrafast`)return`Ultrafast mode enabled.`;return e===`auto`?`Fast mode set to auto.`:`Fast mode ${e?`enabled`:`disabled`}.`}function formatFastModeAutoLabel(e){return`auto (${normalizeFastModeAutoOnSeconds(e?.fastAutoOnSeconds)??60} sec)`}function formatFastModeStatusValue(e){if(e.mode===`auto`)return formatFastModeAutoLabel({fastAutoOnSeconds:e.fastAutoOnSeconds});return formatFastModeValue(e.mode)}function formatFastModeCommandOptions(e){return`on, off, ultrafast, ${formatFastModeAutoLabel({fastAutoOnSeconds:e?.fastAutoOnSeconds})}, default, status`}function formatFastModeSourceSuffix(e){switch(e){case`session`:return` (session)`;case`agent`:return` (default: agent)`;case`config`:return` (default: model)`;case`default`:return` (default)`;default:return``}}function formatFastModeCurrentStatus(e){return`${e.label??`Current fast mode`}: ${formatFastModeStatusValue({mode:e.mode,fastAutoOnSeconds:e.fastAutoOnSeconds})}${formatFastModeSourceSuffix(e.source)}.`}export{formatFastModeCurrentStatus as a,formatFastModeValue as c,formatFastModeConfirmation as i,resolveFastModeForElapsed as l,formatFastModeAutoProgressText as n,formatFastModeSourceSuffix as o,formatFastModeCommandOptions as r,formatFastModeStatusValue as s,formatFastModeAutoLabel as t,resolveFastModeModelAutoOnSeconds as u};