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.

9.5 KB
Raw Blame
/**
 * Assistant group / workflow UI β€” tunable limits, timing, heuristics, and apiName display labels.
 * Centralizes magic numbers used by Group, WorkflowCollapse, and toolDisplayNames helpers.
 */

// ─── Workflow collapse (WorkflowCollapse) ─────────────────────────────────

/** Elapsed timer in the working header only appears after this many ms (aligns with ContentLoading). */
export const WORKFLOW_WORKING_ELAPSED_SHOW_AFTER_MS = 2100;

/** Debounce when B/C headline text changes to avoid streaming arg chunks thrashing the title animation. */
export const WORKFLOW_HEADLINE_DEBOUNCE_MS = 320;

/** After prose forms a complete sentence (trailing CJK/Latin punct), commit headline after this delay. */
export const WORKFLOW_PROSE_QUICK_COMMIT_MS = 280;

/** Partial prose without sentence end: commit headline after this idle delay. */
export const WORKFLOW_PROSE_IDLE_COMMIT_MS = 680;

/** Min height (px) for the streaming title row to reduce layout shift during motion. */
export const WORKFLOW_STREAMING_TITLE_MIN_HEIGHT_PX = 22;

/** Pixels from bottom of scroll port: auto-scroll in expanded workflow list stays active within this margin. */
export const WORKFLOW_EXPANDED_SCROLL_THRESHOLD_PX = 120;

// ─── One-line prose headline shaping ─────────────────────────────────────────

/** Hard cap for shaped workflow title before word-boundary ellipsis. */
export const WORKFLOW_PROSE_HEADLINE_MAX_CHARS = 100;

/** Ignore very short fragments; also minimum for β€œvalid” sentence after cut. */
export const WORKFLOW_PROSE_MIN_CHARS = 8;

/** Minimum trimmed `content` length when picking a block for live headline source. */
export const WORKFLOW_PROSE_SOURCE_MIN_CHARS = 8;

/**
 * List-marker junk filter: reject single-line bodies like "- a" from being a headline
 * (max word chars after list marker).
 */
export const WORKFLOW_PROSE_LIST_MARKER_MAX_TAIL_WORD_CHARS = 3;

/** When truncating at space, require last space to be at least this fraction of max (avoid tiny cuts). */
export const WORKFLOW_TRUNCATE_WORD_BOUNDARY_MIN_RATIO = 0.55;

/** Strip markdown headings: match ATX `#` up to this many levels. */
export const WORKFLOW_MARKDOWN_HEADING_MAX_LEVEL = 6;

// ─── Tool argument / step lines (headline B/C and summaries) ───────────────

/** First string tool argument preview: show at most this many chars before "…". */
export const TOOL_FIRST_DETAIL_MAX_CHARS = 80;

/** Tool step / arg combined headline: soft cap for readable one-liner. */
export const TOOL_HEADLINE_DETAIL_MAX_CHARS = 120;

/** Slice length before appending ellipsis when over TOOL_HEADLINE_DETAIL_MAX_CHARS (room for "..."). */
export const TOOL_HEADLINE_DETAIL_TRUNCATE_LEN = 117;

/** Suffix when truncating tool strings. */
export const TOOL_HEADLINE_TRUNCATION_SUFFIX = '...';

// ─── Time formatting (workflow summary / reasoning suffix) ───────────────

/** Duration inputs are in milliseconds; convert to whole seconds for display. */
export const TIME_MS_PER_SECOND = 1000;

// ─── apiName β†’ i18n key for human-readable label (workflow summary & headlines) ─

