Skip to content

armgit / clipy

Public Imported from GitHub
0

The AI-native screen recorder. Record your screen and talk; the people you share it with and your AI agents both get it.

3.2 KB
Raw Blame
export type Platform = "darwin" | "win32" | "linux";

export interface CaptureSource {
  id: string;
  kind: "display" | "window";
  name: string;
  width?: number;
  height?: number;
}

/** Same shape as the moment planner's interaction schema. */
export interface InteractionEvent {
  kind: "move" | "down" | "up" | "scroll" | "key_down" | "key_up";
  time_ms: number;
  x?: number;
  y?: number;
  button?: number;
}

/**
 * The captured rectangle in the same coordinate space as the pointer events
 * (screen pixels on Linux and Windows, points on macOS), plus the size of the
 * video frames it became.
 */
export interface CaptureGeometry {
  x: number;
  y: number;
  width: number;
  height: number;
  output_width?: number;
  output_height?: number;
}

export interface CaptureOptions {
  /** A CaptureSource id; default: the main display. */
  source?: string;
  /** .mp4 (H.264, yuv420p, fragmented MP4 so a crash leaves a playable file). */
  outPath: string;
  /** Default 30. */
  fps?: number;
  quality?: "small" | "balanced" | "high";
  /** Stop automatically after this many seconds. */
  maxSeconds?: number;
  /** Draw the cursor in the recorded video. Default: true. */
  cursor?: boolean;
  /**
   * false (default), true (default device) or a device name. A name matches
   * exactly first, then as part of a device name. On macOS a number such as
   * "1" also selects the avfoundation audio device at that index.
   */
  microphone?: boolean | string;
  /** Linux only: false (default), true (default sink's monitor) or a sink or monitor name (".monitor" is appended if missing). */
  systemAudio?: boolean | string;
  /** Linux: volume multiplier for the microphone when it is mixed with `systemAudio` (default 1, above 0 and at most 10). */
  micGain?: number;
  /** Linux: volume multiplier for the system audio when it is mixed with `microphone` (default 1, above 0 and at most 10). */
  systemGain?: number;
  /** Linux only, e.g. ":99". Default: $DISPLAY. */
  xDisplay?: string;
}

export interface CaptureResult {
  path: string;
  durationMs: number;
  interactions: InteractionEvent[];
  geometry: CaptureGeometry | null;
  warnings: string[];
}

export interface CaptureSession {
  /** Epoch ms when ffmpeg started recording: time_ms 0 of the interactions. */
  readonly startedAt: number;
  /**
   * Resolves when ffmpeg exits by itself (maxSeconds reached, or a failure).
   * stop() still has to be called to collect the result.
   */
  readonly ended: Promise<void>;
  /**
   * Pause recording until resume(). ffmpeg cannot pause a screen grab, so this
   * ends the current video segment; resume() records the next one and stop()
   * joins them into the output file. The paused stretch is left out of the
   * video and pointer samples taken while paused are dropped, so durationMs and
   * the interaction times count only recorded time. Pausing a capture that is
   * already paused does nothing.
   */
  pause(): Promise<void>;
  /** Start a new segment after pause(). Does nothing if already recording. */
  resume(): Promise<void>;
  stop(): Promise<CaptureResult>;
  abort(): Promise<void>;
}

export interface CaptureCheck {
  ok: boolean;
  ffmpeg: string | null;
  problems: string[];
  hints: string[];
}