read

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultMaxImageDimension is the default maximum width/height
	DefaultMaxImageDimension = 2048

	// DefaultThumbnailDimension is the default thumbnail size
	DefaultThumbnailDimension = 512

	// TokenEstimationFactor is the factor to estimate tokens from base64 length
	// base64_length * 0.125 ≈ token count
	TokenEstimationFactor = 0.125

	// DefaultMaxImageTokens is the default maximum tokens for images
	DefaultMaxImageTokens = 4096
)

Image processing constants

View Source
const (
	// DefaultLimit is the default number of lines to read
	DefaultLimit = 100

	// MaxLimit is the maximum number of lines to read
	MaxLimit = 10000

	// MaxFileSize is the maximum file size to read (10MB)
	MaxFileSize = 10 * 1024 * 1024

	// MaxImageSize is the maximum image size to read (5MB)
	MaxImageSize = 5 * 1024 * 1024

	// MinLineLength is the minimum line length for binary detection
	MinLineLength = 1000
)
View Source
const (
	// MaxNotebookCells is the maximum number of cells to read from a notebook
	MaxNotebookCells = 500

	// MaxCellOutputLength is the maximum length of cell output to include
	MaxCellOutputLength = 10000
)

Notebook constants

View Source
const (
	// MaxPagesPerRead is the maximum number of pages per read
	MaxPagesPerRead = 50

	// PDFATMentionInlineThreshold is the page count threshold for inline PDF reading
	PDFATMentionInlineThreshold = 20
)

PDF constants

View Source
const (
	// CyberRiskMitigationReminder is the security reminder for file reads
	CyberRiskMitigationReminder = "" /* 331-byte string literal not displayed */
)
View Source
const MaxLinesToRead = 2000

MaxLinesToRead is the maximum number of lines to read.

View Source
const SearchHint = "read files from the filesystem"

SearchHint is a hint for tool search functionality.

View Source
const ToolName = "read_file"

ToolName is the name of the file read tool.

Variables

View Source
var BlockedDevicePaths = map[string]bool{
	"/dev/zero":    true,
	"/dev/random":  true,
	"/dev/urandom": true,
	"/dev/full":    true,
	"/dev/stdin":   true,
	"/dev/tty":     true,
	"/dev/console": true,
	"/dev/stdout":  true,
	"/dev/stderr":  true,
	"/dev/fd/0":    true,
	"/dev/fd/1":    true,
	"/dev/fd/2":    true,
}

Blocked device paths that would hang the process

View Source
var Description = fmt.Sprintf(`Read the contents of a file. Supports text files, images, PDFs, and - when docling-serve is configured - DOCX, PPTX, XLSX documents and audio transcription (WAV, MP3). For large text files, use offset/limit to read specific ranges. For PDFs, use the pages parameter to read specific page ranges.

Reads a file from the local filesystem. You can access any file directly by using this tool. Assume this tool is able to read all files on the machine. If the user provides a path to a file assume that path is valid. It is okay to read a file that does not exist; an error will be returned.

Usage:
- The file_path parameter must be an absolute path, not a relative path
- By default, it reads up to %d lines starting from the beginning of the file
- You can optionally specify a line offset and limit (especially handy for long files), but it is recommended to read the whole file by not providing these parameters
- Results are returned using cat -n format, with line numbers starting at 1
- When you already know which part of the file you need, only read that part. This can be important for larger files.
- This tool allows reading images (eg PNG, JPG, etc). When reading an image file the contents are presented visually.
- This tool can read PDF files (.pdf). For large PDFs (more than 10 pages), you must provide the pages parameter to read specific page ranges (e.g., pages: "1-5"). Reading a large PDF without the pages parameter will fail. Maximum 20 pages per request.
- This tool can read Jupyter notebooks (.ipynb files) and returns all cells with their outputs, combining code, text, and visualizations.
- When docling-serve is configured, this tool can convert DOCX, PPTX, XLSX documents and transcribe WAV/MP3 audio files to markdown automatically.
- This tool can only read files, not directories. To read a directory, use an ls command via the Bash tool.
- You will regularly be asked to read screenshots. If the user provides a path to a screenshot, always use this tool to view the file at the path.
- If you read a file that exists but has empty contents you will receive a warning in place of file contents.`, MaxLinesToRead)

Description is the description of the file read tool.

View Source
var DoclingExtensions = map[string]bool{
	".docx": true,
	".pptx": true,
	".xlsx": true,
	".wav":  true,
	".mp3":  true,
}

