// <openspace-protocol-events:generated>
// Generated by python -m openspace.protocol.codegen --write
export const TUI_TO_CORE_MSG_TYPES = [
  "query",
  "cancel",
  "permission_response",
  "tool_permission_response",
  "prompt_response",
  "slash_command",
  "resume_session",
  "settings_update",
  "mcp_reconnect",
  "elicitation_response",
  "agent_input",
  "background_control",
  "tui_unavailable",
] as const;

export const CORE_TO_TUI_MSG_TYPES = [
  "llm_start",
  "llm_token",
  "llm_complete",
  "tool_start",
  "tool_progress",
  "tool_complete",
  "tool_error",
  "permission_request",
  "tool_permission_ask",
  "prompt_request",
  "tool_permission_cancel",
  "iteration_start",
  "iteration_end",
  "compact_start",
  "compact_complete",
  "token_warning",
  "memory_selector",
  "memory_saved",
  "memory_logged",
  "memory_extraction_start",
  "memory_extraction_complete",
  "memory_extraction_error",
  "auto_dream_start",
  "auto_dream_progress",
  "auto_dream_complete",
  "auto_dream_error",
  "auto_dream_cancelled",
  "task_start",
  "task_progress",
  "task_complete",
  "task_error",
  "skill_selected",
  "session_list",
  "session_restored",
  "doctor_result",
  "status_update",
  "settings_update",
  "mcp_status",
  "elicitation_request",
  "notification",
  "command_result",
  "agent_list",
  "agent_event",
  "agent_transcript",
  "background_session_update",
  "agent_start",
  "agent_progress",
  "agent_output",
  "agent_error",
  "agent_complete",
  "agent_spawn",
  "agent_task_update",
  "agent_task_complete",
  "team_update",
  "todo_update",
  "task_started",
  "task_completed",
  "task_failed",
  "task_stopped",
  "hook_start",
  "hook_complete",
  "hook_message",
  "hook_non_blocking_error",
  "stop_hook_summary",
  "stop_hook_message",
  "conversation_recovery",
  "token_budget_continue",
  "token_budget_completed",
  "time_based_microcompact",
  "nested_memory_consumed",
  "dynamic_skills_consumed",
  "skill_discovery_prefetch_consumed",
  "cost_summary",
  "side_query_start",
  "side_query_complete",
  "side_query_cancelled",
  "side_query_error",
  "llm_retry",
  "memory_extraction_skipped",
  "memory_extraction_coalesced",
  "memory_extraction_trailing_start",
  "session_memory_extraction_skipped",
  "session_memory_extraction_complete",
  "session_memory_extraction_error",
  "session_memory_extraction_coalesced",
  "session_memory_extraction_trailing_start",
  "session_memory_compact",
  "session_memory_compact_skipped",
  "session_memory_compact_resumed_session",
  "session_memory_checked",
  "session_memory_updated",
  "tool_cancelled",
  "tool_deferred_intercepted",
  "bash_tool_command_executed",
  "tool_executing",
  "tool_hook_stopped",
  "tool_permission_denied",
  "tool_pipeline_complete",
  "tool_quality_recorded",
  "tool_validation_error",
  "task_finished_pre_persist",
  "task_session_persisted",
  "background_drain",
  "memory_background_drain_timeout",
  "background_housekeeping_drain_timeout",
  "background_housekeeping_idle",
  "background_housekeeping_cleanup_complete",
  "background_housekeeping_recurring_cleanup",
  "quality_signal_checkpoint_warning",
] as const;

export type TuiToCoreMsgType = typeof TUI_TO_CORE_MSG_TYPES[number];

export type CoreToTuiMsgType = typeof CORE_TO_TUI_MSG_TYPES[number];

export type EventType = TuiToCoreMsgType | CoreToTuiMsgType;

