infrastructure

package
v0.182.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFileService added in v0.178.1

func NewFileService() agentdomain.FileService

NewFileService creates a new file service

Types

type BaseFormatter

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

BaseFormatter provides common formatting functionality that tools can embed

func NewBaseFormatter

func NewBaseFormatter(toolName string) BaseFormatter

NewBaseFormatter creates a new base formatter for a tool

func (BaseFormatter) FormatAsJSON

func (f BaseFormatter) FormatAsJSON(data any) string

FormatAsJSON formats data as JSON if possible, falls back to string representation

func (BaseFormatter) FormatDuration

func (f BaseFormatter) FormatDuration(result *agentdomain.ToolExecutionResult) string

FormatDuration formats a duration for display in a human-friendly way

func (BaseFormatter) FormatExpanded

func (f BaseFormatter) FormatExpanded(result *agentdomain.ToolExecutionResult, dataContent string) string

FormatExpanded renders the full expanded result as a single native lipgloss/tree, replacing the hand-drawn ├─/└─ connectors that used to live across three methods. dataContent is the tool-specific result body (may be ""). Output is plain: the UI wraps and themes it (services.themeTreeLines); LLM / headless consume it as-is.

func (BaseFormatter) FormatStatusIcon

func (f BaseFormatter) FormatStatusIcon(success bool) string

FormatStatusIcon returns just the status icon

func (BaseFormatter) FormatToolCall

func (f BaseFormatter) FormatToolCall(args map[string]any, expanded bool) string

FormatToolCall formats a tool call for consistent display

func (BaseFormatter) GetDomainFromURL

func (f BaseFormatter) GetDomainFromURL(url string) string

GetDomainFromURL extracts domain from URL

func (BaseFormatter) GetFileName

func (f BaseFormatter) GetFileName(path string) string

GetFileName extracts filename from a path

func (BaseFormatter) ShouldCollapseArg

func (f BaseFormatter) ShouldCollapseArg(key string) bool

ShouldCollapseArg provides default collapse behavior (can be overridden by tools)

func (BaseFormatter) TruncateText

func (f BaseFormatter) TruncateText(text string, maxLength int) string

TruncateText truncates text to specified length with ellipsis

type CustomFormatter

type CustomFormatter struct {
	BaseFormatter
	// contains filtered or unexported fields
}

CustomFormatter extends BaseFormatter with customizable collapse behavior

func NewCustomFormatter

func NewCustomFormatter(toolName string, collapseFunc func(string) bool) CustomFormatter

NewCustomFormatter creates a formatter with custom collapse logic

func (CustomFormatter) FormatExpanded

func (f CustomFormatter) FormatExpanded(result *agentdomain.ToolExecutionResult, dataContent string) string

FormatExpanded renders the expanded tree using the custom collapse behavior.

func (CustomFormatter) FormatToolCall

func (f CustomFormatter) FormatToolCall(args map[string]any, expanded bool) string

FormatToolCall overrides BaseFormatter to use custom collapse logic

func (CustomFormatter) ShouldCollapseArg

func (f CustomFormatter) ShouldCollapseArg(key string) bool

ShouldCollapseArg uses the custom collapse function if provided

type DirectoryFrameSource added in v0.178.1

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

DirectoryFrameSource serves the newest image file under a configured directory - the integration surface for camera daemons and anything else that drops frames on disk. An optional retention sweep (max_files/max_age) runs after each read; omit retention when the producer manages cleanup.

func NewDirectoryFrameSource added in v0.178.1

func NewDirectoryFrameSource(name string, cfg config.VisionSourceConfig, images agentdomain.ImageService) *DirectoryFrameSource

NewDirectoryFrameSource creates a frame source over cfg.Path. The retention max_age was validated at config load, so a parse failure here means zero (no age limit).

func (*DirectoryFrameSource) GetLatestFrame added in v0.178.1

func (d *DirectoryFrameSource) GetLatestFrame() (*agentdomain.Frame, error)

GetLatestFrame returns the newest image file in the directory by mtime.

type FileServiceImpl added in v0.178.1

type FileServiceImpl struct{}

FileServiceImpl implements agentdomain.FileService

