// Package api holds the JSON types shared by the server, the REST client, // and the CLI. No terminal-emulation types leak in here. package api // CreateSessionRequest is the body of POST /sessions. type CreateSessionRequest struct { Command []string `json:"command,omitempty"` Cwd string `json:"cwd,omitempty"` Env map[string]string `json:"env,omitempty"` Cols int `json:"cols,omitempty"` Rows int `json:"rows,omitempty"` Term string `json:"term,omitempty"` } // SessionInfo describes a session in list/get/create responses. type SessionInfo struct { ID string `json:"id"` PID int `json:"pid"` Command []string `json:"command"` Cols int `json:"cols"` Rows int `json:"rows"` Title string `json:"title"` Exited bool `json:"exited"` ExitCode *int `json:"exit_code"` } // SessionList is the body of GET /sessions. type SessionList struct { Sessions []SessionInfo `json:"sessions"` } // InputItem is one element of an input request. Exactly one field must be set. type InputItem struct { Text *string `json:"text,omitempty"` Key *string `json:"key,omitempty"` Raw *string `json:"raw,omitempty"` } // InputRequest is the body of POST /sessions/{id}/input. type InputRequest struct { Input []InputItem `json:"input"` } // InputResponse reports how many raw bytes were fed to the terminal. type InputResponse struct { Written int `json:"written"` } // MouseRequest is the body of POST /sessions/{id}/mouse. type MouseRequest struct { Type string `json:"type"` // press|release|click|move|drag|scroll Button string `json:"button"` // left|middle|right|wheel-up|wheel-down X int `json:"x"` // 0-based cell column Y int `json:"y"` // 0-based cell row Modifiers []string `json:"modifiers,omitempty"` } // ResizeRequest is the body of POST /sessions/{id}/resize. type ResizeRequest struct { Cols int `json:"cols"` Rows int `json:"rows"` } // Cursor is the cursor part of a screen snapshot. Coordinates are 0-based. type Cursor struct { X int `json:"x"` Y int `json:"y"` Visible bool `json:"visible"` } // Modes reports the DEC private modes the application has set, so a caller // knows whether mouse clicks will even be delivered. type Modes struct { Mouse string `json:"mouse"` // off|x10|normal|button_event|any_event MouseEncoding string `json:"mouse_encoding"` // default|sgr AppCursorKeys bool `json:"app_cursor_keys"` // DECCKM BracketedPaste bool `json:"bracketed_paste"` } // Screen is the body of GET /sessions/{id}/screen. type Screen struct { Lines []string `json:"lines"` Cols int `json:"cols"` Rows int `json:"rows"` Cursor Cursor `json:"cursor"` AltScreen bool `json:"alt_screen"` Title string `json:"title"` Modes Modes `json:"modes"` Exited bool `json:"exited"` ExitCode *int `json:"exit_code"` // Raw is the styled ANSI snapshot, only present with ?format=raw. Raw string `json:"raw,omitempty"` } // Error is the body of every non-2xx response. For mouse rejections the // current modes are included so the caller can see why. type Error struct { Error string `json:"error"` Modes *Modes `json:"modes,omitempty"` }