/**
 * nexus-agents/mcp
 *
 * MCP server implementation for Nexus Agents.
 * Provides tools for orchestrating multi-agent workflows.
 *
 * (Source: MCP Protocol 2025-11-25)
 */

// Server
export {
  createServer,
  startStdioServer,
  connectTransport,
  closeServer,
  type ServerConfig,
  type ServerInstance,
  type ServerError,
} from './server.js';

// Middleware
export {
  // Validation
  validateToolInput,
  createValidator,
  isZodError,
  // Rate limiting
  RateLimiter,
  createDefaultRateLimiter,
  type RateLimiterConfig,
  type RateLimiterState,
  // Logging
  createMcpLogger,
  createToolLogger,
  logToolStart,
  logToolSuccess,
  logToolError,
  createTimer,
  withLogging,
  type McpLogContext,
  // Policy firewall
  type Artifact,
  type ExecutionMode,
  type PolicyMode,
  type PolicyDecision,
  type PolicyContext,
  type PolicyRule,
  type IPolicyFirewall,
  type PolicyFirewallConfig,
  type PolicyConfig,
  PolicyFirewall,
  PolicyError,
  PolicyConfigSchema,
  denyMutationsWithoutModeRule,
  safePathsRule,
  createDefaultPolicyFirewall,
  evaluatePolicy,
  createPolicyContext,
} from './middleware/index.js';

// MCP Notifier (Issue #974 — Claude Code Observability)
export {
  createMcpNotifier,
  NOOP_NOTIFIER,
  type IMcpNotifier,
  type McpLogLevel,
} from './mcp-notifier.js';

// EventBus Bridge (Issue #307)
export {
  initializeEventBusBridge,
  getEventBusStats,
  type EventBusBridgeResult,
} from './eventbus-bridge.js';

// Prompts (Issue #1287)
export {
  registerPrompts,
  PROMPT_DEFINITIONS,
  type PromptDefinition,
  type PromptMessage,
  type PromptRegistrationResult,
} from './prompts/index.js';

// Resources (Issue #1288)
export {
  registerResources,
  registerModelsResource,
  registerResearchResource,
  registerExpertsResource,
} from './resources/index.js';