func (*FileServiceImpl) GetFileInfo added in v0.178.1

func (s *FileServiceImpl) GetFileInfo(path string) (agentdomain.FileInfo, error)

GetFileInfo returns information about a file

func (*FileServiceImpl) ListProjectFiles added in v0.178.1

func (s *FileServiceImpl) ListProjectFiles() ([]string, error)

ListProjectFiles returns a list of all files in the current directory and subdirectories

func (*FileServiceImpl) ReadFile added in v0.178.1

func (s *FileServiceImpl) ReadFile(path string) (string, error)

ReadFile reads the content of a file

func (*FileServiceImpl) ReadFileLines added in v0.178.1

func (s *FileServiceImpl) ReadFileLines(path string, startLine, endLine int) (string, error)

ReadFileLines reads specific lines from a file

func (*FileServiceImpl) ValidateFile added in v0.178.1

func (s *FileServiceImpl) ValidateFile(path string) error

ValidateFile checks if a file path is valid and accessible

type ImageService added in v0.178.1

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

ImageService handles image operations including file-based image loading and base64 encoding Note: Direct clipboard support requires platform-specific dependencies and is not yet implemented

func NewImageService added in v0.178.1

func NewImageService(cfg *config.Config, client sdk.Client) *ImageService

NewImageService creates a new image service

func (*ImageService) CreateDataURL added in v0.178.1

func (s *ImageService) CreateDataURL(attachment *agentdomain.ImageAttachment) string

CreateDataURL creates a data URL from an image attachment

func (*ImageService) CreateImageVariation added in v0.178.1

func (s *ImageService) CreateImageVariation(ctx context.Context, model, imagePath, size string) (string, error)

CreateImageVariation creates a variation of the image at imagePath using model ("provider/name") and returns the path of the saved PNG. A blank size is omitted from the request, leaving the provider's own default.

func (*ImageService) EditImage added in v0.178.1

func (s *ImageService) EditImage(ctx context.Context, model, prompt, imagePath, quality, size, maskPath string) (string, error)

EditImage edits the image at imagePath using prompt and model ("provider/name") and returns the path of the saved PNG. A blank quality or size is omitted from the request, leaving the provider's own default. A non-empty maskPath points to a PNG whose transparent (alpha=0) areas mark the editable region; all other pixels are preserved exactly.

func (*ImageService) GenerateImage added in v0.178.1

func (s *ImageService) GenerateImage(ctx context.Context, model, prompt, quality, size string) (string, error)

GenerateImage generates an image from prompt using model ("provider/name") and returns the path of the saved PNG. A blank quality or size is omitted from the request, leaving the provider's own default.

func (*ImageService) IsImageFile added in v0.178.1

func (s *ImageService) IsImageFile(filePath string) bool

IsImageFile checks if a file is a supported image format

func (*ImageService) IsImageModel added in v0.178.1

func (s *ImageService) IsImageModel(model string) bool

IsImageModel reports whether the model generates images rather than text. Uses gateway-reported modalities: a model is an image-generation model if its modalities include "image" but NOT "text". Falls back to false when the model is not in the registry.

func (*ImageService) IsImageURL added in v0.178.1

func (s *ImageService) IsImageURL(urlStr string) bool

IsImageURL checks if a string is a valid image URL

func (*ImageService) ReadImageFromBinary added in v0.178.1

func (s *ImageService) ReadImageFromBinary(imageData []byte, filename string) (*agentdomain.ImageAttachment, error)

ReadImageFromBinary reads an image from binary data and returns it as a base64 attachment

func (*ImageService) ReadImageFromFile added in v0.178.1

func (s *ImageService) ReadImageFromFile(filePath string) (*agentdomain.ImageAttachment, error)

ReadImageFromFile reads an image from a file path and returns it as a base64 attachment

func (*ImageService) ReadImageFromURL added in v0.178.1

func (s *ImageService) ReadImageFromURL(imageURL string) (*agentdomain.ImageAttachment, error)

ReadImageFromURL fetches an image from a URL and returns it as a base64 attachment. URLs reach this from untrusted sources (LLM tool arguments), so only http(s) to public addresses is allowed.

Jump to

Keyboard shortcuts

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