Skip to main content

Module tool

Module tool 

Source
Expand description

Tool type definitions, traits, and utilities translated from the TypeScript SDK.

This module defines the core tool system including:

  • The Tool trait with all optional methods (mirroring the TS Tool type)
  • Tool permission context and validation types
  • Tool use context for runtime execution
  • Progress tracking types
  • Utility functions for tool lookup and matching
  • The build_tool pattern for constructing tools with safe defaults

Re-exports§

pub use crate::types::hooks::HookProgress;
pub use crate::types::message::AssistantMessage;
pub use crate::types::message::AttachmentMessage;
pub use crate::types::message::Message;
pub use crate::types::message::ProgressMessage;
pub use crate::types::message::SystemLocalCommandMessage;
pub use crate::types::message::SystemMessage;
pub use crate::types::message::UserMessage;
pub use crate::types::tools::ToolProgressData;
pub use crate::types::ToolDefinition;
pub use crate::types::ToolInputSchema;
pub use crate::types::CompactProgressEvent;
pub use crate::types::permissions::ToolPermissionContext;

Structs§

AgentDefinitionsResult
DenialTrackingState
FileReadingLimits
GlobLimits
GroupedToolUse
GroupedToolUseRenderOptions
GroupedToolUseResult
ImageSource
McpMeta
MCP metadata passed through to SDK consumers.
McpToolInfo
QueryChainTracking
SearchOrReadInfo
SetToolJsxArgs
TerminalSize
ToolBuilder
Builder for constructing a Tool implementation with default values filled in.
ToolDecisionEntry
ToolDefaults
Default values for tool methods, mirroring the TypeScript TOOL_DEFAULTS.
ToolErrorRenderOptions
ToolProgress
Progress associated with a specific tool use.
ToolProgressRenderOptions
ToolRejectedRenderOptions
ToolResult
Result returned by a tool call.
ToolResultBlockParam
Maps a tool result to the Anthropic SDK ToolResultBlockParam shape.
ToolResultRenderOptions
ToolUseContext
Context passed to tool calls during execution, providing access to configuration, state, callbacks, and other runtime infrastructure.
ToolUseContextOptions
ToolUseRenderOptions

Enums§

ContentBlockParam
PermissionDecision
PermissionResult
ToolResultMessage
Messages that can be produced as part of a tool result.
ValidationResult
Result of validating tool input.

Traits§

Tool
A tool that can be called by the agent.

Functions§

filter_tool_progress_messages
Filter out hook_progress messages from a list of progress messages.
find_tool_by_name
Finds a tool by name or alias from a list of tool definitions.
get_empty_tool_permission_context
Creates an empty tool permission context (matches TS getEmptyToolPermissionContext).
tool_matches_name
Checks if a tool matches the given name (primary name or alias).

Type Aliases§

SetToolJsxFn
Callback to update tool JSX/UI rendering state. In Rust this is a generic boxed async callback.
ToolCallProgressFn
Callback type for reporting progress during tool execution.
ToolInputJsonSchema
JSON schema for tool input, used when a tool specifies its schema directly in JSON Schema format rather than converting from a Zod schema.
Tools
A collection of tools. Use this type instead of Vec<ToolDefinition> to make it easier to track where tool sets are assembled, passed, and filtered across the codebase.