summaryrefslogblamecommitdiff
path: root/makima/frontend/src/types/messages.ts
blob: b6c7320ce1a7f78a8151409123fdd4c46fab240a (plain) (tree)
1
2
3
4
5
6
7
8





                               

                      


































                                                       





                                      



                           

                           









                                  
// Client -> Server messages
export type StartMessage = {
  type: "start";
  sampleRate: number;
  channels: number;
  encoding: "pcm32f" | "pcm16";
  contractId?: string;
  authToken?: string;
};

export type StopMessage = {
  type: "stop";
  reason?: string;
};

export type ClientMessage = StartMessage | StopMessage;

// Server -> Client messages
export type ReadyMessage = {
  type: "ready";
  sessionId: string;
};

export type TranscriptMessage = {
  type: "transcript";
  speaker: string;
  start: number;
  end: number;
  text: string;
  isFinal: boolean;
};

export type ErrorMessage = {
  type: "error";
  code: string;
  message: string;
};

export type StoppedMessage = {
  type: "stopped";
  reason: string;
};

export type TranscriptSavedMessage = {
  type: "transcriptSaved";
  fileId: string;
  contractId: string;
};

export type ServerMessage =
  | ReadyMessage
  | TranscriptMessage
  | ErrorMessage
  | StoppedMessage
  | TranscriptSavedMessage;

// Transcript entry for display
export interface TranscriptEntry {
  id: string;
  speaker: string;
  start: number;
  end: number;
  text: string;
  isFinal: boolean;
}