DoclingExtensions lists binary formats that require docling-serve for extraction. PDF has its own dedicated path (FileTypePDF); images go through the multimodal path. Text-based formats (.tex, .html) remain in TextExtensions and are read directly.

View Source
var ImageMimeTypes = map[string]string{
	".jpg":  "image/jpeg",
	".jpeg": "image/jpeg",
	".png":  "image/png",
	".gif":  "image/gif",
	".webp": "image/webp",
	".bmp":  "image/bmp",
	".svg":  "image/svg+xml",
}

ImageMimeTypes maps extensions to MIME types

View Source
var TextExtensions = map[string]bool{
	".txt":        true,
	".md":         true,
	".markdown":   true,
	".json":       true,
	".xml":        true,
	".html":       true,
	".css":        true,
	".js":         true,
	".ts":         true,
	".go":         true,
	".py":         true,
	".rs":         true,
	".c":          true,
	".cpp":        true,
	".h":          true,
	".hpp":        true,
	".java":       true,
	".sh":         true,
	".bash":       true,
	".zsh":        true,
	".fish":       true,
	".yaml":       true,
	".yml":        true,
	".toml":       true,
	".ini":        true,
	".cfg":        true,
	".conf":       true,
	".log":        true,
	".csv":        true,
	".tsv":        true,
	".sql":        true,
	".php":        true,
	".rb":         true,
	".swift":      true,
	".kt":         true,
	".scala":      true,
	".dart":       true,
	".lua":        true,
	".r":          true,
	".m":          true,
	".pl":         true,
	".tcl":        true,
	".vim":        true,
	".dockerfile": true,
}

TextExtensions are common text file extensions

Functions

func AddCompactLineNumbers

func AddCompactLineNumbers(content string, startLine int) string

AddCompactLineNumbers adds compact line numbers (no padding)

func AddLineNumbers

func AddLineNumbers(content string, startLine int) string

AddLineNumbers adds cat -n style line numbers to content

func CacheFileRead

func CacheFileRead(filePath string, content string, fileInfo os.FileInfo, offset, limit int, isPartialView bool)

CacheFileRead stores a file read in the cache

func EstimateImageTokens

func EstimateImageTokens(imageData []byte) int

EstimateImageTokens estimates token count from image data

func FormatNotFoundError

func FormatNotFoundError(path string, workingDir string) error

FormatNotFoundError formats a file not found error with suggestions

func FormatNotebookCell

func FormatNotebookCell(cell NotebookCell, index int) string

FormatNotebookCell formats a single notebook cell for display

func FormatNotebookResult

func FormatNotebookResult(result *NotebookResult) string

FormatNotebookResult formats a notebook result for display

func FormatTextWithLineNumbers

func FormatTextWithLineNumbers(result *FileReadResult, compact bool) string

FormatTextWithLineNumbers formats text file result with line numbers

func GetAlternateScreenshotPath

func GetAlternateScreenshotPath(filePath string) (string, bool)

GetAlternateScreenshotPath tries alternate paths for macOS screenshots

func GetCanonicalName

func GetCanonicalName(modelName string) string

GetCanonicalName returns a canonical name for models (for future use)

func GetImageMimeType

func GetImageMimeType(filePath string) string

GetImageMimeType returns the MIME type for an image file

func GetPDFPageCount

func GetPDFPageCount(filePath string) (int, error)

GetPDFPageCount returns the number of pages in a PDF file

func InvalidateFileCache

func InvalidateFileCache(filePath string)

InvalidateFileCache removes a file from the cache

func IsImageByExtension

func IsImageByExtension(filePath string) bool

IsImageByExtension checks if a file is likely an image based on extension

func IsNotebookExtension

func IsNotebookExtension(ext string) bool

IsNotebookExtension checks if a file extension is a notebook extension

func IsPDFExtension

func IsPDFExtension(ext string) bool

IsPDFExtension checks if a file extension is a PDF extension

func IsTextByExtension

func IsTextByExtension(filePath string) bool

IsTextByExtension checks if a file is likely text based on extension

func ReadFileInRange

func ReadFileInRange(
	ctx context.Context,
	filePath string,
	offset int,
	limit int,
	maxBytes int64,
) (content string, lineCount int, totalLines int, totalBytes int64, readBytes int, mtimeMs int64, err error)

ReadFileInRange reads a file with offset/limit support and cancellation Checks ctx.Done() during reading to support cancellation

func ReadFileWithCancellation

