Documentation
¶
Overview ¶
Package filesystem provides middlewares.
Index ¶
Constants ¶
View Source
const ( ListFilesToolDesc = `` /* 389-byte string literal not displayed */ ReadFileToolDesc = `` /* 1310-byte string literal not displayed */ EditFileToolDesc = `` /* 1091-byte string literal not displayed */ WriteFileToolDesc = `` /* 280-byte string literal not displayed */ GlobToolDesc = `` /* 480-byte string literal not displayed */ GrepToolDesc = `` /* 791-byte string literal not displayed */ ExecuteToolDesc = `` /* 2204-byte string literal not displayed */ ToolsSystemPrompt = `` /* 486-byte string literal not displayed */ ExecuteToolsSystemPrompt = `` /* 280-byte string literal not displayed */ )
Variables ¶
This section is empty.
Functions ¶
func NewMiddleware ¶
NewMiddleware constructs and returns the filesystem middleware.
Types ¶
type Backend ¶
type Backend interface {
// LsInfo lists file information under the given path.
//
// Returns:
// - []FileInfo: List of matching file information
// - error: Error if the operation fails
LsInfo(ctx context.Context, req *LsInfoRequest) ([]FileInfo, error)
// Read reads file content with support for line-based offset and limit.
//
// Returns:
// - string: The file content read
// - error: Error if file does not exist or read fails
Read(ctx context.Context, req *ReadRequest) (string, error)
// GrepRaw searches for content matching the specified pattern in files.
//
// Returns:
// - []GrepMatch: List of all matching results
// - error: Error if the search fails
GrepRaw(ctx context.Context, req *GrepRequest) ([]GrepMatch, error)
// GlobInfo returns file information matching the glob pattern.
//
// Returns:
// - []FileInfo: List of matching file information
// - error: Error if the pattern is invalid or operation fails
GlobInfo(ctx context.Context, req *GlobInfoRequest) ([]FileInfo, error)
// Write creates or updates file content.
//
// Returns:
// - error: Error if the write operation fails
Write(ctx context.Context, req *WriteRequest) error
// Edit replaces string occurrences in a file.
//
// Returns:
// - error: Error if file does not exist, OldString is empty, or OldString is not found
Edit(ctx context.Context, req *EditRequest) error
}
Backend is a pluggable, unified file backend protocol interface.
All methods use struct-based parameters to allow future extensibility without breaking backward compatibility.
type Config ¶
type Config struct {
// Backend provides filesystem operations used by tools and offloading.
// If the Backend also implements ShellBackend, an additional execute tool
// will be registered to support shell command execution.
// required
Backend Backend
// WithoutLargeToolResultOffloading disables automatic offloading of large tool result to Backend
// optional, false(enabled) by default
WithoutLargeToolResultOffloading bool
// LargeToolResultOffloadingTokenLimit sets the token threshold to trigger offloading
// optional, 20000 by default
LargeToolResultOffloadingTokenLimit int
// LargeToolResultOffloadingPathGen generates the write path for offloaded results based on context and ToolInput
// optional, "/large_tool_result/{ToolCallID}" by default
LargeToolResultOffloadingPathGen func(ctx context.Context, input *compose.ToolInput) (string, error)
// CustomSystemPrompt overrides the default ToolsSystemPrompt appended to agent instruction
// optional, ToolsSystemPrompt by default
CustomSystemPrompt *string
// CustomLsToolDesc overrides the ls tool description used in tool registration
// optional, ListFilesToolDesc by default
CustomLsToolDesc *string
// CustomReadFileToolDesc overrides the read_file tool description
// optional, ReadFileToolDesc by default
CustomReadFileToolDesc *string
// CustomGrepToolDesc overrides the grep tool description
// optional, GrepToolDesc by default
CustomGrepToolDesc *string
// CustomGlobToolDesc overrides the glob tool description
// optional, GlobToolDesc by default
CustomGlobToolDesc *string
// CustomWriteFileToolDesc overrides the write_file tool description
// optional, WriteFileToolDesc by default
CustomWriteFileToolDesc *string
// CustomEditToolDesc overrides the edit_file tool description
// optional, EditFileToolDesc by default
CustomEditToolDesc *string
// CustomExecuteToolDesc overrides the execute tool description
// optional, ExecuteToolDesc by default
CustomExecuteToolDesc *string
}
Config is the configuration for the filesystem middleware
type EditRequest ¶
type EditRequest = filesystem.EditRequest
type FileInfo ¶
type FileInfo = filesystem.FileInfo
type GlobInfoRequest ¶
type GlobInfoRequest = filesystem.GlobInfoRequest
type GrepMatch ¶
type GrepMatch = filesystem.GrepMatch
type GrepRequest ¶
type GrepRequest = filesystem.GrepRequest
type LsInfoRequest ¶
type LsInfoRequest = filesystem.LsInfoRequest
type ReadRequest ¶
type ReadRequest = filesystem.ReadRequest
type WriteRequest ¶
type WriteRequest = filesystem.WriteRequest
Click to show internal directories.
Click to hide internal directories.