Commit Graph

61 Commits

Author SHA1 Message Date
Dickson Tsai
b57e05afa5 Improve examples 2025-07-19 19:57:17 -07:00
Dickson Tsai
3b56577b2f CLAUDE.md 2025-07-19 19:12:15 -07:00
Dickson Tsai
739a5723f9 PR feedback 2025-07-19 19:12:07 -07:00
Dickson Tsai
9520852839 Fix types 2025-07-19 18:47:07 -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
Dickson Tsai
6c25bf7d37 Fix examples 2025-07-19 13:44:53 -07:00
Dickson Tsai
361c7e0be3 Working examples 2025-07-19 13:23:53 -07:00
Dickson Tsai
6dd12b0df8 Implement proper client and bidi streaming 2025-07-19 10:43:23 -07:00
Dickson Tsai
f4cff21590 Finalize streaming impl 2025-07-18 00:16:18 -07:00
Dickson Tsai
4c67548d87 Initial implementation of bidi streaming 2025-07-17 13:44:31 -07:00
Lina Tawfik
343ec4812c Merge pull request #42 from RomainGehrig/fix/cwd-not-exists
Explicit error if the cwd does not exist
2025-07-05 14:29:03 -07:00
Lina Tawfik
5a4f617309 Merge pull request #49 from anthropics/add-claude-issue-triage
Add Claude issue triage workflow
2025-07-03 11:21:18 -07:00
Lina Tawfik
7a9f606e5f Add Claude issue triage workflow
- Uses claude-code-base-action for automated issue triage
- Analyzes new issues and applies appropriate labels
- Uses GitHub MCP server for issue operations
- Requires ANTHROPIC_API_KEY secret to be configured

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-03 11:15:41 -07:00
Lina Tawfik
de27b6bf89 Merge pull request #65 from anthropics/chore/bump-version-0.0.14-signed
chore: bump version to 0.0.14
2025-07-01 20:40:21 -07:00
Lina Tawfik
e4de22eba4 Merge pull request #60 from anthropics/fix-fastapi-streaming-issue-4
Fix FastAPI SSE streaming compatibility
2025-07-01 20:40:12 -07:00
Lina Tawfik
1c792f155f chore: bump version to 0.0.14
This PR updates the version to 0.0.14 after publishing to PyPI.

## Changes
- Updated version in `pyproject.toml`
- Updated version in `src/claude_code_sdk/__init__.py`

## Release Information
- Published to PyPI: https://pypi.org/project/claude-code-sdk/0.0.14/
- Install with: `pip install claude-code-sdk==0.0.14`

## Next Steps
After merging this PR, a release tag will be created automatically.

Signed-off-by: Lina <lina@anthropic.com>
2025-07-01 18:31:56 -07:00
Lina Tawfik
be040c6161 Fix linting issues - use lowercase variable names 2025-07-01 16:27:32 -07:00
Lina Tawfik
4460dfbe3b Improve FastAPI SSE streaming fix with safety limits
Add critical safety mechanisms to the sequential stderr reading approach:
- 10MB memory limit on stderr collection with truncation message
- 30 second timeout protection to prevent hanging
- Proper exit code based error detection instead of string matching
- Debug logging for stderr on successful runs
- Better exception handling for edge cases