func ReadFileWithCancellation(ctx context.Context, filePath string) ([]byte, error)

ReadFileWithCancellation reads entire file content with cancellation support

func RecordExternalRead

func RecordExternalRead(filePath string, modTime time.Time, content string, isFullRead bool)

RecordExternalRead stores externally-observed read state in the shared cache.

func ShouldIncludeCyberRiskReminder

func ShouldIncludeCyberRiskReminder() bool

ShouldIncludeCyberRiskReminder determines if we should include the security reminder

func SuggestPathUnderCwd

func SuggestPathUnderCwd(requestedPath string, workingDir string) (string, error)

SuggestPathUnderCwd suggests an alternative path under the current working directory This is an improved version with symlink support

Types

type BinaryFileResult

type BinaryFileResult struct {
	// FilePath is the path to the file
	FilePath string `json:"file_path"`

	// Reason is the reason why the file cannot be read
	Reason string `json:"reason"`

	// Suggestion is a suggested alternative tool or action
	Suggestion string `json:"suggestion,omitempty"`
}

BinaryFileResult represents the result of trying to read a binary file

type CancellationGroup

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

CancellationGroup allows waiting for multiple operations with cancellation

func NewCancellationGroup

func NewCancellationGroup(ctx context.Context) *CancellationGroup

NewCancellationGroup creates a new cancellation group

func (*CancellationGroup) Cancel

func (g *CancellationGroup) Cancel()

Cancel cancels all operations in the group

func (*CancellationGroup) Go

func (g *CancellationGroup) Go(fn func(context.Context) error)

Go starts a goroutine with cancellation support

func (*CancellationGroup) Wait

func (g *CancellationGroup) Wait() error

Wait waits for all operations to complete

type DoclingFileResult

type DoclingFileResult struct {
	FilePath     string     `json:"file_path"`
	Format       string     `json:"format"` // lowercase extension without dot, e.g. "docx"
	Markdown     string     `json:"markdown"`
	OriginalSize int64      `json:"original_size"`
	PageCount    int        `json:"page_count,omitempty"` // 0 for audio
	Images       []PDFImage `json:"images,omitempty"`
}

DoclingFileResult is the result of converting a non-PDF file (DOCX, PPTX, XLSX, audio) via docling-serve.

type FileReadCache

type FileReadCache struct {

	// MaxEntries is the maximum number of entries to cache
	MaxEntries int

	// MaxAge is the maximum age of cache entries
	MaxAge time.Duration
	// contains filtered or unexported fields
}

FileReadCache manages deduplication of file reads

func GetGlobalCache

func GetGlobalCache() *FileReadCache

GetGlobalCache returns the global file read cache (singleton)

func NewFileReadCache

func NewFileReadCache() *FileReadCache

NewFileReadCache creates a new file read cache

func (*FileReadCache) Cleanup

func (c *FileReadCache) Cleanup()

Cleanup removes expired entries from the cache

func (*FileReadCache) Clear

func (c *FileReadCache) Clear()

Clear removes all entries from the cache

func (*FileReadCache) Get

func (c *FileReadCache) Get(filePath string, offset, limit int) (*FileReadState, bool)

Get retrieves a cached file read state if it exists and is still valid

func (*FileReadCache) GetLatest

func (c *FileReadCache) GetLatest(filePath string) (*FileReadState, bool)

GetLatest retrieves the latest cached state for a file if it is still valid.

func (*FileReadCache) Invalidate

func (c *FileReadCache) Invalidate(filePath string)

Invalidate removes a file from the cache

func (*FileReadCache) Set

func (c *FileReadCache) Set(filePath string, content string, fileInfo os.FileInfo, offset, limit int, isPartialView bool)

Set stores a file read state in the cache

func (*FileReadCache) SetState

func (c *FileReadCache) SetState(filePath string, state *FileReadState)

SetState stores a precomputed file read state in the cache.

func (*FileReadCache) Size

func (c *FileReadCache) Size() int

Size returns the number of entries in the cache

type FileReadResult

