export interface Theme { name?: string; background: string; foreground: string; cursor?: string; cursorAccent?: string; selectionBackground?: string; black: string; red: string; green: string; yellow: string; blue: string; magenta: string; cyan: string; white: string; brightBlack: string; brightRed: string; brightGreen: string; brightYellow: string; brightBlue: string; brightMagenta: string; brightCyan: string; brightWhite: string; } /** * A theme name: one of the built-ins (autocompleted) or any of the ~800 Ghostty themes, matched case- and * punctuation-insensitively ("Catppuccin Mocha", "catppuccin-mocha", "GitHub Dark" …). `tcut themes` lists them. */ export type ThemeName = "catppuccin-mocha" | "dracula" | "github-dark" | "tokyo-night" | "one-dark" | (string & {}); /** `user` is the shell tcut was launched from (interactive login, with its config); the others are clean shells with the configured prompt. */ export type ShellName = "bash" | "zsh" | "fish" | "sh" | "user"; /** Terminal emulator core: libghostty (full VT, answers queries) or wterm's lite Zig core (faster, fewer features). */ export type CoreName = "ghostty" | "lite"; export type WindowBar = "none" | "colorful" | "colorfulRight" | "rings" | "ringsRight"; /** Duration as milliseconds or a string like "500ms", "1.5s", "2m". */ export type Duration = number | string; export interface FontConfig { /** CSS font-family list. Default: JetBrains Mono → Menlo → monospace. */ family?: string; /** Pixel size. Default 20. */ size?: number; /** Line height multiplier. Default 1.2. */ lineHeight?: number; /** Extra letter spacing in px. Default 0. */ letterSpacing?: number; } export interface KeysConfig { position?: "bottom" | "top"; /** How long a chip stays visible, e.g. "1.2s". */ ttl?: Duration; /** Printable keys pressed within this window merge into one chip. Default "350ms". */ merge?: Duration; /** How many chips are visible at once. Default 1 (the latest press replaces the previous). */ limit?: number; /** Chip font size in px. Default ~0.9× the terminal font. */ font?: number; /** Chip text color. Default "#fff". */ color?: string; /** Chip background (any CSS color). Default "rgba(15, 15, 20, 0.85)". */ background?: string; /** Chip corner radius in px. Default 8. */ radius?: number; } /** Presenter-only notes attached to a prerecorded demo step. */ export interface StepOptions { notes?: string; } /** Subtitle overlay. Returns immediately, so commands continue beneath it. */ export interface CaptionOptions { /** Omit to keep it until the next caption or caption(null). */ duration?: Duration; /** Classic: dark box; TikTok: timed word highlights; Pop: bouncing entrance; Minimal: small shadowed text. */ style?: "classic" | "tiktok" | "pop" | "minimal"; position?: "bottom" | "top"; /** Distance in pixels from the selected edge, inside the terminal window. Default 16. */ offset?: number; fontSize?: number; color?: string; background?: string; /** Active-word color for the TikTok preset. */ highlightColor?: string; } /** A transition card shown between feature demos. */ export interface SlideOptions { /** Smaller line under the heading. */ subtitle?: string; /** Small mark above the heading: a step number, a section name. */ eyebrow?: string; /** How long the card stays up, fades included. Default "2s". */ duration?: Duration; /** Fade in / fade out time. Default "400ms". */ fade?: Duration; /** Also record a chapter with the heading's text. Default true. */ chapter?: boolean; /** * Work to do while the card is up: `cd`, `clear`, start a server. It happens on the terminal * underneath, so it is invisible, and the card holds until it finishes. */ during?: () => Promise; } /** A region of the terminal grid to magnify. */ export interface ZoomRegion { /** Inclusive row range, 0-based. Default: all rows. */ rows?: [number, number]; /** Inclusive column range, 0-based. Default: all columns. */ cols?: [number, number]; /** Animation length on the render clock. Default "400ms". */ duration?: Duration; /** Inner padding around the region, in cells. Default 1. */ padding?: number; } /** A browser window recorded next to the terminal (Bun.WebView). */ export interface BrowserConfig { /** Page to open when recording starts (may also be opened later with `t.browser.goto`). */ url?: string; /** Pane size in px. Default 720 × the terminal frame height. */ width?: number; height?: number; /** How often the page is sampled while recording. Default 10. */ fps?: number; /** Text shown in the browser window's address bar. Default: the current URL. */ title?: string; /** * Where the browser window sits: beside/above/below the terminal, or "overlay" — overlapping it like two desktop * windows, with `t.focus()` deciding which one is in front. Default "right". */ position?: "right" | "left" | "top" | "bottom" | "overlay"; /** Overlay only: browser window offset from the terminal window's top-left corner, px. Default ~40%/18% of it. */ offset?: { x: number; y: number }; } /** Control of the recorded browser window. */ export interface BrowserSession { goto(url: string): Promise; /** Wait until the page's visible text matches. */ waitFor(pattern: RegExp | string, opts?: { timeout?: Duration }): Promise; click(selector: string): Promise; reload(): Promise; evaluate(script: string): Promise; readonly url: string; } /** Drop shadow under the window(s). Drawn by the compositor, so it is in every output that has pixels — and in SVG. */ export interface ShadowConfig { /** Horizontal offset, px. Default 0. */ x?: number; /** Vertical offset, px. Default 18. */ y?: number; /** Blur radius, px. Default 50. */ blur?: number; /** Shadow colour. Default "#000000". */ color?: string; /** 0–1. Default 0.45. */ opacity?: number; } export type WatermarkPosition = "top-left" | "top-right" | "bottom-left" | "bottom-right" | "center"; /** A watermark drawn over the whole picture (outside the terminal grid): a line of text or an image file. */ export interface WatermarkConfig { text?: string; /** PNG/JPEG/SVG/WebP file. */ image?: string; /** Default "bottom-right". */ position?: WatermarkPosition; /** 0–1. Default 0.6. */ opacity?: number; /** Text size in px (default 14) or image height in px (default 28). */ size?: number; /** Text colour. Default: the theme foreground. */ color?: string; /** Distance from the picture's edge, px. Default 16. */ margin?: number; } export interface CursorConfig { /** Default true. Blink is driven by the render clock, so it is deterministic. */ blink?: boolean; /** Full blink period in ms (on + off). Default 1000. */ period?: number; } export interface VideoConfig { /** * One or more outputs. Extension picks the encoder: .mp4, .webm, .gif, .webp. * A path ending in "/" writes a PNG sequence into that directory. */ output: string | string[]; /** Where to save the .cast recording. Default: next to the first output. */ cast?: string; /** Shell to drive. Named shells get a clean, rc-free, deterministic setup. Default "bash". */ shell?: ShellName | string[]; /** Prompt text used for the clean shell setup and for auto-wait in `run()`. Default "> ". */ prompt?: string; /** Override the regex used to detect the prompt on the cursor line. */ promptPattern?: RegExp; cwd?: string; env?: Record; /** Terminal grid. Default 80 × 24 — or derived from `width`/`height` when those are given. */ cols?: number; rows?: number; /** * Video size in pixels (including margin). When set, the output is exactly this size and the terminal is * centred inside; `cols`/`rows` default to what fits. */ width?: number; height?: number; /** Where looping outputs (GIF, WebP) start: a frame number or a percentage like "50%". */ loopOffset?: number | string; /** Idle compression: at render time, gaps between events longer than this are shortened to this. */ maxPause?: Duration; /** Show recent key presses as chips. `true` = bottom centre, 1.2 s. */ keys?: boolean | KeysConfig; /** A named bundle of defaults applied under explicit settings: readme | x | youtube | square. */ preset?: "readme" | "x" | "youtube" | "square"; /** Frames per second of the output. Default 60. */ fps?: number; /** * Pixel density. `2` renders every pixel of the layout as 2×2 output pixels — same composition, crisp text * on Retina/HiDPI screens and when a player scales the video up. 1–3, default 1. */ scale?: number; /** Delay between typed characters. Default "50ms". */ typingSpeed?: Duration; /** 0–1, randomises typing delay by ±jitter using a seeded PRNG (reproducible). Default 0. */ typingJitter?: number; /** Seed for the PRNG used by jitter. Default 1. */ seed?: number; /** Speed multiplier applied at render time. 2 = twice as fast. Default 1. */ playbackSpeed?: number; /** Default timeout for `wait()` / `run()` prompt detection. Default "15s". */ waitTimeout?: Duration; /** Extra still time appended after the script ends. Default "1s". */ endPause?: Duration; /** Snap recorded timestamps up to the next 1/fps boundary so identical output gives identical casts. Default false. */ quantize?: boolean; /** Emulator used for the screen model and rendering. Default "ghostty". */ core?: CoreName; /** Reuse the existing cast when the script and record config are unchanged. Default true. */ cache?: boolean; /** Programs the script needs on the PATH (`["bun", "eza"]`). Checked before the shell starts; missing ones fail fast with a clear message. */ requires?: string[]; /** Font for the rendered terminal, or `"auto"`: the font of the terminal tcut runs in (read from its config). */ font?: FontConfig | "auto"; /** A bundled theme name, an inline Theme, or `"auto"`: the colours of the terminal tcut runs in. */ theme?: ThemeName | Theme | "auto"; cursor?: CursorConfig; /** Record a browser window beside the terminal. */ browser?: BrowserConfig; /** Padding inside the window, px. Default 24. */ padding?: number; /** Space around the window, px. Default 0. */ margin?: number; /** * Colour behind the window (visible when margin > 0). Default: theme background. `"transparent"` gives real * alpha in PNG, WebP, GIF, WebM, SVG and HTML output (MP4 and JPEG fall back to the theme background). */ marginFill?: string; /** Drop shadow under the window; `true` uses soft defaults. Needs margin — `margin` defaults to 40 when unset. */ shadow?: boolean | ShadowConfig; /** Watermark over the picture: a string is text in the bottom-right corner; an object picks image/position/size. */ watermark?: string | WatermarkConfig; /** Rounded corner radius of the window, px. Default 0 (12 is nice with a margin). */ borderRadius?: number; windowBar?: WindowBar; /** Title shown in the window bar. `"auto"` follows the title the program sets (OSC 0/2: vim, ssh, …). */ title?: string; } /** Fully resolved config with every default applied. Serialised into the .cast header. */ export interface ResolvedConfig { output: string[]; cast: string; shell: ShellName | string[]; prompt: string; promptPattern: string; cwd: string; env: Record; cols: number; rows: number; width?: number; height?: number; loopOffset?: number | string; maxPause?: number; keys?: Required & { ttl: number; merge: number }; fps: number; scale: number; typingSpeed: number; typingJitter: number; seed: number; playbackSpeed: number; waitTimeout: number; endPause: number; quantize: boolean; core: CoreName; cache: boolean; requires: string[]; font: Required; theme: Theme; /** `"auto"` requests still to be resolved against the terminal (see applyTerminalLook). */ auto: { theme: boolean; font: boolean }; /** Which of theme/font were taken from the terminal; a generated script writes `"auto"` back for those. */ detected?: { theme: boolean; font: boolean }; cursor: Required; browser?: Required> & Pick; padding: number; margin: number; marginFill: string; shadow?: Required; watermark?: Required> & Pick; borderRadius: number; windowBar: WindowBar; title: string; } export type KeyName = | "enter" | "tab" | "backspace" | "delete" | "escape" | "space" | "up" | "down" | "left" | "right" | "home" | "end" | "pageUp" | "pageDown" | "insert" | `f${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}`; export interface WaitOptions { /** Match against the cursor line (default), the whole visible screen, or the screen plus everything that scrolled off. */ scope?: "line" | "screen" | "scrollback"; timeout?: Duration; } export interface TypeOptions { /** Per-character delay for this call only. */ speed?: Duration; } export interface RunOptions extends TypeOptions { /** What to wait for after pressing Enter. `true` (default) = the prompt, a RegExp = custom, `false` = don't wait. */ wait?: boolean | RegExp; timeout?: Duration; } /** The `t` object handed to your script. */ export interface TerminalSession { /** Type text with per-character delay. "\n" is sent as Enter. */ type(text: string, opts?: TypeOptions): Promise; /** Type `command`, press Enter, and wait for the prompt to come back. */ run(command: string, opts?: RunOptions): Promise; /** Send text instantly, as if pasted. When the program enabled bracketed paste, the text is wrapped in paste markers. */ paste(text: string): Promise; key(name: KeyName, times?: number): Promise; enter(times?: number): Promise; tab(times?: number): Promise; backspace(times?: number): Promise; delete(times?: number): Promise; escape(times?: number): Promise; space(times?: number): Promise; up(times?: number): Promise; down(times?: number): Promise; left(times?: number): Promise; right(times?: number): Promise; home(): Promise; end(): Promise; pageUp(times?: number): Promise; pageDown(times?: number): Promise; /** Ctrl+, e.g. `t.ctrl("c")`. */ ctrl(letter: string, times?: number): Promise; /** Alt/Meta+. */ alt(key: string, times?: number): Promise; /** Shift+: "tab" (back-tab), arrows/home/end/pageUp/pageDown/delete, or a letter (sent uppercase). */ shift(key: KeyName | string, times?: number): Promise; /** Mouse-wheel up/down at the cursor. Only programs with mouse tracking (vim, less --mouse, TUIs) react. */ scrollUp(times?: number): Promise; scrollDown(times?: number): Promise; /** Send raw bytes to the PTY. */ raw(data: string | Uint8Array): Promise; sleep(duration: Duration): Promise; /** Wait until `pattern` matches the cursor line (or screen). Defaults to the prompt pattern. */ wait(pattern?: RegExp | string, opts?: WaitOptions): Promise; /** Assert that `pattern` matches the screen right now (after output settles). Throws with a screen dump otherwise. */ expect(pattern: RegExp | string, opts?: Pick): Promise; /** Everything inside `fn` happens, but is cut from the video (state changes are kept). */ hide(fn: () => Promise): Promise; /** * Save a still of this exact moment when the video renders: `.png` (pixel-perfect raster) or `.svg` * (vector, selectable text — produced headlessly, no WebView). Written by `tcut