Commit graph

46 commits

Author SHA1 Message Date
Lina Tawfik
343ec4812c
Merge pull request #42 from RomainGehrig/fix/cwd-not-exists
Some checks failed
Test / test (3.13) (push) Has been cancelled
Lint / lint (push) Has been cancelled
Test / test (3.10) (push) Has been cancelled
Test / test (3.11) (push) Has been cancelled
Test / test (3.12) (push) Has been cancelled
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
Some checks failed
Test / test (3.12) (push) Has been cancelled
Test / test (3.13) (push) Has been cancelled
Lint / lint (push) Has been cancelled
Test / test (3.10) (push) Has been cancelled
Test / test (3.11) (push) Has been cancelled
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
Some checks failed
Lint / lint (push) Has been cancelled
Test / test (3.10) (push) Has been cancelled
Test / test (3.11) (push) Has been cancelled
Test / test (3.12) (push) Has been cancelled
Test / test (3.13) (push) Has been cancelled
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
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
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
Some checks failed
Lint / lint (push) Has been cancelled
Test / test (3.10) (push) Has been cancelled
Test / test (3.11) (push) Has been cancelled
Test / test (3.12) (push) Has been cancelled
Test / test (3.13) (push) Has been cancelled
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
Some checks failed
Lint / lint (push) Has been cancelled
Test / test (3.10) (push) Has been cancelled
Test / test (3.11) (push) Has been cancelled
Test / test (3.12) (push) Has been cancelled
Test / test (3.13) (push) Has been cancelled
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
Some checks failed
Test / test (3.10) (push) Has been cancelled
Lint / lint (push) Has been cancelled
Test / test (3.11) (push) Has been cancelled
Test / test (3.12) (push) Has been cancelled
Test / test (3.13) (push) Has been cancelled
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
Some checks are pending
Lint / lint (push) Waiting to run
Test / test (3.13) (push) Waiting to run
Test / test (3.12) (push) Waiting to run
Test / test (3.10) (push) Waiting to run
Test / test (3.11) (push) Waiting to run
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
Bradley-Butcher
87e2699f6a
fix multi-line buffering issue
Signed-off-by: Bradley-Butcher <brad@phoebe.ai>
2025-06-19 11:39:44 +01:00
Lina Tawfik
7efa8b3987
Merge pull request #19 from anthropics/add-claude-workflow
Some checks failed
Lint / lint (push) Has been cancelled
Test / test (3.10) (push) Has been cancelled
Test / test (3.11) (push) Has been cancelled
Test / test (3.12) (push) Has been cancelled
Test / test (3.13) (push) Has been cancelled
Add Claude Code GitHub Workflow
2025-06-17 17:17:29 -07:00
Lina Tawfik
9b1387a5ff
Merge pull request #17 from anthropics/fix-optional-cost-fields
Fix: Remove unused cost_usd field
2025-06-17 17:17:17 -07:00
Lina Tawfik
7d488f47c0
Add Claude Code GitHub Workflow
This PR adds a GitHub Actions workflow that enables Claude Code integration in our repository.

Claude Code is an AI coding agent that can help with:
- Bug fixes and improvements
- Documentation updates
- Implementing new features
- Code reviews and suggestions
- Writing tests
- And more\!

Once merged, we'll be able to interact with Claude by mentioning @claude in a pull request or issue comment.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-17 17:03:37 -07:00
Lina Tawfik
b3448f4baa
Fix tests to match updated ResultMessage type
- Remove cost_usd field from test expectations
- Update to use total_cost_usd instead of total_cost
- All 30 tests now pass

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-17 16:51:28 -07:00
Lina Tawfik
6cc5b34d54
Fix: Remove cost_usd field and handle GeneratorExit
The CLI only sends total_cost_usd, not cost_usd. This PR:

- Removes the non-existent cost_usd field from ResultMessage
- Makes total_cost_usd optional since it may be missing
- Handles GeneratorExit gracefully in subprocess transport
- Removes unnecessary cancel scope call

Fixes the error users were experiencing:
- KeyError: 'cost_usd'
- Field required [type=missing, input_value=...]

The anyio cancel scope error still appears in logs but doesn't affect functionality.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-17 16:38:52 -07:00
Lina Tawfik
54bff2e85d
Merge pull request #1 from anthropics/initial-sdk-import
Initial Python SDK import
2025-06-12 00:26:15 -07:00
Lina Tawfik
8c950a7457
Fix CI: Don't fail on Codecov upload errors
The tests are passing but CI was failing due to missing Codecov token.
Set fail_ci_if_error to false since coverage upload is optional.
2025-06-12 00:21:45 -07:00
Lina Tawfik
63ef121e18
Fix code formatting for CI 2025-06-12 00:20:28 -07:00
Lina Tawfik
6ca3514261
Initial Python SDK import 2025-06-12 00:16:19 -07:00
Lina Tawfik
19c71ae9ca
Initial commit 2025-06-11 14:33:43 -07:00