claude-agent-sdk 0.16.3 → 0.16.4

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: b2c37eb821ab8e4fe91cc69b4d0d683b364617b321d74e642f330c7c560850dd
4
- data.tar.gz: 62c00c3973e9bfabda1ebf5f95b4ce4ca79bd6dc4c36e8f0bcf0038ede7c588f
3
+ metadata.gz: 98b00605830d86d1dc5e632ef9887574b255d2ace8fdc815451a53983ca0ea2e
4
+ data.tar.gz: d28cb3256fa5944f966e21afa753d082559a6d537d527dfc2abb5aaa962a450b
5
5
  SHA512:
6
- metadata.gz: af171dc45b39c86eee1dacd829f062e230b3369225ef394df0df43b9a05d2ecec087a6566dd00cb7a4a01d1af1f3a5677f08f9ae04ecaa9c46d9490c75acaf46
7
- data.tar.gz: f96ce5a7ee822ef161a541e29fa6677fb28c77c5e316965aa15477a782e087a60b15ea706665488e09f102356f91fa43491be82f526910c2d4afa4f08b3256fd
6
+ metadata.gz: 807595177836563a86f0dc72a3a70b297860d07f76d19c90d70f97dafae7a1bdd69a52583a8c005172148f6742b59fbd80e78f79a3d10c47ad33ba24d7ade89c
7
+ data.tar.gz: af94cf3bbd037da6b1a7998a41438f10227d731657c2050e4a0f1d57551e682d4dd9dcfef9d98c67f6ead150472804468093cc226622392b8b3ecdb25cae4d18
data/CHANGELOG.md CHANGED
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.16.4] - 2026-04-23
11
+
12
+ ### Fixed
13
+ - `Client#receive_response` no longer hangs in interactive Client mode. The 0.16.1 flag-based fix relied on the loop draining via the transport's `:end` sentinel, which only arrives when the CLI subprocess exits — true for one-shot `query()` but never for a `Client` whose CLI stays alive between turns. `receive_response` now drives `QueryHandler#receive_messages` directly so its `break` runs on the same fiber as the underlying `Async::Queue#dequeue` loop and unwinds it. The 0.16.1 regression spec passed only because its stub iterated a finite array; replaced with a real `Async::Queue` driven from a sibling task so a hang now fails the test.
14
+
15
+ ### Internal
16
+ - `FiberBoundary` doc-comment now warns that `break`/`return`/`next` cannot cross the thread hop, so SDK-internal loops yielding user callbacks must keep loop control on the outer side of the boundary.
17
+
10
18
  ## [0.16.3] - 2026-04-23
11
19
 
12
20
  ### Changed
data/README.md CHANGED
@@ -108,7 +108,7 @@ Add this line to your application's Gemfile:
108
108
  gem 'claude-agent-sdk', github: 'ya-luotao/claude-agent-sdk-ruby'
109
109
 
110
110
  # Or use a stable version from RubyGems
111
- gem 'claude-agent-sdk', '~> 0.16.3'
111
+ gem 'claude-agent-sdk', '~> 0.16.4'
112
112
  ```
113
113
 
114
114
  And then execute:
@@ -23,6 +23,10 @@ module ClaudeAgentSDK
23
23
  # user's app makes.
24
24
  #
25
25
  # No-op when no scheduler is active, so it's cheap to use unconditionally.
26
+ #
27
+ # The thread hop severs `break`/`return`/`next` from the surrounding method,
28
+ # so SDK loops yielding user callbacks must keep loop control outside the
29
+ # invoked block (see `Client#receive_response`).
26
30
  module FiberBoundary
27
31
  module_function
28
32
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClaudeAgentSDK
4
- VERSION = '0.16.3'
4
+ VERSION = '0.16.4'
5
5
  end
@@ -418,15 +418,18 @@ module ClaudeAgentSDK
418
418
  def receive_response(&block)
419
419
  return enum_for(:receive_response) unless block
420
420
 
421
- # Flag-based rather than `break`: `receive_messages` hops this
422
- # block onto a plain thread via `FiberBoundary.invoke`, which
423
- # severs break's unwind target.
424
- result_seen = false
425
- receive_messages do |message|
426
- next if result_seen
427
-
428
- block.call(message)
429
- result_seen = true if message.is_a?(ResultMessage)
421
+ raise CLIConnectionError, 'Not connected. Call connect() first' unless @connected
422
+
423
+ # Keep `break` on the same fiber as the underlying dequeue. Going through
424
+ # Client#receive_messages would put the FiberBoundary hop above the break
425
+ # and hang in Client mode — the CLI keeps stdin open and never emits `:end`.
426
+ @query_handler.receive_messages do |data|
427
+ message = MessageParser.parse(data)
428
+ next unless message
429
+
430
+ ClaudeAgentSDK.notify_observers(@resolved_observers, :on_message, message)
431
+ FiberBoundary.invoke { block.call(message) }
432
+ break if message.is_a?(ResultMessage)
430
433
  end
431
434
  end
432
435
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claude-agent-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.3
4
+ version: 0.16.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Community Contributors