BeforeToolCallEvent
Defined in: src/hooks/events.ts:211
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:229
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
data | { agent: LocalAgent; toolUse: { name: string; toolUseId: string; input: JSONValue; }; tool: Tool; invocationState: InvocationState; } |
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 |
data.invocationState | InvocationState |
Returns
Section titled “Returns”BeforeToolCallEvent
Overrides
Section titled “Overrides”Properties
Section titled “Properties”readonly type: "beforeToolCallEvent";Defined in: src/hooks/events.ts:212
readonly agent: LocalAgent;Defined in: src/hooks/events.ts:213
toolUse
Section titled “toolUse”readonly toolUse: { name: string; toolUseId: string; input: JSONValue;};Defined in: src/hooks/events.ts:214
name: string;toolUseId
Section titled “toolUseId”toolUseId: string;input: JSONValue;readonly tool: Tool;Defined in: src/hooks/events.ts:219
invocationState
Section titled “invocationState”readonly invocationState: InvocationState;Defined in: src/hooks/events.ts:220
cancel
Section titled “cancel”cancel: string | boolean = false;Defined in: src/hooks/events.ts:227
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:246
Serializes for wire transport, excluding the agent reference, tool instance, invocationState, and mutable cancel flag. Called automatically by JSON.stringify().
Returns
Section titled “Returns”Pick<BeforeToolCallEvent, "type" | "toolUse">