claude-code-sdk-python/examples
Ashwin Bhat d754e5cc1d
feat: add strongly-typed hook inputs with TypedDict (#240)
Add typed hook input structures (PreToolUseHookInput,
PostToolUseHookInput, etc.) to provide better IDE autocomplete and type
safety for hook callbacks. Also convert HookContext from dataclass to
TypedDict to match runtime behavior.

Changes:
- Add BaseHookInput, PreToolUseHookInput, PostToolUseHookInput,
UserPromptSubmitHookInput, StopHookInput, SubagentStopHookInput, and
PreCompactHookInput TypedDict classes
- Update HookCallback signature to use HookInput union type
- Convert HookContext from dataclass to TypedDict (fixes type mismatch)
- Export all new hook input types from __init__.py
- Update all examples and tests to use typed hook inputs

Benefits:
- Zero breaking changes (TypedDict is dict-compatible at runtime)
- Full type safety and IDE autocomplete for hook callbacks
- Matches TypeScript SDK structure exactly
- Self-documenting hook input fields

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-10 16:22:13 -07:00
..
agents.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
hooks.py feat: add strongly-typed hook inputs with TypedDict (#240) 2025-10-10 16:22:13 -07:00
include_partial_messages.py Update model references to claude-sonnet-4-5 (#198) 2025-09-30 12:59:14 -07:00
mcp_calculator.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
quick_start.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
setting_sources.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
stderr_callback_example.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
streaming_mode.py Update model references to claude-sonnet-4-5 (#198) 2025-09-30 12:59:14 -07:00
streaming_mode_ipython.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
streaming_mode_trio.py Update model references to claude-sonnet-4-5 (#198) 2025-09-30 12:59:14 -07:00
system_prompt.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00
tool_permission_callback.py Rename claude_code to claude_agent (#188) 2025-09-28 14:52:53 -07:00