const KNOWN_EVENT_TYPES: ReadonlySet<string> = new Set([
  "query",
  "cancel",
  "permission_response",
  "tool_permission_response",
  "prompt_response",
  "slash_command",
  "resume_session",
  "settings_update",
  "mcp_reconnect",
  "elicitation_response",
  "agent_input",
  "background_control",
  "tui_unavailable",
  "llm_start",
  "llm_token",
  "llm_complete",
  "tool_start",
  "tool_progress",
  "tool_complete",
  "tool_error",
  "permission_request",
  "tool_permission_ask",
  "prompt_request",
  "tool_permission_cancel",
  "iteration_start",
  "iteration_end",
  "compact_start",
  "compact_complete",
  "token_warning",
  "memory_selector",
  "memory_saved",
  "memory_logged",
  "memory_extraction_start",
  "memory_extraction_complete",
  "memory_extraction_error",
  "auto_dream_start",
  "auto_dream_progress",
  "auto_dream_complete",
  "auto_dream_error",
  "auto_dream_cancelled",
  "task_start",
  "task_progress",
  "task_complete",
  "task_error",
  "skill_selected",
  "session_list",
  "session_restored",
  "doctor_result",
  "status_update",
  "mcp_status",
  "elicitation_request",
  "notification",
  "command_result",
  "agent_list",
  "agent_event",
  "agent_transcript",
  "background_session_update",
  "agent_start",
  "agent_progress",
  "agent_output",
  "agent_error",
  "agent_complete",
  "agent_spawn",
  "agent_task_update",
  "agent_task_complete",
  "team_update",
  "todo_update",
  "task_started",
  "task_completed",
  "task_failed",
  "task_stopped",
  "hook_start",
  "hook_complete",
  "hook_message",
  "hook_non_blocking_error",
  "stop_hook_summary",
  "stop_hook_message",
  "conversation_recovery",
  "token_budget_continue",
  "token_budget_completed",
  "time_based_microcompact",
  "nested_memory_consumed",
  "dynamic_skills_consumed",
  "skill_discovery_prefetch_consumed",
  "cost_summary",
  "side_query_start",
  "side_query_complete",
  "side_query_cancelled",
  "side_query_error",
  "llm_retry",
  "memory_extraction_skipped",
  "memory_extraction_coalesced",
  "memory_extraction_trailing_start",
  "session_memory_extraction_skipped",
  "session_memory_extraction_complete",
  "session_memory_extraction_error",
  "session_memory_extraction_coalesced",
  "session_memory_extraction_trailing_start",
  "session_memory_compact",
  "session_memory_compact_skipped",
  "session_memory_compact_resumed_session",
  "session_memory_checked",
  "session_memory_updated",
  "tool_cancelled",
  "tool_deferred_intercepted",
  "bash_tool_command_executed",
  "tool_executing",
  "tool_hook_stopped",
  "tool_permission_denied",
  "tool_pipeline_complete",
  "tool_quality_recorded",
  "tool_validation_error",
  "task_finished_pre_persist",
  "task_session_persisted",
  "background_drain",
  "memory_background_drain_timeout",
  "background_housekeeping_drain_timeout",
  "background_housekeeping_idle",
  "background_housekeeping_cleanup_complete",
  "background_housekeeping_recurring_cleanup",
  "quality_signal_checkpoint_warning",
]);

export function isKnownEventType(value: string): value is EventType {
  return KNOWN_EVENT_TYPES.has(value);
}

export function makeProtocolWarningMessage(
  eventType: string,
  reason: string,
): IPCMessage<"notification"> {
  return {
    type: "notification",
    data: {
      level: "warn",
      title: "Protocol warning",
      message: `${reason}: ${eventType}`,
      event_type: eventType,
    },
  };
}
// </openspace-protocol-events:generated>

// ── Per-event data shapes ───────────────────────────────────────

export interface QueryData {
  text: string;
  attachments?: string[];
}

export interface CancelData {
  reason?: string;
}

export interface PermissionResponseData {
  tool_use_id: string;
  decision: "allow" | "deny" | "allow_always";
  pattern?: string; // glob for allow_always
}

export interface ToolPermissionResponseData {
  tool_use_id: string;
  option_id?: "allow_once" | "allow_always" | "deny" | "provide_input";
  suggestion_index?: number | null;
  selected_suggestion?: number | null;
  edited_input?: Record<string, unknown>;
  updated_input?: Record<string, unknown>;
  message?: string;
}

export interface PromptResponseData {
  prompt_id: string;
  decision: "submit" | "cancel";
  value?: string;
}

export interface SlashCommandData {
  command: string;
  args?: string[];
}

export interface ResumeSessionData {
  action: "list" | "restore" | "fork" | "rewind";
  session_id?: string;
  messages?: StructuredMessageData[];
  page?: number;
  page_size?: number;
  all_projects?: boolean;
  show_all_projects?: boolean;
}