// Tools
export {
  // Tool registration
  registerTools,
  toolSuccess,
  toolSuccessStructured,
  toolError,
  type ToolRegistrationOptions,
  type ToolRegistrationResult,
  type BaseMcpToolDeps,
  type TextContent,
  type ToolResult,
  // create_expert tool
  registerCreateExpertTool,
  createDefaultDeps,
  getAvailableRoles,
  getCapabilitiesForRole,
  CreateExpertInputSchema,
  type CreateExpertInput,
  type CreateExpertDeps,
  type CreateExpertResponse,
  type IExpertFactory,
  // execute_expert tool (Issue #437)
  registerExecuteExpertTool,
  ExecuteExpertInputSchema,
  type ExecuteExpertInput,
  type ExecuteExpertDeps,
  type ExecuteExpertResponse,
  // consensus_vote tool (Issue #435)
  registerConsensusVoteTool,
  ConsensusVoteInputSchema,
  type ConsensusVoteInput,
  type ConsensusVoteDeps,
  type ConsensusVoteResponse,
  type AgentVoteSummary,
  type VoteDecisionStatus,
  // pr_review tool (#2233)
  registerPrReviewTool,
  PrReviewInputSchema,
  PR_REVIEW_ROLES,
  MAX_DIFF_LENGTH,
  buildPrReviewProposal,
  mapVoteDecisionToPrDecision,
  aggregatePrDecisions,
  type PrReviewInput,
  type PrReviewDecision,
  type PrReviewVote,
  type PrReviewResponse,
  type PrReviewDeps,
  // run_workflow tool
  registerRunWorkflowTool,
  RunWorkflowInputSchema,
  type RunWorkflowDeps,
  type RunWorkflowInput,
  type WorkflowToolResult,
  type StepResultSummary,
  type DryRunResult,
  // orchestrate tool
  registerOrchestrateTool,
  OrchestrateInputSchema,
  OrchestrateOutputSchema,
  OrchestrationError,
  OrchestrationUnavailableError,
  type OrchestrateInput,
  type OrchestrateOutput,
  type OrchestrateDeps,
  // delegate_to_model tool
  registerDelegateToModelTool,
  DelegateInputSchema,
  DelegateOutputSchema,
  MODEL_CAPABILITIES,
  type DelegateInput,
  type DelegateOutput,
  type DelegateDeps,
  type CapabilityProfile,
  type PreferredCapability,
  // list_experts tool (Issue #436)
  registerListExpertsTool,
  ListExpertsInputSchema,
  type ListExpertsInput,
  type ListExpertsDeps,
  type ListExpertsResponse,
  type ExpertInfo,
  // list_workflows tool (Issue #436)
  registerListWorkflowsTool,
  ListWorkflowsInputSchema,
  type ListWorkflowsInput,
  type ListWorkflowsDeps,
  type ListWorkflowsResponse,
  type WorkflowInfo,
  // research tools (Research System Enhancement)
  registerResearchQueryTool,
  ResearchQueryInputSchema,
  type ResearchQueryInput,
  type ResearchQueryDeps,
  type ResearchQueryResponse,
  registerResearchAddTool,
  ResearchAddInputSchema,
  type ResearchAddInput,
  type ResearchAddDeps,
  type ResearchAddResponse,
  registerResearchAddSourceTool,
  ResearchAddSourceInputSchema,
  type ResearchAddSourceInput,
  type ResearchAddSourceDeps,
  type ResearchAddSourceResponse,
  registerResearchDiscoverTool,
  ResearchDiscoverInputSchema,
  type ResearchDiscoverInput,
  type ResearchDiscoverDeps,
  type ResearchDiscoverResponse,
  type DiscoveredItem,
  type DiscoverySource,
  registerResearchAnalyzeTool,
  ResearchAnalyzeInputSchema,
  type ResearchAnalyzeInput,
  type ResearchAnalyzeDeps,
  type ResearchAnalyzeResponse,
  type AnalysisFocus,
  registerResearchCatalogReviewTool,
  ResearchCatalogReviewInputSchema,
  type ResearchCatalogReviewInput,
  type ResearchCatalogReviewDeps,
  type ResearchCatalogReviewResponse,
  // Research synthesis (Issue #1386)
  registerResearchSynthesizeTool,
  ResearchSynthesizeInputSchema,
  type ResearchSynthesizeInput,
  type ResearchSynthesizeDeps,
  type ResearchSynthesizeResponse,
  // Survey OSS landscape (transient — Issue #2295, child of #2293)
  registerSurveyOssLandscapeTool,
  SurveyOssLandscapeInputSchema,
  type SurveyOssLandscapeInput,
  type SurveyOssLandscapeDeps,
  type SurveyOssLandscapeResponse,
  type OssCandidate,
  // Vendor publishing audit (Issue #2296, child of #2293)
  registerVendorPublishingAuditTool,
  VendorPublishingAuditInputSchema,
  type VendorPublishingAuditInput,
  type VendorPublishingAuditDeps,
  type VendorPublishingAuditResponse,
  // Compare data feeds (Issue #2297, child of #2293)
  registerCompareDataFeedsTool,
  CompareDataFeedsInputSchema,
  type CompareDataFeedsInput,
  type CompareDataFeedsDeps,
  type CompareDataFeedsResponse,
  type FieldDifference,
  ResearchAutoCatalog,
  getAutoCatalog,
  type CatalogedReference,
  // Memory observability tools (Issue #751, #753)
  registerMemoryQueryTool,
  MemoryQueryInputSchema,
  type MemoryQueryInput,
  type MemoryQueryDeps,
  type MemoryQueryResponse,
  registerMemoryStatsTool,
  MemoryStatsInputSchema,
  type MemoryStatsInput,
  type MemoryStatsDeps,
  type MemoryStatsResponse,
  // Memory write tool (Issue #1090)
  registerMemoryWriteTool,
  MemoryWriteInputSchema,
  type MemoryWriteInput,
  type MemoryWriteDeps,
  type MemoryWriteResponse,
  // Weather report tool (Issue #865)
  registerWeatherReportTool,
  type WeatherReportDeps,
  WeatherReportInputSchema,
  type WeatherReportInput,
  type WeatherReportResponse,
  generateWeatherReport,
  // Improvement review tool (Issue #2402)
  registerImprovementReviewTool,
  type ImprovementReviewDeps,
  ImprovementReviewInputSchema,
  type ImprovementReviewInput,
  type ImprovementReviewResponse,
  type ImprovementSignal,
  type SignalCategory,
  // Registry import tool (Issue #889)
  registerRegistryImportTool,
  type RegistryImportDeps,
  RegistryImportInputSchema,
  type RegistryImportInput,
  type RegistryImportResponse,
  generateRegistryEntry,
  // Repo analyze tool (Issue #1074)
  registerRepoAnalyzeTool,
  type RepoAnalyzeDeps,
  RepoAnalyzeInputSchema,
  type RepoAnalyzeInput,
  type RepoAnalysis,
  analyzeRepo,
  analyzeGitHubRepo,
  normalizeRepoId,
  // Repo security plan tool (Issue #1079)
  registerRepoSecurityPlanTool,
  type RepoSecurityPlanDeps,
  RepoSecurityPlanInputSchema,
  type RepoSecurityPlanInput,
  type RepoSecurityPlan,
  type ScannerRecommendation,
  type ConflictWarning,
  type CoverageAnalysis,
  buildPlanFromAnalysis,
  generateSecurityPlan,
  resolveScannerData,
  FALLBACK_SCANNER_DATA,
  type ScannerEntry,
  type ScannerData,
  // Scanner registry fetcher (externalization vote 6-0)
  getRegistryManifest,
  clearRegistryCache,
  type RegistryScanner,
  type RegistryRelationship,
  type LanguageMatrixEntry,
  type ScannerRegistryManifest,
  // Delegate helpers (Issue #872 — TUI)
  analyzeTask,
  selectModel,
  type TaskRequirements,
  // Graph workflow templates (Issue #841, #866)
  getGraphWorkflowList,
  getGraphRegistry,
  type GraphWorkflowInfo,
  // Issue triage tool (Issue #828)
  registerIssueTriageTool,
  IssueTriageInputSchema,
  type IssueTriageInput,
  type IssueTriageDeps,
  type IssueTriageResponse,
  // Graph workflow tool (Issue #840)
  registerRunGraphWorkflowTool,
  RunGraphWorkflowInputSchema,
  type RunGraphWorkflowInput,
  type RunGraphWorkflowDeps,
  type RunGraphWorkflowResponse,
  // Execute spec tool (Issue #853)
  registerExecuteSpecTool,
  ExecuteSpecInputSchema,
  type ExecuteSpecInput,
  type ExecuteSpecDeps,
  // Codebase search tool (Issue #1567)
  registerSearchCodebaseTool,
  SearchCodebaseInputSchema,
  type SearchCodebaseDeps,
  // Symbol extraction tool (Issue #1559)
  registerExtractSymbolsTool,
  ExtractSymbolsInputSchema,
  type ExtractSymbolsDeps,
  // Query trace tool (Epic #952, Phase 5)
  registerQueryTraceTool,
  QueryTraceInputSchema,
  queryTraceFromDisk,
  type QueryTraceDeps,
  type QueryTraceInput,
  type QueryTraceResponse,
  // Query task state tool (#2046)
  registerQueryTaskStateTool,
  QueryTaskStateInputSchema,
  type QueryTaskStateDeps,
  type QueryTaskStateInput,
  type QueryTaskStateResponse,
  // Verify audit chain tool (#2281 follow-up)
  registerVerifyAuditChainTool,
  VerifyAuditChainInputSchema,
  type VerifyAuditChainDeps,
  type VerifyAuditChainInput,
  type VerifyAuditChainResponse,
} from './tools/index.js';