/** Translation keys for built-in / known tool api names. Unknown api names use title-cased fallback. */
export const TOOL_API_DISPLAY_NAMES: Record<string, string> = {
  // Web browsing
  crawlMultiPages: 'workflow.toolDisplayName.crawlMultiPages',
  crawlSinglePage: 'workflow.toolDisplayName.crawlSinglePage',
  search: 'workflow.toolDisplayName.search',

  // Knowledge base
  readKnowledge: 'workflow.toolDisplayName.readKnowledge',
  searchKnowledgeBase: 'workflow.toolDisplayName.searchKnowledgeBase',

  // Notebook
  createDocument: 'workflow.toolDisplayName.createDocument',
  deleteDocument: 'workflow.toolDisplayName.deleteDocument',
  getDocument: 'workflow.toolDisplayName.getDocument',
  updateDocument: 'workflow.toolDisplayName.updateDocument',

  // Agent documents
  copyDocument: 'workflow.toolDisplayName.copyDocument',
  createFolder: 'workflow.toolDisplayName.createFolder',
  listDocuments: 'workflow.toolDisplayName.listDocuments',
  moveDocuments: 'workflow.toolDisplayName.moveDocuments',
  readDocument: 'workflow.toolDisplayName.readDocument',
  removeDocument: 'workflow.toolDisplayName.removeDocument',
  renameDocument: 'workflow.toolDisplayName.renameDocument',
  replaceDocumentContent: 'workflow.toolDisplayName.replaceDocumentContent',
  updateLoadRule: 'workflow.toolDisplayName.updateLoadRule',

  // Calculator
  calculate: 'workflow.toolDisplayName.calculate',
  evaluate: 'workflow.toolDisplayName.evaluate',
  solve: 'workflow.toolDisplayName.solve',
  execute: 'workflow.toolDisplayName.execute',

  // Local system / cloud sandbox (file ops share the same display label)
  editFile: 'workflow.toolDisplayName.editLocalFile',
  globFiles: 'workflow.toolDisplayName.globLocalFiles',
  grepContent: 'workflow.toolDisplayName.grepContent',
  killCommand: 'workflow.toolDisplayName.killCommand',
  listFiles: 'workflow.toolDisplayName.listLocalFiles',
  moveFiles: 'workflow.toolDisplayName.moveLocalFiles',
  readFile: 'workflow.toolDisplayName.readLocalFile',
  runCommand: 'workflow.toolDisplayName.runCommand',
  searchFiles: 'workflow.toolDisplayName.searchLocalFiles',
  writeFile: 'workflow.toolDisplayName.writeLocalFile',
  getCommandOutput: 'workflow.toolDisplayName.getCommandOutput',
  // Legacy aliases β€” keep so historical messages still get a label.
  // `renameLocalFile` is kept even though the new surface drops rename
  // (rename is now done via `moveFiles`).
  editLocalFile: 'workflow.toolDisplayName.editLocalFile',
  globLocalFiles: 'workflow.toolDisplayName.globLocalFiles',
  listLocalFiles: 'workflow.toolDisplayName.listLocalFiles',
  moveLocalFiles: 'workflow.toolDisplayName.moveLocalFiles',
  readLocalFile: 'workflow.toolDisplayName.readLocalFile',
  renameLocalFile: 'workflow.toolDisplayName.renameLocalFile',
  searchLocalFiles: 'workflow.toolDisplayName.searchLocalFiles',
  writeLocalFile: 'workflow.toolDisplayName.writeLocalFile',

  // Cloud sandbox
  executeCode: 'workflow.toolDisplayName.executeCode',

  // Codex
  command_execution: 'workflow.toolDisplayName.runCommand',
  file_change: 'workflow.toolDisplayName.editLocalFile',
  mcp_tool_call: 'workflow.toolDisplayName.callMcpTool',
  todo_list: 'workflow.toolDisplayName.updateTodos',
  web_search: 'workflow.toolDisplayName.search',

  // Lobe Agent β€” Plan & Todos
  createPlan: 'workflow.toolDisplayName.createPlan',
  createTodos: 'workflow.toolDisplayName.createTodos',
  updatePlan: 'workflow.toolDisplayName.updatePlan',
  updateTodos: 'workflow.toolDisplayName.updateTodos',
  clearTodos: 'workflow.toolDisplayName.clearTodos',

  // Lobe Agent β€” Sub-Agents
  callSubAgent: 'workflow.toolDisplayName.callSubAgent',

  // Memory
  addActivityMemory: 'workflow.toolDisplayName.addActivityMemory',
  addContextMemory: 'workflow.toolDisplayName.addContextMemory',
  addExperienceMemory: 'workflow.toolDisplayName.addExperienceMemory',
  addIdentityMemory: 'workflow.toolDisplayName.addIdentityMemory',
  addPreferenceMemory: 'workflow.toolDisplayName.addPreferenceMemory',
  removeIdentityMemory: 'workflow.toolDisplayName.removeIdentityMemory',
  searchUserMemory: 'workflow.toolDisplayName.searchUserMemory',
  updateIdentityMemory: 'workflow.toolDisplayName.updateIdentityMemory',

  // Agent management
  callAgent: 'workflow.toolDisplayName.callAgent',
  createAgent: 'workflow.toolDisplayName.createAgent',
  deleteAgent: 'workflow.toolDisplayName.deleteAgent',
  searchAgent: 'workflow.toolDisplayName.searchAgent',
  updateAgent: 'workflow.toolDisplayName.updateAgent',

  // Page agent
  bash: 'workflow.toolDisplayName.runCommand',
  editTitle: 'workflow.toolDisplayName.editTitle',
  getPageContent: 'workflow.toolDisplayName.getPageContent',
  initPage: 'workflow.toolDisplayName.initPage',
  modifyNodes: 'workflow.toolDisplayName.modifyNodes',
  replaceText: 'workflow.toolDisplayName.replaceText',

  // Skills
  activateSkill: 'workflow.toolDisplayName.activateSkill',
  activateTools: 'workflow.toolDisplayName.activateTools',
  execScript: 'workflow.toolDisplayName.execScript',

  // Skill store
  importFromMarket: 'workflow.toolDisplayName.importFromMarket',
  importSkill: 'workflow.toolDisplayName.importSkill',
  searchSkill: 'workflow.toolDisplayName.searchSkill',

  // Misc
  finishOnboarding: 'workflow.toolDisplayName.finishOnboarding',
  getTopicContext: 'workflow.toolDisplayName.getTopicContext',
  listOnlineDevices: 'workflow.toolDisplayName.listOnlineDevices',
  activateDevice: 'workflow.toolDisplayName.activateDevice',

  // Web onboarding
  saveUserQuestion: 'workflow.toolDisplayName.saveUserQuestion',
  writeDocument: 'workflow.toolDisplayName.writeDocument',

  // Agent marketplace
  showAgentMarketplace: 'workflow.toolDisplayName.showAgentMarketplace',
  submitAgentPick: 'workflow.toolDisplayName.submitAgentPick',
};

/**
 * Steps an opened workflow list mounts at first. A long turn can run hundreds
 * of steps; mounting them all in one commit froze the page, so the list starts
 * from its tail and earlier steps load on demand.
 */
export const WORKFLOW_LIST_INITIAL_STEPS = 50;

/** Steps one "show earlier steps" click adds above the loaded ones. */
export const WORKFLOW_LIST_LOAD_MORE_STEPS = 100;

/**
 * Above this many tool calls the workflow skips its open/close height
 * animation: animating the height re-lays out the whole list on every frame.
 */
export const WORKFLOW_ANIMATED_MAX_TOOLS = 100;