export interface SettingsUpdateData {
  key: string;
  value: unknown;
}

export interface McpReconnectData {
  server_name: string;
}

export interface ElicitationResponseData {
  elicitation_id: string;
  values: Record<string, unknown>;
}

export interface AgentInputData {
  agent_id: string;
  text: string;
}

export interface BackgroundControlData {
  action:
    | "start"
    | "stop"
    | "pause"
    | "resume"
    | "focus"
    | "status"
    | "snapshot"
    | "background_all_foreground_tasks";
  session_id?: string;
  task_id?: string;
  agent_id?: string;
  title?: string;
}

export interface TuiUnavailableData {
  message: string;
  reason?: string;
}

export interface LLMStartData {
  model: string;
  turn: number;
}

export interface LLMTokenData {
  token: string;
}

export interface LLMCompleteData {
  input_tokens: number;
  output_tokens: number;
  stop_reason: string;
}

export interface ToolStartData {
  tool_use_id: string;
  tool_name: string;
  tool_input: Record<string, unknown>;
}

export interface ToolProgressData {
  tool_use_id: string;
  progress: string;
}

export interface ToolCompleteData {
  tool_use_id: string;
  result?: unknown;
  status?: string;
  duration_ms?: number;
  result_size_chars?: number;
  has_multimodal_content?: boolean;
}

export interface ToolErrorData {
  tool_use_id: string;
  error: string;
}

export interface PermissionRequestData {
  tool_use_id: string;
  tool_name: string;
  tool_input: Record<string, unknown>;
  risk_level?: "low" | "medium" | "high";
  description?: string;
  message?: string;
  request_kind?: "tool" | "network" | "sandbox";
  host?: string;
  origin?: "primary" | "worker";
  agent_id?: string;
  agent_name?: string;
  agent_color?: string;
  allow_always_pattern?: string;
  response_channel?: "permission_response" | "tool_permission_response";
  options?: ToolPermissionOptionData[];
  blocked_path?: string | null;
  decision_reason?: Record<string, unknown> | null;
  interaction?: "ask_user_question" | string;
  requires_user_interaction?: boolean;
  questions?: AskUserQuestionData[];
  metadata?: Record<string, unknown>;
}

export interface ToolPermissionOptionData {
  option_id: NonNullable<ToolPermissionResponseData["option_id"]>;
  label: string;
  suggestion_index?: number | null;
}

export interface AskUserQuestionOptionData {
  label: string;
  description?: string;
  preview?: string;
}

export interface AskUserQuestionData {
  header?: string;
  question: string;
  options: AskUserQuestionOptionData[];
  multiSelect?: boolean;
}

export type ToolPermissionAskData = PermissionRequestData & {
  response_channel?: "tool_permission_response";
  options: ToolPermissionOptionData[];
};

export interface PromptRequestData {
  prompt_id: string;
  title?: string;
  description?: string;
  default_value?: string;
  placeholder?: string;
  multiline?: boolean;
}

export interface ToolPermissionCancelData {
  tool_use_id: string;
  reason?: string;
}

export function isToolPermissionPromptForCancel(
  promptId: string,
  cancel: ToolPermissionCancelData,
): boolean {
  const toolUseId = cancel.tool_use_id.trim();
  if (toolUseId.length === 0) {
    return false;
  }
  const prefix = `tool-permission-${toolUseId}-`;
  if (!promptId.startsWith(prefix)) {
    return false;
  }
  const stage = promptId.slice(prefix.length);
  return (
    stage === "choice" ||
    stage === "edit" ||
    /^ask-(other-)?\d+$/.test(stage)
  );
}

export interface IterationData {
  turn?: number;
  iteration?: number;
  max_iterations?: number;
  status?: string;
  tool_calls_count?: number;
}

export type CompactTrigger = "auto" | "manual" | "prompt_too_long";

export interface CompactEventData {
  trigger?: CompactTrigger;
  reason?: string;
  direction?: "from" | "up_to" | string;
  pre_compact_token_count?: number;
  true_post_compact_token_count?: number;
  post_compact_token_count?: number;
  messages_before?: number;
  messages_after?: number;
  tokens_saved?: number;
  success?: boolean;
  messages?: StructuredMessageData[];
}

export type CompactData = CompactEventData;

