Run chat shell commands in a pseudo-terminal with typed input and resize
Commands start in a PTY (creack/pty; macOS and Linux) of the client's size with TERM=xterm-256color in their own session. chat_shell_input writes typed UTF-8 text in order through a bounded queue; chat_shell_resize sets the size. Output stays the raw terminal stream with byte offsets as sequence numbers, chat_shell_run_output resumes from an offset, and a plain-text rendering is persisted for Copy output and Send to agent. Input is never stored or logged.
This commit is contained in:
@@ -18,14 +18,18 @@ const (
|
||||
// body is ChatQuery.
|
||||
ChatShellRuns = "chat_shell_runs"
|
||||
// ChatShellRunOutput reads one run with its whole retained output (at most
|
||||
// ChatShellRunRetained bytes). The body is ChatShellRunRequest.
|
||||
// ChatShellRunRetained bytes) and its plain-text rendering. The body is
|
||||
// ChatShellRunRequest; a nonzero After asks only for the output from that
|
||||
// absolute byte on (a reconnecting client resuming its copy).
|
||||
ChatShellRunOutput = "chat_shell_run_output"
|
||||
// ChatShellShare queues an ordinary prompt carrying the run's command, exit
|
||||
// status and bounded output tail. The body is ChatShellRunRequest; the
|
||||
// reply is the chat_prompt acknowledgement.
|
||||
ChatShellShare = "chat_shell_share"
|
||||
// ChatShellRunEvent is pushed to every client watching the session: a
|
||||
// lifecycle change (Run set) or an output chunk (Output set).
|
||||
// lifecycle change (Run set) or an output chunk (Output set). Output
|
||||
// chunks of one run are pushed in order; their byte offsets are the
|
||||
// stream's sequence numbers.
|
||||
ChatShellRunEvent = "chat_shell_run_event"
|
||||
)
|
||||
|
||||
@@ -60,11 +64,18 @@ const (
|
||||
|
||||
// ChatShellRunRequest names one session and either a new command or a run.
|
||||
// OperationID is the optional retry identity of chat_shell_share's prompt.
|
||||
// Cols and Rows size a new run's terminal (chat_shell_run) or resize a running
|
||||
// one (chat_shell_resize); Data is chat_shell_input's typed text; After is
|
||||
// chat_shell_run_output's resume offset.
|
||||
type ChatShellRunRequest struct {
|
||||
SessionID string `json:"session_id"`
|
||||
Command string `json:"command,omitempty"`
|
||||
RunID string `json:"run_id,omitempty"`
|
||||
OperationID string `json:"operation_id,omitempty"`
|
||||
Cols int `json:"cols,omitempty"`
|
||||
Rows int `json:"rows,omitempty"`
|
||||
Data string `json:"data,omitempty"`
|
||||
After int64 `json:"after,omitempty"`
|
||||
}
|
||||
|
||||
// ChatShellRunRecord is one operator command and what it produced. Output is
|
||||
@@ -91,6 +102,16 @@ type ChatShellRunRecord struct {
|
||||
// Truncated is true when Output does not hold everything the command
|
||||
// wrote (OutputStart > 0).
|
||||
Truncated bool `json:"truncated,omitempty"`
|
||||
// Terminal is true when the command runs in a pseudo-terminal of Cols x
|
||||
// Rows: Output is then the raw terminal stream, and input is accepted
|
||||
// while it runs.
|
||||
Terminal bool `json:"terminal,omitempty"`
|
||||
Cols int `json:"cols,omitempty"`
|
||||
Rows int `json:"rows,omitempty"`
|
||||
// Text is the plain-text rendering of Output (escape sequences removed,
|
||||
// carriage-return redraws applied): what Copy output copies and Send to
|
||||
// agent shares. Only chat_shell_run_output carries it.
|
||||
Text string `json:"text,omitempty"`
|
||||
}
|
||||
|
||||
// ChatShellRunEventFrame is one live change to a run. A lifecycle frame sets
|
||||
|
||||
Reference in New Issue
Block a user