Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

2.2 KB
Raw Blame
import {
  CODEX_BOT_NAME,
  CODEX_BOT_PRINCIPAL_ID,
} from '@core/constant/codexAgent';
import {
  CURSOR_BOT_NAME,
  CURSOR_BOT_PRINCIPAL_ID,
} from '@core/constant/cursorAgent';
import {
  MACRO_AGENT_NAME,
  MACRO_AGENT_PRINCIPAL_ID,
} from '@core/constant/macroAgent';
import { MACRO_NEW_PRINCIPAL_ID } from '@core/constant/macroNew';
import type { IUser } from '@core/user/types';

// Re-export the shared Macro identity under the names used in this package.
export {
  isMacroAgentId as isMacroAiId,
  MACRO_AGENT_BOT_ID as MACRO_AI_BOT_ID,
  MACRO_AGENT_HANDLE as MACRO_AI_HANDLE,
  MACRO_AGENT_NAME as MACRO_AI_NAME,
  MACRO_AGENT_PRINCIPAL_ID as MACRO_AI_PRINCIPAL_ID,
} from '@core/constant/macroAgent';
export { isMacroCoderId } from '@core/constant/macroCoder';
export { isMacroNewId } from '@core/constant/macroNew';

/**
 * The single synthetic [`IUser`] entry for Macro in the channel `@`-mention
 * typeahead. The mention rides the existing user-mention machinery and is
 * re-tagged as a bot mention at send time (see `authoredMentions`). `email` is set
 * to the display name so the typeahead shows just "Macro". The id uses the
 * canonical `bot|<uuid>` principal form so persisted mention content matches
 * bot sender/participant ids.
 *
 * Which Macro answers is the rollout's business, not the mentioning user's:
 * under chat-v3 `@macro` opens an agent session, otherwise it gets the classic
 * in-channel reply. Only ever one entry, named "Macro" either way.
 */
export function macroMentionUser(agentSessions: boolean): IUser {
  return {
    id: agentSessions ? MACRO_NEW_PRINCIPAL_ID : MACRO_AGENT_PRINCIPAL_ID,
    name: MACRO_AGENT_NAME,
    email: MACRO_AGENT_NAME,
  };
}

/**
 * The Cursor bot as a synthetic mention user, exactly like
 * [`macroMentionUser`]. Mentioning it opens an agent session served by
 * a Cursor cloud agent.
 */
export function cursorMentionUser(): IUser {
  return {
    id: CURSOR_BOT_PRINCIPAL_ID,
    name: CURSOR_BOT_NAME,
    email: CURSOR_BOT_NAME,
  };
}

/** Codex as a bot mention, using the canonical principal identifier. */
export function codexMentionUser(): IUser {
  return {
    id: CODEX_BOT_PRINCIPAL_ID,
    name: CODEX_BOT_NAME,
    email: CODEX_BOT_NAME,
  };
}