claude-agent-sdk 0.16.2 → 0.16.3

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: 184cf490ead1c830e0733d720e8f3580310ea3d68880e4e2945b28f803bea83b
4
- data.tar.gz: fd3d83127d247eec43f30852ee8e5a75b14420721ad32b14e2ee7a811ed1d673
3
+ metadata.gz: b2c37eb821ab8e4fe91cc69b4d0d683b364617b321d74e642f330c7c560850dd
4
+ data.tar.gz: 62c00c3973e9bfabda1ebf5f95b4ce4ca79bd6dc4c36e8f0bcf0038ede7c588f
5
5
  SHA512:
6
- metadata.gz: 054c00ec53645630c0a60e66d78503b46da03f6bc3b43f9021c4dd3274d3309345af83751a7556074e7303205f1d502361c9f1d339a8f9201aea92b5f0dfda6a
7
- data.tar.gz: e32f7b8a2ed41fe1c5db98e5254b1abddcfffe4f935508fe61eeef1c10ed11c1bb14a344fea16f46300d1fd3e0c8e150884b0340600dd161ec1c9582a0ff4289
6
+ metadata.gz: af171dc45b39c86eee1dacd829f062e230b3369225ef394df0df43b9a05d2ecec087a6566dd00cb7a4a01d1af1f3a5677f08f9ae04ecaa9c46d9490c75acaf46
7
+ data.tar.gz: f96ce5a7ee822ef161a541e29fa6677fb28c77c5e316965aa15477a782e087a60b15ea706665488e09f102356f91fa43491be82f526910c2d4afa4f08b3256fd
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.16.3] - 2026-04-23
11
+
12
+ ### Changed
13
+ - Internal: extracted `SubprocessCLITransport#record_bounded_stderr` helper to deduplicate the recent-stderr ring-buffer append/trim logic shared by `handle_stderr` and `drain_stderr_with_accumulation`, and replaced the inlined `20` cap with a named `RECENT_STDERR_LINES_LIMIT` constant. No public behavior change.
14
+
10
15
  ## [0.16.2] - 2026-04-23
11
16
 
12
17
  ### 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.2'
111
+ gem 'claude-agent-sdk', '~> 0.16.3'
112
112
  ```
113
113
 
114
114
  And then execute:
@@ -13,6 +13,7 @@ module ClaudeAgentSDK
13
13
  class SubprocessCLITransport < Transport
14
14
  DEFAULT_MAX_BUFFER_SIZE = 1024 * 1024 # 1MB buffer limit
15
15
  MINIMUM_CLAUDE_CODE_VERSION = '2.0.0'
16
+ RECENT_STDERR_LINES_LIMIT = 20
16
17
 
17
18
  def initialize(options_or_prompt = nil, options = nil)
18
19
  # Support both new single-arg form and legacy two-arg form
@@ -145,11 +146,7 @@ module ClaudeAgentSDK
145
146
  line_str = line.chomp
146
147
  next if line_str.empty?
147
148
 
148
- # Accumulate recent lines for inclusion in ProcessError
149
- @recent_stderr_mutex.synchronize do
150
- @recent_stderr << line_str
151
- @recent_stderr.shift if @recent_stderr.size > 20
152
- end
149
+ record_bounded_stderr(line_str)
153
150
 
154
151
  # Call stderr callback if provided
155
152
  @options.stderr&.call(line_str)
@@ -174,10 +171,7 @@ module ClaudeAgentSDK
174
171
  line_str = line.chomp
175
172
  next if line_str.empty?
176
173
 
177
- @recent_stderr_mutex.synchronize do
178
- @recent_stderr << line_str
179
- @recent_stderr.shift if @recent_stderr.size > 20
180
- end
174
+ record_bounded_stderr(line_str)
181
175
  end
182
176
  end
183
177
 
@@ -282,7 +276,6 @@ module ClaudeAgentSDK
282
276
  def write(data)
283
277
  raise CLIConnectionError, 'ProcessTransport is not ready for writing' unless @ready && @stdin
284
278
  raise CLIConnectionError, "Cannot write to terminated process" if @process && !@process.alive?
285
-
286
279
  raise CLIConnectionError, "Cannot write to process that exited with error: #{@exit_error}" if @exit_error
287
280
 
288
281
  begin
@@ -395,5 +388,17 @@ module ClaudeAgentSDK
395
388
  def ready?
396
389
  @ready
397
390
  end
391
+
392
+ private
393
+
394
+ # Append a stderr line to the recent-stderr ring, dropping the oldest
395
+ # entry once the buffer exceeds RECENT_STDERR_LINES_LIMIT. Used to surface the
396
+ # last few lines in ProcessError when the CLI exits non-zero.
397
+ def record_bounded_stderr(line)
398
+ @recent_stderr_mutex.synchronize do
399
+ @recent_stderr << line
400
+ @recent_stderr.shift if @recent_stderr.size > RECENT_STDERR_LINES_LIMIT
401
+ end
402
+ end
398
403
  end
399
404
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClaudeAgentSDK
4
- VERSION = '0.16.2'
4
+ VERSION = '0.16.3'
5
5
  end
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.2
4
+ version: 0.16.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Community Contributors