io

package
v1.16.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTermFitHeight

func GetTermFitHeight(lines int) int

func GetTerminalHeight

func GetTerminalHeight() int

GetTerminalHeight returns the height of the terminal using a robust fallback chain: 1. Direct TTY query via golang.org/x/term (most reliable) 2. Tmux pane height (if inside tmux) 3. LINES environment variable 4. tput lines command 5. Default fallback of 24

func GetTerminalWidth

func GetTerminalWidth() int

GetTerminalWidth returns the width of the terminal using a robust fallback chain: 1. Direct TTY query via golang.org/x/term (most reliable) 2. Tmux pane width (if inside tmux) 3. COLUMNS environment variable 4. tput cols command 5. Default fallback of 80

func NewSSEErrWriter added in v1.16.16

func NewSSEErrWriter(sse *SSEOutput) stdio.Writer

NewSSEErrWriter creates an stdio.Writer that emits "command" SSE events as errors.

func NewSSEWriter added in v1.16.16

func NewSSEWriter(sse *SSEOutput) stdio.Writer

NewSSEWriter creates an stdio.Writer that emits "command" SSE events as output.

func TerminalSupportsTrueColor

func TerminalSupportsTrueColor() bool

TerminalSupportsTrueColor detects if the terminal supports true color (24-bit) Returns true if COLORTERM is set to "truecolor" or "24bit"

Types

type FileOutput

type FileOutput struct {
	// contains filtered or unexported fields
}

FileOutput is a renderer that writes output to a file

func NewFileOutput

func NewFileOutput(filename string) (*FileOutput, error)

NewFileOutput creates a new instance of FileOutput

func (*FileOutput) Close

func (fr *FileOutput) Close()

Close closes the file renderer and its underlying file

func (*FileOutput) GetFilename

func (fr *FileOutput) GetFilename() string

GetFilename returns the name of the file being written to

func (*FileOutput) Write

func (fr *FileOutput) Write(args ...interface{})

func (*FileOutput) Writef

func (fr *FileOutput) Writef(format string, args ...interface{})

Writef writes formatted output to the file

func (*FileOutput) Writeln

func (fr *FileOutput) Writeln(args ...interface{})

type Output

type Output interface {
	Writeln(args ...interface{})
	Writef(format string, args ...interface{})
	Write(args ...interface{})
	Close()
}

Output defines the interface for output formatting.

type SSEOutput added in v1.16.16

type SSEOutput struct {
	// contains filtered or unexported fields
}

SSEOutput is an implementation of Output that sends data via Server-Sent Events.

func NewSSEOutput added in v1.16.16

func NewSSEOutput(w http.ResponseWriter) (*SSEOutput, error)

NewSSEOutput creates a new SSEOutput from an http.ResponseWriter. It returns an error if the writer does not support the http.Flusher interface.

func (*SSEOutput) Close added in v1.16.16

func (s *SSEOutput) Close()

Close gracefully terminates the SSE stream with the standard [DONE] sentinel.

func (*SSEOutput) Write added in v1.16.16

func (s *SSEOutput) Write(args ...interface{})

Write outputs the unformatted arguments as a content delta.

func (*SSEOutput) WriteCommandEvent added in v1.16.16

func (s *SSEOutput) WriteCommandEvent(content string, errMsg string)

WriteCommandEvent emits REPL command output. The error field is omitted on success.

Success: data: {"type":"command","data":{"content":"..."}}
Error:   data: {"type":"command","data":{"content":"","error":"..."}}

func (*SSEOutput) WriteDiffEvent added in v1.16.16

func (s *SSEOutput) WriteDiffEvent(before, after string)

WriteDiffEvent emits a raw diff to the client so it can render the changes interactively.

data: {"type":"diff","data":{"before":"...","after":"..."}}

func (*SSEOutput) WriteErrorEvent added in v1.16.16

func (s *SSEOutput) WriteErrorEvent(content string, code string)

WriteErrorEvent emits a system or agent-level error with a machine-readable code.

data: {"type":"error","data":{"content":"...","code":"..."}}

func (*SSEOutput) WriteReasoningPayload added in v1.16.16

func (s *SSEOutput) WriteReasoningPayload(content string)

WriteReasoningPayload sends chain-of-thought chunks using the 'reasoning_content' delta key, compatible with DeepSeek/extended OpenAI streaming schemas.

func (*SSEOutput) WriteRequestEvent added in v1.16.16

func (s *SSEOutput) WriteRequestEvent(id string, reqType string, purpose string)

WriteRequestEvent emits a request that the server has paused and needs user input. This is typically used for tool confirmations or "ask user" prompts.

data: {"type":"request","data":{"id":"...","type":"...","purpose":"..."}}

func (*SSEOutput) WriteStatusEvent added in v1.16.16

func (s *SSEOutput) WriteStatusEvent(status string)

WriteStatusEvent emits a status lifecycle notification.

data: {"type":"status","data":{"content":"<status>"}}

func (*SSEOutput) WriteToolCallEvent added in v1.16.16

func (s *SSEOutput) WriteToolCallEvent(function string, description string)

WriteToolCallEvent emits a tool invocation event. The content is a structured object containing the function name and its description. it shouldn't expose the arguments of the function to the web client

data: {"type":"tool_call","data":{"content":{"function":"...","description":"..."}}}

func (*SSEOutput) Writef added in v1.16.16

func (s *SSEOutput) Writef(format string, args ...interface{})

Writef outputs the formatted string as a content delta.

func (*SSEOutput) Writeln added in v1.16.16

func (s *SSEOutput) Writeln(args ...interface{})

Writeln outputs the formatted string followed by a newline as a content delta.

type StdOutput

type StdOutput struct {
}

func NewStdOutput

func NewStdOutput() *StdOutput

func (*StdOutput) Close

func (r *StdOutput) Close()

func (*StdOutput) Write

func (r *StdOutput) Write(args ...interface{})

func (*StdOutput) Writef

func (r *StdOutput) Writef(format string, args ...interface{})

func (*StdOutput) Writeln

func (r *StdOutput) Writeln(args ...interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL