Class: ClaudeHooks::PostToolUse
- Inherits:
-
Base
- Object
- Base
- ClaudeHooks::PostToolUse
show all
- Defined in:
- lib/claude_hooks/post_tool_use.rb
Constant Summary
Constants inherited
from Base
Base::COMMON_INPUT_FIELDS
Instance Attribute Summary
Attributes inherited from Base
#config, #input_data, #logger, #output, #output_data
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#agent_id, #agent_type, #allow_continue!, #base_dir, #call, #clear_specifics!, #clear_system_message!, #cwd, #effort, #home_claude_dir, #home_path_for, #hook_event_name, #hook_type, #initialize, #log, #output_and_exit, #path_for, #permission_mode, #prevent_continue!, #project_claude_dir, #project_path_for, #prompt_id, #read_transcript, #session_id, #show_output!, #stringify_output, #suppress_output!, #system_message!, #terminal_sequence, #terminal_sequence!, #transcript_path
Class Method Details
.hook_type ⇒ Object
7
8
9
|
# File 'lib/claude_hooks/post_tool_use.rb', line 7
def self.hook_type
'PostToolUse'
end
|
11
12
13
|
# File 'lib/claude_hooks/post_tool_use.rb', line 11
def self.input_fields
%w[tool_name tool_input tool_response tool_use_id]
end
|
Instance Method Details
#add_additional_context!(context) ⇒ Object
Also known as:
add_context!
45
46
47
48
49
50
|
# File 'lib/claude_hooks/post_tool_use.rb', line 45
def add_additional_context!(context)
@output_data['hookSpecificOutput'] = {
'hookEventName' => hook_event_name,
'additionalContext' => context
}
end
|
40
41
42
43
|
# File 'lib/claude_hooks/post_tool_use.rb', line 40
def approve_tool!(reason = '')
@output_data['decision'] = nil
@output_data['reason'] = nil
end
|
35
36
37
38
|
# File 'lib/claude_hooks/post_tool_use.rb', line 35
def block_tool!(reason = '')
@output_data['decision'] = 'block'
@output_data['reason'] = reason
end
|
21
22
23
|
# File 'lib/claude_hooks/post_tool_use.rb', line 21
def tool_input
@input_data['tool_input']
end
|
17
18
19
|
# File 'lib/claude_hooks/post_tool_use.rb', line 17
def tool_name
@input_data['tool_name']
end
|
25
26
27
|
# File 'lib/claude_hooks/post_tool_use.rb', line 25
def tool_response
@input_data['tool_response']
end
|
29
30
31
|
# File 'lib/claude_hooks/post_tool_use.rb', line 29
def tool_use_id
@input_data['tool_use_id'] || @input_data['toolUseId']
end
|
58
59
60
61
|
# File 'lib/claude_hooks/post_tool_use.rb', line 58
def update_mcp_tool_output!(value)
@output_data['hookSpecificOutput'] ||= { 'hookEventName' => hook_event_name }
@output_data['hookSpecificOutput']['updatedMCPToolOutput'] = value
end
|
53
54
55
56
|
# File 'lib/claude_hooks/post_tool_use.rb', line 53
def update_tool_output!(value)
@output_data['hookSpecificOutput'] ||= { 'hookEventName' => hook_event_name }
@output_data['hookSpecificOutput']['updatedToolOutput'] = value
end
|