fstool

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeleteFileArgs added in v0.6.0

type DeleteFileArgs struct {
	Path     string `json:"path"`
	TrashDir string `json:"trashDir,omitempty"` // "auto" default
}

type DeleteFileMethod added in v0.6.0

type DeleteFileMethod string
const (
	DeleteFileMethodRename        DeleteFileMethod = "rename"
	DeleteFileMethodCopyAndRemove DeleteFileMethod = "copyAndRemove"
	DeleteFileMethodSymlinkRehome DeleteFileMethod = "symlinkRehome"
)

type DeleteFileOut added in v0.6.0

type DeleteFileOut struct {
	OriginalPath string           `json:"originalPath"`
	TrashedPath  string           `json:"trashedPath"`
	Method       DeleteFileMethod `json:"method"`
}

type FSTool added in v0.7.0

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

FSTool is an instance-owned filesystem tool runner. It centralizes path resolution and sandbox policy:

  • workBaseDir: base for resolving relative paths
  • allowedRoots: optional restriction; if empty, allow all

func NewFSTool added in v0.7.0

func NewFSTool(opts ...FSToolOption) (*FSTool, error)

func (*FSTool) AllowedRoots added in v0.7.0

func (ft *FSTool) AllowedRoots() []string

func (*FSTool) DeleteFile added in v0.7.0

func (ft *FSTool) DeleteFile(ctx context.Context, args DeleteFileArgs) (*DeleteFileOut, error)

func (*FSTool) DeleteFileTool added in v0.7.0

func (ft *FSTool) DeleteFileTool() spec.Tool

func (*FSTool) ListDirectory added in v0.7.0

func (ft *FSTool) ListDirectory(ctx context.Context, args ListDirectoryArgs) (*ListDirectoryOut, error)

func (*FSTool) ListDirectoryTool added in v0.7.0

func (ft *FSTool) ListDirectoryTool() spec.Tool

func (*FSTool) MIMEForExtension added in v0.7.0

func (ft *FSTool) MIMEForExtension(ctx context.Context, args MIMEForExtensionArgs) (*MIMEForExtensionOut, error)

func (*FSTool) MIMEForExtensionTool added in v0.7.0

func (ft *FSTool) MIMEForExtensionTool() spec.Tool

func (*FSTool) MIMEForPath added in v0.7.0

func (ft *FSTool) MIMEForPath(ctx context.Context, args MIMEForPathArgs) (*MIMEForPathOut, error)

func (*FSTool) MIMEForPathTool added in v0.7.0

func (ft *FSTool) MIMEForPathTool() spec.Tool

func (*FSTool) ReadFile added in v0.7.0

func (ft *FSTool) ReadFile(
	ctx context.Context,
	args ReadFileArgs,
) ([]spec.ToolStoreOutputUnion, error)

func (*FSTool) ReadFileTool added in v0.7.0

func (ft *FSTool) ReadFileTool() spec.Tool

func (*FSTool) SearchFiles added in v0.7.0

func (ft *FSTool) SearchFiles(ctx context.Context, args SearchFilesArgs) (*SearchFilesOut, error)

func (*FSTool) SearchFilesTool added in v0.7.0

func (ft *FSTool) SearchFilesTool() spec.Tool

func (*FSTool) SetAllowedRoots added in v0.7.0

func (ft *FSTool) SetAllowedRoots(roots []string) error

SetAllowedRoots updates allowed roots at runtime (best-effort). If the current workBaseDir is not within the new roots, this returns an error and leaves state unchanged.

func (*FSTool) SetWorkBaseDir added in v0.7.0

func (ft *FSTool) SetWorkBaseDir(base string) error

SetWorkBaseDir updates the work base directory at runtime (best-effort).

func (*FSTool) StatPath added in v0.7.0

func (ft *FSTool) StatPath(ctx context.Context, args StatPathArgs) (*StatPathOut, error)

func (*FSTool) StatPathTool added in v0.7.0

func (ft *FSTool) StatPathTool() spec.Tool

func (*FSTool) Tools added in v0.7.0

func (ft *FSTool) Tools() []spec.Tool

Tools returns all fstool tool specs for registration.

func (*FSTool) WorkBaseDir added in v0.7.0

func (ft *FSTool) WorkBaseDir() string

func (*FSTool) WriteFile added in v0.7.0

func (ft *FSTool) WriteFile(ctx context.Context, args WriteFileArgs) (*WriteFileOut, error)

