claude-agent-sdk 0.16.6 → 0.16.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5e77eea013fead986f47ff000864ddb9e52a3408186cf09bf3bb8d5214edec28
4
- data.tar.gz: 49f94edca00072ec403cb26eb79165979d8684e655336bce6ca53f3c1a31eb81
3
+ metadata.gz: 77f3f91c222e9af9b14687a6dfe5a7fdfc5fb175a99b0d1d66e84c3ba21f823d
4
+ data.tar.gz: c421820aa8d1de1863c55183ba8fdf384cd47b7cb334900d26cdd01fe7e5f8d4
5
5
  SHA512:
6
- metadata.gz: '08544dd09bb2d8c1127364517e1cc3527aaa0321d8c2d957550f078c5ce1d20796f5622f987ddd9f128377cad697d314a63a31031cd8eeb2e823bbfef282ee17'
7
- data.tar.gz: e7149a4d3d9546631449d71878a6480d3d8758c2d990b3836cdc1dde65e93d09a8d19658c781c4f2cf5655bcb3c910dac84bc7d0076f635af4957f78a2e91fe9
6
+ metadata.gz: 62f8e35411630b0ff7b4205dfd1444eb4c5d2ee2e86900dacd5a8fbc0feb9537ffbd975e666e9a6f9a57ae3185a1fccd00c840af8accbc11a1d6fb429ee5b6e8
7
+ data.tar.gz: 7077a54c30b2ac6371ce374f75eae8053b922e4c2041331f7440d359f984c67363455e05620a1381596b46aaff173ba3e7890ace17fb7ded21e95d433adbe124
data/CHANGELOG.md CHANGED
@@ -7,6 +7,40 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.16.8] - 2026-05-15
11
+
12
+ ### Added
13
+ - `ServerToolUseBlock` + `ServerToolResultBlock` content blocks for the CLI's built-in server-side tools (web_search, advisor, code_execution). The message parser now recognises `server_tool_use` / `server_tool_result` content types.
14
+ - `DeferredToolUse` class and `ResultMessage#deferred_tool_use` field — populated when a PreToolUse hook returns `permissionDecision: "defer"` so the session can be resumed later to execute the deferred call.
15
+ - `ResultMessage#api_error_status` — integer HTTP status (429, 500, 529) on the `api_error` subtype, from CLI 2.1.110+.
16
+ - `ToolPermissionContext` gains five pre-formatted display fields (`title`, `display_name`, `description`, `blocked_path`, `decision_reason`) populated by CLI 2.1.110+ so `can_use_tool` callbacks can render the same prompt UI the CLI would.
17
+ - `PostToolUseHookSpecificOutput#updated_tool_output` — unified tool-output replacement that works for any tool, MCP or built-in (the legacy `updated_mcp_tool_output` field remains for backwards compatibility).
18
+
19
+ ### Changed
20
+ - README restructured: the 1857-line single-file reference was slimmed to ~285 lines covering intro, comparison table, install, Quick Start, and minimal `query()`/`Client`/MCP/Hooks examples. Detailed sections moved into a new `docs/` directory with nine topic subpages (`client.md`, `mcp-servers.md`, `hooks-and-permissions.md`, `configuration.md`, `sessions.md`, `observability.md`, `rails.md`, `types.md`, `errors.md`). The README now links to each subpage from a single "Advanced Topics" table.
21
+ - `claude-agent-sdk.gemspec` now ships `docs/**/*` so `gem install` includes the topic subpages — the Agentic Coding Skill (and humans browsing `<gem_path>` after `bundle show claude-agent-sdk`) can read the full documentation set without a repo clone.
22
+ - `Query#start` now raises `CLIConnectionError` if invoked outside an `Async{}` block. The previous implementation appeared to support synchronous callers but silently hung forever because the outer `Async{}` root task it spawned waited for `read_messages` to finish, which never happens for a live Client. All documented usage (`query()` and the `Client#connect` pattern) already wraps in `Async{}` so this only surfaces a previously hidden failure mode.
23
+ - `CommandBuilder` raises `ArgumentError` synchronously when both `continue_conversation` and `resume` are set, instead of producing an opaque non-zero CLI exit at runtime.
24
+ - `sdk_mcp_server`'s `read_resource`, `get_prompt`, and the dynamic `Resource#read` / `Prompt#get` callbacks now hop through `FiberBoundary.invoke` (`call_tool` already did). User reader/generator blocks that touch `Thread.current`-keyed libraries (ActiveRecord, pg) no longer see the async-gem fiber scheduler.
25
+
26
+ ### Fixed
27
+ - **Transport `@stdin` race**: `write`/`close` are now serialised by a mutex. User callbacks running on `FiberBoundary` threads can no longer race `close()` and hit `NoMethodError` on a nilled `@stdin`. The mutex only guards the reference snapshot — the blocking IO call happens outside the lock so `close` is never blocked by a full pipe buffer.
28
+ - **Transport stdout poisoning**: stdout lines that do not start with `{` are skipped when `json_buffer` is empty. Previously the CLI's occasional debug prefixes (e.g. `[SandboxDebug]`) accumulated in the buffer until the 1 MB cap raised `CLIJSONDecodeError` and killed the session. Matches the Python SDK's guard.
29
+ - **Transport stderr resilience**: each `stderr` callback invocation is wrapped in `rescue StandardError`, so a transiently failing user logger no longer terminates the read loop and silently stops stderr capture for the lifetime of the process. Matches Python SDK v0.2.82 (PR #932).
30
+ - **Transport process reaping**: `@process.value` is now `&.`-safe and rescues `Errno::ECHILD`, so a concurrent `close()` that already reaped the subprocess cannot crash the message loop.
31
+ - **Query read-loop cancellation**: `@task` now holds the actual `read_messages` child task. The previous outer-`Async`-wrapper assignment completed almost immediately after spawning, so `close`'s `@task.stop` never reached the actual read fiber and the loop only ended when the transport raised.
32
+ - **Query control-request leak**: `send_control_request` now cleans `@pending_control_*` entries in an `ensure` block and uses `Async::Task.current.with_timeout` instead of a nested `Async do ... end.wait`. An `Async::Stop` propagating through `.wait`, or a late `control_response` arriving after timeout, can no longer leak pending state.
33
+ - **Session forks dropped metadata**: `parse_fork_transcript` now filters transcript body by `TRANSCRIPT_TYPES` (`user`/`assistant`/`attachment`/`system`/`progress`). `custom-title`, `tag`, `aiTitle`, `permission-mode` and other metadata entries with the old sessionId no longer bleed into the forked transcript.
34
+ - **Session forks lost content-replacement history**: `content-replacement` entries are now accumulated across compaction rounds (concatenated) rather than overwritten, gated on matching `sessionId`. Forks emit `content-replacement` and `custom-title` entries with `uuid`+`timestamp` so a fork-of-a-fork can re-ingest them.
35
+ - **`delete_session` orphans**: also `FileUtils.rm_rf`s the sibling `<session-id>/` subagent transcript directory. Without this the CLI would later pick up stale subagent state if the same session ID happened to be reused.
36
+ - **`detect_worktrees` hang on stale git lock**: enforces a 5-second hard cap with `SIGKILL` fallback. `Timeout.timeout` is unsafe under the Async fiber scheduler (it raises across threads via `Thread#raise`), so the new implementation drains stdout/stderr on side threads and kills the child process if the deadline passes. A pipe-buffer-overrun edge case (enough worktrees to overrun the 64 KB pipe buffer) that previously silently lost every worktree path is also fixed.
37
+
38
+ ## [0.16.7] - 2026-05-15
39
+
40
+ ### Added
41
+ - `ClaudeAgentOptions#resume_session_at` — forwarded as `--resume-session-at <message-uuid>` to the CLI. When resuming a session, the conversation is truncated to include only messages up to and including the assistant message with the given UUID, enabling history rewriting / branched continuations from a specific turn. Raises `ArgumentError` from `CommandBuilder` if set without `resume` (matches the CLI's own validation but surfaces it synchronously in the caller's stack).
42
+ - `examples/e2b_transport_example.rb` — working ~320-line custom transport that runs the Claude Code CLI inside an E2B Firecracker microVM via the `e2b` gem. Reuses `CommandBuilder` for argv parity with `SubprocessCLITransport` and demonstrates the 6-method `Transport` interface against a remote backend. README's Custom Transport section now includes an interface table, data-flow diagram, code sketch, and production-hardening checklist that link to the example.
43
+
10
44
  ## [0.16.6] - 2026-04-29
11
45
 
12
46
  ### Added