export type UISurface = "chat_inline" | "side_panel" | "canvas" | "map_overlay";

export type UIEnvelope =
  | {
      kind: "registered_component";
      schemaVersion: "agent-ui@1";
      component: string;
      surface: UISurface;
      props: unknown;
      data?: unknown;
      fallbackText?: string;
    }
  | {
      kind: "chart";
      schemaVersion: "agent-ui@1";
      grammar: "echarts-safe-subset";
      surface: "chat_inline" | "side_panel" | "canvas";
      spec: unknown;
      data: unknown;
      fallbackText?: string;
    }
  | {
      kind: "map_action";
      schemaVersion: "agent-ui@1";
      action: string;
      surface: "map_overlay";
      params: unknown;
      fallbackText?: string;
    };

export type UIEnvelopePayload = {
  session_id: string;
  envelope_id: string;
  created_at: number;
  envelope: UIEnvelope;
};

export type UIRegistry = {
  schema_version: "agent-ui-registry@1";
  chart_grammars: string[];
  components: Array<{ id: string; supportedSurfaces: UISurface[] }>;
  actions: Array<{ id: string; supportedSurfaces: UISurface[] }>;
};
