environment

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 25 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package workspace implements local workspace operations.

Index

Constants

View Source
const (
	// DefaultMaxOutputSize is the default character limit before truncation (~7.5k tokens)
	DefaultMaxOutputSize = 30000 // ~7.5k tokens at 4 chars/token
	// DefaultPreviewSize is the maximum characters for preview
	DefaultPreviewSize = 8000 // ~2k tokens
	// DefaultPreviewLines is the number of lines shown in the preview
	DefaultPreviewLines = 20
	// OutputsDir is the directory name for storing large outputs
	OutputsDir = ".outputs"
)

Variables

This section is empty.

Functions

func ShouldSkipForOutputsDir

func ShouldSkipForOutputsDir(command string) bool

ShouldSkipForOutputsDir checks if large output processing should be skipped for commands operating on .outputs/ directory to avoid circular processing.

Types

type Environment

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

Environment handles local filesystem operations.

func New

func New(root string, checker *permission.Checker) (*Environment, error)

New creates a new workspace with the given root directory and permission checker.

func (*Environment) Bash

Bash executes a bash command in the workspace.

func (*Environment) DeleteKnowledgeFiles

DeleteKnowledgeFiles removes the supplied files from the workspace root and scrubs their entries from the sentinel.

func (*Environment) Glob

Glob searches for files matching a pattern.

func (*Environment) Grep

Grep searches for a pattern in files.

func (*Environment) List

List lists entries in a directory.

func (*Environment) MCPCall

func (e *Environment) MCPCall(ctx context.Context, args *protocol.MCPCallArgs, logger *slog.Logger) (*protocol.MCPCallResult, error)

MCPCall executes an MCP tool call.

func (*Environment) MCPListTools

MCPListTools lists available tools from an MCP server.

func (*Environment) Read

Read reads a file from the workspace.

func (*Environment) Root

func (e *Environment) Root() string

Root returns the workspace root directory.

func (*Environment) StageKnowledgeFiles

StageKnowledgeFiles writes the supplied files into the workspace root and updates the sentinel checksum map.

func (*Environment) SyncSkill

SyncSkill syncs a skill from cloud to local workspace.

func (*Environment) WebFetch

WebFetch fetches content from a URL and converts it to readable format.

func (*Environment) Write

func (e *Environment) Write(ctx context.Context, args *protocol.WriteArgs) error

Write writes content to a file in the workspace.

func (*Environment) WriteRaw

func (e *Environment) WriteRaw(ctx context.Context, path string, content []byte) error

WriteRaw writes raw content (not base64 encoded) to a file. Used internally for saving large output files.

type LargeOutputConfig

type LargeOutputConfig struct {
	MaxOutputSize int
	PreviewSize   int
	PreviewLines  int
}

LargeOutputConfig holds configuration for large output handling.

func DefaultLargeOutputConfig

func DefaultLargeOutputConfig() LargeOutputConfig

DefaultLargeOutputConfig returns the default configuration.

type LargeOutputProcessor

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

LargeOutputProcessor handles large output truncation and file storage.

func NewLargeOutputProcessor

func NewLargeOutputProcessor(ws *Environment, config LargeOutputConfig) *LargeOutputProcessor

NewLargeOutputProcessor creates a new processor with the given workspace.

func (*LargeOutputProcessor) Process

func (p *LargeOutputProcessor) Process(ctx context.Context, content string, prefix string) (*ProcessResult, error)

Process checks if content exceeds the limit and handles accordingly.

type LimitedWriter

type LimitedWriter struct {
	W     io.Writer
	Limit int64
	// contains filtered or unexported fields
}

LimitedWriter is an io.Writer that limits the total number of bytes written.

func (*LimitedWriter) Write

func (l *LimitedWriter) Write(p []byte) (n int, err error)

type ProcessResult

type ProcessResult struct {
	Content   string
	Truncated bool
	FilePath  string
	TotalSize int64
}

ProcessResult holds the result of processing large output.

Jump to

Keyboard shortcuts

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