BeforeToolCallEvent
Defined in: src/hooks/events.ts:181
Event triggered just before a tool is executed. Fired after tool lookup but before execution begins. Hook callbacks can set cancel to prevent the tool from executing.
Extends
Section titled “Extends”Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new BeforeToolCallEvent(data): BeforeToolCallEvent;Defined in: src/hooks/events.ts:198
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | { agent: LocalAgent; toolUse: { name: string; toolUseId: string; input: JSONValue; }; tool: Tool; } |
data.agent | LocalAgent |
data.toolUse | { name: string; toolUseId: string; input: JSONValue; } |
data.toolUse.name | string |
data.toolUse.toolUseId | string |
data.toolUse.input | JSONValue |
data.tool | Tool |
Returns
Section titled “Returns”BeforeToolCallEvent
Overrides
Section titled “Overrides”Properties
Section titled “Properties”readonly type: "beforeToolCallEvent";Defined in: src/hooks/events.ts:182
readonly agent: LocalAgent;Defined in: src/hooks/events.ts:183
toolUse
Section titled “toolUse”readonly toolUse: { name: string; toolUseId: string; input: JSONValue;};Defined in: src/hooks/events.ts:184
name: string;toolUseId
Section titled “toolUseId”toolUseId: string;input: JSONValue;readonly tool: Tool;Defined in: src/hooks/events.ts:189
cancel
Section titled “cancel”cancel: string | boolean = false;Defined in: src/hooks/events.ts:196
Set by hook callbacks to cancel this tool call.
When set to true, a default cancel message is used.
When set to a string, that string is used as the tool result error message.
Methods
Section titled “Methods”toJSON()
Section titled “toJSON()”toJSON(): Pick<BeforeToolCallEvent, "type" | "toolUse">;Defined in: src/hooks/events.ts:213
Serializes for wire transport, excluding the agent reference, tool instance, and mutable cancel flag. Called automatically by JSON.stringify().
Returns
Section titled “Returns”Pick<BeforeToolCallEvent, "type" | "toolUse">