export const MAPPING_PROFILE = {
  BUS: 'bus',
  MEMORY: 'memory',
  CONFIG: 'config',
  TRACE: 'trace',
  STORAGE: 'storage',
  DEPLOYER: 'deployer',
  KNOWLEDGE: 'knowledge',
  DOCS: 'docs',
  SEARCH: 'search',
  API: 'api',
  SQS: 'sqs',
} as const;

export const MATCH_KEYWORDS = {
  BUS: ['agentbus', 'bus'],
  QUEUE: ['queue', 'sqs'],
  API: ['api', 'webhookapi'],
  DATABASE: ['memorytable', 'memory', 'tracetable', 'traces', 'configtable', 'config'],
  KNOWLEDGE: ['knowledgebucket', 'knowledge'],
  DOCS: ['documentation', 'docs', 'documents'],
  SEARCH: ['search', 'vector', 'collection'],
  STAGING: ['stagingbucket', 'staging'],
  DEPLOYER: ['deployer', 'codebuild'],
  NOTIFIER: ['notifier'],
  DASHBOARD: ['dashboard', 'clawcenter'],
  REALTIME_BRIDGE: ['realtimebridge', 'bridge'],
  REALTIME_BUS: ['realtimebus', 'realtime'],
  HEARTBEAT: ['heartbeathandler', 'heartbeat'],
  MONITOR: ['concurrencymonitor'],
  EVENTS: ['eventhandler', 'events'],
  RECOVERY: ['deadmansswitch', 'recovery'],
  MCP: ['mcp', 'server', 'mcpwarmuphandler', 'mcpservermultiplexer'],
  SUPERCLAW: ['superclaw'],
  UTILITY_HANDLERS: [
    'mcpservermultiplexer',
    'multiplexer',
    'monitor',
    'buildmonitor',
    'build-monitor',
    'eventhandler',
    'events',
    'deadmansswitch',
    'recovery',
    'bridge',
    'realtimebridge',
    'dlqhandler',
    'notifier',
    'heartbeathandler',
    'concurrencymonitor',
    'worker',
    'handler',
  ],
  AGENTS: [
    'coder',
    'strategicplanner',
    'strategic-planner',
    'planner',
    'reflector',
    'cognitionreflector',
    'cognition-reflector',
    'qa',
    'critic',
    'agentrunner',
    'runner',
    'merger',
    'researcher',
    'agent',
  ],
  DLQ: ['eventdlq', 'dlq'],
} as const;

export const INFRA_NODE_ID = {
  API: 'api',
  BUS: 'bus',
  AGENT_BUS: 'agentbus',
  WEBHOOK_API: 'webhookapi',
  CODEBUILD: 'codebuild',
  CONFIG: 'config',
  CONFIG_TABLE: 'clawdb',
  MEMORY: 'memory',
  MEMORY_TABLE: 'clawdb',
  STORAGE: 'storage',
  STAGING_BUCKET: 'stagingbucket',
  TRACES: 'traces',
  TRACE_TABLE: 'clawdb',
  CLAWDB: 'clawdb',
  KNOWLEDGE: 'knowledge',
  KNOWLEDGE_BUCKET: 'knowledgebucket',
  NOTIFIER: 'notifier',
  BRIDGE: 'bridge',
  REALTIME_BRIDGE: 'realtimebridge',
  REALTIME_BUS: 'realtimebus',
  TELEGRAM: 'telegram',
  DASHBOARD: 'dashboard',
  SCHEDULER: 'scheduler',
  HEARTBEAT: 'heartbeat',
  DEPLOYER: 'deployer',
  MCP_AST: 'mcpastserver',
  MCP_GIT: 'mcpgitserver',
  MCP_FILESYSTEM: 'mcpfilesystemserver',
  MCP_GOOGLE_SEARCH: 'mcpgooglesearchserver',
  MCP_PUPPETEER: 'mcppuppeteerserver',
  MCP_FETCH: 'mcpfetchserver',
  MCP_AWS: 'mcpawsserver',
  MCP_AWS_S3: 'mcpawss3server',
  SQS: 'sqs',
  DOCUMENTS: 'documents',
  OPEN_SEARCH: 'opensearch',
} as const;

