Complete multi-pane broadcast, standard terminal right-click actions, batch host selection with progress, and native ssh_close_shell so closing a pane tears down the remote shell. Co-authored-by: Cursor <cursoragent@cursor.com>
278 lines
5.5 KiB
TypeScript
278 lines
5.5 KiB
TypeScript
/**
|
|
* IPC Types - 统一的 IPC 类型定义
|
|
* 定义所有 IPC 请求/响应的类型
|
|
*/
|
|
|
|
import type { Session, ProxyConfig, JumpHostConfig } from './session.types'
|
|
|
|
// ============== SSH IPC ==============
|
|
|
|
export interface SSHConnectRequest {
|
|
host: string
|
|
port: number
|
|
username: string
|
|
password?: string
|
|
privateKey?: string
|
|
passphrase?: string
|
|
proxy?: ProxyConfig
|
|
jumpHost?: JumpHostConfig
|
|
jumpHosts?: JumpHostConfig[]
|
|
timeoutSeconds?: number
|
|
keepAlive?: boolean
|
|
}
|
|
|
|
export interface SSHConnectResponse {
|
|
success: boolean
|
|
connectionId?: string
|
|
error?: string
|
|
}
|
|
|
|
export interface SSHExecRequest {
|
|
connectionId: string
|
|
command: string
|
|
}
|
|
|
|
export interface SSHExecResponse {
|
|
success: boolean
|
|
result?: string
|
|
exitCode?: number
|
|
error?: string
|
|
}
|
|
|
|
export interface SSHCreateShellRequest {
|
|
connectionId?: string
|
|
cols?: number
|
|
rows?: number
|
|
}
|
|
|
|
export interface SSHCreateShellResponse {
|
|
success: boolean
|
|
shellId?: string
|
|
error?: string
|
|
}
|
|
|
|
export interface SSHShellWriteRequest {
|
|
shellId: string
|
|
data: string
|
|
}
|
|
|
|
export interface SSHShellResizeRequest {
|
|
shellId: string
|
|
cols: number
|
|
rows: number
|
|
}
|
|
|
|
// ============== Port Forward IPC ==============
|
|
|
|
export interface SSHForwardLocalRequest {
|
|
connectionId: string
|
|
localPort: number
|
|
remoteHost: string
|
|
remotePort: number
|
|
}
|
|
|
|
export interface SSHForwardRemoteRequest {
|
|
connectionId: string
|
|
remotePort: number
|
|
localHost: string
|
|
localPort: number
|
|
}
|
|
|
|
export interface SSHForwardDynamicRequest {
|
|
connectionId: string
|
|
localPort: number
|
|
}
|
|
|
|
export interface SSHForwardResponse {
|
|
success: boolean
|
|
forwardId?: string
|
|
boundPort?: number
|
|
error?: string
|
|
}
|
|
|
|
export interface SSHForwardStatus {
|
|
forwardId: string
|
|
connectionId: string
|
|
kind: 'local' | 'remote' | 'dynamic'
|
|
bindHost: string
|
|
boundPort: number
|
|
targetHost?: string
|
|
targetPort?: number
|
|
startedAt: number
|
|
running: boolean
|
|
activeConnections: number
|
|
bytesUp: number
|
|
bytesDown: number
|
|
}
|
|
|
|
export interface SSHForwardListResponse {
|
|
success: boolean
|
|
tunnels?: SSHForwardStatus[]
|
|
error?: string
|
|
}
|
|
|
|
// ============== Session IPC ==============
|
|
|
|
export interface SessionCreateResponse {
|
|
success: boolean
|
|
session?: Session
|
|
error?: string
|
|
}
|
|
|
|
export interface SessionUpdateResponse {
|
|
success: boolean
|
|
session?: Session
|
|
error?: string
|
|
}
|
|
|
|
export interface SessionDeleteResponse {
|
|
success: boolean
|
|
error?: string
|
|
}
|
|
|
|
// ============== Settings IPC ==============
|
|
|
|
export interface SettingsGetRequest {
|
|
key: string
|
|
}
|
|
|
|
export interface SettingsSetRequest {
|
|
key: string
|
|
value: unknown
|
|
}
|
|
|
|
// ============== Dialog IPC ==============
|
|
|
|
export interface DialogOptions {
|
|
title?: string
|
|
defaultPath?: string
|
|
filters?: { name: string; extensions: string[] }[]
|
|
properties?: ('openFile' | 'openDirectory' | 'multiSelections')[]
|
|
}
|
|
|
|
export interface DialogResult {
|
|
canceled: boolean
|
|
filePath?: string
|
|
filePaths?: string[]
|
|
}
|
|
|
|
// ============== File IPC ==============
|
|
|
|
export interface FileReadRequest {
|
|
filePath: string
|
|
}
|
|
|
|
export interface FileWriteRequest {
|
|
filePath: string
|
|
data: string
|
|
}
|
|
|
|
export interface FileOperationResponse {
|
|
success: boolean
|
|
error?: string
|
|
}
|
|
|
|
export interface FileStats {
|
|
size: number
|
|
modified: number
|
|
isDirectory: boolean
|
|
isFile: boolean
|
|
}
|
|
|
|
export interface DirEntry {
|
|
name: string
|
|
path: string
|
|
isDirectory: boolean
|
|
}
|
|
|
|
// ============== Zmodem IPC ==============
|
|
|
|
export interface ZmodemProgress {
|
|
sessionId: string
|
|
fileName: string
|
|
progress: number
|
|
bytesTransferred: number
|
|
totalBytes: number
|
|
}
|
|
|
|
export interface ZmodemComplete {
|
|
sessionId: string
|
|
success: boolean
|
|
fileName?: string
|
|
error?: string
|
|
}
|
|
|
|
// ============== App IPC ==============
|
|
|
|
export interface AppVersionResponse {
|
|
version: string
|
|
}
|
|
|
|
// ============== IPC Channel Names ==============
|
|
|
|
export const IPC_CHANNELS = {
|
|
// SSH
|
|
SSH_CONNECT: 'ssh:connect',
|
|
SSH_DISCONNECT: 'ssh:disconnect',
|
|
SSH_EXEC: 'ssh:exec',
|
|
SSH_CREATE_SHELL: 'ssh:createShell',
|
|
SSH_SHELL_WRITE: 'ssh:shellWrite',
|
|
SSH_SHELL_RESIZE: 'ssh:shellResize',
|
|
SSH_SHELL_CLOSE: 'ssh:shellClose',
|
|
SSH_FORWARD_LOCAL: 'ssh:forwardLocal',
|
|
SSH_FORWARD_REMOTE: 'ssh:forwardRemote',
|
|
SSH_FORWARD_DYNAMIC: 'ssh:forwardDynamic',
|
|
|
|
// SFTP
|
|
SFTP_CONNECT: 'sftp:connect',
|
|
SFTP_LIST_DIRECTORY: 'sftp:listDirectory',
|
|
SFTP_UPLOAD: 'sftp:upload',
|
|
SFTP_DOWNLOAD: 'sftp:download',
|
|
SFTP_RENAME: 'sftp:rename',
|
|
SFTP_DELETE: 'sftp:delete',
|
|
|
|
// Session
|
|
SESSION_CREATE: 'session:create',
|
|
SESSION_GET_ALL: 'session:getAll',
|
|
SESSION_GET_BY_ID: 'session:getById',
|
|
SESSION_UPDATE: 'session:update',
|
|
SESSION_DELETE: 'session:delete',
|
|
|
|
// Settings
|
|
SETTINGS_GET: 'settings:get',
|
|
SETTINGS_SET: 'settings:set',
|
|
|
|
// Dialog
|
|
DIALOG_SHOW_SAVE: 'dialog:showSaveDialog',
|
|
DIALOG_SHOW_OPEN: 'dialog:showOpenDialog',
|
|
|
|
// App
|
|
APP_GET_VERSION: 'app:getVersion',
|
|
APP_GET_DOWNLOADS_PATH: 'app:getDownloadsPath',
|
|
|
|
// File
|
|
FILE_READ: 'file:read',
|
|
FILE_WRITE: 'file:write',
|
|
LOCAL_GET_HOME: 'local:getHome',
|
|
LOCAL_READ_DIR: 'local:readDir',
|
|
LOCAL_GET_STATS: 'local:getStats',
|
|
LOCAL_DELETE: 'local:delete',
|
|
LOCAL_RENAME: 'local:rename',
|
|
LOCAL_MKDIR: 'local:mkdir',
|
|
|
|
// Zmodem
|
|
ZMODEM_SEND: 'zmodem:send',
|
|
ZMODEM_RECEIVE: 'zmodem:receive',
|
|
ZMODEM_CANCEL: 'zmodem:cancel',
|
|
|
|
// Events (renderer listens)
|
|
SHELL_DATA: 'ssh:shellData',
|
|
SFTP_PROGRESS: 'sftp:progress',
|
|
ZMODEM_PROGRESS: 'zmodem:progress',
|
|
ZMODEM_COMPLETE: 'zmodem:complete',
|
|
MENU_NEW_SESSION: 'menu-new-session',
|
|
MENU_QUICK_CONNECT: 'menu-quick-connect',
|
|
MENU_IMPORT_SESSIONS: 'menu-import-sessions',
|
|
MENU_EXPORT_SESSIONS: 'menu-export-sessions',
|
|
} as const
|