[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-anthropics--claude-agent-sdk-python":3,"tool-anthropics--claude-agent-sdk-python":64},[4,17,27,35,43,56],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":16},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,3,"2026-04-05T11:01:52",[13,14,15],"开发框架","图像","Agent","ready",{"id":18,"name":19,"github_repo":20,"description_zh":21,"stars":22,"difficulty_score":23,"last_commit_at":24,"category_tags":25,"status":16},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",138956,2,"2026-04-05T11:33:21",[13,15,26],"语言模型",{"id":28,"name":29,"github_repo":30,"description_zh":31,"stars":32,"difficulty_score":23,"last_commit_at":33,"category_tags":34,"status":16},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",107662,"2026-04-03T11:11:01",[13,14,15],{"id":36,"name":37,"github_repo":38,"description_zh":39,"stars":40,"difficulty_score":23,"last_commit_at":41,"category_tags":42,"status":16},3704,"NextChat","ChatGPTNextWeb\u002FNextChat","NextChat 是一款轻量且极速的 AI 助手，旨在为用户提供流畅、跨平台的大模型交互体验。它完美解决了用户在多设备间切换时难以保持对话连续性，以及面对众多 AI 模型不知如何统一管理的痛点。无论是日常办公、学习辅助还是创意激发，NextChat 都能让用户随时随地通过网页、iOS、Android、Windows、MacOS 或 Linux 端无缝接入智能服务。\n\n这款工具非常适合普通用户、学生、职场人士以及需要私有化部署的企业团队使用。对于开发者而言，它也提供了便捷的自托管方案，支持一键部署到 Vercel 或 Zeabur 等平台。\n\nNextChat 的核心亮点在于其广泛的模型兼容性，原生支持 Claude、DeepSeek、GPT-4 及 Gemini Pro 等主流大模型，让用户在一个界面即可自由切换不同 AI 能力。此外，它还率先支持 MCP（Model Context Protocol）协议，增强了上下文处理能力。针对企业用户，NextChat 提供专业版解决方案，具备品牌定制、细粒度权限控制、内部知识库整合及安全审计等功能，满足公司对数据隐私和个性化管理的高标准要求。",87618,"2026-04-05T07:20:52",[13,26],{"id":44,"name":45,"github_repo":46,"description_zh":47,"stars":48,"difficulty_score":23,"last_commit_at":49,"category_tags":50,"status":16},2268,"ML-For-Beginners","microsoft\u002FML-For-Beginners","ML-For-Beginners 是由微软推出的一套系统化机器学习入门课程，旨在帮助零基础用户轻松掌握经典机器学习知识。这套课程将学习路径规划为 12 周，包含 26 节精炼课程和 52 道配套测验，内容涵盖从基础概念到实际应用的完整流程，有效解决了初学者面对庞大知识体系时无从下手、缺乏结构化指导的痛点。\n\n无论是希望转型的开发者、需要补充算法背景的研究人员，还是对人工智能充满好奇的普通爱好者，都能从中受益。课程不仅提供了清晰的理论讲解，还强调动手实践，让用户在循序渐进中建立扎实的技能基础。其独特的亮点在于强大的多语言支持，通过自动化机制提供了包括简体中文在内的 50 多种语言版本，极大地降低了全球不同背景用户的学习门槛。此外，项目采用开源协作模式，社区活跃且内容持续更新，确保学习者能获取前沿且准确的技术资讯。如果你正寻找一条清晰、友好且专业的机器学习入门之路，ML-For-Beginners 将是理想的起点。",84991,"2026-04-05T10:45:23",[14,51,52,53,15,54,26,13,55],"数据工具","视频","插件","其他","音频",{"id":57,"name":58,"github_repo":59,"description_zh":60,"stars":61,"difficulty_score":10,"last_commit_at":62,"category_tags":63,"status":16},3128,"ragflow","infiniflow\u002Fragflow","RAGFlow 是一款领先的开源检索增强生成（RAG）引擎，旨在为大语言模型构建更精准、可靠的上下文层。它巧妙地将前沿的 RAG 技术与智能体（Agent）能力相结合，不仅支持从各类文档中高效提取知识，还能让模型基于这些知识进行逻辑推理和任务执行。\n\n在大模型应用中，幻觉问题和知识滞后是常见痛点。RAGFlow 通过深度解析复杂文档结构（如表格、图表及混合排版），显著提升了信息检索的准确度，从而有效减少模型“胡编乱造”的现象，确保回答既有据可依又具备时效性。其内置的智能体机制更进一步，使系统不仅能回答问题，还能自主规划步骤解决复杂问题。\n\n这款工具特别适合开发者、企业技术团队以及 AI 研究人员使用。无论是希望快速搭建私有知识库问答系统，还是致力于探索大模型在垂直领域落地的创新者，都能从中受益。RAGFlow 提供了可视化的工作流编排界面和灵活的 API 接口，既降低了非算法背景用户的上手门槛，也满足了专业开发者对系统深度定制的需求。作为基于 Apache 2.0 协议开源的项目，它正成为连接通用大模型与行业专有知识之间的重要桥梁。",77062,"2026-04-04T04:44:48",[15,14,13,26,54],{"id":65,"github_repo":66,"name":67,"description_en":68,"description_zh":69,"ai_summary_zh":69,"readme_en":70,"readme_zh":71,"quickstart_zh":72,"use_case_zh":73,"hero_image_url":74,"owner_login":75,"owner_name":76,"owner_avatar_url":77,"owner_bio":78,"owner_company":68,"owner_location":68,"owner_email":68,"owner_twitter":68,"owner_website":79,"owner_url":80,"languages":81,"stars":90,"forks":91,"last_commit_at":92,"license":93,"difficulty_score":23,"env_os":94,"env_gpu":95,"env_ram":95,"env_deps":96,"category_tags":99,"github_topics":68,"view_count":10,"oss_zip_url":68,"oss_zip_packed_at":68,"status":16,"created_at":100,"updated_at":101,"faqs":102,"releases":123},1053,"anthropics\u002Fclaude-agent-sdk-python","claude-agent-sdk-python",null,"claude-agent-sdk-python 是一个用于与 Claude Code 交互的 Python SDK，支持异步查询和双向对话。它允许开发者通过简单接口调用 Claude 的代码能力，同时提供自定义工具和权限管理功能。该工具解决了传统方式下与 AI 代码助手交互复杂、权限控制繁琐的问题，通过灵活的配置实现高效开发。\n\n适合需要集成 AI 代码助手的开发者，尤其是那些希望扩展 Claude 功能、自定义工具逻辑或管理代码权限的用户。其核心亮点在于支持在进程内运行的自定义工具（MCP 服务器），无需额外进程即可实现复杂交互；同时提供细粒度的权限控制机制，可自动审批工具使用或动态决策。通过设置工作目录和系统提示词，用户还能更精准地控制代码生成场景。该工具为需要深度定制 AI 代码助手行为的开发者提供了强大而灵活的解决方案。","# Claude Agent SDK for Python\n\nPython SDK for Claude Agent. See the [Claude Agent SDK documentation](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Fpython) for more information.\n\n## Installation\n\n```bash\npip install claude-agent-sdk\n```\n\n**Prerequisites:**\n\n- Python 3.10+\n\n**Note:** The Claude Code CLI is automatically bundled with the package - no separate installation required! The SDK will use the bundled CLI by default. If you prefer to use a system-wide installation or a specific version, you can:\n\n- Install Claude Code separately: `curl -fsSL https:\u002F\u002Fclaude.ai\u002Finstall.sh | bash`\n- Specify a custom path: `ClaudeAgentOptions(cli_path=\"\u002Fpath\u002Fto\u002Fclaude\")`\n\n## Quick Start\n\n```python\nimport anyio\nfrom claude_agent_sdk import query\n\nasync def main():\n    async for message in query(prompt=\"What is 2 + 2?\"):\n        print(message)\n\nanyio.run(main)\n```\n\n## Basic Usage: query()\n\n`query()` is an async function for querying Claude Code. It returns an `AsyncIterator` of response messages. See [src\u002Fclaude_agent_sdk\u002Fquery.py](src\u002Fclaude_agent_sdk\u002Fquery.py).\n\n```python\nfrom claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, TextBlock\n\n# Simple query\nasync for message in query(prompt=\"Hello Claude\"):\n    if isinstance(message, AssistantMessage):\n        for block in message.content:\n            if isinstance(block, TextBlock):\n                print(block.text)\n\n# With options\noptions = ClaudeAgentOptions(\n    system_prompt=\"You are a helpful assistant\",\n    max_turns=1\n)\n\nasync for message in query(prompt=\"Tell me a joke\", options=options):\n    print(message)\n```\n\n### Using Tools\n\nBy default, Claude has access to the full [Claude Code toolset](https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fsettings#tools-available-to-claude) (Read, Write, Edit, Bash, and others). `allowed_tools` is a permission allowlist: listed tools are auto-approved, and unlisted tools fall through to `permission_mode` and `can_use_tool` for a decision. It does not remove tools from Claude's toolset. To block specific tools, use `disallowed_tools`. See the [permissions guide](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Fpermissions) for the full evaluation order.\n\n```python\noptions = ClaudeAgentOptions(\n    allowed_tools=[\"Read\", \"Write\", \"Bash\"],  # auto-approve these tools\n    permission_mode='acceptEdits'  # auto-accept file edits\n)\n\nasync for message in query(\n    prompt=\"Create a hello.py file\",\n    options=options\n):\n    # Process tool use and results\n    pass\n```\n\n### Working Directory\n\n```python\nfrom pathlib import Path\n\noptions = ClaudeAgentOptions(\n    cwd=\"\u002Fpath\u002Fto\u002Fproject\"  # or Path(\"\u002Fpath\u002Fto\u002Fproject\")\n)\n```\n\n## ClaudeSDKClient\n\n`ClaudeSDKClient` supports bidirectional, interactive conversations with Claude\nCode. See [src\u002Fclaude_agent_sdk\u002Fclient.py](src\u002Fclaude_agent_sdk\u002Fclient.py).\n\nUnlike `query()`, `ClaudeSDKClient` additionally enables **custom tools** and **hooks**, both of which can be defined as Python functions.\n\n### Custom Tools (as In-Process SDK MCP Servers)\n\nA **custom tool** is a Python function that you can offer to Claude, for Claude to invoke as needed.\n\nCustom tools are implemented in-process MCP servers that run directly within your Python application, eliminating the need for separate processes that regular MCP servers require.\n\nFor an end-to-end example, see [MCP Calculator](examples\u002Fmcp_calculator.py).\n\n#### Creating a Simple Tool\n\n```python\nfrom claude_agent_sdk import tool, create_sdk_mcp_server, ClaudeAgentOptions, ClaudeSDKClient\n\n# Define a tool using the @tool decorator\n@tool(\"greet\", \"Greet a user\", {\"name\": str})\nasync def greet_user(args):\n    return {\n        \"content\": [\n            {\"type\": \"text\", \"text\": f\"Hello, {args['name']}!\"}\n        ]\n    }\n\n# Create an SDK MCP server\nserver = create_sdk_mcp_server(\n    name=\"my-tools\",\n    version=\"1.0.0\",\n    tools=[greet_user]\n)\n\n# Use it with Claude. allowed_tools pre-approves the tool so it runs\n# without a permission prompt; it does not control tool availability.\noptions = ClaudeAgentOptions(\n    mcp_servers={\"tools\": server},\n    allowed_tools=[\"mcp__tools__greet\"]\n)\n\nasync with ClaudeSDKClient(options=options) as client:\n    await client.query(\"Greet Alice\")\n\n    # Extract and print response\n    async for msg in client.receive_response():\n        print(msg)\n```\n\n#### Benefits Over External MCP Servers\n\n- **No subprocess management** - Runs in the same process as your application\n- **Better performance** - No IPC overhead for tool calls\n- **Simpler deployment** - Single Python process instead of multiple\n- **Easier debugging** - All code runs in the same process\n- **Type safety** - Direct Python function calls with type hints\n\n#### Migration from External Servers\n\n```python\n# BEFORE: External MCP server (separate process)\noptions = ClaudeAgentOptions(\n    mcp_servers={\n        \"calculator\": {\n            \"type\": \"stdio\",\n            \"command\": \"python\",\n            \"args\": [\"-m\", \"calculator_server\"]\n        }\n    }\n)\n\n# AFTER: SDK MCP server (in-process)\nfrom my_tools import add, subtract  # Your tool functions\n\ncalculator = create_sdk_mcp_server(\n    name=\"calculator\",\n    tools=[add, subtract]\n)\n\noptions = ClaudeAgentOptions(\n    mcp_servers={\"calculator\": calculator}\n)\n```\n\n#### Mixed Server Support\n\nYou can use both SDK and external MCP servers together:\n\n```python\noptions = ClaudeAgentOptions(\n    mcp_servers={\n        \"internal\": sdk_server,      # In-process SDK server\n        \"external\": {                # External subprocess server\n            \"type\": \"stdio\",\n            \"command\": \"external-server\"\n        }\n    }\n)\n```\n\n### Hooks\n\nA **hook** is a Python function that the Claude Code _application_ (_not_ Claude) invokes at specific points of the Claude agent loop. Hooks can provide deterministic processing and automated feedback for Claude. Read more in [Intercept and control agent behavior with hooks](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Fhooks).\n\nFor more examples, see examples\u002Fhooks.py.\n\n#### Example\n\n```python\nfrom claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient, HookMatcher\n\nasync def check_bash_command(input_data, tool_use_id, context):\n    tool_name = input_data[\"tool_name\"]\n    tool_input = input_data[\"tool_input\"]\n    if tool_name != \"Bash\":\n        return {}\n    command = tool_input.get(\"command\", \"\")\n    block_patterns = [\"foo.sh\"]\n    for pattern in block_patterns:\n        if pattern in command:\n            return {\n                \"hookSpecificOutput\": {\n                    \"hookEventName\": \"PreToolUse\",\n                    \"permissionDecision\": \"deny\",\n                    \"permissionDecisionReason\": f\"Command contains invalid pattern: {pattern}\",\n                }\n            }\n    return {}\n\noptions = ClaudeAgentOptions(\n    allowed_tools=[\"Bash\"],\n    hooks={\n        \"PreToolUse\": [\n            HookMatcher(matcher=\"Bash\", hooks=[check_bash_command]),\n        ],\n    }\n)\n\nasync with ClaudeSDKClient(options=options) as client:\n    # Test 1: Command with forbidden pattern (will be blocked)\n    await client.query(\"Run the bash command: .\u002Ffoo.sh --help\")\n    async for msg in client.receive_response():\n        print(msg)\n\n    print(\"\\n\" + \"=\" * 50 + \"\\n\")\n\n    # Test 2: Safe command that should work\n    await client.query(\"Run the bash command: echo 'Hello from hooks example!'\")\n    async for msg in client.receive_response():\n        print(msg)\n```\n\n## Types\n\nSee [src\u002Fclaude_agent_sdk\u002Ftypes.py](src\u002Fclaude_agent_sdk\u002Ftypes.py) for complete type definitions:\n\n- `ClaudeAgentOptions` - Configuration options\n- `AssistantMessage`, `UserMessage`, `SystemMessage`, `ResultMessage` - Message types\n- `TextBlock`, `ToolUseBlock`, `ToolResultBlock` - Content blocks\n\n## Error Handling\n\n```python\nfrom claude_agent_sdk import (\n    ClaudeSDKError,      # Base error\n    CLINotFoundError,    # Claude Code not installed\n    CLIConnectionError,  # Connection issues\n    ProcessError,        # Process failed\n    CLIJSONDecodeError,  # JSON parsing issues\n)\n\ntry:\n    async for message in query(prompt=\"Hello\"):\n        pass\nexcept CLINotFoundError:\n    print(\"Please install Claude Code\")\nexcept ProcessError as e:\n    print(f\"Process failed with exit code: {e.exit_code}\")\nexcept CLIJSONDecodeError as e:\n    print(f\"Failed to parse response: {e}\")\n```\n\nSee [src\u002Fclaude_agent_sdk\u002F\\_errors.py](src\u002Fclaude_agent_sdk\u002F_errors.py) for all error types.\n\n## Available Tools\n\nSee the [Claude Code documentation](https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fsettings#tools-available-to-claude) for a complete list of available tools.\n\n## Examples\n\nSee [examples\u002Fquick_start.py](examples\u002Fquick_start.py) for a complete working example.\n\nSee [examples\u002Fstreaming_mode.py](examples\u002Fstreaming_mode.py) for comprehensive examples involving `ClaudeSDKClient`. You can even run interactive examples in IPython from [examples\u002Fstreaming_mode_ipython.py](examples\u002Fstreaming_mode_ipython.py).\n\n## Migrating from Claude Code SDK\n\nIf you're upgrading from the Claude Code SDK (versions \u003C 0.1.0), please see the [CHANGELOG.md](CHANGELOG.md#010) for details on breaking changes and new features, including:\n\n- `ClaudeCodeOptions` → `ClaudeAgentOptions` rename\n- Merged system prompt configuration\n- Settings isolation and explicit control\n- New programmatic subagents and session forking features\n\n## Development\n\nIf you're contributing to this project, run the initial setup script to install git hooks:\n\n```bash\n.\u002Fscripts\u002Finitial-setup.sh\n```\n\nThis installs a pre-push hook that runs lint checks before pushing, matching the CI workflow. To skip the hook temporarily, use `git push --no-verify`.\n\n### Building Wheels Locally\n\nTo build wheels with the bundled Claude Code CLI:\n\n```bash\n# Install build dependencies\npip install build twine\n\n# Build wheel with bundled CLI\npython scripts\u002Fbuild_wheel.py\n\n# Build with specific version\npython scripts\u002Fbuild_wheel.py --version 0.1.4\n\n# Build with specific CLI version\npython scripts\u002Fbuild_wheel.py --cli-version 2.0.0\n\n# Clean bundled CLI after building\npython scripts\u002Fbuild_wheel.py --clean\n\n# Skip CLI download (use existing)\npython scripts\u002Fbuild_wheel.py --skip-download\n```\n\nThe build script:\n\n1. Downloads Claude Code CLI for your platform\n2. Bundles it in the wheel\n3. Builds both wheel and source distribution\n4. Checks the package with twine\n\nSee `python scripts\u002Fbuild_wheel.py --help` for all options.\n\n### Release Workflow\n\nThe package is published to PyPI via the GitHub Actions workflow in `.github\u002Fworkflows\u002Fpublish.yml`. To create a new release:\n\n1. **Trigger the workflow** manually from the Actions tab with two inputs:\n   - `version`: The package version to publish (e.g., `0.1.5`)\n   - `claude_code_version`: The Claude Code CLI version to bundle (e.g., `2.0.0` or `latest`)\n\n2. **The workflow will**:\n   - Build platform-specific wheels for macOS, Linux, and Windows\n   - Bundle the specified Claude Code CLI version in each wheel\n   - Build a source distribution\n   - Publish all artifacts to PyPI\n   - Create a release branch with version updates\n   - Open a PR to main with:\n     - Updated `pyproject.toml` version\n     - Updated `src\u002Fclaude_agent_sdk\u002F_version.py`\n     - Updated `src\u002Fclaude_agent_sdk\u002F_cli_version.py` with bundled CLI version\n     - Auto-generated `CHANGELOG.md` entry\n\n3. **Review and merge** the release PR to update main with the new version information\n\nThe workflow tracks both the package version and the bundled CLI version separately, allowing you to release a new package version with an updated CLI without code changes.\n\n## License and terms\n\nUse of this SDK is governed by Anthropic's [Commercial Terms of Service](https:\u002F\u002Fwww.anthropic.com\u002Flegal\u002Fcommercial-terms), including when you use it to power products and services that you make available to your own customers and end users, except to the extent a specific component or dependency is covered by a different license as indicated in that component's LICENSE file.\n","# Claude Agent SDK for Python\n\nClaude Agent 的 Python SDK。更多信息请参阅 [Claude Agent SDK 文档](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Fpython)。\n\n## 安装\n\n```bash\npip install claude-agent-sdk\n```\n\n**前置要求：**\n\n- Python 3.10+\n\n**注意：** Claude Code CLI 已自动捆绑在包中 - 无需单独安装！SDK 默认使用捆绑的 CLI。如需使用全局安装或特定版本，可以：\n\n- 单独安装 Claude Code：`curl -fsSL https:\u002F\u002Fclaude.ai\u002Finstall.sh | bash`\n- 指定自定义路径：`ClaudeAgentOptions(cli_path=\"\u002Fpath\u002Fto\u002Fclaude\")`\n\n## 快速开始\n\n```python\nimport anyio\nfrom claude_agent_sdk import query\n\nasync def main():\n    async for message in query(prompt=\"What is 2 + 2?\"):\n        print(message)\n\nanyio.run(main)\n```\n\n## 基本用法：query()\n\n`query()` 是用于查询 Claude Code 的异步函数（async function）。它返回响应消息的 `AsyncIterator`（异步迭代器）。详见 [src\u002Fclaude_agent_sdk\u002Fquery.py](src\u002Fclaude_agent_sdk\u002Fquery.py)。\n\n```python\nfrom claude_agent_sdk import query, ClaudeAgentOptions, AssistantMessage, TextBlock\n\n# 简单查询\nasync for message in query(prompt=\"Hello Claude\"):\n    if isinstance(message, AssistantMessage):\n        for block in message.content:\n            if isinstance(block, TextBlock):\n                print(block.text)\n\n# 使用选项\noptions = ClaudeAgentOptions(\n    system_prompt=\"You are a helpful assistant\",\n    max_turns=1\n)\n\nasync for message in query(prompt=\"Tell me a joke\", options=options):\n    print(message)\n```\n\n### 使用工具\n\n默认情况下，Claude 可以访问完整的 [Claude Code 工具集](https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fsettings#tools-available-to-claude)（读取、写入、编辑、Bash 等）。`allowed_tools` 是权限白名单：列出的工具会自动批准，未列出的工具会根据 `permission_mode` 和 `can_use_tool` 决定是否允许。这不会从 Claude 工具集中移除工具。要阻止特定工具，请使用 `disallowed_tools`。完整的评估顺序请参阅[权限指南](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Fpermissions)。\n\n```python\noptions = ClaudeAgentOptions(\n    allowed_tools=[\"Read\", \"Write\", \"Bash\"],  # 自动批准这些工具\n    permission_mode='acceptEdits'  # 自动接受文件修改\n)\n\nasync for message in query(\n    prompt=\"Create a hello.py file\",\n    options=options\n):\n    # 处理工具调用和结果\n    pass\n```\n\n### 工作目录\n\n```python\nfrom pathlib import Path\n\noptions = ClaudeAgentOptions(\n    cwd=\"\u002Fpath\u002Fto\u002Fproject\"  # 或 Path(\"\u002Fpath\u002Fto\u002Fproject\")\n)\n```\n\n## ClaudeSDKClient\n\n`ClaudeSDKClient` 支持与 Claude Code 进行双向交互式对话。详见 [src\u002Fclaude_agent_sdk\u002Fclient.py](src\u002Fclaude_agent_sdk\u002Fclient.py)。\n\n与 `query()` 不同，`ClaudeSDKClient` 还支持 **自定义工具** 和 **钩子**，两者都可以定义为 Python 函数。\n\n### 自定义工具（作为进程内 SDK MCP 服务器）\n\n**自定义工具** 是您可以通过 Python 函数实现并提供给 Claude 调用的工具。\n\n自定义工具通过进程内 MCP 服务器实现，直接在您的 Python 应用程序中运行，无需常规 MCP 服务器所需的独立进程。\n\n完整示例请参见 [MCP 计算器](examples\u002Fmcp_calculator.py)。\n\n#### 创建简单工具\n\n```python\nfrom claude_agent_sdk import tool, create_sdk_mcp_server, ClaudeAgentOptions, ClaudeSDKClient\n\n# 使用 @tool 装饰器定义工具\n@tool(\"greet\", \"Greet a user\", {\"name\": str})\nasync def greet_user(args):\n    return {\n        \"content\": [\n            {\"type\": \"text\", \"text\": f\"Hello, {args['name']}!\"}\n        ]\n    }\n\n# 创建 SDK MCP 服务器\nserver = create_sdk_mcp_server(\n    name=\"my-tools\",\n    version=\"1.0.0\",\n    tools=[greet_user]\n)\n\n# 与 Claude 一起使用。allowed_tools 预批准该工具使其无需权限提示运行\n# 但不控制工具可用性\noptions = ClaudeAgentOptions(\n    mcp_servers={\"tools\": server},\n    allowed_tools=[\"mcp__tools__greet\"]\n)\n\nasync with ClaudeSDKClient(options=options) as client:\n    await client.query(\"Greet Alice\")\n\n    # 提取并打印响应\n    async for msg in client.receive_response():\n        print(msg)\n```\n\n#### 相比外部 MCP 服务器的优势\n\n- **无需子进程管理** - 与您的应用程序运行在同一个进程中\n- **更好性能** - 工具调用无 IPC 开销\n- **更简单部署** - 单一 Python 进程而非多个\n- **更容易调试** - 所有代码运行在同一个进程中\n- **类型安全** - 直接的 Python 函数调用和类型提示\n\n#### 从外部服务器迁移\n\n```python\n# 之前：外部 MCP 服务器（独立进程）\noptions = ClaudeAgentOptions(\n    mcp_servers={\n        \"calculator\": {\n            \"type\": \"stdio\",\n            \"command\": \"python\",\n            \"args\": [\"-m\", \"calculator_server\"]\n        }\n    }\n)\n\n# 之后：SDK MCP 服务器（进程内）\nfrom my_tools import add, subtract  # 您的工具函数\n\ncalculator = create_sdk_mcp_server(\n    name=\"calculator\",\n    tools=[add, subtract]\n)\n\noptions = ClaudeAgentOptions(\n    mcp_servers={\"calculator\": calculator}\n)\n```\n\n#### 混合服务器支持\n\n您可以同时使用 SDK 和外部 MCP 服务器：\n\n```python\noptions = ClaudeAgentOptions(\n    mcp_servers={\n        \"internal\": sdk_server,      # 进程内 SDK 服务器\n        \"external\": {                # 外部子进程服务器\n            \"type\": \"stdio\",\n            \"command\": \"external-server\"\n        }\n    }\n)\n```\n\n### 钩子（Hooks）\n\n**钩子（hook）** 是由 Claude Code _应用程序_（而非 Claude）在 Claude 代理循环的特定节点调用的 Python 函数。钩子可以为 Claude 提供确定性处理和自动化反馈。详见 [使用钩子拦截和控制代理行为](https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Fhooks)。\n\n更多示例请查看 [examples\u002Fhooks.py](examples\u002Fhooks.py)。\n\n#### 示例\n\n```python\nfrom claude_agent_sdk import ClaudeAgentOptions, ClaudeSDKClient, HookMatcher\n\nasync def check_bash_command(input_data, tool_use_id, context):\n    tool_name = input_data[\"tool_name\"]\n    tool_input = input_data[\"tool_input\"]\n    if tool_name != \"Bash\":\n        return {}\n    command = tool_input.get(\"command\", \"\")\n    block_patterns = [\"foo.sh\"]\n    for pattern in block_patterns:\n        if pattern in command:\n            return {\n                \"hookSpecificOutput\": {\n                    \"hookEventName\": \"PreToolUse\",\n                    \"permissionDecision\": \"deny\",\n                    \"permissionDecisionReason\": f\"命令包含非法模式: {pattern}\",\n                }\n            }\n    return {}\n\noptions = ClaudeAgentOptions(\n    allowed_tools=[\"Bash\"],\n    hooks={\n        \"PreToolUse\": [\n            HookMatcher(matcher=\"Bash\", hooks=[check_bash_command]),\n        ],\n    }\n)\n\nasync with ClaudeSDKClient(options=options) as client:\n    # 测试1: 包含禁止模式的命令（将被拦截）\n    await client.query(\"运行bash命令: .\u002Ffoo.sh --help\")\n    async for msg in client.receive_response():\n        print(msg)\n\n    print(\"\\n\" + \"=\" * 50 + \"\\n\")\n\n    # 测试2: 可正常执行的安全命令\n    await client.query(\"运行bash命令: echo 'Hello from hooks example!'\")\n    async for msg in client.receive_response():\n        print(msg)\n```\n\n## 类型定义\n\n完整类型定义请查看 [src\u002Fclaude_agent_sdk\u002Ftypes.py](src\u002Fclaude_agent_sdk\u002Ftypes.py)：\n\n- `ClaudeAgentOptions` - 配置选项\n- `AssistantMessage`, `UserMessage`, `SystemMessage`, `ResultMessage` - 消息类型\n- `TextBlock`, `ToolUseBlock`, `ToolResultBlock` - 内容块类型\n\n## 错误处理\n\n```python\nfrom claude_agent_sdk import (\n    ClaudeSDKError,      # 基类错误\n    CLINotFoundError,    # 未安装Claude Code\n    CLIConnectionError,  # 连接问题\n    ProcessError,        # 进程失败\n    CLIJSONDecodeError,  # JSON解析问题\n)\n\ntry:\n    async for message in query(prompt=\"Hello\"):\n        pass\nexcept CLINotFoundError:\n    print(\"请安装Claude Code\")\nexcept ProcessError as e:\n    print(f\"进程失败，退出码: {e.exit_code}\")\nexcept CLIJSONDecodeError as e:\n    print(f\"响应解析失败: {e}\")\n```\n\n所有错误类型定义请查看 [src\u002Fclaude_agent_sdk\u002F_errors.py](src\u002Fclaude_agent_sdk\u002F_errors.py)。\n\n## 可用工具\n\n完整可用工具列表请查看 [Claude Code 文档](https:\u002F\u002Fcode.claude.com\u002Fdocs\u002Fen\u002Fsettings#tools-available-to-claude)。\n\n## 示例\n\n完整工作示例请查看 [examples\u002Fquick_start.py](examples\u002Fquick_start.py)。\n\n包含 `ClaudeSDKClient` 的综合示例请查看 [examples\u002Fstreaming_mode.py](examples\u002Fstreaming_mode.py)。您还可以在 IPython 中运行交互式示例 [examples\u002Fstreaming_mode_ipython.py](examples\u002Fstreaming_mode_ipython.py)。\n\n## 从Claude Code SDK迁移\n\n如果您正在升级自Claude Code SDK（版本\u003C0.1.0），请查看 [CHANGELOG.md](CHANGELOG.md#010) 中的破坏性变更和新特性说明，包括：\n\n- `ClaudeCodeOptions` → `ClaudeAgentOptions` 重命名\n- 系统提示配置合并\n- 设置隔离和显式控制\n- 新的程序化子代理和会话分叉特性\n\n## 开发\n\n如需贡献代码，请运行初始化脚本安装git钩子：\n\n```bash\n.\u002Fscripts\u002Finitial-setup.sh\n```\n\n该脚本会安装预推送钩子，在推送前运行代码检查，与CI流程保持一致。临时跳过钩子可使用 `git push --no-verify`。\n\n### 本地构建wheel包\n\n构建包含Claude Code CLI的wheel包：\n\n```bash\n# 安装构建依赖\npip install build twine\n\n# 构建wheel包\npython scripts\u002Fbuild_wheel.py\n\n# 指定版本构建\npython scripts\u002Fbuild_wheel.py --version 0.1.4\n\n# 指定CLI版本构建\npython scripts\u002Fbuild_wheel.py --cli-version 2.0.0\n\n# 构建后清理CLI文件\npython scripts\u002Fbuild_wheel.py --clean\n\n# 跳过CLI下载（使用现有文件）\npython scripts\u002Fbuild_wheel.py --skip-download\n```\n\n构建脚本会执行以下步骤：\n1. 下载适用于您平台的Claude Code CLI\n2. 将其打包进wheel\n3. 构建wheel和源码分发包\n4. 使用twine验证包\n\n完整选项请查看 `python scripts\u002Fbuild_wheel.py --help`。\n\n### 发布流程\n\n包通过 `.github\u002Fworkflows\u002Fpublish.yml` 中的GitHub Actions工作流发布到PyPI。创建新版本需：\n1. **手动触发工作流**（在Actions标签页）并提供两个输入：\n   - `version`: 要发布的包版本（如 `0.1.5`）\n   - `claude_code_version`: 要打包的Claude Code CLI版本（如 `2.0.0` 或 `latest`）\n\n2. **工作流将**：\n   - 为macOS、Linux和Windows构建平台特定的wheel包\n   - 在每个wheel中打包指定版本的Claude Code CLI\n   - 构建源码分发包\n   - 将所有制品发布到PyPI\n   - 创建包含版本更新的发布分支\n   - 提交PR合并到main分支，包含：\n     - 更新 `pyproject.toml` 版本\n     - 更新 `src\u002Fclaude_agent_sdk\u002F_version.py`\n     - 更新 `src\u002Fclaude_agent_sdk\u002F_cli_version.py` 中的CLI版本\n     - 自动生成的 `CHANGELOG.md` 条目\n\n3. **审核并合并** 发布PR以更新main分支的版本信息\n\n工作流分别跟踪包版本和CLI版本，允许您在不修改代码的情况下发布包含更新CLI的新版本。\n\n## 许可协议\n\n本SDK的使用受Anthropic [商业服务条款](https:\u002F\u002Fwww.anthropic.com\u002Flegal\u002Fcommercial-terms) 约束，包括您使用其为自有客户提供产品和服务的场景，除非特定组件或依赖项另有许可协议（详见对应组件的LICENSE文件）。","# Claude Agent SDK Python 快速上手指南\n\n## 环境准备\n- **系统要求**：Python 3.10 或更高版本\n- **前置依赖**：\n  ```bash\n  # 建议使用国内镜像加速安装\n  pip install --upgrade pip\n  ```\n\n## 安装步骤\n```bash\n# 推荐使用清华源加速安装\npip install claude-agent-sdk -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n```\n\n## 基本使用\n### 最简示例\n1. 创建 `main.py` 文件，内容如下：\n   ```python\n   import anyio\n   from claude_agent_sdk import query\n\n   async def main():\n       async for message in query(prompt=\"What is 2 + 2?\"):\n           print(message)\n\n   anyio.run(main)\n   ```\n\n2. 运行示例：\n   ```bash\n   python main.py\n   ```\n\n### 进阶用法（可选）\n- 自定义系统提示：\n  ```python\n  from claude_agent_sdk import ClaudeAgentOptions\n\n  options = ClaudeAgentOptions(\n      system_prompt=\"You are a helpful assistant\",\n      max_turns=1\n  )\n  ```\n\n- 指定工作目录：\n  ```python\n  from pathlib import Path\n\n  options = ClaudeAgentOptions(\n      cwd=Path(\"\u002Fpath\u002Fto\u002Fproject\")\n  )\n  ```\n\n> 提示：完整工具集使用、自定义工具开发等内容请参考官方文档的[工具使用](#using-tools)和[自定义工具](#custom-tools)章节。","数据分析师小李需要为新项目快速搭建Python代码框架，需生成多个模块文件并配置依赖关系。传统手动操作耗时且易错，而claude-agent-sdk-python的智能代码生成能力可显著提升效率。\n\n### 没有 claude-agent-sdk-python 时\n- 手动创建文件结构需反复切换终端和编辑器，10分钟仅能完成基础框架搭建\n- 文件权限配置需逐个执行chmod命令，容易遗漏导致安全风险\n- 代码生成需多次复制粘贴模板，重复劳动占工作量的40%\n- 无法实时验证代码结构合理性，后期调试耗时增加30%\n- 团队协作时版本差异导致文件覆盖，需额外使用Git手动管理\n\n### 使用 claude-agent-sdk-python 后\n- 通过Bash工具自动创建完整项目结构，30秒完成包含5个模块的框架搭建\n- 权限模式设置为acceptEdits后，自动生成带正确权限的文件配置\n- 自定义工具集成代码模板生成器，单次交互输出完整代码片段\n- 实时流式响应显示代码验证结果，提前发现结构问题减少70%调试时间\n- 工作目录锁定功能确保所有操作在指定路径下，避免文件覆盖风险\n- 异步API支持批量处理多个代码生成任务，提升团队协作效率\n\n核心价值：通过智能代码生成与自动化流程编排，将项目初始化时间从小时级压缩至分钟级，同时保障代码质量与系统安全。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fanthropics_claude-agent-sdk-python_fc828661.png","anthropics","Anthropic","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fanthropics_1ed37989.png","","https:\u002F\u002Fanthropic.com","https:\u002F\u002Fgithub.com\u002Fanthropics",[82,86],{"name":83,"color":84,"percentage":85},"Python","#3572A5",99.5,{"name":87,"color":88,"percentage":89},"Shell","#89e051",0.5,6133,848,"2026-04-05T10:13:02","MIT","Linux, macOS, Windows","未说明",{"notes":78,"python":97,"dependencies":98},"3.10+",[],[15,13],"2026-03-27T02:49:30.150509","2026-04-06T06:44:45.138150",[103,108,113,118],{"id":104,"question_zh":105,"answer_zh":106,"source_url":107},4694,"如何在Claude SDK中获取结构化输出（如JSON）？","通过`ClaudeAgentOptions`的`output_format`参数配置JSON Schema，示例代码：\n```python\noptions = ClaudeAgentOptions(\n    output_format={\n        \"type\": \"json_schema\",\n        \"schema\": {\n            \"type\": \"object\",\n            \"properties\": {\n                \"answer\": {\"type\": \"string\"},\n                \"confidence\": {\"type\": \"number\"}\n            },\n            \"required\": [\"answer\", \"confidence\"]\n        }\n    }\n)\n```\n文档地址：https:\u002F\u002Fplatform.claude.com\u002Fdocs\u002Fen\u002Fagent-sdk\u002Fstructured-outputs","https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-agent-sdk-python\u002Fissues\u002F180",{"id":109,"question_zh":110,"answer_zh":111,"source_url":112},4695,"如何在SDK中实现类似CLI的工具权限批准？","通过`ClaudeAgentOptions`的`can_use_tool`回调实现权限控制，具体示例参考仓库中的`examples\u002Ftool_permission_callback.py`文件。维护者确认该方法有效。","https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-agent-sdk-python\u002Fissues\u002F137",{"id":114,"question_zh":115,"answer_zh":116,"source_url":117},4696,"如何使用环境变量进行Claude Code SDK的身份验证？","在`ClaudeAgentOptions`中通过`env`参数传递环境变量，示例：\n```python\noptions = ClaudeAgentOptions(\n    env={\n        \"ANTHROPIC_API_KEY\": \"sk-...\",\n        \"ANTHROPIC_BASE_URL\": \"https:\u002F\u002Fcustom-endpoint.example.com\",\n        \"ANTHROPIC_MODEL\": \"claude-sonnet-4-20250514\",\n        \"ANTHROPIC_SMALL_FAST_MODEL\": \"claude-haiku-4-20250514\",\n    },\n)\n```\n注意：使用系统安装的CLI可避免部分环境变量传递问题。","https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-agent-sdk-python\u002Fissues\u002F106",{"id":119,"question_zh":120,"answer_zh":121,"source_url":122},4697,"使用claude_code_sdk时出现JSONDecodeError如何解决？","升级SDK至0.0.14版本修复此问题。若仍需旧版本，可应用社区提供的修复方案（如Phantom168的分支：https:\u002F\u002Fgithub.com\u002FPhantom168\u002Fclaude-code-sdk-python\u002Ftree\u002Ffix\u002Fpartial-json-in-buffer）。","https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fclaude-agent-sdk-python\u002Fissues\u002F15",[124,129,134,139,144,149,154,159,164,169,174,179,184,189,194,199,204,209,214,219],{"id":125,"version":126,"summary_zh":127,"released_at":128},104189,"v0.1.56","\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.92\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.56\u002F\n\n```bash\npip install claude-agent-sdk==0.1.56\n```\n","2026-04-04T00:57:36",{"id":130,"version":131,"summary_zh":132,"released_at":133},104190,"v0.1.55","\n### Bug Fixes\n\n- **MCP large tool results**: Forward `maxResultSizeChars` from `ToolAnnotations` via `_meta` to bypass Zod annotation stripping in the CLI, fixing silent truncation of large MCP tool results (>50K chars) (#756)\n\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.91\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.55\u002F\n\n```bash\npip install claude-agent-sdk==0.1.55\n```\n","2026-04-03T00:38:02",{"id":135,"version":136,"summary_zh":137,"released_at":138},104191,"v0.1.54","\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.54\u002F\n\n```bash\npip install claude-agent-sdk==0.1.54\n```\n","2026-04-02T00:09:24",{"id":140,"version":141,"summary_zh":142,"released_at":143},104192,"v0.1.53","\n### Bug Fixes\n\n- **Setting sources flag**: Fixed `--setting-sources` being passed as an empty string when not provided, which caused the CLI to misparse subsequent flags (#778)\n- **String prompt deadlock**: Fixed deadlock when using `query()` with a string prompt and hooks\u002FMCP servers that trigger many tool calls, by spawning `wait_for_result_and_end_input()` as a background task (#780)\n\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.88\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.53\u002F\n\n```bash\npip install claude-agent-sdk==0.1.53\n```\n","2026-03-31T00:47:03",{"id":145,"version":146,"summary_zh":147,"released_at":148},104193,"v0.1.52","\n### New Features\n\n- **Context usage**: Added `get_context_usage()` method to `ClaudeSDKClient` for querying context window usage by category (#764)\n- **Annotated parameter descriptions**: The `@tool` decorator and `create_sdk_mcp_server` now support `typing.Annotated` for per-parameter descriptions in JSON Schema (#762)\n- **ToolPermissionContext fields**: Exposed `tool_use_id` and `agent_id` in `ToolPermissionContext` for distinguishing parallel permission requests (#754)\n- **Session ID option**: Added `session_id` option to `ClaudeAgentOptions` for specifying custom session IDs (#750)\n\n### Bug Fixes\n\n- **String prompt in connect()**: Fixed `connect(prompt=\"...\")` silently dropping the string prompt, causing `receive_messages()` to hang indefinitely (#769)\n- **Cancel request handling**: Implemented `control_cancel_request` handling so in-flight hook callbacks are properly cancelled when the CLI abandons them (#751)\n\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.87\n- Increased CI timeout for example tests and reduced sleep duration in error handling example (#760)\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.52\u002F\n\n```bash\npip install claude-agent-sdk==0.1.52\n```\n","2026-03-29T02:41:27",{"id":150,"version":151,"summary_zh":152,"released_at":153},104194,"v0.1.51","\n### New Features\n\n- **Session management**: Added `fork_session()`, `delete_session()`, and offset-based pagination for session listing (#744)\n- **Task budget**: Added `task_budget` option for token budget management (#747)\n- **SystemPromptFile**: Added support for `--system-prompt-file` CLI flag via `SystemPromptFile` (#591)\n- **AgentDefinition fields**: Added `disallowedTools`, `maxTurns`, and `initialPrompt` to `AgentDefinition` (#759)\n- **Preserved fields**: Preserve dropped fields on `AssistantMessage` and `ResultMessage` for forward compatibility (#718)\n\n### Bug Fixes\n\n- **Python 3.10 compatibility**: Use `typing_extensions.TypedDict` on Python 3.10 for `NotRequired` support (#761)\n- **ResultMessage errors field**: Added missing `errors` field to `ResultMessage` (#749)\n- **Async generator cleanup**: Resolved cross-task cancel scope `RuntimeError` on async generator cleanup (#746)\n- **MCP tool input_schema**: Convert `TypedDict` input_schema to proper JSON Schema in SDK MCP tools (#736)\n- **initialize_timeout**: Pass `initialize_timeout` from env var in `query()` (#743)\n- **Async event loop blocking**: Defer CLI discovery to `connect()` to avoid blocking async event loops (#722)\n- **Permission mode**: Added missing `dontAsk` permission mode to types (#719)\n- **Environment filtering**: Filter `CLAUDECODE` env var from subprocess environment (#732)\n- **Process cleanup**: Added `SIGKILL` fallback when `SIGTERM` handler blocks in `close()` (#729)\n- **Duplicate warning**: Removed duplicate version warning and included CLI path (#720)\n- **MCP resource types**: Handle `resource_link` and embedded resource content types in SDK MCP tools (#725)\n- **Stdin timeout**: Removed stdin timeout for hooks and SDK MCP servers (#731)\n- **Stdout parsing**: Skip non-JSON lines on CLI stdout to prevent buffer corruption (#723)\n- **MCP error propagation**: Propagate `is_error` flag from SDK MCP tool results (#717)\n- **Install script**: Retry `install.sh` fetch on 429 with pipefail + jitter (#708)\n\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.85\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.51\u002F\n\n```bash\npip install claude-agent-sdk==0.1.51\n```\n","2026-03-27T20:22:23",{"id":155,"version":156,"summary_zh":157,"released_at":158},104195,"v0.1.50","\n### New Features\n\n- **Session info**: Added `tag` and `created_at` fields to `SDKSessionInfo` and new `get_session_info()` function for retrieving session metadata (#667)\n\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.81\n- Hardened PyPI publish workflow against partial-upload failures (#700)\n- Added daily PyPI storage quota monitoring (#705)\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.50\u002F\n\n```bash\npip install claude-agent-sdk==0.1.50\n```\n","2026-03-20T23:02:22",{"id":160,"version":161,"summary_zh":162,"released_at":163},104196,"v0.1.49","\n### New Features\n\n- **AgentDefinition**: Added `skills`, `memory`, and `mcpServers` fields (#684)\n- **AssistantMessage usage**: Preserve per-turn `usage` on `AssistantMessage` (#685)\n- **Session tagging**: Added `tag_session()` with Unicode sanitization (#670)\n- **Session renaming**: Added `rename_session()` (#668)\n- **RateLimitEvent**: Added typed `RateLimitEvent` message (#648)\n\n### Bug Fixes\n\n- **CLAUDE_CODE_ENTRYPOINT**: Use default-if-absent semantics to match TS SDK (#686)\n- **Fine-grained tool streaming**: Reverted the env-var workaround from 0.1.48; partial-message delivery is now handled upstream (#671)\n\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.77\n- Added macOS x86_64 wheel to the published matrix (#661)\n- Upload wheel-check artifacts in CI (#662)\n- Docs: clarified `allowed_tools` as a permission allowlist (#649)\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.49\u002F\n\n```bash\npip install claude-agent-sdk==0.1.49\n```\n","2026-03-20T18:08:59",{"id":165,"version":166,"summary_zh":167,"released_at":168},104197,"v0.1.48","\n### Bug Fixes\n\n- **Fine-grained tool streaming**: Fixed `include_partial_messages=True` not delivering `input_json_delta` events by enabling the `CLAUDE_CODE_ENABLE_FINE_GRAINED_TOOL_STREAMING` environment variable in the subprocess. This regression affected versions 0.1.36 through 0.1.47 for users without the server-side feature flag (#644)\n\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.71\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.48\u002F\n\n```bash\npip install claude-agent-sdk==0.1.48\n```\n","2026-03-07T00:22:37",{"id":170,"version":171,"summary_zh":172,"released_at":173},104198,"v0.1.47","\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.70\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.47\u002F\n\n```bash\npip install claude-agent-sdk==0.1.47\n```\n","2026-03-06T01:30:26",{"id":175,"version":176,"summary_zh":177,"released_at":178},104199,"v0.1.46","\n### New Features\n\n- **Session history functions**: Added `list_sessions()` and `get_session_messages()` top-level functions for retrieving past session data (#622)\n- **MCP control methods**: Added `add_mcp_server()`, `remove_mcp_server()`, and typed `McpServerStatus` for runtime MCP server management (#620)\n- **Typed task messages**: Added `TaskStarted`, `TaskProgress`, and `TaskNotification` message subclasses for better type safety when handling task-related events (#621)\n- **ResultMessage stop_reason**: Added `stop_reason` field to `ResultMessage` for inspecting why a conversation turn ended (#619)\n- **Hook input enhancements**: Added `agent_id` and `agent_type` fields to tool-lifecycle hook inputs (`PreToolUseHookInput`, `PostToolUseHookInput`, `PostToolUseFailureHookInput`) (#628)\n\n### Bug Fixes\n\n- **String prompt MCP initialization**: Fixed an issue where passing a string prompt would close stdin before MCP server initialization completed, causing MCP servers to fail to register (#630)\n\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.69\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.46\u002F\n\n```bash\npip install claude-agent-sdk==0.1.46\n```\n","2026-03-05T00:37:19",{"id":180,"version":181,"summary_zh":182,"released_at":183},104200,"v0.1.45","\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.63\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.45\u002F\n\n```bash\npip install claude-agent-sdk==0.1.45\n```\n","2026-03-03T17:21:52",{"id":185,"version":186,"summary_zh":187,"released_at":188},104201,"v0.1.44","\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.59\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.44\u002F\n\n```bash\npip install claude-agent-sdk==0.1.44\n```\n","2026-02-26T01:18:12",{"id":190,"version":191,"summary_zh":192,"released_at":193},104202,"v0.1.43","\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.56\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.43\u002F\n\n```bash\npip install claude-agent-sdk==0.1.43\n```\n","2026-02-25T06:49:32",{"id":195,"version":196,"summary_zh":197,"released_at":198},104203,"v0.1.42","\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.55\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.42\u002F\n\n```bash\npip install claude-agent-sdk==0.1.42\n```\n","2026-02-25T03:33:13",{"id":200,"version":201,"summary_zh":202,"released_at":203},104204,"v0.1.41","\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.52\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.41\u002F\n\n```bash\npip install claude-agent-sdk==0.1.41\n```\n","2026-02-24T06:56:49",{"id":205,"version":206,"summary_zh":207,"released_at":208},104205,"v0.1.40","\n### Bug Fixes\n\n- **Unknown message type handling**: Fixed an issue where unrecognized CLI message types (e.g., `rate_limit_event`) would crash the session by raising `MessageParseError`. Unknown message types are now silently skipped, making the SDK forward-compatible with future CLI message types (#598)\n\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.51\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.40\u002F\n\n```bash\npip install claude-agent-sdk==0.1.40\n```\n","2026-02-24T02:00:49",{"id":210,"version":211,"summary_zh":212,"released_at":213},104206,"v0.1.39","\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.49\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.39\u002F\n\n```bash\npip install claude-agent-sdk==0.1.39\n```\n","2026-02-19T23:44:40",{"id":215,"version":216,"summary_zh":217,"released_at":218},104207,"v0.1.38","\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.47\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.38\u002F\n\n```bash\npip install claude-agent-sdk==0.1.38\n```\n","2026-02-18T21:57:56",{"id":220,"version":221,"summary_zh":222,"released_at":223},104208,"v0.1.37","\n### Internal\u002FOther Changes\n\n- Updated bundled Claude CLI to version 2.1.44\n\n\n---\n\n**PyPI:** https:\u002F\u002Fpypi.org\u002Fproject\u002Fclaude-agent-sdk\u002F0.1.37\u002F\n\n```bash\npip install claude-agent-sdk==0.1.37\n```\n","2026-02-16T21:51:27"]