type FileReadResult struct {
	// Type indicates the type of result
	Type FileType `json:"type"`

	// Text contains the text file result (if Type == FileTypeText)
	Text *TextFileResult `json:"text,omitempty"`

	// Image contains the image file result (if Type == FileTypeImage)
	Image *ImageFileResult `json:"image,omitempty"`

	// PDF contains the PDF file result (if Type == FileTypePDF)
	PDF *PDFFileResult `json:"pdf,omitempty"`

	// PDFExtracted contains the PDF extracted pages result (if Type == FileTypePDFExtracted)
	PDFExtracted *PDFExtractedResult `json:"pdf_extracted,omitempty"`

	// PDFMarkdown contains the docling-converted PDF result (if Type == FileTypePDFMarkdown)
	PDFMarkdown *PDFMarkdownFileResult `json:"pdf_markdown,omitempty"`

	// Docling contains the result of a docling conversion of a non-PDF format (if Type == FileTypeDocling)
	Docling *DoclingFileResult `json:"docling,omitempty"`

	// Notebook contains the notebook result (if Type == FileTypeNotebook)
	Notebook *NotebookResult `json:"notebook,omitempty"`

	// Unchanged contains the unchanged file result (if Type == FileTypeUnchanged)
	Unchanged *UnchangedFileResult `json:"unchanged,omitempty"`

	// Binary contains the binary file result (if Type == FileTypeBinary)
	Binary *BinaryFileResult `json:"binary,omitempty"`

	// Error contains any error that occurred
	Error string `json:"error,omitempty"`
}

FileReadResult is the union type for file read results

type FileReadState

type FileReadState struct {
	// Content is the cached content
	Content string `json:"content"`

	// Timestamp is the file modification time when cached
	Timestamp int64 `json:"timestamp"`

	// Offset is the line offset used for text files (0-based)
	Offset int `json:"offset,omitempty"`

	// Limit is the number of lines read
	Limit int `json:"limit,omitempty"`

	// IsPartialView indicates if this is a partial view (offset/limit used)
	IsPartialView bool `json:"is_partial_view,omitempty"`

	// CachedAt is when this entry was created
	CachedAt time.Time `json:"cached_at"`
}

FileReadState represents the state of a previously read file

func CheckFileUnchanged

func CheckFileUnchanged(filePath string, offset, limit int) (*FileReadState, bool)

CheckFileUnchanged checks if a file has the same content as cached

func GetLastReadState

func GetLastReadState(filePath string) (*FileReadState, bool)

GetLastReadState returns the most recent cached read state for a file.

type FileType

type FileType string

FileType represents the type of file

const (
	FileTypeText         FileType = "text"
	FileTypeImage        FileType = "image"
	FileTypePDF          FileType = "pdf"
	FileTypePDFExtracted FileType = "pdf_extracted"
	FileTypePDFMarkdown  FileType = "pdf_markdown"
	FileTypeNotebook     FileType = "notebook"
	FileTypeUnchanged    FileType = "file_unchanged"
	FileTypeBinary       FileType = "binary"
	// FileTypeDocling represents formats converted via docling-serve (DOCX, PPTX, XLSX, audio).
	FileTypeDocling FileType = "docling"
)

func DetectFileType

func DetectFileType(filePath string) (FileType, error)

DetectFileType detects the type of file

type ImageDimensions

type ImageDimensions struct {
	// Width is the image width in pixels
	Width int `json:"width"`

	// Height is the image height in pixels
	Height int `json:"height"`
}

ImageDimensions represents the dimensions of an image

func GetImageDimensions

func GetImageDimensions(imageData []byte) (*ImageDimensions, error)

GetImageDimensions extracts dimensions from image data

type ImageFileResult

type ImageFileResult struct {
	// FilePath is the path to the file that was read
	FilePath string `json:"file_path"`

	// Base64 is the base64-encoded image data
	Base64 string `json:"base64"`

	// MimeType is the MIME type of the image
	MimeType string `json:"type"`

	// OriginalSize is the original file size in bytes
	OriginalSize int64 `json:"original_size"`

	// Dimensions contains the image dimensions (optional)
	Dimensions *ImageDimensions `json:"dimensions,omitempty"`
}

ImageFileResult represents the result of reading an image file

type ImageProcessingResult

type ImageProcessingResult struct {
	Base64          string           `json:"base64"`
	MimeType        string           `json:"mime_type"`
	OriginalSize    int64            `json:"original_size"`
	ProcessedSize   int64            `json:"processed_size"`
	Dimensions      *ImageDimensions `json:"dimensions,omitempty"`
	WasResized      bool             `json:"was_resized"`
	WasCompressed   bool             `json:"was_compressed"`
	EstimatedTokens int              `json:"estimated_tokens"`
}

ImageProcessingResult represents the result of image processing

func ReadAndProcessImage

func ReadAndProcessImage(filePath string, maxTokens int) (*ImageProcessingResult, error)

ReadAndProcessImage reads and processes an image file

type Notebook

