claude-agent-sdk 0.6.0 → 0.6.1

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: 8934de13efa22ba9e3e679393dfb3ef39e8eed194a9db4af8ef5981c8fa66570
4
- data.tar.gz: 79bfbe222fb677a49be4249e00bdc5148a43e9e0a9bac8e9e4e7fa7d3a34abd7
3
+ metadata.gz: 74a467e8e7f814ad55325db2de60cee2bd1f7a8bd849945b28302cf7776db2b9
4
+ data.tar.gz: b0c9dc121f7500f314ebe03ba77db2e16a112c60222a7e7d50ca68897d36af41
5
5
  SHA512:
6
- metadata.gz: c3c722b1a6ab8ff9ca7484a7b6fd59c1d60660d6fb1e111864c2afe81852bb913c5cc9bf241eb7ad635686b9d1dd8cc6ff849f2a2b6acf2eec3546c09e0e7de2
7
- data.tar.gz: 2ae9442e915901908b5c48496a348479685273701182a18ace8a20402b1e15c8630b38fd82f2ea480bf97af4e5c25c697711f5ffcc768bf15868081b9b5f24e4
6
+ metadata.gz: 5c6b145098e0e8489838f4d9b6e1a3f0af50a18e20a15055497fca65c1922e6f0e556bfb1e1844720989b81811eaf50d1605392d4d6bbf500fe367cbd744c172
7
+ data.tar.gz: 7ca8630977ebe60f00d8592c993d80eab1cc9754a1190dbd579b239a6f8ee105c48bbf3e5fe3b1aaa3da26c6ea62f369ee00d040d48eab002253f27aecee26a5
data/README.md CHANGED
@@ -996,15 +996,18 @@ end
996
996
  # Base exception class for all SDK errors
997
997
  class ClaudeSDKError < StandardError; end
998
998
 
999
+ # Raised when connection to Claude Code fails
1000
+ class CLIConnectionError < ClaudeSDKError; end
1001
+
1002
+ # Raised when the control protocol does not respond in time
1003
+ class ControlRequestTimeoutError < CLIConnectionError; end
1004
+
999
1005
  # Raised when Claude Code CLI is not found
1000
1006
  class CLINotFoundError < CLIConnectionError
1001
1007
  # @param message [String] Error message (default: "Claude Code not found")
1002
1008
  # @param cli_path [String, nil] Optional path to the CLI that was not found
1003
1009
  end
1004
1010
 
1005
- # Raised when connection to Claude Code fails
1006
- class CLIConnectionError < ClaudeSDKError; end
1007
-
1008
1011
  # Raised when the Claude Code process fails
1009
1012
  class ProcessError < ClaudeSDKError
1010
1013
  attr_reader :exit_code, # Integer | nil
@@ -1027,6 +1030,7 @@ end
1027
1030
 
1028
1031
  | Type | Description |
1029
1032
  |------|-------------|
1033
+ | `Configuration` | Global defaults via `ClaudeAgentSDK.configure` block |
1030
1034
  | `ClaudeAgentOptions` | Main configuration for queries and clients |
1031
1035
  | `HookMatcher` | Hook configuration with matcher pattern and timeout |
1032
1036
  | `PermissionResultAllow` | Permission callback result to allow tool use |
@@ -1088,6 +1092,8 @@ begin
1088
1092
  ClaudeAgentSDK.query(prompt: "Hello") do |message|
1089
1093
  puts message
1090
1094
  end
1095
+ rescue ClaudeAgentSDK::ControlRequestTimeoutError
1096
+ puts "Control protocol timed out — consider increasing the timeout"
1091
1097
  rescue ClaudeAgentSDK::CLINotFoundError
1092
1098
  puts "Please install Claude Code"
1093
1099
  rescue ClaudeAgentSDK::ProcessError => e
@@ -1097,13 +1103,23 @@ rescue ClaudeAgentSDK::CLIJSONDecodeError => e
1097
1103
  end
1098
1104
  ```
1099
1105
 
1106
+ #### Configuring Timeout
1107
+
1108
+ The control request timeout defaults to **1200 seconds** (20 minutes) to accommodate long-running agent sessions. Override it via environment variable:
1109
+
1110
+ ```bash
1111
+ # Set a custom timeout (in seconds)
1112
+ export CLAUDE_AGENT_SDK_CONTROL_REQUEST_TIMEOUT_SECONDS=300 # 5 minutes
1113
+ ```
1114
+
1100
1115
  ### Error Types
1101
1116
 
1102
1117
  | Error | Description |
1103
1118
  |-------|-------------|
1104
1119
  | `ClaudeSDKError` | Base error for all SDK errors |
1105
- | `CLINotFoundError` | Claude Code not installed |
1106
1120
  | `CLIConnectionError` | Connection issues |
1121
+ | `ControlRequestTimeoutError` | Control protocol timeout (configurable via env var) |
1122
+ | `CLINotFoundError` | Claude Code not installed |
1107
1123
  | `ProcessError` | Process failed (includes `exit_code` and `stderr`) |
1108
1124
  | `CLIJSONDecodeError` | JSON parsing issues |
1109
1125
  | `MessageParseError` | Message parsing issues |
@@ -262,7 +262,9 @@ module ClaudeAgentSDK
262
262
  # Build environment
263
263
  # Convert symbol keys to strings for spawn compatibility
264
264
  custom_env = @options.env.transform_keys { |k| k.to_s }
265
- process_env = ENV.to_h.merge('CLAUDE_AGENT_SDK_VERSION' => VERSION).merge(custom_env)
265
+ # Strip CLAUDECODE to prevent "nested session" detection when the SDK
266
+ # launches Claude Code from within an existing Claude Code terminal
267
+ process_env = ENV.to_h.except('CLAUDECODE').merge('CLAUDE_AGENT_SDK_VERSION' => VERSION).merge(custom_env)
266
268
  process_env['CLAUDE_CODE_ENTRYPOINT'] ||= 'sdk-rb'
267
269
  process_env['PWD'] = @cwd.to_s if @cwd
268
270
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ClaudeAgentSDK
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claude-agent-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Community Contributors
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-02-12 00:00:00.000000000 Z
10
+ date: 2026-02-15 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: async