claude-agent-sdk 0.10.0 → 0.11.0

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: '03965bed10e6220b6f00d32ad789aa5c743c7c74f5625f046bd58c0137f1ccae'
4
- data.tar.gz: c1460d6d10d52ddb5e0ece51e3b5eab2c6d5962d8a7ead7a07661e1ee63aaf99
3
+ metadata.gz: ca3c257ced832f2e2120e7600aa346ef7e8487567309ac1ff579e8672743819e
4
+ data.tar.gz: f3598c2b3abe03b67042b5f04b5a0fd4b6cc12f80ba73d36bb9708e6b080d94e
5
5
  SHA512:
6
- metadata.gz: 52e72c3cf52957c54965300787f213add70236025b7fd5de309aabba4fcb9243e1ff973141f4c0ae85aefddf3b182ac49a737a2696bd5f57893ca031af70999d
7
- data.tar.gz: 3472c21997df7a77cf96eafd6f08671f77574321b23cbb8128d81364b2c523b64617c624c63f70a7a64f0bd6e1d3de807430bfd570e12ba989dda80163704417
6
+ metadata.gz: d88cfa73d92aa49aaf83d94ad51ba6f0e65761c51b7f4703477e606765a4cee06f65725cf295f30e8605c694cafc40f389f96e131f0db668db145ec31409da02
7
+ data.tar.gz: fa86ac725b72ee1896525cccaebc119b0d1c8138c931e375e95e8549275ff0b89426cc9dbaa2f352ff389e9b7614d4cb7164a1c290ed92c0b03634246f17db4b
data/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.11.0] - 2026-03-20
9
+
10
+ ### Added
11
+
12
+ #### Custom Transport Support
13
+ - `Client.new` accepts `transport_class:` and `transport_args:` keyword arguments, allowing consumers to plug in custom transports (e.g., E2B sandbox, remote SSH) without duplicating `Client#connect` internals
14
+ - Default remains `SubprocessCLITransport` — zero behavior change for existing callers
15
+ - Custom transport class must implement the `Transport` interface (`connect`, `write`, `read_messages`, `end_input`, `close`, `ready?`)
16
+ - `transport_args` are passed as keyword arguments to `transport_class.new(options, **transport_args)`
17
+ - All option transformations, MCP extraction, hook conversion, and Query lifecycle stay in `Client#connect` — the transport only handles I/O
18
+
8
19
  ## [0.10.0] - 2026-03-20
9
20
 
10
21
  Port of Python SDK v0.1.48 features for feature parity.
