sealed class StreamEvent {}

class ThinkingEvent extends StreamEvent {
  final String content;
  ThinkingEvent(this.content);
}

class TextEvent extends StreamEvent {
  final String content;
  TextEvent(this.content);
}

class ToolUseEvent extends StreamEvent {
  final String toolName;
  final Map<String, dynamic> input;
  ToolUseEvent(this.toolName, this.input);
}

class ToolResultEvent extends StreamEvent {
  final String toolName;
  final String output;
  final bool isError;
  ToolResultEvent(this.toolName, this.output, this.isError);
}

class ApprovalRequiredEvent extends StreamEvent {
  final String taskId;
  final String command;
  final int riskLevel;
  ApprovalRequiredEvent(this.taskId, this.command, this.riskLevel);
}

class CompletedEvent extends StreamEvent {
  final String summary;
  CompletedEvent(this.summary);
}

class ErrorEvent extends StreamEvent {
  final String message;
  ErrorEvent(this.message);
}

class StandingOrderDraftEvent extends StreamEvent {
  final Map<String, dynamic> draft;
  StandingOrderDraftEvent(this.draft);
}

class StandingOrderConfirmedEvent extends StreamEvent {
  final String orderId;
  final String orderName;
  StandingOrderConfirmedEvent(this.orderId, this.orderName);
}

/// Carries the real sessionId assigned by the backend.
class SessionInfoEvent extends StreamEvent {
  final String sessionId;
  SessionInfoEvent(this.sessionId);
}

/// Carries the taskId assigned by the backend for cancel tracking.
class TaskInfoEvent extends StreamEvent {
  final String taskId;
  TaskInfoEvent(this.taskId);
}

/// Emitted when a task is cancelled (by user or by injection).
class CancelledEvent extends StreamEvent {
  CancelledEvent();
}
