claude-code-sdk-python/tests
kashyap murali 68f0d7aa7d
Some checks failed
Lint / lint (push) Has been cancelled
Test / test (3.10) (push) Has been cancelled
Test / test (3.11) (push) Has been cancelled
Test / test (3.12) (push) Has been cancelled
Test / test (3.13) (push) Has been cancelled
feat: Add tool permission and hook callbacks support (#143)
## Summary

Adds comprehensive support for tool permission callbacks and hook
callbacks to the Python SDK, enabling fine-grained control over tool
execution and custom event handling.

## Key Changes

- **Tool Permission Callbacks**: Control which tools Claude can use and
modify their inputs
  -  type with async support
  -  with suggestions from CLI
  -  for structured responses
  
- **Hook Callbacks**: React to events in the Claude workflow
  -  type for event handlers
  -  for conditional hook execution
  - Support for tool_use_start, tool_use_end events
  
- **Integration**: Full plumbing through ClaudeCodeOptions → Client →
Query
- **Examples**: Comprehensive example showing permission control
patterns
- **Tests**: Coverage for all callback scenarios

## Implementation Details

- Callbacks are registered during initialization phase
- Control protocol handles can_use_tool and hook_callback requests
- Backwards compatible with dict returns for tool permissions
- Proper error handling and type safety throughout

Builds on top of #139's control protocol implementation.

---------

Co-authored-by: Dickson Tsai <dickson@anthropic.com>
2025-09-03 10:16:11 -07:00
..
conftest.py Initial Python SDK import 2025-06-12 00:16:19 -07:00
test_changelog.py Add changelog and changelog format check (#77) 2025-07-21 10:53:01 -07:00
test_client.py Implement control protocol support for Python SDK (#139) 2025-09-01 23:04:22 -07:00
test_errors.py Initial Python SDK import 2025-06-12 00:16:19 -07:00
test_integration.py Implement control protocol support for Python SDK (#139) 2025-09-01 23:04:22 -07:00
test_message_parser.py Move thinking block parsing from user to assistant messages (#119) 2025-08-19 13:36:12 -07:00
test_sdk_mcp_integration.py feat: Add in-process SDK MCP server support (#142) 2025-09-03 08:29:32 -07:00
test_streaming_client.py Implement control protocol support for Python SDK (#139) 2025-09-01 23:04:22 -07:00
test_subprocess_buffering.py Implement control protocol support for Python SDK (#139) 2025-09-01 23:04:22 -07:00
test_tool_callbacks.py feat: Add tool permission and hook callbacks support (#143) 2025-09-03 10:16:11 -07:00
test_transport.py Implement control protocol support for Python SDK (#139) 2025-09-01 23:04:22 -07:00
test_types.py Add support for plan permission mode (#116) 2025-08-07 13:06:05 -07:00