IToolRegistry (src/SharpClaw.Code.Tools/Abstractions/IToolRegistry.cs) exposes:
ListAsync,SearchAsync,GetRequiredAsync(allasync; plugin tools are loaded withCancellationToken)
ToolRegistry merges:
- All
ISharpClawToolinstances registered in DI (built-ins). - Optional plugin tool descriptors from
IPluginManager.ListToolDescriptorsAsyncwrapped asPluginToolProxyTool(only for enabled plugins — seePluginManager).
Registration: ToolsServiceCollectionExtensions.AddSharpClawTools.
ToolExecutor (IToolExecutor):
- Resolves the tool.
- Builds
ToolExecutionRequest+PermissionEvaluationContext(includesPluginToolSourcewhen applicable). - Publishes
ToolStartedEvent,PermissionRequestedEvent,PermissionResolvedEvent,ToolCompletedEventthroughIRuntimeEventPublisherwhen registered. - Calls
IPermissionPolicyEngine.EvaluateAsync; on allow,ISharpClawTool.ExecuteAsync.
From ToolsServiceCollectionExtensions:
| Tool | Constant / name |
|---|---|
| Read file | ReadFileTool.ToolName |
| Write file | WriteFileTool.ToolName |
| Edit file | EditFileTool.ToolName |
| Read snapshot | ReadFileSnapshotTool.ToolName (read_file_snapshot) |
| Preview snapshot edit | PreviewFileSnapshotTool.ToolName (preview_file_snapshot) |
| Edit snapshot | EditFileSnapshotTool.ToolName (edit_file_snapshot) |
| Glob search | GlobSearchTool.ToolName |
| Grep search | GrepSearchTool.ToolName |
| Bash / shell | BashTool.ToolName |
| Web search | WebSearchTool |
| Web fetch | WebFetchTool |
| Tool search | ToolSearchTool.ToolName (tool_search) |
Built-ins are registered as ISharpClawTool singletons; some also expose their concrete type through DI.
- Subclass
SharpClawToolBase(src/SharpClaw.Code.Tools/BuiltIn/SharpClawToolBase.cs). - Implement
DefinitionasToolDefinition(name, description,ApprovalScope,RequiresApproval,IsDestructive, input type name, tags). - Implement
ExecuteAsync: parse arguments withDeserializeArguments<T>, returnCreateSuccessResult/CreateFailureResult. - Register in
ToolsServiceCollectionExtensions.AddSharpClawTools:services.AddSingleton<YourTool>();services.AddSingleton<ISharpClawTool>(sp => sp.GetRequiredService<YourTool>());
Use Protocol types for stable payloads where appropriate; tool JSON helpers live in ToolJson (Tools/Utilities).
tool_searchqueriesIToolRegistry.SearchAsync.AgentFrameworkBridgesupplies registered tool definitions toProviderBackedAgentKernel. Its tool loop dispatches calls throughToolCallDispatcherand the permission-awareIToolExecutor, including snapshot editing.
See permissions.md for gates on destructive and elevated tools.
Compiler-backed .NET tools are described in .NET intelligence. They share normal tool discovery, explicit schemas, and a separate execution decision before cold MSBuild evaluation.
The permission-gated verify_workspace tool and CLI/REPL equivalents are documented in Verification.
Use read_file_snapshot to read bounded line windows, preview_file_snapshot to review exact before/after fragments, and edit_file_snapshot to apply a batch. Passing the preview ID to the write tool binds the apply request to the reviewed file and result. Successful writes participate in the mutation journal. Existing file-tool contracts are unchanged. See snapshot editing for schemas, newline handling, and publication guarantees.
Runtime provider context uses bounded previews for large tool results while retaining complete results and events. The permission-aware read_tool_output tool retrieves full text from session artifacts. See runtime resilience.