export interface TokenWarningEventData {
  token_count?: number;
  model?: string;
  percent_left: number;
  is_above_warning_threshold: boolean;
  is_above_error_threshold: boolean;
  is_above_auto_compact_threshold: boolean;
  is_at_blocking_limit: boolean;
}

export interface MemoryTargetData {
  label: string;
  path: string;
  kind: string;
  description?: string;
  exists?: boolean;
  is_folder?: boolean;
  display_path?: string;
}

export interface MemorySelectorData {
  cwd?: string;
  targets: MemoryTargetData[];
}

export interface MemorySavedEventData {
  memory_paths?: string[];
  verb?: "Saved" | "Improved" | string;
  source?: "extract" | "auto_dream" | "manual_dream" | "daily_log" | "direct" | string;
  message?: unknown;
  log_entry_ids?: string[];
}

export interface MemoryLoggedEventData {
  memory_dir?: string;
  log_path?: string;
  log_paths?: string[];
  entry_ids?: string[];
  entry_count?: number;
  session_id?: string;
  source?: string;
}

export interface MemoryExtractionStartData {
  task_id?: string;
  message_count?: number;
  memory_mode?: string;
  memory_dir?: string;
  is_trailing_run?: boolean;
}

export interface MemoryExtractionCompleteData {
  task_id?: string;
  message_count?: number;
  turn_count?: number;
  files_written?: number;
  memories_saved?: number;
  input_tokens?: number;
  output_tokens?: number;
  duration_ms?: number;
  memory_mode?: string;
  logged_entry_ids?: string[];
  logs_written?: number;
}

export interface MemoryExtractionErrorData {
  task_id?: string;
  duration_ms?: number;
  error: string;
}

export interface AutoDreamEventData {
  task_id?: string;
  phase?: "starting" | "scanning" | "consolidating" | "updating" | "complete" | "error" | "cancelled" | string;
  sessions_reviewing?: number;
  sessions_reviewed?: number;
  memory_dir?: string;
  files_touched?: string[];
  log_entry_ids?: string[];
  turn_count?: number;
  input_tokens?: number;
  output_tokens?: number;
  duration_ms?: number;
  source?: string;
  error?: string;
  turn?: {
    text?: string;
    tool_use_count?: number;
  };
}

export interface TaskStartData {
  task_id: string;
  title?: string;
  status?: string;
}

export interface TaskProgressData {
  task_id: string;
  title?: string;
  status?: string;
  progress?: string;
}

export interface TaskCompleteData {
  result?: string;
  task_id?: string;
  status?: string;
  iterations?: number;
  tool_calls?: number;
  execution_time?: number;
}

export interface TaskErrorData {
  error: string;
  task_id?: string;
  execution_time?: number;
}

export interface SkillSelectedData {
  skill_name?: string;
  skill_ids?: string[];
}

export type StructuredMessageContentBlock =
  | {
      type: "text";
      text: string;
    }
  | {
      type: "tool_use";
      tool_name?: string;
      tool_use_id?: string;
      tool_input?: unknown;
      status?: "pending" | "running" | "complete" | "error";
      summary?: string;
      result?: string;
      error?: string;
    }
  | {
      type: "status";
      text: string;
      level?: "info" | "warn" | "error";
    }
  | {
      type: "field";
      label: string;
      value: string;
    }
  | {
      type: string;
      [key: string]: unknown;
    };

export interface StructuredMessageData {
  id?: string;
  role?: string;
  text?: string;
  content?: string | StructuredMessageContentBlock[];
  timestamp?: number | string;
  meta?: Record<string, unknown>;
  [key: string]: unknown;
}

export interface SessionSummaryItem {
  session_id: string;
  title?: string;
  first_prompt?: string;
  cwd?: string;
  project_root?: string;
  project_path?: string;
  worktree_path?: string;
  agent_name?: string;
  agent_type?: string;
  mode?: string;
  cost?: number | null;
  forked_from?: string;
  same_project?: boolean;
  preview: string;
  updated_at: string;
  last_active_at?: string;
  created_at?: string;
  message_count: number;
  cross_project?: boolean;
  cross_project_result?: Record<string, unknown>;
  session_dir?: string;
  transcript_path?: string;
}

export interface SessionListData {
  sessions: SessionSummaryItem[];
  total?: number;
  page?: number;
  page_size?: number;
  has_more?: boolean;
}

export interface SessionRestoredData {
  session_id: string;
  title?: string;
  mode?: string;
  metadata: Record<string, unknown>;
  runtime: Record<string, unknown>;
  messages: StructuredMessageData[];
  cost?: number | null;
  agent?: Record<string, unknown> | null;
  standalone_agent_context?: Record<string, unknown> | null;
  worktree?: Record<string, unknown> | null;
  file_history_snapshots?: unknown[];
  content_replacements?: unknown[];
}

export interface DoctorResultData {
  section: string;
  section_title?: string;
  section_order?: number;
  section_status?: "pass" | "warn" | "fail" | "info";
  checks: Array<{
    name: string;
    status: "pass" | "warn" | "fail";
    message: string;
    details?: string;
  }>;
  summary?: string;
  run_id?: string;
  section_done?: boolean;
  run_done?: boolean;
  done?: boolean;
}

export interface SandboxDependencyIssueData {
  severity?: "error" | "warning" | string;
  code?: string;
  message?: string;
  remediation?: string;
}

export interface SandboxViolationData {
  command?: string;
  command_tag?: string;
  platform?: string;
  operation?: string;
  path?: string | null;
  domain?: string | null;
  raw_message?: string;
  timestamp_ms?: number;
}

export interface SandboxStatusData {
  status?: "pass" | "warn" | "fail" | string;
  mode?: "disabled" | "unavailable" | "auto-allow" | "regular" | string;
  platform?: string;
  supported_platform?: boolean;
  platform_enabled?: boolean;
  enabled_in_settings?: boolean;
  sandboxing_enabled?: boolean;
  fail_if_unavailable?: boolean;
  auto_allow_bash_if_sandboxed?: boolean;
  allow_unsandboxed_commands?: boolean;
  enabled_platforms?: string[] | null;
  settings_locked?: boolean;
  unavailable_reason?: string | null;
  dependency_errors?: SandboxDependencyIssueData[];
  dependency_warnings?: SandboxDependencyIssueData[];
  linux_glob_warnings?: string[];
  excluded_commands_count?: number;
  violation_count?: number;
  recent_violation_count?: number;
  recent_violations?: SandboxViolationData[];
}

export interface StatusUpdateData {
  phase?: string;
  model?: string;
  input_tokens?: number;
  output_tokens?: number;
  cache_read_input_tokens?: number;
  cache_creation_input_tokens?: number;
  reasoning_tokens?: number;
  cost_usd?: number;
  unknown_model_cost?: boolean;
  session_id?: string;
  task_id?: string;
  max_iterations?: number;
  total_iterations?: number;
  sandbox?: SandboxStatusData;
}

export interface McpStatusData {
  server_name: string;
  status: "connected" | "disconnected" | "error";
  error?: string;
  message?: string;
  tools?: Array<{
    name: string;
    description?: string;
    server_name?: string;
  }>;
  commands?: Array<{
    name: string;
    description: string;
    handler: "local" | "core";
    aliases?: string[];
    availability?: Array<"local" | "core">;
  }>;
  resources?: Record<string, string[]>;
}

export interface ElicitationRequestData {
  elicitation_id: string;
  server_name: string;
  message: string;
  schema?: Record<string, unknown>;
}

export interface AgentListData {
  session_id?: string;
  agents: Array<Record<string, unknown>>;
}

export interface AgentEventData {
  session_id?: string;
  run_index?: number;
  event_count?: number;
  event_id?: string;
  agent_id?: string;
  event?: string;
  event_type?: string;
  kind?: string;
  timestamp?: number | string;
  source?: string;
  payload?: Record<string, unknown>;
}

export interface AgentTranscriptData {
  session_id?: string;
  agent_id: string;
  messages: StructuredMessageData[];
}

export interface BackgroundSessionUpdateData {
  session_id?: string;
  task_id?: string;
  status?: string;
  title?: string;
  run_index?: number;
  created_at?: string;
  started_at?: string;
  finished_at?: string;
  updated_at?: string;
  primary_agent_id?: string;
  active_agent_id?: string;
  agent_count?: number;
  event_count?: number;
  transcript_count?: number;
  metadata?: Record<string, unknown>;
}

export interface AgentSpawnData {
  session_id?: string;
  agent_id?: string;
  agent_type?: string;
  name?: string;
  team_name?: string;
  description?: string;
  status?: string;
  background?: boolean;
  task_id?: string;
  model?: string;
}

export interface AgentTaskUpdateData {
  session_id?: string;
  task_id?: string;
  agent_id?: string;
  agent_type?: string;
  task_type?: string;
  team_name?: string;
  description?: string;
  current_operation?: string;
  status?: string;
  command?: string;
  output_file?: string;
  output_tail?: string;
  parent_task_id?: string;
  model?: string;
  is_backgrounded?: boolean;
  backgrounded_by_user?: boolean;
  assistant_auto_backgrounded?: boolean;
  kind?: string;
  pid?: number;
  exit_code?: number | null;
  interrupted?: boolean | null;
  start_time?: number;
  end_time?: number;
  elapsed_ms?: number;
  progress?: Record<string, unknown>;
  error?: string;
}

export interface RuntimeActivityData {
  [key: string]: unknown;
  session_id?: string;
  task_id?: string;
  agent_id?: string;
  name?: string;
  status?: string;
  summary?: string;
  message?: string;
  description?: string;
  current_operation?: string;
  content?: string;
  error?: string;
  timestamp?: number | string;
  metadata?: Record<string, unknown>;
}

export interface HookEventData extends RuntimeActivityData {
  hook_event?: string;
  hook_name?: string;
  hook_count?: number;
}

export interface TeamUpdateData {
  session_id?: string;
  action?: string;
  status?: string;
  team_name?: string;
  description?: string;
  lead_agent_id?: string;
  lead_agent_type?: string;
  running_workers?: number;
  total_workers?: number;
  message?: string;
}

export interface TodoUpdateData {
  session_id?: string;
  todo_key?: string;
  agent_id?: string;
  oldTodos?: Array<Record<string, unknown>>;
  newTodos?: Array<Record<string, unknown>>;
  storedTodos?: Array<Record<string, unknown>>;
  todos?: Array<Record<string, unknown>>;
  all_done?: boolean;
  verificationNudgeNeeded?: boolean;
}

export interface NotificationData {
  level: "info" | "warn" | "error";
  title: string;
  message: string;
  event_type?: string;
}

export interface CommandResultData {
  command: string;
  message?: string;
  display?: "system" | "user" | "skip";
  clear_messages?: boolean;
  next_input?: string;
  submit_next_input?: boolean;
}

// ── Unified IPC message envelope ────────────────────────────────

