data/services/tool_execution_service
library
Functions
-
classifyToolError(Object error)
→ String
-
Classify a tool execution error into a telemetry-safe string.
-
createChildAbortController(AbortController parent)
→ AbortController
-
Create a child abort controller that fires when the parent fires.
-
decisionReasonToOTelSource(PermissionDecisionReason? reason, PermissionBehavior behavior)
→ String
-
Map a PermissionDecisionReason to the OTel source label.
-
findToolByName(List<ToolDefinition> tools, String name)
→ ToolDefinition?
-
Find a tool by name in the tools list.
-
getMaxToolUseConcurrency()
→ int
-
Max concurrent tool executions.
-
isMcpTool(String toolName)
→ bool
-
Check if a tool name corresponds to an MCP tool.
-
partitionToolCalls(List<ToolUseBlock> toolUseMessages, ToolUseContext toolUseContext)
→ List<ToolBatch>
-
Partition tool calls into batches for orchestration.
-
resolveHookPermissionDecision({required PermissionResult? hookPermissionResult, required ToolDefinition tool, required Map<String, dynamic> input, required ToolUseContext toolUseContext, required CanUseToolFn canUseTool, required AssistantMessage assistantMessage, required String toolUseID, Future<PermissionResult?> checkRuleBasedPermissions(ToolDefinition, Map<String, dynamic>, ToolUseContext)?})
→ Future<({PermissionResult decision, Map<String, dynamic> input})>
-
Resolve a PreToolUse hook's permission result into a final decision.
-
ruleSourceToOTelSource(String ruleSource, PermissionBehavior behavior)
→ String
-
Map a rule's origin to OTel
source vocabulary.
-
runTools(List<ToolUseBlock> toolUseMessages, List<AssistantMessage> assistantMessages, CanUseToolFn canUseTool, ToolUseContext toolUseContext)
→ Stream<MessageUpdate>
-
Run tools — handles both serial and concurrent execution.
-
runToolUse(ToolUseBlock toolUse, AssistantMessage assistantMessage, CanUseToolFn canUseTool, ToolUseContext toolUseContext)
→ Stream<MessageUpdate>
-
Run a single tool use block — checks permissions and executes the tool.
-
sanitizeToolNameForAnalytics(String toolName)
→ String
-
Sanitize tool name for analytics (strips MCP prefix details).
Exceptions / Errors
-
AbortError
-
Abort error when tool execution is cancelled.
-
ShellError
-
Shell error for tool execution.