Merge branch 'worktree-agent-a26df8b0059ab1b12'
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
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package protocol
|
||||
|
||||
// Interactive operator shell commands. On macOS and Linux every chat_shell_run
|
||||
// runs inside a pseudo-terminal (ChatShellRunRecord.Terminal): the command sees
|
||||
// a TTY of the requested size with TERM=xterm-256color, its output is the raw
|
||||
// terminal stream (escape sequences included) and any authenticated client
|
||||
// watching the chat may type into it until it ends. Other platforms keep
|
||||
// plain pipes and refuse input.
|
||||
const (
|
||||
// ChatShellInput writes Data to a running terminal command's input. The
|
||||
// body is ChatShellRunRequest (session_id, run_id, data). Data is the
|
||||
// UTF-8 text of what was typed or pasted, control characters included
|
||||
// (Ctrl-C is "\u0003", Enter is "\r", arrow keys are their escape
|
||||
// sequences); the bytes written are exactly its UTF-8 encoding. Input is
|
||||
// never persisted or logged; the reply carries no body.
|
||||
ChatShellInput = "chat_shell_input"
|
||||
// ChatShellResize sets a running terminal command's size (cols, rows); the
|
||||
// process receives SIGWINCH. The last resize from any client wins. The
|
||||
// reply echoes the run.
|
||||
ChatShellResize = "chat_shell_resize"
|
||||
)
|
||||
|
||||
// Bounds of interactive terminals.
|
||||
const (
|
||||
// ChatShellInputLimit bounds the UTF-8 bytes of one chat_shell_input.
|
||||
// Clients split a longer paste into several requests.
|
||||
ChatShellInputLimit = 16 << 10
|
||||
// ChatShellInputQueue bounds the input requests waiting for the command
|
||||
// to read them; beyond it chat_shell_input is refused.
|
||||
ChatShellInputQueue = 64
|
||||
// Terminal sizes are clamped to these bounds; a run started without a
|
||||
// size gets the defaults.
|
||||
ChatShellTerminalMinCols = 20
|
||||
ChatShellTerminalMaxCols = 500
|
||||
ChatShellTerminalMinRows = 4
|
||||
ChatShellTerminalMaxRows = 200
|
||||
ChatShellTerminalDefaultCols = 100
|
||||
ChatShellTerminalDefaultRows = 30
|
||||
)
|
||||
|
||||
// ChatShellTerminalUnsupported is the refusal of chat_shell_input and
|
||||
// chat_shell_resize on a server or run without a pseudo-terminal.
|
||||
const ChatShellTerminalUnsupported = "interactive terminals are not supported on this server"
|
||||
Reference in New Issue
Block a user