-
Notifications
You must be signed in to change notification settings - Fork 257
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Problem
HookJSONOutput is defined in types.py and used as the return type for HookCallback:
HookCallback = Callable[
[dict[str, Any], str | None, HookContext],
Awaitable[HookJSONOutput],
]
However, HookJSONOutput is not exported in init.py, which causes type checking issues when implementing hook callbacks.
Current Workaround
Users need to either:
- Import from the private module: from claude_agent_sdk.types import HookJSONOutput
- Define their own TypedDict matching the structure
- Use dict[str, Any] and lose type safety
Example Code
from claude_agent_sdk import HookContext
HookJSONOutput is not available
async def my_hook(
input_data: dict[str, Any],
tool_use_id: str | None,
context: HookContext,
) -> HookJSONOutput: # Type error: HookJSONOutput not found
return {"decision": "block", "systemMessage": "Not allowed"}
Suggested Fix
Add HookJSONOutput to the all list in init.py:
__all__ = [
# ... existing exports
"HookCallback",
"HookContext",
"HookMatcher",
"HookJSONOutput", # Add this
# ...
]
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers