Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

5.5 KB
Raw Blame
import { ENABLE_BUSINESS_FEATURES } from '@lobechat/business-const';

import { type labPreferSelectors } from '@/store/user/slices/preference/selectors/labPrefer';

/**
 * Maturity stage of a lab experiment:
 * - alpha: internal testing only, not recommended for daily use yet
 * - beta: relatively usable β€” core flow works, details still being polished
 */
export type LabStage = 'alpha' | 'beta';

/**
 * Locale key stems under the `labs` namespace (`features.${stem}.title|desc`),
 * listed as literals so the dynamic `t()` calls stay inside the typed key union.
 */
type LabFeatureI18nKey =
  | 'agentGraphConfig'
  | 'agentIdentity'
  | 'artifactDeployment'
  | 'claudeCodeSdk'
  | 'codexAppServer'
  | 'desktopSplitView'
  | 'deviceTunnel'
  | 'evalCapture'
  | 'heteroSessionImport'
  | 'imessage'
  | 'messageTextSelectionActions'
  | 'oauthApps'
  | 'pageCollab'
  | 'projects'
  | 'selfLearning'
  | 'topicBugReport';

/** Locale key stems that also carry a `features.${stem}.note` line */
type LabFeatureNoteI18nKey = 'selfLearning';

export interface LabFeatureItem {
  /**
   * Only offered when business features are on: the experiment needs a service
   * that a self-hosted deployment does not have, so its toggle would do nothing.
   */
  businessOnly?: boolean;
  /** Only rendered (and searchable) in the Electron shell */
  desktopOnly?: boolean;
  /** Lab flag, also the search anchor suffix (`labs-${flag}`) */
  flag: keyof typeof labPreferSelectors;
  /** Locale key stem in the `labs` namespace: `features.${i18nKey}.title|desc` */
  i18nKey: LabFeatureI18nKey;
  /**
   * Second description line for what the user must know before turning it on
   * (e.g. extra usage cost): `features.${noteI18nKey}.note`
   */
  noteI18nKey?: LabFeatureNoteI18nKey;
  /** Extra untranslated English synonyms for the settings search index */
  searchKeywords: string[];
  stage: LabStage;
  /** Only rendered (and searchable) for users with workspace access */
  workspaceOnly?: boolean;
}

const ALL_LAB_FEATURES: LabFeatureItem[] = [
  {
    flag: 'enableAgentGraphConfig',
    i18nKey: 'agentGraphConfig',
    searchKeywords: ['agent graph', 'graph runtime'],
    stage: 'alpha',
  },
  {
    flag: 'enableAgentIdentity',
    i18nKey: 'agentIdentity',
    searchKeywords: ['agent identity', 'agent mail', 'inbox', 'address'],
    stage: 'alpha',
  },
  {
    flag: 'enableMessageTextSelectionActions',
    i18nKey: 'messageTextSelectionActions',
    searchKeywords: ['text selection', 'quote'],
    stage: 'alpha',
  },
  {
    flag: 'enableSelfLearning',
    i18nKey: 'selfLearning',
    noteI18nKey: 'selfLearning',
    searchKeywords: [
      'self-evolving',
      'self learning',
      'rule base',
      'rules',
      'memory rules',
      'delivery rules',
      'verifier',
    ],
    stage: 'alpha',
  },
  {
    flag: 'enableEvalCapture',
    i18nKey: 'evalCapture',
    searchKeywords: ['eval', 'test case', 'capture', 'regression', 'benchmark'],
    stage: 'alpha',
  },
  {
    businessOnly: true,
    flag: 'enableTopicBugReport',
    i18nKey: 'topicBugReport',
    searchKeywords: ['bug', 'report', 'feedback', 'issue', 'support'],
    stage: 'alpha',
  },
  {
    flag: 'enableDeviceTunnel',
    i18nKey: 'deviceTunnel',
    searchKeywords: ['tunnel', 'port forwarding', 'dev server', 'localhost'],
    stage: 'alpha',
  },
  {
    flag: 'enableProjects',
    i18nKey: 'projects',
    searchKeywords: ['project', 'workspace'],
    stage: 'alpha',
  },
  {
    flag: 'enableOAuthApps',
    i18nKey: 'oauthApps',
    searchKeywords: ['oauth', 'oauth apps'],
    stage: 'beta',
  },
  {
    flag: 'enableArtifactDeployment',
    i18nKey: 'artifactDeployment',
    searchKeywords: ['artifact', 'deploy', 'publish'],
    stage: 'beta',
  },
  {
    businessOnly: true,
    flag: 'enablePageCollab',
    i18nKey: 'pageCollab',
    searchKeywords: ['collaboration', 'co-editing', 'realtime', 'live editing', 'page'],
    stage: 'alpha',
    workspaceOnly: true,
  },
  {
    desktopOnly: true,
    flag: 'enableDesktopSplitView',
    i18nKey: 'desktopSplitView',
    searchKeywords: ['split view', 'split tab'],
    stage: 'alpha',
  },
  {
    desktopOnly: true,
    flag: 'enableImessage',
    i18nKey: 'imessage',
    searchKeywords: ['imessage', 'bluebubbles'],
    stage: 'alpha',
  },
  {
    desktopOnly: true,
    flag: 'enableClaudeCodeSdk',
    i18nKey: 'claudeCodeSdk',
    searchKeywords: ['claude code', 'claude sdk'],
    stage: 'alpha',
  },
  {
    flag: 'enableCodexAppServer',
    i18nKey: 'codexAppServer',
    searchKeywords: ['codex', 'app server'],
    stage: 'alpha',
  },
  // rides on the Claude Code hetero-agent stack: scans local CLI transcripts
  // via the Electron main process β€” desktop only
  {
    desktopOnly: true,
    flag: 'enableHeteroSessionImport',
    i18nKey: 'heteroSessionImport',
    searchKeywords: ['import session', 'claude code', 'codex'],
    stage: 'beta',
  },
];

export const filterAvailableLabFeatures = (
  features: LabFeatureItem[],
  enableBusinessFeatures: boolean,
): LabFeatureItem[] =>
  features.filter((feature) => enableBusinessFeatures || !feature.businessOnly);

/**
 * Single source of truth for the lab experiments: the Labs settings page
 * renders this list (general first, then workspace-only, then desktop-only), and the settings
 * search index derives its entries from it β€” adding a flag here makes it both
 * visible and searchable without a second registration.
 */
export const LAB_FEATURES: LabFeatureItem[] = filterAvailableLabFeatures(
  ALL_LAB_FEATURES,
  ENABLE_BUSINESS_FEATURES,
);