/**
 * Tool Tier Configuration
 *
 * Controls which tools are exposed by default vs on-demand.
 * Tier 1: Always exposed (small browser essentials for every session)
 * Tier 2: Exposed on demand (specialist/niche tools)
 * Tier 3: Orchestration only (workflow lifecycle tools)
 */

export type ToolTier = 1 | 2 | 3;

/** Map of tool name → tier assignment */
export const TOOL_TIERS: Record<string, ToolTier> = {
  // Tier 1: Browser essentials (always exposed)
  navigate: 1,
  computer: 1,
  read_page: 1,
  find: 1,
  query_dom: 1,
  interact: 1,
  form_input: 1,
  tabs_context: 1,
  tabs_create: 1,
  tabs_close: 1,
  wait_for: 1,
  page_screenshot: 1,
  oc_connection_health: 1,
  oc_stop: 1,

  // Tier 2: Specialist (on demand)
  javascript_tool: 2,
  network: 2,
  page_reload: 2,
  cookies: 2,
  page_content: 2,
  storage: 2,
  user_agent: 2,
  geolocation: 2,
  emulate_device: 2,
  page_pdf: 2,
  console_capture: 2,
  performance_metrics: 2,
  request_intercept: 2,
  network_capture_lite: 2,
  network_capture_full: 2,
  file_upload: 2,
  http_auth: 2,
  drag_drop: 2,
  fill_form: 2,
  batch_execute: 2,
  lightweight_scroll: 2,
  batch_paginate: 2,
  inspect: 2,
  vision_find: 2,
  memory: 2,
  oc_query: 2,
  oc_reap_orphans: 2,
  oc_profile_status: 2,
  list_profiles: 2,
  oc_session_snapshot: 2,
  oc_session_resume: 2,
  oc_journal: 2,
  oc_reflect: 2,
  oc_policy: 2,
  oc_checkpoint: 2,
  oc_get_connection_info: 2,
  oc_copy_to_clipboard: 2,
  oc_open_host_settings: 2,
  oc_recording_start: 2,
  oc_recording_stop: 2,
  oc_recording_status: 2,
  oc_recording_list: 2,
  oc_recording_export: 2,
  crawl: 2,
  crawl_sitemap: 2,
  crawl_start: 2,
  crawl_status: 2,
  crawl_cancel: 2,
  act: 2,
  validate_page: 2,
  extract_data: 2,
  oc_totp_generate: 2,
  oc_assert: 2,
  oc_journal_compact: 2,
  image_qa: 2,
  oc_gate_inspect: 2,
  oc_normalize_action: 2,
  oc_progress_status: 2,
  oc_vitals: 2,
  oc_output_fetch: 2,
  oc_evidence_bundle: 2,
  oc_diff: 2,
  oc_skill_record: 2,
  oc_skill_recall: 2,
  oc_skill_export: 2,
  oc_doctor_report: 2,
  oc_performance_insights: 2,
  oc_performance_analyze: 2,
  oc_observe: 2,
  element_pick: 2,
  oc_devtools_url: 2,
  oc_context_export: 2,
  oc_context_import: 2,

  // Tier 3: Orchestration only
  worker: 3,
  workflow_init: 3,
  workflow_status: 3,
  workflow_collect: 3,
  workflow_collect_partial: 3,
  workflow_cleanup: 3,
  worker_update: 3,
  worker_complete: 3,
  execute_plan: 3,
  oc_task_start: 3,
  oc_task_list: 3,
  oc_task_get: 3,
  oc_task_cancel: 3,
  oc_task_wait: 3,
  oc_task_update: 3,
  oc_task_finish: 3,
  oc_lane_create: 3,
  oc_lane_list: 3,
  oc_lane_get: 3,
  oc_lane_close: 3,
  oc_run_start: 3,
  oc_run_status: 3,
  oc_run_events: 3,
  oc_run_finish: 3,
  oc_task_run_start: 3,
  oc_task_run_update: 3,
  oc_task_run_checkpoint: 3,
  oc_task_run_needs_help: 3,
  oc_task_run_complete: 3,
  oc_task_run_get: 3,
  oc_task_run_list: 3,
};

/** Get the tier for a tool (defaults to on-demand so new tools do not bloat startup). */
export function getToolTier(toolName: string): ToolTier {
  return TOOL_TIERS[toolName] ?? 2;
}
