Documentation
¶
Overview ¶
Package tool contains the concrete Lightcode tools and compatibility aliases for the engine-owned generic tool contracts.
Index ¶
- Variables
- func PermissionArg(toolName string, params map[string]any) string
- func PermissionArgAtRoot(root, toolName string, params map[string]any) string
- func PermissionCheckArg(toolName string, params map[string]any) string
- func PermissionCheckArgAtRoot(root, toolName string, params map[string]any) string
- type ApplyWriteResult
- type ArgumentNormalizer
- type AskActionFunc
- type AskFunc
- type BatchResult
- type CheckFunc
- type DefaultPendingCoordinator
- type DiagFileMeta
- type DiagStore
- type DiagTurnEntry
- type DiagnosticsClient
- type DisplayMetadataProvider
- type EditBufferResult
- type EditFile
- func (e *EditFile) Description() string
- func (e *EditFile) DisplayMetadata(_ context.Context, args json.RawMessage, result string) map[string]any
- func (e *EditFile) Execute(_ context.Context, params map[string]any) (string, error)
- func (e *EditFile) Name() string
- func (e *EditFile) ParametersSchema() map[string]any
- func (e *EditFile) SetToolsConfig(cfg config.ToolsConfig)
- func (e *EditFile) StagedResultMessage() string
- func (e *EditFile) ValidateStaged(_ context.Context, args json.RawMessage) error
- type EditFileWithSnapshot
- func (*EditFileWithSnapshot) Description() string
- func (*EditFileWithSnapshot) DisplayMetadata(_ context.Context, args json.RawMessage, result string) map[string]any
- func (e *EditFileWithSnapshot) Execute(_ context.Context, params map[string]any) (string, error)
- func (*EditFileWithSnapshot) Name() string
- func (*EditFileWithSnapshot) ParametersSchema() map[string]any
- func (e *EditFileWithSnapshot) SetToolsConfig(cfg config.ToolsConfig)
- func (*EditFileWithSnapshot) StagedResultMessage() string
- func (*EditFileWithSnapshot) ValidateStaged(_ context.Context, args json.RawMessage) error
- type ExecutePending
- type ExitError
- type FileChangedError
- type FileIdentity
- type FileTracker
- func (t *FileTracker) HasRead(path string) bool
- func (t *FileTracker) IsDuplicateIdentity(path string, offset, limit int, current FileIdentity) (bool, ReadRecord)
- func (t *FileTracker) PopulateFromMessages(messages []PersistedMessage)
- func (t *FileTracker) Reset()
- func (t *FileTracker) Restore(reads []ReadRecord)
- func (t *FileTracker) Snapshot() []ReadRecord
- func (t *FileTracker) TrackIdentity(path string, offset, limit int, identity FileIdentity)
- func (t *FileTracker) UpdateAfterWriteIdentity(path string, identity FileIdentity)
- func (t *FileTracker) WasReadCheckIdentity(path string, current FileIdentity) error
- type HistorySearcher
- type LSPDiagnostics
- type MemorySaver
- type MemorySearcher
- type PendingCoordinator
- type PendingExecutor
- type PendingQueue
- type PermWrapped
- type PersistedMessage
- type ProcessController
- type ProcessManager
- type ProcessTool
- type ReadFile
- type ReadOnlyRunCommand
- type ReadRecord
- type ReadRequiredError
- type Registry
- type RunCommand
- type SaveMemory
- type SearchHistory
- type SearchMemory
- type Sleep
- type SnapshotStore
- type StageableTool
- type StagedCall
- type StagedExecutor
- type Tool
- type ToolCall
- type WorkspaceSymbol
- type WorkspaceSymbolClient
- type WriteFile
- func (w *WriteFile) Description() string
- func (w *WriteFile) Execute(_ context.Context, params map[string]any) (string, error)
- func (w *WriteFile) Name() string
- func (w *WriteFile) ParametersSchema() map[string]any
- func (w *WriteFile) SetToolsConfig(cfg config.ToolsConfig)
- func (w *WriteFile) StagedResultMessage() string
- func (w *WriteFile) ValidateStaged(_ context.Context, args json.RawMessage) error
- type WriteFileWithSnapshot
- func (*WriteFileWithSnapshot) Description() string
- func (w *WriteFileWithSnapshot) Execute(_ context.Context, params map[string]any) (string, error)
- func (*WriteFileWithSnapshot) Name() string
- func (*WriteFileWithSnapshot) ParametersSchema() map[string]any
- func (w *WriteFileWithSnapshot) SetToolsConfig(cfg config.ToolsConfig)
- func (*WriteFileWithSnapshot) StagedResultMessage() string
- func (*WriteFileWithSnapshot) ValidateStaged(_ context.Context, args json.RawMessage) error
Constants ¶
This section is empty.
Variables ¶
var ErrDenied = enginetool.ErrDenied
var NewPendingQueue = enginetool.NewPendingQueue
var NewRegistry = enginetool.NewRegistry
Functions ¶
func PermissionArg ¶
PermissionArg pulls the permission-relevant argument from the tool params. File paths are resolved to absolute so they match against resolved rule patterns.
func PermissionArgAtRoot ¶
Types ¶
type ApplyWriteResult ¶
ApplyWriteResult holds the result of a write applied to a string buffer.
func ApplyWrite ¶
func ApplyWrite(content, path string) *ApplyWriteResult
ApplyWrite returns the result for a write_file applied to a buffer.
type ArgumentNormalizer ¶
type ArgumentNormalizer = enginetool.ArgumentNormalizer
type AskActionFunc ¶
type AskActionFunc func(ctx context.Context, req permission.Request) permission.ResponseAction
AskActionFunc blocks until the user answers a staged permission prompt.
type AskFunc ¶
type AskFunc func(ctx context.Context, req permission.Request) permission.ResponseAction
AskFunc blocks until the user responds to a permission prompt. Returns a response action from the user.
type BatchResult ¶
type BatchResult = enginetool.BatchResult
type CheckFunc ¶
type CheckFunc func(toolName, arg string) permission.Decision
CheckFunc evaluates rules for a tool call and returns a Decision.
type DefaultPendingCoordinator ¶
type DefaultPendingCoordinator = enginetool.DefaultPendingCoordinator
func NewPendingCoordinator ¶
func NewPendingCoordinator(executor PendingExecutor) *DefaultPendingCoordinator
NewPendingCoordinator returns the default pending flush coordinator.
type DiagFileMeta ¶
type DiagFileMeta struct {
OriginalPath string
}
type DiagStore ¶
type DiagStore interface {
CurrentTurn() int
ListTurns() ([]DiagTurnEntry, error)
}
type DiagTurnEntry ¶
type DiagTurnEntry struct {
Turn int
Files []DiagFileMeta
}
type DiagnosticsClient ¶
type DisplayMetadataProvider ¶
type DisplayMetadataProvider = enginetool.DisplayMetadataProvider
type EditBufferResult ¶
EditBufferResult holds the result of an edit applied to a string buffer.
type EditFile ¶
type EditFile struct {
// contains filtered or unexported fields
}
EditFile implements the edit_file tool with mtime enforcement, O(1) results with line ranges, and pending support.
func NewEditFile ¶
func NewEditFile(tracker *FileTracker, cfg config.ToolsConfig) *EditFile
NewEditFile creates an EditFile tool.
func NewEditFileAtRoot ¶
func NewEditFileAtRoot(tracker *FileTracker, cfg config.ToolsConfig, workspaceRoot string) *EditFile
func (*EditFile) Description ¶
func (*EditFile) DisplayMetadata ¶
func (*EditFile) ParametersSchema ¶
func (*EditFile) SetToolsConfig ¶ added in v0.0.2
func (e *EditFile) SetToolsConfig(cfg config.ToolsConfig)
func (*EditFile) StagedResultMessage ¶
func (*EditFile) ValidateStaged ¶
type EditFileWithSnapshot ¶
type EditFileWithSnapshot struct {
// contains filtered or unexported fields
}
EditFileWithSnapshot wraps EditFile so the pre-edit file content is captured by the snapshot store before the edit is applied.
func NewEditFileWithSnapshot ¶
func NewEditFileWithSnapshot(store SnapshotStore, tracker *FileTracker, cfg config.ToolsConfig) *EditFileWithSnapshot
NewEditFileWithSnapshot returns a snapshot-aware edit_file tool.
func NewEditFileWithSnapshotAtRoot ¶
func NewEditFileWithSnapshotAtRoot(store SnapshotStore, tracker *FileTracker, cfg config.ToolsConfig, workspaceRoot string) *EditFileWithSnapshot
func (*EditFileWithSnapshot) Description ¶
func (*EditFileWithSnapshot) Description() string
func (*EditFileWithSnapshot) DisplayMetadata ¶
func (*EditFileWithSnapshot) DisplayMetadata(_ context.Context, args json.RawMessage, result string) map[string]any
func (*EditFileWithSnapshot) Name ¶
func (*EditFileWithSnapshot) Name() string
func (*EditFileWithSnapshot) ParametersSchema ¶
func (*EditFileWithSnapshot) ParametersSchema() map[string]any
func (*EditFileWithSnapshot) SetToolsConfig ¶ added in v0.0.2
func (e *EditFileWithSnapshot) SetToolsConfig(cfg config.ToolsConfig)
func (*EditFileWithSnapshot) StagedResultMessage ¶
func (*EditFileWithSnapshot) StagedResultMessage() string
func (*EditFileWithSnapshot) ValidateStaged ¶
func (*EditFileWithSnapshot) ValidateStaged(_ context.Context, args json.RawMessage) error
type ExecutePending ¶
type ExecutePending struct{}
ExecutePending implements the execute_pending tool. The actual flush is handled by the loop's dispatch; this tool is registered for schema visibility but Execute is a no-op.
func (ExecutePending) Description ¶
func (ExecutePending) Description() string
func (ExecutePending) Name ¶
func (ExecutePending) Name() string
func (ExecutePending) ParametersSchema ¶
func (ExecutePending) ParametersSchema() map[string]any
type ExitError ¶
type ExitError = enginetool.ExitError
type FileChangedError ¶
type FileChangedError struct {
Path string
}
FileChangedError is returned when a file was modified since last read.
func (*FileChangedError) Error ¶
func (e *FileChangedError) Error() string
type FileIdentity ¶
type FileIdentity struct {
Mtime time.Time
Ctime time.Time
Dev uint64
Ino uint64
Mode os.FileMode
Hash [32]byte
Valid bool
HasHash bool
}
FileIdentity records the kernel identity of a file observed through an already-open descriptor.
func FileIdentityFromFileInfo ¶
func FileIdentityFromFileInfo(info os.FileInfo) FileIdentity
func FileIdentityFromFileInfoAndData ¶
func FileIdentityFromFileInfoAndData(info os.FileInfo, data []byte) FileIdentity
type FileTracker ¶
type FileTracker struct {
// contains filtered or unexported fields
}
FileTracker tracks which files have been read and their mtimes. It is populated from conversation history on session load and updated by read_file executions.
func NewFileTracker ¶
func NewFileTracker() *FileTracker
NewFileTracker returns an empty FileTracker.
func (*FileTracker) HasRead ¶
func (t *FileTracker) HasRead(path string) bool
func (*FileTracker) IsDuplicateIdentity ¶
func (t *FileTracker) IsDuplicateIdentity(path string, offset, limit int, current FileIdentity) (bool, ReadRecord)
IsDuplicateIdentity checks duplicate status against identity metadata from an already-opened file.
func (*FileTracker) PopulateFromMessages ¶
func (t *FileTracker) PopulateFromMessages(messages []PersistedMessage)
PopulateFromMessages scans historical tool result messages and marks read_file paths as having been read. Since we don't have mtime in persisted messages, we mark them with a zero time, which means the "was read" check passes but "modified since" check always fails (forces a re-read on first edit after session load).
func (*FileTracker) Reset ¶
func (t *FileTracker) Reset()
Reset clears all tracked reads. Call this when visible conversation history changes so hidden or old reads cannot authorize future edits.
func (*FileTracker) Restore ¶
func (t *FileTracker) Restore(reads []ReadRecord)
Restore resets the tracker to a prior read snapshot.
func (*FileTracker) Snapshot ¶
func (t *FileTracker) Snapshot() []ReadRecord
Snapshot returns a copy of the tracked read state.
func (*FileTracker) TrackIdentity ¶
func (t *FileTracker) TrackIdentity(path string, offset, limit int, identity FileIdentity)
TrackIdentity records a read using identity metadata from the already-opened file.
func (*FileTracker) UpdateAfterWriteIdentity ¶
func (t *FileTracker) UpdateAfterWriteIdentity(path string, identity FileIdentity)
UpdateAfterWriteIdentity refreshes the tracked identity using metadata from the already-opened file after a successful write.
func (*FileTracker) WasReadCheckIdentity ¶
func (t *FileTracker) WasReadCheckIdentity(path string, current FileIdentity) error
WasReadCheckIdentity checks read authorization against identity metadata from an already-opened file.
type HistorySearcher ¶
type LSPDiagnostics ¶
type LSPDiagnostics struct {
// contains filtered or unexported fields
}
func NewLSPDiagnostics ¶
func NewLSPDiagnostics(client DiagnosticsClient, store DiagStore) *LSPDiagnostics
func (*LSPDiagnostics) Description ¶
func (t *LSPDiagnostics) Description() string
func (*LSPDiagnostics) Name ¶
func (t *LSPDiagnostics) Name() string
func (*LSPDiagnostics) ParametersSchema ¶
func (t *LSPDiagnostics) ParametersSchema() map[string]any
func (*LSPDiagnostics) Reset ¶
func (t *LSPDiagnostics) Reset()
type MemorySaver ¶
type MemorySearcher ¶
type PendingCoordinator ¶
type PendingCoordinator = enginetool.PendingCoordinator
type PendingExecutor ¶
type PendingExecutor = enginetool.PendingExecutor
type PendingQueue ¶
type PendingQueue = enginetool.PendingQueue
type PermWrapped ¶
type PermWrapped struct {
// contains filtered or unexported fields
}
PermWrapped wraps a Tool with permission enforcement. The wrapped tool's Execute is only called if the check allows it or the user approves via ask.
func WrapWithPermission ¶
func WrapWithPermission(t Tool, check CheckFunc, ask AskFunc) *PermWrapped
WrapWithPermission wraps t so that every Execute call is gated by the check and ask functions.
func WrapWithPermissionAtRoot ¶
func WrapWithPermissionAtRoot(t Tool, workspaceRoot string, check CheckFunc, ask AskFunc) *PermWrapped
func (*PermWrapped) Description ¶
func (p *PermWrapped) Description() string
func (*PermWrapped) Name ¶
func (p *PermWrapped) Name() string
func (*PermWrapped) ParametersSchema ¶
func (p *PermWrapped) ParametersSchema() map[string]any
func (*PermWrapped) WrappedTool ¶
func (p *PermWrapped) WrappedTool() Tool
type PersistedMessage ¶
PersistedMessage is a simplified message for tracker population.
type ProcessController ¶
type ProcessManager ¶
ProcessManager is the interface for background process management. The concrete implementation lives in internal/process/ and is wired in by the agent. May be nil if background process support is not loaded.
type ProcessTool ¶
type ProcessTool struct {
// contains filtered or unexported fields
}
ProcessTool implements the process management tool for background commands.
func NewProcessTool ¶
func NewProcessTool(mgr ProcessController) *ProcessTool
NewProcessTool creates a process management tool.
func (*ProcessTool) Description ¶
func (*ProcessTool) Description() string
func (*ProcessTool) Name ¶
func (*ProcessTool) Name() string
func (*ProcessTool) ParametersSchema ¶
func (*ProcessTool) ParametersSchema() map[string]any
type ReadFile ¶
type ReadFile struct {
// contains filtered or unexported fields
}
ReadFile implements the read_file tool with line-numbered output, pagination, byte caps, binary detection, mtime tracking, and re-read deduplication.
func NewReadFile ¶
func NewReadFile(cfg config.ToolsConfig, tracker *FileTracker) *ReadFile
NewReadFile creates a ReadFile tool with the given config and tracker.
func NewReadFileAtRoot ¶
func NewReadFileAtRoot(cfg config.ToolsConfig, tracker *FileTracker, workspaceRoot string) *ReadFile
func (*ReadFile) Description ¶
func (*ReadFile) ParametersSchema ¶
func (*ReadFile) SetToolsConfig ¶ added in v0.0.2
func (r *ReadFile) SetToolsConfig(cfg config.ToolsConfig)
type ReadOnlyRunCommand ¶
type ReadOnlyRunCommand struct {
// contains filtered or unexported fields
}
ReadOnlyRunCommand wraps RunCommand and restricts commands to a whitelist of non-destructive operations (ls, cat, grep, git log, etc.).
func NewReadOnlyRunCommand ¶
func NewReadOnlyRunCommand(inner *RunCommand) *ReadOnlyRunCommand
NewReadOnlyRunCommand creates a read-only command tool.
func (*ReadOnlyRunCommand) Description ¶
func (*ReadOnlyRunCommand) Description() string
func (*ReadOnlyRunCommand) Name ¶
func (*ReadOnlyRunCommand) Name() string
func (*ReadOnlyRunCommand) ParametersSchema ¶
func (r *ReadOnlyRunCommand) ParametersSchema() map[string]any
type ReadRecord ¶
ReadRecord records a read_file call for deduplication and edit enforcement.
type ReadRequiredError ¶
type ReadRequiredError struct {
Path string
}
ReadRequiredError is returned when a file was not read before editing.
func (*ReadRequiredError) Error ¶
func (e *ReadRequiredError) Error() string
type Registry ¶
type Registry = enginetool.Registry
type RunCommand ¶
type RunCommand struct {
// contains filtered or unexported fields
}
RunCommand implements the run_command tool.
func NewRunCommand ¶
func NewRunCommand(cfg config.ToolsConfig, homeDir string, procMgr ProcessManager) *RunCommand
NewRunCommand creates a RunCommand tool.
func NewRunCommandAtRoot ¶
func NewRunCommandAtRoot(cfg config.ToolsConfig, homeDir, workspaceRoot string, procMgr ProcessManager) *RunCommand
func (*RunCommand) Description ¶
func (*RunCommand) Description() string
func (*RunCommand) Name ¶
func (*RunCommand) Name() string
func (*RunCommand) ParametersSchema ¶
func (*RunCommand) ParametersSchema() map[string]any
func (*RunCommand) SetToolsConfig ¶ added in v0.0.2
func (r *RunCommand) SetToolsConfig(cfg config.ToolsConfig)
type SaveMemory ¶
type SaveMemory struct {
// contains filtered or unexported fields
}
func NewSaveMemory ¶
func NewSaveMemory(store MemorySaver, memoriesDir string) *SaveMemory
func (*SaveMemory) Description ¶
func (t *SaveMemory) Description() string
func (*SaveMemory) Name ¶
func (t *SaveMemory) Name() string
func (*SaveMemory) ParametersSchema ¶
func (t *SaveMemory) ParametersSchema() map[string]any
type SearchHistory ¶
type SearchHistory struct {
// contains filtered or unexported fields
}
func NewSearchHistory ¶
func NewSearchHistory(store HistorySearcher, projectID string) *SearchHistory
func (*SearchHistory) Description ¶
func (t *SearchHistory) Description() string
func (*SearchHistory) Name ¶
func (t *SearchHistory) Name() string
func (*SearchHistory) ParametersSchema ¶
func (t *SearchHistory) ParametersSchema() map[string]any
type SearchMemory ¶
type SearchMemory struct {
// contains filtered or unexported fields
}
func NewSearchMemory ¶
func NewSearchMemory(store MemorySearcher, projectID string) *SearchMemory
func (*SearchMemory) Description ¶
func (t *SearchMemory) Description() string
func (*SearchMemory) Name ¶
func (t *SearchMemory) Name() string
func (*SearchMemory) ParametersSchema ¶
func (t *SearchMemory) ParametersSchema() map[string]any
type Sleep ¶
type Sleep struct{}
Sleep implements a sleep/wait tool for the model to pause before checking background process output or waiting for servers.
func (Sleep) Description ¶
func (Sleep) NormalizeArguments ¶
func (Sleep) NormalizeArguments(args json.RawMessage) (json.RawMessage, error)
func (Sleep) ParametersSchema ¶
type SnapshotStore ¶
SnapshotStore is the minimum surface WriteFileWithSnapshot and EditFileWithSnapshot need from the snapshot store.
type StageableTool ¶
type StageableTool = enginetool.StageableTool
type StagedCall ¶
type StagedCall = enginetool.StagedCall
type StagedExecutor ¶
type StagedExecutor struct {
// contains filtered or unexported fields
}
StagedExecutor executes pending edit/write calls as a batch while preserving the normal permission, snapshot, and read-before-edit rules.
func NewStagedExecutor ¶
func NewStagedExecutor(store SnapshotStore, tracker *FileTracker, cfg config.ToolsConfig, check CheckFunc, ask AskActionFunc) *StagedExecutor
NewStagedExecutor creates a staged batch executor.
func NewStagedExecutorAtRoot ¶
func NewStagedExecutorAtRoot(store SnapshotStore, tracker *FileTracker, cfg config.ToolsConfig, workspaceRoot string, check CheckFunc, ask AskActionFunc) *StagedExecutor
func (*StagedExecutor) ExecutePending ¶
func (e *StagedExecutor) ExecutePending(ctx context.Context, staged []StagedCall) []BatchResult
ExecutePending applies staged calls in emission order, using a running buffer per file and a single final disk write per changed file.
func (*StagedExecutor) SetToolsConfig ¶ added in v0.0.2
func (e *StagedExecutor) SetToolsConfig(cfg config.ToolsConfig)
type Tool ¶
type Tool = enginetool.Tool
type ToolCall ¶
type ToolCall = enginetool.ToolCall
type WorkspaceSymbol ¶
type WorkspaceSymbol struct {
// contains filtered or unexported fields
}
func NewWorkspaceSymbol ¶
func NewWorkspaceSymbol(client WorkspaceSymbolClient) *WorkspaceSymbol
func (*WorkspaceSymbol) Description ¶
func (t *WorkspaceSymbol) Description() string
func (*WorkspaceSymbol) Name ¶
func (t *WorkspaceSymbol) Name() string
func (*WorkspaceSymbol) ParametersSchema ¶
func (t *WorkspaceSymbol) ParametersSchema() map[string]any
type WorkspaceSymbolClient ¶
type WriteFile ¶
type WriteFile struct {
// contains filtered or unexported fields
}
WriteFile implements the write_file tool with mtime enforcement and pending support.
func NewWriteFile ¶
func NewWriteFile(tracker *FileTracker, cfg config.ToolsConfig) *WriteFile
NewWriteFile creates a WriteFile tool.
func NewWriteFileAtRoot ¶
func NewWriteFileAtRoot(tracker *FileTracker, cfg config.ToolsConfig, workspaceRoot string) *WriteFile
func (*WriteFile) Description ¶
func (*WriteFile) ParametersSchema ¶
func (*WriteFile) SetToolsConfig ¶ added in v0.0.2
func (w *WriteFile) SetToolsConfig(cfg config.ToolsConfig)
func (*WriteFile) StagedResultMessage ¶
func (*WriteFile) ValidateStaged ¶
type WriteFileWithSnapshot ¶
type WriteFileWithSnapshot struct {
// contains filtered or unexported fields
}
WriteFileWithSnapshot wraps WriteFile so that every successful write is preceded by a call to the snapshot store.
func NewWriteFileWithSnapshot ¶
func NewWriteFileWithSnapshot(store SnapshotStore, tracker *FileTracker, cfg config.ToolsConfig) *WriteFileWithSnapshot
NewWriteFileWithSnapshot returns a snapshot-aware write_file tool.
func NewWriteFileWithSnapshotAtRoot ¶
func NewWriteFileWithSnapshotAtRoot(store SnapshotStore, tracker *FileTracker, cfg config.ToolsConfig, workspaceRoot string) *WriteFileWithSnapshot
func (*WriteFileWithSnapshot) Description ¶
func (*WriteFileWithSnapshot) Description() string
func (*WriteFileWithSnapshot) Name ¶
func (*WriteFileWithSnapshot) Name() string
func (*WriteFileWithSnapshot) ParametersSchema ¶
func (*WriteFileWithSnapshot) ParametersSchema() map[string]any
func (*WriteFileWithSnapshot) SetToolsConfig ¶ added in v0.0.2
func (w *WriteFileWithSnapshot) SetToolsConfig(cfg config.ToolsConfig)
func (*WriteFileWithSnapshot) StagedResultMessage ¶
func (*WriteFileWithSnapshot) StagedResultMessage() string
func (*WriteFileWithSnapshot) ValidateStaged ¶
func (*WriteFileWithSnapshot) ValidateStaged(_ context.Context, args json.RawMessage) error