mirror of
https://github.com/anthropics/claude-code-sdk-python.git
synced 2025-12-23 09:19:52 +00:00
Add missing hook output fields to match TypeScript SDK (#226)
Closes the gap between Python and TypeScript SDK hook output types by adding: - `reason` field for explaining decisions - `continue_` field for controlling execution flow - `suppressOutput` field for hiding stdout - `stopReason` field for stop explanations - `decision` now supports both "approve" and "block" (not just "block") - `AsyncHookJSONOutput` type for deferred hook execution - Proper typing for `hookSpecificOutput` with discriminated unions Also adds comprehensive examples and tests: - New examples in hooks.py demonstrating all new fields - Unit tests in test_tool_callbacks.py for new output types - E2E tests in e2e-tests/test_hooks.py with real API calls - CI integration in .github/workflows/test.yml 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5bea2dc27d
commit
e8d7e71a0a
6 changed files with 526 additions and 9 deletions
12
.github/workflows/test.yml
vendored
12
.github/workflows/test.yml
vendored
|
|
@ -125,6 +125,8 @@ jobs:
|
|||
run: |
|
||||
python examples/quick_start.py
|
||||
timeout 120 python examples/streaming_mode.py all
|
||||
timeout 120 python examples/hooks.py PreToolUse
|
||||
timeout 120 python examples/hooks.py DecisionFields
|
||||
|
||||
- name: Run example scripts (Windows)
|
||||
if: runner.os == 'Windows'
|
||||
|
|
@ -136,4 +138,14 @@ jobs:
|
|||
Wait-Job $job -Timeout 120 | Out-Null
|
||||
Stop-Job $job
|
||||
Receive-Job $job
|
||||
|
||||
$job = Start-Job { python examples/hooks.py PreToolUse }
|
||||
Wait-Job $job -Timeout 120 | Out-Null
|
||||
Stop-Job $job
|
||||
Receive-Job $job
|
||||
|
||||
$job = Start-Job { python examples/hooks.py DecisionFields }
|
||||
Wait-Job $job -Timeout 120 | Out-Null
|
||||
Stop-Job $job
|
||||
Receive-Job $job
|
||||
shell: pwsh
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue