Documentation
¶
Index ¶
- Constants
- type API
- type HeadTailBuffer
- func (b *HeadTailBuffer) Bytes() []byte
- func (b *HeadTailBuffer) Close()
- func (b *HeadTailBuffer) Len() int
- func (b *HeadTailBuffer) Output() (string, *workspacesdk.ProcessTruncation)
- func (b *HeadTailBuffer) Reset()
- func (b *HeadTailBuffer) TotalWritten() int
- func (b *HeadTailBuffer) Write(p []byte) (int, error)
Constants ¶
const ( // MaxHeadBytes is the number of bytes retained from the // beginning of the output for LLM consumption. MaxHeadBytes = 16 << 10 // 16KB // MaxTailBytes is the number of bytes retained from the // end of the output for LLM consumption. MaxTailBytes = 16 << 10 // 16KB // MaxLineLength is the maximum length of a single line // before it is truncated. This prevents minified files // or other long single-line output from consuming the // entire buffer. MaxLineLength = 2048 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type API ¶ added in v2.32.0
type API struct {
// contains filtered or unexported fields
}
API exposes process-related operations through the agent.
func NewAPI ¶ added in v2.32.0
func NewAPI(logger slog.Logger, execer agentexec.Execer, updateEnv func(current []string) (updated []string, err error), pathStore *agentgit.PathStore, workingDir func() string) *API
NewAPI creates a new process API handler.
type HeadTailBuffer ¶ added in v2.32.0
type HeadTailBuffer struct {
// contains filtered or unexported fields
}
HeadTailBuffer is a thread-safe buffer that captures process output and provides head+tail truncation for LLM consumption. It implements io.Writer so it can be used directly as cmd.Stdout or cmd.Stderr.
The buffer stores up to MaxHeadBytes from the beginning of the output and up to MaxTailBytes from the end in a ring buffer, keeping total memory usage bounded regardless of how much output is written.
func NewHeadTailBuffer ¶ added in v2.32.0
func NewHeadTailBuffer() *HeadTailBuffer
NewHeadTailBuffer creates a new HeadTailBuffer with the default head and tail sizes.
func NewHeadTailBufferSized ¶ added in v2.32.0
func NewHeadTailBufferSized(maxHead, maxTail int) *HeadTailBuffer
NewHeadTailBufferSized creates a HeadTailBuffer with custom head and tail sizes. This is useful for testing truncation logic with smaller buffers.
func (*HeadTailBuffer) Bytes ¶ added in v2.32.0
func (b *HeadTailBuffer) Bytes() []byte
Bytes returns a copy of the raw buffer contents. If no truncation has occurred the full output is returned; otherwise the head and tail portions are concatenated.
func (*HeadTailBuffer) Close ¶ added in v2.32.0
func (b *HeadTailBuffer) Close()
Close marks the buffer as closed and wakes any waiters. This is called when the process exits.
func (*HeadTailBuffer) Len ¶ added in v2.32.0
func (b *HeadTailBuffer) Len() int
Len returns the number of bytes currently stored in the buffer.
func (*HeadTailBuffer) Output ¶ added in v2.32.0
func (b *HeadTailBuffer) Output() (string, *workspacesdk.ProcessTruncation)
Output returns the truncated output suitable for LLM consumption, along with truncation metadata. If the total output fits within the head buffer alone, the full output is returned with nil truncation info. Otherwise the head and tail are joined with an omission marker and long lines are truncated.
func (*HeadTailBuffer) Reset ¶ added in v2.32.0
func (b *HeadTailBuffer) Reset()
Reset clears the buffer, discarding all data.
func (*HeadTailBuffer) TotalWritten ¶ added in v2.32.0
func (b *HeadTailBuffer) TotalWritten() int
TotalWritten returns the total number of bytes written to the buffer, which may exceed the stored capacity.