Documentation
¶
Index ¶
- type BackendFactory
- type BackendProtocol
- type CompositeBackend
- func (b *CompositeBackend) AddRoute(prefix string, backend BackendProtocol)
- func (b *CompositeBackend) Edit(ctx context.Context, path string, oldStr, newStr string, replaceAll bool) (*EditResult, error)
- func (b *CompositeBackend) Execute(ctx context.Context, command string) (*ExecuteResult, error)
- func (b *CompositeBackend) Glob(ctx context.Context, pattern string, basePath string) ([]string, error)
- func (b *CompositeBackend) Grep(ctx context.Context, pattern string, path string, globFilter string) ([]GrepMatch, error)
- func (b *CompositeBackend) List(ctx context.Context, path string) ([]FileInfo, error)
- func (b *CompositeBackend) Read(ctx context.Context, path string, offset, limit int) (string, error)
- func (b *CompositeBackend) SupportsExecution() bool
- func (b *CompositeBackend) Write(ctx context.Context, path string, content string) (*WriteResult, error)
- type EditResult
- type ExecuteResult
- type FileData
- type FileInfo
- type GrepMatch
- type SandboxBackendProtocol
- type StateBackend
- func (b *StateBackend) Edit(ctx context.Context, path string, oldStr, newStr string, replaceAll bool) (*EditResult, error)
- func (b *StateBackend) Glob(ctx context.Context, pattern string, basePath string) ([]string, error)
- func (b *StateBackend) Grep(ctx context.Context, pattern string, path string, globFilter string) ([]GrepMatch, error)
- func (b *StateBackend) List(ctx context.Context, path string) ([]FileInfo, error)
- func (b *StateBackend) Read(ctx context.Context, path string, offset, limit int) (string, error)
- func (b *StateBackend) Write(ctx context.Context, path string, content string) (*WriteResult, error)
- type StoreBackend
- func (b *StoreBackend) Edit(ctx context.Context, path string, oldStr, newStr string, replaceAll bool) (*EditResult, error)
- func (b *StoreBackend) Glob(ctx context.Context, pattern string, basePath string) ([]string, error)
- func (b *StoreBackend) Grep(ctx context.Context, pattern string, path string, globFilter string) ([]GrepMatch, error)
- func (b *StoreBackend) List(ctx context.Context, path string) ([]FileInfo, error)
- func (b *StoreBackend) Read(ctx context.Context, path string, offset, limit int) (string, error)
- func (b *StoreBackend) Write(ctx context.Context, path string, content string) (*WriteResult, error)
- type WriteResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackendFactory ¶
type BackendFactory func(runtime interface{}) BackendProtocol
BackendFactory is a function that creates a backend from a ToolRuntime This allows backends to access agent state and store at runtime
type BackendProtocol ¶
type BackendProtocol interface {
// Read reads file content with optional pagination
// Returns formatted content (with line numbers in cat -n style)
Read(ctx context.Context, path string, offset, limit int) (string, error)
// Write creates or overwrites a file
Write(ctx context.Context, path string, content string) (*WriteResult, error)
// Edit performs string replacement in a file
Edit(ctx context.Context, path string, oldStr, newStr string, replaceAll bool) (*EditResult, error)
// List lists files in a directory
List(ctx context.Context, path string) ([]FileInfo, error)
// Glob finds files matching a pattern
Glob(ctx context.Context, pattern string, basePath string) ([]string, error)
// Grep searches for text in files
Grep(ctx context.Context, pattern string, path string, globFilter string) ([]GrepMatch, error)
}
BackendProtocol defines the interface for filesystem backends This matches LangGraph's FilesystemMiddleware backend abstraction
type CompositeBackend ¶
type CompositeBackend struct {
// contains filtered or unexported fields
}
CompositeBackend routes different paths to different backends This matches LangGraph's CompositeBackend pattern for mixed storage Example: /memories/* -> StoreBackend (persistent), everything else -> StateBackend (ephemeral)
func NewCompositeBackend ¶
func NewCompositeBackend(defaultBackend BackendProtocol) *CompositeBackend
NewCompositeBackend creates a new composite backend with a default
func (*CompositeBackend) AddRoute ¶
func (b *CompositeBackend) AddRoute(prefix string, backend BackendProtocol)
AddRoute adds a path prefix route to a specific backend Longer prefixes are matched first (most specific wins)
func (*CompositeBackend) Edit ¶
func (b *CompositeBackend) Edit(ctx context.Context, path string, oldStr, newStr string, replaceAll bool) (*EditResult, error)
Edit delegates to the appropriate backend
func (*CompositeBackend) Execute ¶
func (b *CompositeBackend) Execute(ctx context.Context, command string) (*ExecuteResult, error)
Execute implements SandboxBackendProtocol if default backend supports it
func (*CompositeBackend) Glob ¶
func (b *CompositeBackend) Glob(ctx context.Context, pattern string, basePath string) ([]string, error)
Glob finds files, potentially across multiple backends
func (*CompositeBackend) Grep ¶
func (b *CompositeBackend) Grep(ctx context.Context, pattern string, path string, globFilter string) ([]GrepMatch, error)
Grep searches across files, potentially in multiple backends
func (*CompositeBackend) Read ¶
func (b *CompositeBackend) Read(ctx context.Context, path string, offset, limit int) (string, error)
Read delegates to the appropriate backend
func (*CompositeBackend) SupportsExecution ¶
func (b *CompositeBackend) SupportsExecution() bool
SupportsExecution checks if the composite backend supports execution
func (*CompositeBackend) Write ¶
func (b *CompositeBackend) Write(ctx context.Context, path string, content string) (*WriteResult, error)
Write delegates to the appropriate backend
type EditResult ¶
type EditResult struct {
// Path is the file path that was edited
Path string
// Occurrences is the number of replacements made
Occurrences int
// FilesUpdate contains state updates for StateBackend
// nil for other backends
FilesUpdate map[string]*FileData
// Error message if operation failed (empty string on success)
Error string
}
EditResult contains the result of an edit operation
type ExecuteResult ¶
type ExecuteResult struct {
// Output is the combined stdout/stderr
Output string
// ExitCode is the command exit code
ExitCode int
// Truncated indicates if output was truncated
Truncated bool
}
ExecuteResult contains the result of a command execution
type FileData ¶
type FileData struct {
// Content is the file content split into lines
Content []string
// CreatedAt is ISO 8601 timestamp
CreatedAt string
// ModifiedAt is ISO 8601 timestamp
ModifiedAt string
}
FileData represents file content with metadata
type GrepMatch ¶
type GrepMatch struct {
// Path is the file path
Path string
// LineNumber is the line number (1-indexed)
LineNumber int
// Line is the matching line content
Line string
}
GrepMatch represents a grep search result
type SandboxBackendProtocol ¶
type SandboxBackendProtocol interface {
BackendProtocol
// Execute runs a shell command in a sandboxed environment
Execute(ctx context.Context, command string) (*ExecuteResult, error)
}
SandboxBackendProtocol extends BackendProtocol with command execution Only backends implementing this can support the "execute" tool
type StateBackend ¶
type StateBackend struct {
// contains filtered or unexported fields
}
StateBackend stores files in agent state (ephemeral, session-scoped) Files are stored in state["files"] and persist only within the thread/session This matches LangGraph's default StateBackend behavior
func NewStateBackend ¶
func NewStateBackend(getState func() map[string]interface{}) *StateBackend
NewStateBackend creates a new state-based backend
func (*StateBackend) Edit ¶
func (b *StateBackend) Edit(ctx context.Context, path string, oldStr, newStr string, replaceAll bool) (*EditResult, error)
Edit performs string replacement in a file
func (*StateBackend) Grep ¶
func (b *StateBackend) Grep(ctx context.Context, pattern string, path string, globFilter string) ([]GrepMatch, error)
Grep searches for text in files
func (*StateBackend) Write ¶
func (b *StateBackend) Write(ctx context.Context, path string, content string) (*WriteResult, error)
Write creates or overwrites a file in state
type StoreBackend ¶
type StoreBackend struct {
// contains filtered or unexported fields
}
StoreBackend persists files across sessions using persistence.Store Files are stored in the persistent store and survive beyond thread lifetime This matches LangGraph's StoreBackend for long-term memory
func NewStoreBackend ¶
func NewStoreBackend(store persistence.Store, namespace string) *StoreBackend
NewStoreBackend creates a new store-based backend
func (*StoreBackend) Edit ¶
func (b *StoreBackend) Edit(ctx context.Context, path string, oldStr, newStr string, replaceAll bool) (*EditResult, error)
Edit performs string replacement in a file
func (*StoreBackend) Grep ¶
func (b *StoreBackend) Grep(ctx context.Context, pattern string, path string, globFilter string) ([]GrepMatch, error)
Grep searches for text in files
func (*StoreBackend) Write ¶
func (b *StoreBackend) Write(ctx context.Context, path string, content string) (*WriteResult, error)
Write creates or overwrites a file in persistent store
type WriteResult ¶
type WriteResult struct {
// Path is the file path that was written
Path string
// FilesUpdate contains state updates for StateBackend
// nil for other backends
FilesUpdate map[string]*FileData
// Error message if operation failed (empty string on success)
Error string
}
WriteResult contains the result of a write operation