// Gateway — Tiered Orchestration Routing (Issue #888, #892, #893, #894)
export {
  classifyRequestTier,
  RequestTier,
  TOOL_TIER_MAP,
  type TierOverrides,
  createGateway,
  type GatewayConfig,
  type GatewayInstance,
  type GatewayToolHandler,
  type GatewayToolResult,
  type GatewayLogEntry,
  classifyWithGovernance,
  auditGovernancePromotion,
  type GovernanceClassification,
  type GovernanceDomain,
  type VotingThreshold,
  generateTierRecommendations,
  type TierRecommendation,
  type TierRecommenderConfig,
  type TierDirection,
} from './gateway/index.js';

// STPA Safety Analysis Framework (Issue #328)
export {
  // Types and Enums
  HazardCategory,
  HazardSeverity,
  HazardLikelihood,
  UnsafeControlActionType,
  ConstraintEnforcement,
  ConstraintPriority,
  RiskLevel,
  ToolCategory,
  type Hazard,
  type UnsafeControlAction,
  type TriggerPattern,
  type SafetyConstraint,
  type ToolAnalysisResult,
  type StpaAnalysisResult,
  type AnalysisSummary,
  type HazardInteraction,
  type AnalysisMetadata,
  type AnalysisConfiguration,
  type AnalysisConfigurationInput,
  type ToolDefinition,
  type ToolInputSchema,
  type PropertySchema,
  type ValidationResult,
  type ConstraintViolation,
  type ValidationWarning,
  // Schemas
  HazardCategorySchema,
  ToolDefinitionSchema,
  AnalysisConfigurationSchema,
  DEFAULT_ANALYSIS_CONFIG,
  // Hazard Catalog
  classifyTool,
  classifyToolMultiple,
  getHazardsForTool,
  getTriggerPatternsForCategory,
  FILE_READ_HAZARDS,
  FILE_WRITE_HAZARDS,
  FILE_DELETE_HAZARDS,
  SHELL_EXECUTE_HAZARDS,
  NETWORK_HAZARDS,
  DATABASE_HAZARDS,
  AUTH_HAZARDS,
  ORCHESTRATION_HAZARDS,
  PATH_TRIGGER_PATTERNS,
  SHELL_TRIGGER_PATTERNS,
  NETWORK_TRIGGER_PATTERNS,
  HAZARD_CATALOG,
  // Analyzer
  analyzeToolForHazards,
  generateUnsafeControlActions,
  generateSafetyConstraints,
  validateToolAgainstConstraints,
  analyzeTools,
  StpaAnalysisError,
} from './safety/index.js';