type Notebook struct {
	Cells         []NotebookCell   `json:"cells"`
	Metadata      NotebookMetadata `json:"metadata"`
	NBFormat      int              `json:"nbformat"`
	NBFormatMinor int              `json:"nbformat_minor"`
}

Notebook represents a parsed Jupyter notebook

func ReadNotebook

func ReadNotebook(filePath string) (*Notebook, error)

ReadNotebook reads and parses a Jupyter notebook file

type NotebookCell

type NotebookCell struct {
	ID             string           `json:"id,omitempty"`
	CellType       string           `json:"cell_type"`
	Source         []string         `json:"source"`
	Metadata       json.RawMessage  `json:"metadata,omitempty"`
	Outputs        []NotebookOutput `json:"outputs,omitempty"`
	ExecutionCount *int             `json:"execution_count,omitempty"`
}

NotebookCell represents a cell in a Jupyter notebook

type NotebookKernelspec

type NotebookKernelspec struct {
	Name     string `json:"name"`
	Display  string `json:"display,omitempty"`
	Language string `json:"language"`
}

NotebookKernelspec represents kernel specification

type NotebookLanguageInfo

type NotebookLanguageInfo struct {
	Name          string `json:"name"`
	Version       string `json:"version,omitempty"`
	FileExtension string `json:"file_extension,omitempty"`
}

NotebookLanguageInfo represents language information

type NotebookMetadata

type NotebookMetadata struct {
	LanguageInfo *NotebookLanguageInfo `json:"language_info,omitempty"`
	Kernelspec   *NotebookKernelspec   `json:"kernelspec,omitempty"`
	Title        string                `json:"title,omitempty"`
	Author       string                `json:"author,omitempty"`
	Description  string                `json:"description,omitempty"`
}

NotebookMetadata represents notebook metadata

type NotebookOutput

type NotebookOutput struct {
	OutputType string          `json:"output_type"`
	Text       []string        `json:"text,omitempty"`
	Data       map[string]any  `json:"data,omitempty"`
	Metadata   json.RawMessage `json:"metadata,omitempty"`
	Ename      string          `json:"ename,omitempty"`
	Evalue     string          `json:"evalue,omitempty"`
	Traceback  []string        `json:"traceback,omitempty"`
}

NotebookOutput represents output from a code cell

type NotebookResult

type NotebookResult struct {
	FilePath      string         `json:"file_path"`
	Cells         []NotebookCell `json:"cells"`
	Language      string         `json:"language,omitempty"`
	CellCount     int            `json:"cell_count"`
	CodeCells     int            `json:"code_cells"`
	MarkdownCells int            `json:"markdown_cells"`
	RawCells      int            `json:"raw_cells"`
}

NotebookResult represents the result of reading a notebook

func ParseNotebook

func ParseNotebook(notebook *Notebook, filePath string) (*NotebookResult, error)

ParseNotebook parses a notebook into a structured result

type PDFExtractedResult

type PDFExtractedResult struct {
	// FilePath is the path to the file that was read
	FilePath string `json:"file_path"`

	// OriginalSize is the original file size in bytes
	OriginalSize int64 `json:"original_size"`

	// Count is the number of pages extracted
	Count int `json:"count"`

	// OutputDir is the directory containing extracted page images
	OutputDir string `json:"output_dir"`
}

PDFExtractedResult represents the result of extracting pages from a PDF

type PDFExtractionResult

type PDFExtractionResult struct {
	FilePath     string
	OriginalSize int64
	Count        int
	OutputDir    string
}

PDFExtractionResult represents the result of extracting PDF pages

func ExtractPDFPages

func ExtractPDFPages(filePath string, pageRange *PDFPageRange) (*PDFExtractionResult, error)

ExtractPDFPages extracts specific pages from a PDF and returns images

type PDFFileResult

type PDFFileResult struct {
	// FilePath is the path to the file that was read
	FilePath string `json:"file_path"`

	// Base64 is the base64-encoded PDF data
	Base64 string `json:"base64"`

	// OriginalSize is the original file size in bytes
	OriginalSize int64 `json:"original_size"`

	// PageCount is the number of pages in the PDF
	PageCount int `json:"page_count"`
}

PDFFileResult represents the result of reading a PDF file

type PDFImage

type PDFImage struct {
	Filename string `json:"filename"`
	MimeType string `json:"mime_type"`
	Base64   string `json:"base64"`
}

PDFImage is one picture extracted from a converted PDF.

type PDFMarkdownFileResult

type PDFMarkdownFileResult struct {
	FilePath     string     `json:"file_path"`
	Markdown     string     `json:"markdown"`
	OriginalSize int64      `json:"original_size"`
	PageCount    int        `json:"page_count"`
	Images       []PDFImage `json:"images,omitempty"`
}

PDFMarkdownFileResult is the result of a docling-converted PDF.

type PDFPageRange

type PDFPageRange struct {
	FirstPage int
	LastPage  int
}

PDFPageRange represents a parsed PDF page range

func ParsePDFPageRange

func ParsePDFPageRange(pages string) (*PDFPageRange, error)

ParsePDFPageRange parses a PDF page range string Supports formats: "1-5", "3", "10-20", "5-" (5 to end)

type PDFResult

type PDFResult struct {
	FilePath     string
	Base64       string
	OriginalSize int64
	PageCount    int
}

PDFResult represents the result of reading a PDF

func ReadPDF

func ReadPDF(filePath string) (*PDFResult, error)

ReadPDF reads a PDF file and returns base64-encoded data

type TextFileResult

type TextFileResult struct {
	// FilePath is the path to the file that was read
	FilePath string `json:"file_path"`

	// Content is the content of the file
	Content string `json:"content"`

	// NumLines is the number of lines in the returned content
	NumLines int `json:"num_lines"`

	// StartLine is the starting line number (1-indexed)
	StartLine int `json:"start_line"`

	// TotalLines is the total number of lines in the file
	TotalLines int `json:"total_lines"`

	// Truncated indicates if the output was truncated
	Truncated bool `json:"truncated,omitempty"`
}

TextFileResult represents the result of reading a text file

type Tool

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

Tool represents the FileRead tool

func NewTool

func NewTool(config *ToolConfig) *Tool

NewTool creates a new FileRead tool

func (*Tool) BackfillInput

func (t *Tool) BackfillInput(ctx context.Context, input map[string]any) map[string]any

BackfillInput enriches a shallow clone of the parsed input with derived fields.

func (*Tool) Call

func (t *Tool) Call(
	ctx context.Context,
	input tool.CallInput,
	permissionCheck types.CanUseToolFn,
) (tool.CallResult, error)

Call executes the tool

func (*Tool) CheckPermissions

func (t *Tool) CheckPermissions(ctx context.Context, input map[string]any, toolCtx tool.ToolUseContext) types.PermissionResult

CheckPermissions performs file-read-specific permission checks before the global pipeline.

func (*Tool) Definition

func (t *Tool) Definition() tool.Definition

Definition returns the tool definition

func (*Tool) Description

func (t *Tool) Description(ctx context.Context) (string, error)

Description returns a human-readable description

func (*Tool) FormatResult

func (t *Tool) FormatResult(data any) string

FormatResult serialises the tool output into the tool_result content string.

func (*Tool) IsConcurrencySafe

func (t *Tool) IsConcurrencySafe(input map[string]any) bool

IsConcurrencySafe returns whether this tool use can run concurrently.

func (*Tool) IsEnabled

func (t *Tool) IsEnabled() bool

IsEnabled returns whether this tool is currently active.

func (*Tool) IsReadOnly

func (t *Tool) IsReadOnly(input map[string]any) bool

IsReadOnly returns whether this tool use is read-only.

func (*Tool) ValidateInput

func (t *Tool) ValidateInput(ctx context.Context, input map[string]any) (map[string]any, error)

ValidateInput validates and normalizes file-read input.

type ToolConfig

type ToolConfig struct {
	// MaxFileSize is the maximum file size to read
	MaxFileSize int64

	// MaxImageSize is the maximum image size to read
	MaxImageSize int64

	// DefaultLimit is the default number of lines to read
	DefaultLimit int

	// MaxLimit is the maximum number of lines to read
	MaxLimit int

	// DoclingURL is the base URL of a running docling-serve instance.
	// When non-empty a Client is created and PDFs are converted to markdown.
	// Example: "http://localhost:5001"
	DoclingURL string
}

ToolConfig represents the FileRead tool configuration

func DefaultToolConfig

func DefaultToolConfig() *ToolConfig

DefaultToolConfig returns default tool configuration

type UnchangedFileResult

type UnchangedFileResult struct {
	// FilePath is the path to the file
	FilePath string `json:"file_path"`

	// Message indicates the file is unchanged
	Message string `json:"message"`
}

UnchangedFileResult represents the result when a file hasn't changed since last read

Jump to

Keyboard shortcuts

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