// <openspace-protocol-event-data-map:generated>
// Generated by python -m openspace.protocol.codegen --write
export type EventDataMap = {
  query: QueryData;
  cancel: CancelData;
  permission_response: PermissionResponseData;
  tool_permission_response: ToolPermissionResponseData;
  prompt_response: PromptResponseData;
  slash_command: SlashCommandData;
  resume_session: ResumeSessionData;
  settings_update: SettingsUpdateData;
  mcp_reconnect: McpReconnectData;
  elicitation_response: ElicitationResponseData;
  agent_input: AgentInputData;
  background_control: BackgroundControlData;
  tui_unavailable: TuiUnavailableData;
  llm_start: LLMStartData;
  llm_token: LLMTokenData;
  llm_complete: LLMCompleteData;
  tool_start: ToolStartData;
  tool_progress: ToolProgressData;
  tool_complete: ToolCompleteData;
  tool_error: ToolErrorData;
  permission_request: PermissionRequestData;
  tool_permission_ask: ToolPermissionAskData;
  prompt_request: PromptRequestData;
  tool_permission_cancel: ToolPermissionCancelData;
  iteration_start: IterationData;
  iteration_end: IterationData;
  compact_start: CompactData;
  compact_complete: CompactData;
  token_warning: TokenWarningEventData;
  memory_selector: MemorySelectorData;
  memory_saved: MemorySavedEventData;
  memory_logged: MemoryLoggedEventData;
  memory_extraction_start: MemoryExtractionStartData;
  memory_extraction_complete: MemoryExtractionCompleteData;
  memory_extraction_error: MemoryExtractionErrorData;
  auto_dream_start: AutoDreamEventData;
  auto_dream_progress: AutoDreamEventData;
  auto_dream_complete: AutoDreamEventData;
  auto_dream_error: AutoDreamEventData;
  auto_dream_cancelled: AutoDreamEventData;
  task_start: TaskStartData;
  task_progress: TaskProgressData;
  task_complete: TaskCompleteData;
  task_error: TaskErrorData;
  skill_selected: SkillSelectedData;
  session_list: SessionListData;
  session_restored: SessionRestoredData;
  doctor_result: DoctorResultData;
  status_update: StatusUpdateData;
  mcp_status: McpStatusData;
  elicitation_request: ElicitationRequestData;
  notification: NotificationData;
  command_result: CommandResultData;
  agent_list: AgentListData;
  agent_event: AgentEventData;
  agent_transcript: AgentTranscriptData;
  background_session_update: BackgroundSessionUpdateData;
  agent_start: RuntimeActivityData;
  agent_progress: RuntimeActivityData;
  agent_output: RuntimeActivityData;
  agent_error: RuntimeActivityData;
  agent_complete: RuntimeActivityData;
  agent_spawn: AgentSpawnData;
  agent_task_update: AgentTaskUpdateData;
  agent_task_complete: AgentTaskUpdateData;
  team_update: TeamUpdateData;
  todo_update: TodoUpdateData;
  task_started: AgentTaskUpdateData;
  task_completed: AgentTaskUpdateData;
  task_failed: AgentTaskUpdateData;
  task_stopped: AgentTaskUpdateData;
  hook_start: HookEventData;
  hook_complete: HookEventData;
  hook_message: RuntimeActivityData;
  hook_non_blocking_error: RuntimeActivityData;
  stop_hook_summary: RuntimeActivityData;
  stop_hook_message: RuntimeActivityData;
  conversation_recovery: RuntimeActivityData;
  token_budget_continue: RuntimeActivityData;
  token_budget_completed: RuntimeActivityData;
  time_based_microcompact: RuntimeActivityData;
  nested_memory_consumed: RuntimeActivityData;
  dynamic_skills_consumed: RuntimeActivityData;
  skill_discovery_prefetch_consumed: RuntimeActivityData;
  cost_summary: RuntimeActivityData;
  side_query_start: RuntimeActivityData;
  side_query_complete: RuntimeActivityData;
  side_query_cancelled: RuntimeActivityData;
  side_query_error: RuntimeActivityData;
  llm_retry: RuntimeActivityData;
  memory_extraction_skipped: RuntimeActivityData;
  memory_extraction_coalesced: RuntimeActivityData;
  memory_extraction_trailing_start: RuntimeActivityData;
  session_memory_extraction_skipped: RuntimeActivityData;
  session_memory_extraction_complete: RuntimeActivityData;
  session_memory_extraction_error: RuntimeActivityData;
  session_memory_extraction_coalesced: RuntimeActivityData;
  session_memory_extraction_trailing_start: RuntimeActivityData;
  session_memory_compact: RuntimeActivityData;
  session_memory_compact_skipped: RuntimeActivityData;
  session_memory_compact_resumed_session: RuntimeActivityData;
  session_memory_checked: RuntimeActivityData;
  session_memory_updated: RuntimeActivityData;
  tool_cancelled: RuntimeActivityData;
  tool_deferred_intercepted: RuntimeActivityData;
  bash_tool_command_executed: RuntimeActivityData;
  tool_executing: RuntimeActivityData;
  tool_hook_stopped: RuntimeActivityData;
  tool_permission_denied: RuntimeActivityData;
  tool_pipeline_complete: RuntimeActivityData;
  tool_quality_recorded: RuntimeActivityData;
  tool_validation_error: RuntimeActivityData;
  task_finished_pre_persist: RuntimeActivityData;
  task_session_persisted: RuntimeActivityData;
  background_drain: RuntimeActivityData;
  memory_background_drain_timeout: RuntimeActivityData;
  background_housekeeping_drain_timeout: RuntimeActivityData;
  background_housekeeping_idle: RuntimeActivityData;
  background_housekeeping_cleanup_complete: RuntimeActivityData;
  background_housekeeping_recurring_cleanup: RuntimeActivityData;
  quality_signal_checkpoint_warning: RuntimeActivityData;
};
// </openspace-protocol-event-data-map:generated>

export interface IPCMessage<T extends EventType = EventType> {
  type: T;
  data: T extends keyof EventDataMap ? EventDataMap[T] : unknown;
  timestamp?: number; // epoch-ms timestamp, added automatically by send()
}