This addresses potential production issues while maintaining FastAPI compatibility.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-01 16:24:47 -07:00
Lina Tawfik
67193350e2 Remove implementation-specific test
The test was checking source code for specific strings rather than
testing behavior. The existing subprocess tests already verify the
functionality works correctly.
2025-07-01 15:23:55 -07:00
Lina Tawfik
9ef9da9ab6 Fix linting issues 2025-07-01 15:12:26 -07:00
Romain Gehrig
d336a22ab4 Explicit error if the cwd does not exist
Previously was raised as a CLINotFoundError
2025-07-01 16:33:30 +02:00
Lina Tawfik
404c50bce0 Fix FastAPI SSE streaming compatibility (fixes #4)
Remove anyio.create_task_group() from receive_messages() to fix the
RuntimeError "Attempted to exit cancel scope in a different task than
it was entered in" when using the SDK with FastAPI's SSE streaming.

The issue occurred because FastAPI can move async generators between
different asyncio tasks during the streaming lifecycle, which conflicts
with anyio's cancel scope tracking.

Changes:
- Remove task group usage from receive_messages()
- Read stderr sequentially after stdout completes
- Add test to ensure no task groups are used
- Fix existing test expectation for buffer overflow

This is a minimal fix that maintains compatibility while solving the
core issue. The trade-off is that stderr is read after stdout instead
of concurrently, but this is unlikely to cause issues in practice.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-01 00:04:50 -07:00
Lina Tawfik
4af210ee8f Merge pull request #53 from anthropics/fix/json-streaming-buffer
fix: handle JSON messages split across multiple stream reads
2025-06-30 23:03:27 -07:00
Lina Tawfik
8233533148 Add comment explaining JSON buffer accumulation logic 2025-06-30 23:00:54 -07:00
Lina Tawfik
1791031d20 chore: Remove obvious comments from code
Removed redundant comments that simply restate what the code is doing.
Kept only comments that provide valuable context or explain complex behavior.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-30 22:27:48 -07:00
Lina Tawfik
3ab62b617d fix: Pass proper Exception to CLIJSONDecodeError
The CLIJSONDecodeError constructor expects an Exception as the second
argument, not None. Changed to pass a ValueError with details about
the buffer size limit being exceeded.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-30 22:02:02 -07:00
Lina Tawfik
977bf6438b style: apply ruff formatting 2025-06-30 21:58:37 -07:00
Lina Tawfik
24295417ac fix: handle JSON messages split across multiple stream reads
Adds buffering to accumulate incomplete JSON messages that are split
across multiple stream reads due to asyncio's 64KB default buffer limit.

- Implement 1MB buffer to accumulate partial JSON
- Clear buffer on successful parse or size limit exceeded
- Add comprehensive tests for split JSON scenarios

Fixes CLIJSONDecodeError when reading large minified JSON files.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-30 21:55:06 -07:00
Lina Tawfik
012e1d1f09 Merge pull request #51 from vanducng/fix/changelog-comparison-url
fix: changelog comparison URL in release workflow
2025-06-30 21:26:32 -07:00
Duc Nguyen
c7630bb3c1 chore: cleanup 2025-06-29 14:35:44 +07:00
Duc Nguyen
1e20f633f1 fix: changelog comparison URL in release workflow 2025-06-29 14:27:08 +07:00
Lina Tawfik
9376957c2e Merge pull request #48 from anthropics/release/v0.0.13-verified
chore: bump version to 0.0.13
2025-06-28 20:39:20 -07:00
Lina Tawfik
91e02f1a0a chore: bump version to 0.0.13
- Updated version in pyproject.toml
- Updated version in src/claude_code_sdk/__init__.py

This version has been published to PyPI.
2025-06-27 18:21:23 -07:00
Lina Tawfik
b3c20bd7e3 Merge pull request #46 from anthropics/automated-version-update-workflow
feat: automate version updates after PyPI release
2025-06-27 18:15:59 -07:00
Lina Tawfik
149142c960 feat: automate version updates after PyPI release
- Update publish.yml to create PR after publishing
- Add create-release-tag.yml to tag releases when PR merges
- Eliminates manual version syncing between repo and PyPI
2025-06-27 16:56:01 -07:00
Lina Tawfik
9bda4e8982 Merge pull request #5 from Bradley-Butcher/fix/subprocess-buffering-issue
fix multi-line buffering issue
2025-06-27 15:33:29 -07:00
Lina Tawfik
7610791803 Apply ruff formatting
- Fixed quotes to use double quotes consistently
- Adjusted line breaks per ruff formatter rules
- No functional changes

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-27 15:08:20 -07:00
Lina Tawfik
ecad93a0c0 Apply ruff linting fixes
- Fixed formatting in test_subprocess_buffering.py
- No functional changes, only code style improvements

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-27 15:06:28 -07:00
Lina Tawfik
3f25c3bb83 Fix test to use anyio.run() pattern and add edge case tests
- Convert async test to use anyio.run() pattern consistent with other tests
- Remove unused CLIJSONDecodeError import
- Add tests for JSON with embedded newlines
- Add tests for multiple newlines between objects
- All tests passing

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-27 15:06:28 -07:00
Lina Tawfik
3bc37b5f61 Merge pull request #43 from gcmurphy/fix/update-readme
fix: update the tool list in README.md
2025-06-27 14:16:22 -07:00
Grant Murphy
b65751b828 fix: update the tool list in README.md
Fixes #21
2025-06-27 06:30:54 +10:00
Lina Tawfik
adf115fe6b Merge pull request #41 from jlaneve/patch-1
cost_usd -> total_cost_usd in example
2025-06-25 23:24:35 -07:00
Julian LaNeve
f868c59c72 cost_usd -> total_cost_usd in example 2025-06-25 15:18:52 -04:00
Dickson Tsai
52cc0db139 Merge pull request #40 from anthropics/dickson/mcp
Update MCP types to align with what Claude Code expects
2025-06-25 08:06:27 -07:00
Dickson Tsai
242c7197b6 Update MCP types to align with what Claude Code expects 2025-06-25 00:59:44 -07:00