agentproc

package
v2.33.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
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.

func (*API) Close added in v2.32.0

func (api *API) Close() error

Close shuts down the process manager, killing all running processes.

func (*API) Routes added in v2.32.0

func (api *API) Routes() http.Handler

Routes returns the HTTP handler for process-related routes.

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

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.

func (*HeadTailBuffer) Write added in v2.32.0

func (b *HeadTailBuffer) Write(p []byte) (int, error)

Write implements io.Writer. It is safe for concurrent use. All bytes are accepted; the return value always equals len(p) with a nil error.

Jump to

Keyboard shortcuts

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