34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
/** Local PTY handles are scoped to their creating window and conversation. */
|
|
export interface TerminalReplayChunk { data: string; cols: number; rows: number }
|
|
export interface TerminalHostView {
|
|
id: string
|
|
sessionId?: string
|
|
cwd: string
|
|
title: string
|
|
shell: string
|
|
cols: number
|
|
rows: number
|
|
/** Bounded ANSI output replay; credentials are never added to the shell environment. */
|
|
buffer: string
|
|
replay: TerminalReplayChunk[]
|
|
sequence: number
|
|
exited: boolean
|
|
exitCode?: number
|
|
}
|
|
export type TerminalHostEvent = {
|
|
id: string
|
|
sessionId?: string
|
|
sequence: number
|
|
} & ({ type: 'data'; data: string } | { type: 'exit'; exitCode: number })
|
|
|
|
export interface TerminalHostApi {
|
|
create(sessionId?: string, cols?: number, rows?: number): Promise<TerminalHostView>
|
|
get(id: string, sessionId?: string): Promise<TerminalHostView>
|
|
write(id: string, data: string, sessionId?: string): Promise<void>
|
|
resize(id: string, cols: number, rows: number, sessionId?: string): Promise<void>
|
|
clear(id: string, sessionId?: string): Promise<void>
|
|
rebind(id: string, previousSessionId: string | undefined, nextSessionId: string): Promise<TerminalHostView>
|
|
close(id: string, sessionId?: string): Promise<void>
|
|
onEvent(listener: (event: TerminalHostEvent) => void): () => void
|
|
}
|