fstools

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const MaxReadFileSize = 64 * 1024 // 64KB limit to avoid context overflow

Variables

This section is empty.

Functions

func IsAllowedPath

func IsAllowedPath(path string, patterns []*regexp.Regexp) bool

func ToolChannel

func ToolChannel(ctx context.Context) string

func ToolChatID

func ToolChatID(ctx context.Context) string

func ValidatePathWithAllowPaths

func ValidatePathWithAllowPaths(
	path, workspace string,
	restrict bool,
	patterns []*regexp.Regexp,
) (string, error)

func WithToolContext

func WithToolContext(ctx context.Context, channel, chatID string) context.Context

Types

type AppendFileTool

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

func NewAppendFileTool

func NewAppendFileTool(workspace string, restrict bool, allowPaths ...[]*regexp.Regexp) *AppendFileTool

func (*AppendFileTool) Description

func (t *AppendFileTool) Description() string

func (*AppendFileTool) Execute

func (t *AppendFileTool) Execute(ctx context.Context, args map[string]any) *ToolResult

func (*AppendFileTool) Name

func (t *AppendFileTool) Name() string

func (*AppendFileTool) Parameters

func (t *AppendFileTool) Parameters() map[string]any

type EditFileTool

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

EditFileTool edits a file by replacing old_text with new_text. The old_text must exist exactly in the file.

func NewEditFileTool

func NewEditFileTool(workspace string, restrict bool, allowPaths ...[]*regexp.Regexp) *EditFileTool

NewEditFileTool creates a new EditFileTool with optional directory restriction.

func (*EditFileTool) Description

func (t *EditFileTool) Description() string

func (*EditFileTool) Execute

func (t *EditFileTool) Execute(ctx context.Context, args map[string]any) *ToolResult

func (*EditFileTool) Name

func (t *EditFileTool) Name() string

func (*EditFileTool) Parameters

func (t *EditFileTool) Parameters() map[string]any

type ListDirTool

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

func NewListDirTool

func NewListDirTool(workspace string, restrict bool, allowPaths ...[]*regexp.Regexp) *ListDirTool

func (*ListDirTool) Description

func (t *ListDirTool) Description() string

func (*ListDirTool) Execute

func (t *ListDirTool) Execute(ctx context.Context, args map[string]any) *ToolResult

func (*ListDirTool) Name

func (t *ListDirTool) Name() string

func (*ListDirTool) Parameters

func (t *ListDirTool) Parameters() map[string]any

type LoadImageTool

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

LoadImageTool loads a local image file into the MediaStore and returns a media:// reference. The agent loop's resolveMediaRefs will then base64-encode it and attach it as an image_url part in the next LLM request, enabling vision on local files — the same pipeline used when a user sends an image through a chat channel.

This is intentionally different from SendFileTool:

  • SendFileTool → MediaResult + WithResponseHandled() → sends file to user, ends turn
  • LoadImageTool → plain ToolResult with media:// in ForLLM → LLM sees the image next turn

func NewLoadImageTool

func NewLoadImageTool(
	workspace string,
	restrict bool,
	maxFileSize int,
	store media.MediaStore,
	allowPaths ...[]*regexp.Regexp,
) *LoadImageTool

func (*LoadImageTool) Description

func (t *LoadImageTool) Description() string

func (*LoadImageTool) Execute

func (t *LoadImageTool) Execute(ctx context.Context, args map[string]any) *ToolResult

func (*LoadImageTool) Name

func (t *LoadImageTool) Name() string

func (*LoadImageTool) Parameters

func (t *LoadImageTool) Parameters() map[string]any

func (*LoadImageTool) SetContext

func (t *LoadImageTool) SetContext(channel, chatID string)

func (*LoadImageTool) SetMediaStore

func (t *LoadImageTool) SetMediaStore(store media.MediaStore)

type ReadFileLinesTool

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

func NewReadFileLinesTool

func NewReadFileLinesTool(
	workspace string,
	restrict bool,
	maxReadFileSize int,
	allowPaths ...[]*regexp.Regexp,
) *ReadFileLinesTool

func (*ReadFileLinesTool) Description

func (t *ReadFileLinesTool) Description() string

func (*ReadFileLinesTool) Execute

func (t *ReadFileLinesTool) Execute(ctx context.Context, args map[string]any) *ToolResult

func (*ReadFileLinesTool) Name

func (t *ReadFileLinesTool) Name() string

func (*ReadFileLinesTool) Parameters

func (t *ReadFileLinesTool) Parameters() map[string]any

type ReadFileTool

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

func NewReadFileBytesTool

func NewReadFileBytesTool(
	workspace string,
	restrict bool,
	maxReadFileSize int,
	allowPaths ...[]*regexp.Regexp,
) *ReadFileTool

func NewReadFileTool

func NewReadFileTool(
	workspace string,
	restrict bool,
	maxReadFileSize int,
	allowPaths ...[]*regexp.Regexp,
) *ReadFileTool

func (*ReadFileTool) Description

func (t *ReadFileTool) Description() string

func (*ReadFileTool) Execute

func (t *ReadFileTool) Execute(ctx context.Context, args map[string]any) *ToolResult

func (*ReadFileTool) Name

func (t *ReadFileTool) Name() string

func (*ReadFileTool) Parameters

func (t *ReadFileTool) Parameters() map[string]any

type SendFileTool

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

SendFileTool allows the LLM to send a local file (image, document, etc.) to the user on the current chat channel via the MediaStore pipeline.

func NewSendFileTool

func NewSendFileTool(
	workspace string,
	restrict bool,
	maxFileSize int,
	store media.MediaStore,
	allowPaths ...[]*regexp.Regexp,
) *SendFileTool

func (*SendFileTool) Description

func (t *SendFileTool) Description() string

func (*SendFileTool) Execute

func (t *SendFileTool) Execute(ctx context.Context, args map[string]any) *ToolResult

func (*SendFileTool) Name

func (t *SendFileTool) Name() string

func (*SendFileTool) Parameters

func (t *SendFileTool) Parameters() map[string]any

func (*SendFileTool) SetContext

func (t *SendFileTool) SetContext(channel, chatID string)

func (*SendFileTool) SetMediaStore

func (t *SendFileTool) SetMediaStore(store media.MediaStore)

type ToolResult

type ToolResult = toolshared.ToolResult

func ErrorResult

func ErrorResult(message string) *ToolResult

func MediaResult

func MediaResult(forLLM string, mediaRefs []string) *ToolResult

func NewToolResult

func NewToolResult(forLLM string) *ToolResult

func SilentResult

func SilentResult(forLLM string) *ToolResult

type WriteFileTool

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

func NewWriteFileTool

func NewWriteFileTool(
	workspace string,
	restrict bool,
	allowPaths ...[]*regexp.Regexp,
) *WriteFileTool

func (*WriteFileTool) Description

func (t *WriteFileTool) Description() string

func (*WriteFileTool) Execute

func (t *WriteFileTool) Execute(ctx context.Context, args map[string]any) *ToolResult

func (*WriteFileTool) Name

func (t *WriteFileTool) Name() string

func (*WriteFileTool) Parameters

func (t *WriteFileTool) Parameters() map[string]any

Jump to

Keyboard shortcuts

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