/** Canonical icon keys for the topology graph. Mapped to UI icons in the dashboard. */
export const NODE_ICON = {
  APP: 'APP',
  BOT: 'BOT',
  BRAIN: 'BRAIN',
  BUS: 'BUS',
  DATABASE: 'DATABASE',
  DASHBOARD: 'DASHBOARD',
  HAMMER: 'HAMMER',
  RADIO: 'RADIO',
  SEND: 'SEND',
  SERVER: 'SERVER',
  SIGNAL: 'SIGNAL',
  STETHOSCOPE: 'STETHOSCOPE',
  ZAP: 'ZAP',
  CODE: 'CODE',
  SEARCH: 'SEARCH',
  QA: 'QA',
  GEAR: 'GEAR',
  BELL: 'BELL',
  CALENDAR: 'CALENDAR',
} as const;

/** Node type discriminators for the topology graph renderer. */
export const NODE_TYPE = {
  INFRA: 'infra' as const,
  AGENT: 'agent' as const,
  DASHBOARD: 'dashboard' as const,
  BUS: 'bus' as const,
};

/**
 * Vertical placement tiers for nodes.
 * 1: User-facing / Entry points
 * 2: Communication / Logic Hub
 * 3: Specialized Agents
 * 4: Infrastructure / Persistence
 */
export const NODE_TIER = {
  APP: 'APP' as const,
  GATEWAY: 'GATEWAY' as const,
  COMM: 'COMM' as const,
  AGENT: 'AGENT' as const,
  UTILITY: 'UTILITY' as const,
  INFRA: 'INFRA' as const,
};

/** Human-readable labels for topology nodes. */
export const TOPOLOGY_LABELS = {
  AGENT_BUS: 'AgentBus (EventBridge)',
  ASYNC_QUEUE: 'Async Queue (SQS)',
  WEBHOOK_API: 'Webhook API',
  CLAW_DB: 'ClawDB (Single Table)',
  KNOWLEDGE_STORAGE: 'Knowledge Storage (S3)',
  DOCUMENT_STORE: 'Document Store (S3)',
  OPEN_SEARCH: 'OpenSearch Vector DB',
  STAGING_STORAGE: 'Staging Storage (S3)',
  CLAW_CENTER: 'ClawCenter (Next.js)',
  REALTIME_BRIDGE: 'Realtime Bridge (Lambda)',
  REALTIME_BUS: 'Realtime Bus (IoT Core)',
  HEARTBEAT_ENGINE: 'Heartbeat Engine',
  CONCURRENCY_MONITOR: 'Concurrency Monitor',
  EVENT_HANDLER: 'Event Handler',
  DEAD_MANS_SWITCH: "Dead Man's Switch",
  MCP_MULTIPLEXER: 'MCP Multiplexer (Lambda)',
  MCP_WARMUP_HANDLER: 'MCP Warmup Handler',
  DEAD_LETTER_QUEUE: 'Dead Letter Queue',
  REALTIME_BUS_IOT: 'Realtime Bus (IoT)',
} as const;

/** Standard edge label vocabulary for topology links. */
export const EDGE_LABEL = {
  INBOUND: 'INBOUND',
  SIGNAL: 'SIGNAL',
  MANAGE: 'MANAGE',
  DEPLOY: 'DEPLOY',
  EVENT: 'EVENT',
  REALTIME: 'REALTIME',
  QUERY: 'QUERY',
  WEBHOOK: 'WEBHOOK',
  READ_FILES: 'READ_FILES',
  MANAGE_FILES: 'MANAGE_FILES',
  ARCHIVE: 'ARCHIVE',
  OUTBOUND: 'OUTBOUND',
  SYNC: 'SYNC',
  ORCHESTRATE: 'ORCHESTRATE',
  USE: 'USE',
  SCHEDULE: 'SCHEDULE',
  HEARTBEAT: 'HEARTBEAT',
} as const;
