ToolRuntime class

State shared by every tool during a session: the workspace, files the model has read, session tasks, and the callbacks that reach the user.

Constructors

ToolRuntime({required void onMessage(ToolStatus status), required Future<bool> requestApproval(ToolApprovalRequest request), required Future<Map<String, String>> askQuestions(List<ToolQuestion> questions), required String workspaceRoot, String? currentWorkingDirectory, McpResourceAdapter? mcpResourceAdapter})

Properties

askQuestions → Future<Map<String, String>> Function(List<ToolQuestion> questions)
final
currentWorkingDirectory ↔ String
getter/setter pair
hashCode → int
The hash code for this object.
no setterinherited
mcpResourceAdapter → McpResourceAdapter?
final
onMessage → void Function(ToolStatus status)
final
requestApproval → Future<bool> Function(ToolApprovalRequest request)
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
workspaceRoot → String
final

Methods

clearTasks() → void
createTask({required String subject, required String description, String? activeForm, Map<String, dynamic>? metadata}) → SessionTask
displayPath(String path) → String
Workspace-relative path for display, or path itself when outside.
endTool(String name, String message, {bool isError = false}) → void
fileMatchesTrackedState(String path) → Future<bool>
isWithinWorkspace(String path) → bool
listTasks() → List<SessionTask>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recordFileRead(String path, String content, FileStat stat) → void
resolvePath(String path, {String? fromDirectory}) → String
Resolves path against fromDirectory (or the current working directory) and normalizes away . and .. segments.
setCurrentWorkingDirectory(String path) → void
startTool(String name, String message) → void
taskById(String id) → SessionTask?
toString() → String
A string representation of this object.
inherited
trackedFile(String path) → TrackedFileState?
validateTaskTransition({required String taskId, SessionTaskStatus? newStatus}) → String?

Operators

operator ==(Object other) → bool
The equality operator.
inherited