func (*FSTool) WriteFileTool added in v0.7.0

func (ft *FSTool) WriteFileTool() spec.Tool

type FSToolOption added in v0.7.0

type FSToolOption func(*FSTool) error

func WithAllowedRoots added in v0.7.0

func WithAllowedRoots(roots []string) FSToolOption

WithAllowedRoots restricts all filesystem paths to be within one of the provided roots. Roots are canonicalized (clean+abs+best-effort symlink eval) and must exist as directories.

func WithWorkBaseDir added in v0.7.0

func WithWorkBaseDir(base string) FSToolOption

WithWorkBaseDir sets the base directory used to resolve relative input paths. If empty/whitespace, the current process working directory is used.

type ListDirectoryArgs

type ListDirectoryArgs struct {
	Path    string `json:"path,omitempty"`    // default "."
	Pattern string `json:"pattern,omitempty"` // Optional glob
}

type ListDirectoryOut

type ListDirectoryOut struct {
	Entries []string `json:"entries"`
}

type MIMEDetectMethod added in v0.4.0

type MIMEDetectMethod string
const (
	MIMEDetectMethodExtension MIMEDetectMethod = "extension"
	MIMEDetectMethodSniff     MIMEDetectMethod = "sniff"
)

type MIMEForExtensionArgs added in v0.4.0

type MIMEForExtensionArgs struct {
	Extension string `json:"extension"`
}

type MIMEForExtensionOut added in v0.4.0

type MIMEForExtensionOut struct {
	Extension           string   `json:"extension"`
	NormalizedExtension string   `json:"normalizedExtension"`
	MIMEType            string   `json:"mimeType"`
	BaseMIMEType        string   `json:"baseMimeType"`
	Mode                MIMEMode `json:"mode"`
	Known               bool     `json:"known"`
}

type MIMEForPathArgs added in v0.4.0

type MIMEForPathArgs struct {
	Path string `json:"path"`
}

type MIMEForPathOut added in v0.4.0

type MIMEForPathOut struct {
	Path                string           `json:"path"`
	Extension           string           `json:"extension,omitempty"`
	NormalizedExtension string           `json:"normalizedExtension,omitempty"`
	MIMEType            string           `json:"mimeType"`
	BaseMIMEType        string           `json:"baseMimeType"`
	Mode                MIMEMode         `json:"mode"`
	Method              MIMEDetectMethod `json:"method"`
}

type MIMEMode added in v0.4.0

type MIMEMode string
const (
	MIMEModeText     MIMEMode = "text"
	MIMEModeImage    MIMEMode = "image"
	MIMEModeDocument MIMEMode = "document"
	MIMEModeDefault  MIMEMode = "default"
)

type ReadFileArgs

type ReadFileArgs struct {
	Path     string `json:"path"`               // required
	Encoding string `json:"encoding,omitempty"` // "text" (default) | "binary"
}

type SearchFilesArgs

type SearchFilesArgs struct {
	Root       string `json:"root,omitempty"` // default "."
	Pattern    string `json:"pattern"`        // required (RE2)
	MaxResults int    `json:"maxResults,omitempty"`
}

type SearchFilesOut

type SearchFilesOut struct {
	MatchCount        int      `json:"matchCount"`
	ReachedMaxResults bool     `json:"reachedMaxResults"`
	Matches           []string `json:"matches"`
}

type StatPathArgs

type StatPathArgs struct {
	Path string `json:"path"`
}

type StatPathOut

type StatPathOut struct {
	Path      string     `json:"path"`
	Name      string     `json:"name"`
	Exists    bool       `json:"exists"`
	IsDir     bool       `json:"isDir"`
	SizeBytes int64      `json:"sizeBytes,omitempty"`
	ModTime   *time.Time `json:"modTime,omitempty"`
}

type WriteFileArgs added in v0.6.0

type WriteFileArgs struct {
	Path          string `json:"path"`
	Encoding      string `json:"encoding,omitempty"` // "text"(default) | "binary"
	Content       string `json:"content"`
	Overwrite     bool   `json:"overwrite,omitempty"`
	CreateParents bool   `json:"createParents,omitempty"`
}

type WriteFileOut added in v0.6.0

type WriteFileOut struct {
	Path         string `json:"path"`
	BytesWritten int64  `json:"bytesWritten"`
}

Jump to

Keyboard shortcuts

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