Commit graph

13 commits

Author SHA1 Message Date
Dickson Tsai
05e932d2d1
Use anyio, not asyncio, in src 2025-09-02 06:35:00 +09:00
Kashyap Murali
910b9cbff4
Fix ruff linting issues
- Remove trailing whitespace from blank lines in test_streaming_client.py
2025-09-01 04:00:58 -07:00
Kashyap Murali
866bdf7929
Fix remaining test failures for control protocol
- Update test_transport.py: disconnect() -> close(), is_connected() -> is_ready()
- Update test_subprocess_buffering.py: receive_messages() -> read_messages()
- Fix test_streaming_client.py edge cases:
  - Add control protocol init to test_double_connect (use side_effect for multiple mocks)
  - Add control protocol init to test_receive_response_list_comprehension
  - Add control protocol init to test_concurrent_send_receive
- All transport method calls now use read_messages() instead of receive_messages()

Test results: 89 of 90 tests passing (1 subprocess test still needs work)
2025-09-01 03:45:59 -07:00
Kashyap Murali
a50b134ecf
Fix failing tests for control protocol implementation
- Update test mocks to handle control protocol initialization
- Fix interrupt test to check for control requests via write() instead of interrupt()
- Add control protocol support to mock_receive functions in streaming tests
- Ensure all tests properly handle init handshake before sending messages
- Fix formatting issues (trailing whitespace, blank lines)

All tests now properly support the new Query/Transport architecture with
bidirectional control protocol communication.
2025-09-01 03:24:02 -07:00
Kashyap Murali
105da74f68
clean up sdk refactor 2025-09-01 03:00:14 -07:00
yokomotod
f1e6dda230
fix: add support for thinking content blocks (#28)
Some checks are pending
Lint / lint (push) Waiting to run
Test / test (3.10) (push) Waiting to run
Test / test (3.11) (push) Waiting to run
Test / test (3.12) (push) Waiting to run
Test / test (3.13) (push) Waiting to run
## Summary

Fixes an issue where `thinking` content blocks in Claude Code responses
were not being parsed, resulting in empty `AssistantMessage` content
arrays.

## Changes
- Added `ThinkingBlock` dataclass to handle thinking content with
`thinking` and `signature` fields
- Updated client parsing logic in `_internal/client.py` to recognize and
create `ThinkingBlock` instances
- Added comprehensive test coverage for thinking block functionality

## Before

```python
# Claude Code response with thinking block resulted in:
AssistantMessage(content=[])  # Empty content!
```

## After

```python
# Now correctly parses to:
AssistantMessage(content=[
    ThinkingBlock(thinking="...", signature="...")
])
```

Fixes #27

---------

Co-authored-by: Dickson Tsai <dickson@anthropic.com>
2025-08-06 19:00:02 -07:00
Dickson Tsai
b57e05afa5
Improve examples 2025-07-19 19:57:17 -07:00
Dickson Tsai
a813a4d665
Fix lint 2025-07-19 15:26:30 -07:00
Dickson Tsai
e65c2f417a
Fix test 2025-07-19 15:25:34 -07:00
Dickson Tsai
c95c077b9b
Ruff 2025-07-19 15:21:02 -07:00
Dickson Tsai
712948c2e7
Fix test 2025-07-19 15:20:02 -07:00
Dickson Tsai
eeb0be9955
Close stdin for query() 2025-07-19 15:01:43 -07:00
Dickson Tsai
489677d614
Add tests 2025-07-19 13:57:52 -07:00