data/README.md CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  [![Gem Version](https://badge.fury.io/rb/claude-agent-sdk.svg?icon=si%3Arubygems)](https://badge.fury.io/rb/claude-agent-sdk)
8
8
 
9
- ### Feature Parity with Python SDK (v0.1.48)
9
+ ### Feature Parity with Python SDK (v0.1.48) + Ruby Extras
10
10
 
11
11
  | Feature | Python | Ruby |
12
12
  |---------|:------:|:----:|
@@ -34,6 +34,7 @@
34
34
  | `usage` on `AssistantMessage` | ✅ | ✅ |
35
35
  | Fallback model | ✅ | ✅ |
36
36
  | Plugin support | ✅ | ✅ |
37
+ | Custom transport (pluggable I/O layer) | — | ✅ |
37
38
  | Rails integration (configure block, ActionCable) | — | ✅ |
38
39
  | Bundled CLI binary | ✅ | — |
39
40
 
@@ -127,6 +128,7 @@ Both SDKs spawn `claude` CLI as a subprocess with stream-JSON over stdin/stdout.
127
128
  - [Quick Start](#quick-start)
128
129
  - [Basic Usage: query()](#basic-usage-query)
129
130
  - [Client](#client)
131
+ - [Custom Transport](#custom-transport)
130
132
  - [Custom Tools (SDK MCP Servers)](#custom-tools-sdk-mcp-servers)
131
133
  - [Hooks](#hooks)
132
134
  - [Permission Callbacks](#permission-callbacks)
@@ -156,7 +158,7 @@ Add this line to your application's Gemfile:
156
158
  gem 'claude-agent-sdk', github: 'ya-luotao/claude-agent-sdk-ruby'
157
159
 
158
160
  # Or use a stable version from RubyGems
159
- gem 'claude-agent-sdk', '~> 0.10.0'
161
+ gem 'claude-agent-sdk', '~> 0.11.0'
160
162
  ```
161
163
 
162
164
  And then execute:
@@ -358,6 +360,59 @@ Async do
358
360
  end.wait
359
361
  ```
360
362
 
363
+ ### Custom Transport
364
+
365
+ By default, `Client` uses `SubprocessCLITransport` to spawn the Claude Code CLI locally. You can provide a custom transport class to connect via other channels (e.g., E2B sandbox, remote SSH, WebSocket):
366
+
367
+ ```ruby
368
+ # Custom transport must implement the Transport interface:
369
+ # connect, write, read_messages, end_input, close, ready?
370
+ class E2BSandboxTransport < ClaudeAgentSDK::Transport
371
+ def initialize(options, sandbox:)
372
+ @options = options
373
+ @sandbox = sandbox
374
+ end
375
+
376
+ def connect
377
+ @sandbox.connect
378
+ end
379
+
380
+ def write(data)
381
+ @sandbox.stdin_write(data)
382
+ end
383
+
384
+ def read_messages(&block)
385
+ @sandbox.stdout_read_lines { |line| yield JSON.parse(line, symbolize_names: true) }
386
+ end
387
+
388
+ def end_input
389
+ @sandbox.close_stdin
390
+ end
391
+
392
+ def close
393
+ @sandbox.disconnect
394
+ end
395
+
396
+ def ready?
397
+ @sandbox.connected?
398
+ end
399
+ end
400
+
401
+ # Use it with Client — all connect orchestration (option transforms,
402
+ # MCP extraction, hook conversion, Query lifecycle) is handled for you
403
+ Async do
404
+ client = ClaudeAgentSDK::Client.new(
405
+ options: options,
406
+ transport_class: E2BSandboxTransport,
407
+ transport_args: { sandbox: my_sandbox }
408
+ )
409
+ client.connect
410
+ client.query("Hello from the sandbox!")
411
+ client.receive_response { |msg| puts msg }
412
+ client.disconnect
413
+ end.wait
414
+ ```
415
+
361
416
  ## Custom Tools (SDK MCP Servers)
362
417
 
363
418
  A **custom tool** is a Ruby proc/lambda that you can offer to Claude, for Claude to invoke as needed.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClaudeAgentSDK
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.0'
5
5
  end
@@ -239,8 +239,14 @@ module ClaudeAgentSDK
239
239
  class Client
240
240
  attr_reader :query_handler
241
241
 
242
- def initialize(options: nil)
242
+ # @param options [ClaudeAgentOptions, nil] Configuration options
243
+ # @param transport_class [Class] Transport class to use (must implement Transport interface).
244
+ # Defaults to SubprocessCLITransport.
245
+ # @param transport_args [Hash] Additional keyword arguments passed to transport_class.new(options, **transport_args)
246
+ def initialize(options: nil, transport_class: SubprocessCLITransport, transport_args: {})
243
247
  @options = options || ClaudeAgentOptions.new
248
+ @transport_class = transport_class
249
+ @transport_args = transport_args
244
250
  @transport = nil
245
251
  @query_handler = nil
246
252
  @connected = false
@@ -274,7 +280,7 @@ module ClaudeAgentSDK
274
280
  )
275
281
 
276
282
  # Client always uses streaming mode; keep stdin open for bidirectional communication.
277
- @transport = SubprocessCLITransport.new(configured_options)
283
+ @transport = @transport_class.new(configured_options, **@transport_args)
278
284
  @transport.connect
279
285
 
280
286
  # Extract SDK MCP servers
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.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Community Contributors