UNPKG

vibetunnel

Version:

Terminal sharing server with web interface - supports macOS, Linux, and headless environments

246 lines (245 loc) 6.22 kB
/** * Shared type definitions used by both frontend and backend */ /** * HTTP methods enum */ export declare enum HttpMethod { GET = "GET", POST = "POST", PUT = "PUT", DELETE = "DELETE", PATCH = "PATCH", HEAD = "HEAD", OPTIONS = "OPTIONS" } /** * Types of server events that can be received via Server-Sent Events (SSE). * Matches the Swift ServerEventType enum for type safety across platforms. */ export declare enum ServerEventType { SessionStart = "session-start", SessionExit = "session-exit", CommandFinished = "command-finished", CommandError = "command-error", Bell = "bell", ClaudeTurn = "claude-turn", Connected = "connected", TestNotification = "test-notification" } /** * Server event received via Server-Sent Events (SSE). * Matches the Swift ServerEvent struct for cross-platform compatibility. */ export interface ServerEvent { type: ServerEventType; sessionId?: string; sessionName?: string; command?: string; exitCode?: number; duration?: number; processInfo?: string; message?: string; timestamp: string; title?: string; body?: string; } /** * Session status enum */ export type SessionStatus = 'starting' | 'running' | 'exited'; /** * Core session information stored in session.json * Minimal, clean data persisted to disk */ export interface SessionInfo { id: string; name: string; command: string[]; workingDir: string; status: SessionStatus; exitCode?: number; startedAt: string; pid?: number; initialCols?: number; initialRows?: number; /** * Byte offset of the last clear event in the session stdout file. * Used to quickly seek to the most recent content when replaying casts. */ lastClearOffset?: number; version?: string; gitRepoPath?: string; gitBranch?: string; gitAheadCount?: number; gitBehindCount?: number; gitHasChanges?: boolean; gitIsWorktree?: boolean; gitMainRepoPath?: string; gitModifiedCount?: number; gitUntrackedCount?: number; gitStagedCount?: number; gitAddedCount?: number; gitDeletedCount?: number; /** * Whether this session was spawned from within VibeTunnel itself. * Used to distinguish between direct terminal sessions and nested VibeTunnel sessions. * Sessions with attachedViaVT=true are spawned from within an existing VibeTunnel session. */ attachedViaVT?: boolean; } /** * Session as returned by API endpoints * Includes everything from SessionInfo plus additional runtime/computed fields */ export interface Session extends SessionInfo { lastModified: string; active?: boolean; activityStatus?: { isActive: boolean; specificStatus?: { app: string; status: string; }; }; source?: 'local' | 'remote'; remoteId?: string; remoteName?: string; remoteUrl?: string; } /** * Activity status for a session */ export interface SessionActivity { isActive: boolean; timestamp: string; session?: SessionInfo; specificStatus?: { app: string; status: string; }; } /** * Terminal title management modes */ export declare enum TitleMode { NONE = "none",// No title management FILTER = "filter",// Block all title changes from apps STATIC = "static",// Static title: path — command — session DYNAMIC = "dynamic" } /** * Session creation options */ export interface SessionCreateOptions { sessionId?: string; name?: string; workingDir?: string; cols?: number; rows?: number; titleMode?: TitleMode; gitRepoPath?: string; gitBranch?: string; gitAheadCount?: number; gitBehindCount?: number; gitHasChanges?: boolean; gitIsWorktree?: boolean; gitMainRepoPath?: string; } /** * Session input (keyboard/special keys) */ export interface SessionInput { text?: string; key?: SpecialKey; } /** * Special keys that can be sent to sessions */ export type SpecialKey = 'arrow_up' | 'arrow_down' | 'arrow_left' | 'arrow_right' | 'escape' | 'enter' | 'ctrl_enter' | 'shift_enter' | 'backspace' | 'tab' | 'shift_tab' | 'page_up' | 'page_down' | 'home' | 'end' | 'delete' | 'f1' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'f10' | 'f11' | 'f12'; /** * Push notification subscription */ export interface PushSubscription { endpoint: string; keys: { p256dh: string; auth: string; }; } /** * Stored push subscription with metadata */ export interface StoredPushSubscription extends PushSubscription { id: string; deviceId: string; userAgent?: string; createdAt: string; lastUsed: string; } /** * Push notification preferences */ export interface PushNotificationPreferences { enabled: boolean; sessionExit: boolean; sessionStart: boolean; sessionError: boolean; commandNotifications: boolean; systemAlerts: boolean; soundEnabled: boolean; vibrationEnabled: boolean; claudeTurn?: boolean; } /** * Push notification types */ export type PushNotificationType = 'session_exit' | 'session_start' | 'session_error' | 'system_alert' | 'test'; /** * Push notification data */ export interface PushNotificationData { type: PushNotificationType; title: string; body: string; icon?: string; badge?: string; tag?: string; data?: Record<string, unknown>; actions?: Array<{ action: string; title: string; icon?: string; }>; requireInteraction?: boolean; silent?: boolean; } /** * Push notification history entry */ export interface PushNotificationHistoryEntry { id: string; timestamp: string; type: PushNotificationType; title: string; body: string; success: boolean; error?: string; deviceId?: string; } /** * Device registration for push notifications */ export interface PushDeviceRegistration { deviceId: string; subscription: PushSubscription; userAgent?: string; } /** * Server status information */ export interface ServerStatus { macAppConnected: boolean; isHQMode: boolean; version: string; }