claude_agent 0.7.16 → 0.7.17
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/SPEC.md +34 -16
- data/lib/claude_agent/control_protocol/request_handling.rb +2 -0
- data/lib/claude_agent/message_parser.rb +13 -0
- data/lib/claude_agent/messages/system.rb +27 -0
- data/lib/claude_agent/messages.rb +1 -0
- data/lib/claude_agent/permissions.rb +6 -0
- data/lib/claude_agent/sandbox_settings.rb +8 -4
- data/lib/claude_agent/version.rb +1 -1
- data/sig/claude_agent.rbs +21 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 799129d416a271a9271c718286c10671db76af9c47d79e5c8c01c48601a64f5b
|
|
4
|
+
data.tar.gz: 9697cc7268eefc734e3d89bf1e03ccabfc97f7bfa827500bd04332990cfb168b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1eb51e6dfad24b7b904e128b226e45aa1f30354343f44b1ffe99a4b3d211bb8359b58b54c8ad362288b563803cb3393d2a836add9d2831e37e94442b70e72a7e
|
|
7
|
+
data.tar.gz: 83a8fa50917c82011b54192d0d2d69d7473b4868d343fe569ceda3149de79e69c590511c188660eefbbd1658071af6b08c40221ebe80e741d23bb2c5b6a52469
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.7.17] - 2026-03-17
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `APIRetryMessage` system message type with `attempt`, `max_retries`, `retry_delay_ms`, `error_status`, and `error` fields (TypeScript SDK v0.2.77 parity)
|
|
14
|
+
- `title` and `display_name` fields on `ToolPermissionContext` for richer permission prompt context (TypeScript SDK v0.2.77 parity)
|
|
15
|
+
- `allow_read` and `allow_managed_read_paths_only` fields on `SandboxFilesystemConfig` for re-allowing reads within deny regions (TypeScript SDK v0.2.77 parity)
|
|
16
|
+
|
|
10
17
|
## [0.7.16] - 2026-03-15
|
|
11
18
|
|
|
12
19
|
## [0.7.15] - 2026-03-15
|
data/SPEC.md
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
This document provides a comprehensive specification of the Claude Agent SDK, comparing feature parity across the official TypeScript and Python SDKs with this Ruby implementation.
|
|
4
4
|
|
|
5
5
|
**Reference Versions:**
|
|
6
|
-
- TypeScript SDK: v0.2.
|
|
7
|
-
- Python SDK: from GitHub (commit
|
|
6
|
+
- TypeScript SDK: v0.2.77 (npm package)
|
|
7
|
+
- Python SDK: from GitHub (commit 971994c)
|
|
8
8
|
- Ruby SDK: This repository
|
|
9
9
|
|
|
10
|
-
**Last Updated:** 2026-03-
|
|
10
|
+
**Last Updated:** 2026-03-17
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
@@ -116,9 +116,20 @@ Messages exchanged between SDK and CLI.
|
|
|
116
116
|
| `FilesPersistedEvent` | ✅ | ❌ | ✅ | File persistence confirmation |
|
|
117
117
|
| `ElicitationCompleteMessage` | ✅ | ❌ | ✅ | MCP elicitation completed |
|
|
118
118
|
| `LocalCommandOutputMessage` | ✅ | ❌ | ✅ | Local command output |
|
|
119
|
+
| `APIRetryMessage` | ✅ | ❌ | ✅ | API retry notification (v0.2.77) |
|
|
119
120
|
|
|
120
121
|
### Message Fields
|
|
121
122
|
|
|
123
|
+
#### APIRetryMessage
|
|
124
|
+
|
|
125
|
+
| Field | TypeScript | Python | Ruby | Notes |
|
|
126
|
+
|-------------------|:----------:|:------:|:----:|------------------------------------------|
|
|
127
|
+
| `attempt` | ✅ | ❌ | ✅ | Current retry attempt number |
|
|
128
|
+
| `max_retries` | ✅ | ❌ | ✅ | Maximum retry count |
|
|
129
|
+
| `retry_delay_ms` | ✅ | ❌ | ✅ | Delay before retry in milliseconds |
|
|
130
|
+
| `error_status` | ✅ | ❌ | ✅ | HTTP status code (null for conn errors) |
|
|
131
|
+
| `error` | ✅ | ❌ | ✅ | Error type (AssistantMessageError) |
|
|
132
|
+
|
|
122
133
|
#### ResultMessage
|
|
123
134
|
|
|
124
135
|
| Field | TypeScript | Python | Ruby | Notes |
|
|
@@ -666,6 +677,8 @@ Permission handling and updates.
|
|
|
666
677
|
| `toolUseID` | ✅ | ❌ | ✅ | Tool call ID |
|
|
667
678
|
| `agentID` | ✅ | ❌ | ✅ | Subagent ID if applicable |
|
|
668
679
|
| `description` | ✅ | ❌ | ✅ | Human-readable tool description (v0.2.75) |
|
|
680
|
+
| `title` | ✅ | ❌ | ✅ | Full permission prompt sentence (v0.2.77) |
|
|
681
|
+
| `displayName` | ✅ | ❌ | ✅ | Short noun phrase for tool action (v0.2.77) |
|
|
669
682
|
|
|
670
683
|
---
|
|
671
684
|
|
|
@@ -799,15 +812,15 @@ Session management and resumption.
|
|
|
799
812
|
|
|
800
813
|
| Field | TypeScript | Python | Ruby | Notes |
|
|
801
814
|
|------------------|:----------:|:------:|:----:|------------------------------------------------|
|
|
802
|
-
| `dir` | ✅ | ❌ |
|
|
803
|
-
| `upToMessageId` | ✅ | ❌ |
|
|
804
|
-
| `title` | ✅ | ❌ |
|
|
815
|
+
| `dir` | ✅ | ❌ | ✅ | Project directory |
|
|
816
|
+
| `upToMessageId` | ✅ | ❌ | ✅ | Slice transcript up to this UUID (inclusive) |
|
|
817
|
+
| `title` | ✅ | ❌ | ✅ | Custom title for the fork |
|
|
805
818
|
|
|
806
819
|
#### ForkSessionResult
|
|
807
820
|
|
|
808
821
|
| Field | TypeScript | Python | Ruby | Notes |
|
|
809
822
|
|-------------|:----------:|:------:|:----:|--------------------------------|
|
|
810
|
-
| `sessionId` | ✅ | ❌ |
|
|
823
|
+
| `sessionId` | ✅ | ❌ | ✅ | New forked session UUID |
|
|
811
824
|
|
|
812
825
|
### V2 Session API (Unstable)
|
|
813
826
|
|
|
@@ -833,9 +846,10 @@ Custom subagent definitions.
|
|
|
833
846
|
| `tools` | ✅ | ✅ | ✅ | Allowed tools |
|
|
834
847
|
| `disallowedTools` | ✅ | ❌ | ✅ | Blocked tools |
|
|
835
848
|
| `model` | ✅ | ✅ | ✅ | Model override (sonnet/opus/haiku/inherit) |
|
|
836
|
-
| `mcpServers` | ✅ |
|
|
849
|
+
| `mcpServers` | ✅ | ✅ | ✅ | Agent-specific MCP servers |
|
|
837
850
|
| `criticalSystemReminder_EXPERIMENTAL` | ✅ | ❌ | ✅ | Critical reminder (experimental) |
|
|
838
|
-
| `skills` | ✅ |
|
|
851
|
+
| `skills` | ✅ | ✅ | ✅ | Skills to preload into agent context |
|
|
852
|
+
| `memory` | ❌ | ✅ | ❌ | Memory scope for agent (Python-only) |
|
|
839
853
|
| `maxTurns` | ✅ | ❌ | ✅ | Max agentic turns before stopping |
|
|
840
854
|
|
|
841
855
|
---
|
|
@@ -861,11 +875,13 @@ Sandbox configuration for command execution isolation.
|
|
|
861
875
|
|
|
862
876
|
### SandboxFilesystemConfig
|
|
863
877
|
|
|
864
|
-
| Field
|
|
865
|
-
|
|
866
|
-
| `allowWrite`
|
|
867
|
-
| `denyWrite`
|
|
868
|
-
| `denyRead`
|
|
878
|
+
| Field | TypeScript | Python | Ruby |
|
|
879
|
+
|-----------------------------|:----------:|:------:|:----:|
|
|
880
|
+
| `allowWrite` | ✅ | ❌ | ✅ |
|
|
881
|
+
| `denyWrite` | ✅ | ❌ | ✅ |
|
|
882
|
+
| `denyRead` | ✅ | ❌ | ✅ |
|
|
883
|
+
| `allowRead` | ✅ | ❌ | ✅ |
|
|
884
|
+
| `allowManagedReadPathsOnly` | ✅ | ❌ | ✅ |
|
|
869
885
|
|
|
870
886
|
### SandboxNetworkConfig
|
|
871
887
|
|
|
@@ -1017,6 +1033,7 @@ Public API surface for SDK clients.
|
|
|
1017
1033
|
- v0.2.74: Added `renameSession()` for renaming session files
|
|
1018
1034
|
- v0.2.75: Added `tag`/`createdAt` fields on `SDKSessionInfo`; `getSessionInfo()` for single-session lookup; `offset` on `listSessions` for pagination; `tagSession()` for tagging sessions; `supportsAutoMode` in `ModelInfo`; `description` on `SDKControlPermissionRequest`; `prompt` on `SDKTaskStartedMessage`; `fast_mode_state` on `SDKControlInitializeResponse`; `queued_to_running` status on `AgentToolOutput`
|
|
1019
1035
|
- v0.2.76: Added `forkSession(sessionId, opts?)` for branching conversations from a point; `cancel_async_message` control subtype to drop queued user messages; `PostCompact` hook event with `compact_summary` field; `get_settings` control request for reading effective merged settings; `planFilePath` field on `ExitPlanMode` tool input
|
|
1036
|
+
- v0.2.77: Added `SDKAPIRetryMessage` (system subtype `api_retry`) exposing attempt count, max retries, delay, and error status for transient API error retries; added `title` and `displayName` fields on `SDKControlPermissionRequest`/`CanUseTool` options; added `allowRead` and `allowManagedReadPathsOnly` on `SandboxFilesystemConfig`
|
|
1020
1037
|
- Includes `Elicitation`/`ElicitationResult` hook events, `onElicitation` option, `ElicitationCompleteMessage`, `LocalCommandOutputMessage`, `FastModeState` (undocumented in changelog, present in types)
|
|
1021
1038
|
|
|
1022
1039
|
### Python SDK
|
|
@@ -1045,10 +1062,11 @@ Public API surface for SDK clients.
|
|
|
1045
1062
|
- v0.1.48: Fixed fine-grained tool streaming regression
|
|
1046
1063
|
- Added `RateLimitEvent` message type with `RateLimitInfo`
|
|
1047
1064
|
- Added `rename_session()` and `tag_session()` session management functions
|
|
1048
|
-
-
|
|
1065
|
+
- `AgentDefinition` now has `skills`, `mcpServers`, and `memory` (Python-only) fields
|
|
1066
|
+
- Missing: `onElicitation`, `Elicitation`/`ElicitationResult` hooks, `ElicitationCompleteMessage`, `LocalCommandOutputMessage`, `FastModeState`, `InstructionsLoaded` hook, `agentProgressSummaries`, `getSessionInfo()`, `forkSession()`, `PostCompact` hook, `cancel_async_message`, `get_settings`, `APIRetryMessage`
|
|
1049
1067
|
|
|
1050
1068
|
### Ruby SDK (This Repository)
|
|
1051
|
-
- Feature parity with TypeScript SDK v0.2.
|
|
1069
|
+
- Feature parity with TypeScript SDK v0.2.77
|
|
1052
1070
|
- Ruby-idiomatic patterns (Data.define, snake_case)
|
|
1053
1071
|
- Complete control protocol, hook, and V2 Session API support
|
|
1054
1072
|
- Dedicated Client class for multi-turn conversations
|
|
@@ -86,6 +86,7 @@ module ClaudeAgent
|
|
|
86
86
|
register "system:task_progress", :parse_task_progress_message
|
|
87
87
|
register "system:elicitation_complete", :parse_elicitation_complete_message
|
|
88
88
|
register "system:local_command_output", :parse_local_command_output_message
|
|
89
|
+
register "system:api_retry", :parse_api_retry_message
|
|
89
90
|
|
|
90
91
|
private
|
|
91
92
|
|
|
@@ -421,5 +422,17 @@ module ClaudeAgent
|
|
|
421
422
|
suggestion: raw[:suggestion] || ""
|
|
422
423
|
)
|
|
423
424
|
end
|
|
425
|
+
|
|
426
|
+
def parse_api_retry_message(raw)
|
|
427
|
+
APIRetryMessage.new(
|
|
428
|
+
uuid: raw[:uuid] || "",
|
|
429
|
+
session_id: raw[:session_id] || "",
|
|
430
|
+
attempt: raw[:attempt] || 0,
|
|
431
|
+
max_retries: raw[:max_retries] || 0,
|
|
432
|
+
retry_delay_ms: raw[:retry_delay_ms] || 0,
|
|
433
|
+
error_status: raw[:error_status],
|
|
434
|
+
error: raw[:error]
|
|
435
|
+
)
|
|
436
|
+
end
|
|
424
437
|
end
|
|
425
438
|
end
|
|
@@ -55,6 +55,33 @@ module ClaudeAgent
|
|
|
55
55
|
# status: "compacting"
|
|
56
56
|
# )
|
|
57
57
|
#
|
|
58
|
+
# API retry message (TypeScript SDK v0.2.77 parity)
|
|
59
|
+
#
|
|
60
|
+
# Emitted when an API request fails with a retryable error and will be
|
|
61
|
+
# retried after a delay. Exposes attempt count, max retries, delay, and
|
|
62
|
+
# error status for observability.
|
|
63
|
+
#
|
|
64
|
+
# @example
|
|
65
|
+
# msg = APIRetryMessage.new(
|
|
66
|
+
# uuid: "msg-123",
|
|
67
|
+
# session_id: "session-abc",
|
|
68
|
+
# attempt: 1,
|
|
69
|
+
# max_retries: 3,
|
|
70
|
+
# retry_delay_ms: 5000,
|
|
71
|
+
# error_status: 529,
|
|
72
|
+
# error: "rate_limit"
|
|
73
|
+
# )
|
|
74
|
+
#
|
|
75
|
+
APIRetryMessage = Data.define(:uuid, :session_id, :attempt, :max_retries, :retry_delay_ms, :error_status, :error) do
|
|
76
|
+
def initialize(uuid: "", session_id: "", attempt: 0, max_retries: 0, retry_delay_ms: 0, error_status: nil, error: nil)
|
|
77
|
+
super
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def type
|
|
81
|
+
:api_retry
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
58
85
|
StatusMessage = Data.define(:uuid, :session_id, :status, :permission_mode) do
|
|
59
86
|
def initialize(uuid:, session_id:, status:, permission_mode: nil)
|
|
60
87
|
super
|
|
@@ -147,6 +147,8 @@ module ClaudeAgent
|
|
|
147
147
|
# decision_reason: "Path outside allowed directories",
|
|
148
148
|
# tool_use_id: "tool_123",
|
|
149
149
|
# agent_id: "agent_456",
|
|
150
|
+
# title: "Claude wants to read /etc/passwd",
|
|
151
|
+
# display_name: "Read file",
|
|
150
152
|
# signal: abort_signal
|
|
151
153
|
# )
|
|
152
154
|
#
|
|
@@ -158,6 +160,8 @@ module ClaudeAgent
|
|
|
158
160
|
:agent_id,
|
|
159
161
|
:signal,
|
|
160
162
|
:description,
|
|
163
|
+
:title,
|
|
164
|
+
:display_name,
|
|
161
165
|
:request
|
|
162
166
|
) do
|
|
163
167
|
def initialize(
|
|
@@ -168,6 +172,8 @@ module ClaudeAgent
|
|
|
168
172
|
agent_id: nil,
|
|
169
173
|
signal: nil,
|
|
170
174
|
description: nil,
|
|
175
|
+
title: nil,
|
|
176
|
+
display_name: nil,
|
|
171
177
|
request: nil
|
|
172
178
|
)
|
|
173
179
|
super
|
|
@@ -85,17 +85,19 @@ module ClaudeAgent
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
-
# Filesystem-specific configuration for sandbox mode (TypeScript SDK v0.2.
|
|
88
|
+
# Filesystem-specific configuration for sandbox mode (TypeScript SDK v0.2.77 parity)
|
|
89
89
|
#
|
|
90
90
|
# @example
|
|
91
91
|
# filesystem = SandboxFilesystemConfig.new(
|
|
92
92
|
# allow_write: ["/tmp/*"],
|
|
93
93
|
# deny_write: ["/etc/*"],
|
|
94
|
-
# deny_read: ["/secrets/*"]
|
|
94
|
+
# deny_read: ["/secrets/*"],
|
|
95
|
+
# allow_read: ["/secrets/public/*"],
|
|
96
|
+
# allow_managed_read_paths_only: false
|
|
95
97
|
# )
|
|
96
98
|
#
|
|
97
|
-
SandboxFilesystemConfig = Data.define(:allow_write, :deny_write, :deny_read) do
|
|
98
|
-
def initialize(allow_write: [], deny_write: [], deny_read: [])
|
|
99
|
+
SandboxFilesystemConfig = Data.define(:allow_write, :deny_write, :deny_read, :allow_read, :allow_managed_read_paths_only) do
|
|
100
|
+
def initialize(allow_write: [], deny_write: [], deny_read: [], allow_read: [], allow_managed_read_paths_only: false)
|
|
99
101
|
super
|
|
100
102
|
end
|
|
101
103
|
|
|
@@ -104,6 +106,8 @@ module ClaudeAgent
|
|
|
104
106
|
result[:allowWrite] = allow_write unless allow_write.empty?
|
|
105
107
|
result[:denyWrite] = deny_write unless deny_write.empty?
|
|
106
108
|
result[:denyRead] = deny_read unless deny_read.empty?
|
|
109
|
+
result[:allowRead] = allow_read unless allow_read.empty?
|
|
110
|
+
result[:allowManagedReadPathsOnly] = allow_managed_read_paths_only if allow_managed_read_paths_only
|
|
107
111
|
result
|
|
108
112
|
end
|
|
109
113
|
end
|
data/lib/claude_agent/version.rb
CHANGED
data/sig/claude_agent.rbs
CHANGED
|
@@ -314,8 +314,10 @@ module ClaudeAgent
|
|
|
314
314
|
attr_reader allow_write: Array[String]
|
|
315
315
|
attr_reader deny_write: Array[String]
|
|
316
316
|
attr_reader deny_read: Array[String]
|
|
317
|
+
attr_reader allow_read: Array[String]
|
|
318
|
+
attr_reader allow_managed_read_paths_only: bool
|
|
317
319
|
|
|
318
|
-
def initialize: (?allow_write: Array[String], ?deny_write: Array[String], ?deny_read: Array[String]) -> void
|
|
320
|
+
def initialize: (?allow_write: Array[String], ?deny_write: Array[String], ?deny_read: Array[String], ?allow_read: Array[String], ?allow_managed_read_paths_only: bool) -> void
|
|
319
321
|
def to_h: () -> Hash[Symbol, untyped]
|
|
320
322
|
end
|
|
321
323
|
|
|
@@ -573,6 +575,20 @@ module ClaudeAgent
|
|
|
573
575
|
def type: () -> :local_command_output
|
|
574
576
|
end
|
|
575
577
|
|
|
578
|
+
# API retry message (TypeScript SDK v0.2.77 parity)
|
|
579
|
+
class APIRetryMessage
|
|
580
|
+
attr_reader uuid: String
|
|
581
|
+
attr_reader session_id: String
|
|
582
|
+
attr_reader attempt: Integer
|
|
583
|
+
attr_reader max_retries: Integer
|
|
584
|
+
attr_reader retry_delay_ms: Integer
|
|
585
|
+
attr_reader error_status: Integer?
|
|
586
|
+
attr_reader error: String?
|
|
587
|
+
|
|
588
|
+
def initialize: (?uuid: String, ?session_id: String, ?attempt: Integer, ?max_retries: Integer, ?retry_delay_ms: Integer, ?error_status: Integer?, ?error: String?) -> void
|
|
589
|
+
def type: () -> :api_retry
|
|
590
|
+
end
|
|
591
|
+
|
|
576
592
|
class GenericMessage
|
|
577
593
|
attr_reader message_type: String?
|
|
578
594
|
attr_reader raw: Hash[Symbol, untyped]
|
|
@@ -584,7 +600,7 @@ module ClaudeAgent
|
|
|
584
600
|
end
|
|
585
601
|
|
|
586
602
|
# Message types
|
|
587
|
-
type message = UserMessage | UserMessageReplay | AssistantMessage | SystemMessage | ResultMessage | StreamEvent | CompactBoundaryMessage | StatusMessage | ToolProgressMessage | HookResponseMessage | AuthStatusMessage | TaskNotificationMessage | HookStartedMessage | HookProgressMessage | ToolUseSummaryMessage | FilesPersistedEvent | TaskStartedMessage | TaskProgressMessage | RateLimitEvent | PromptSuggestionMessage | ElicitationCompleteMessage | LocalCommandOutputMessage | GenericMessage
|
|
603
|
+
type message = UserMessage | UserMessageReplay | AssistantMessage | SystemMessage | ResultMessage | StreamEvent | CompactBoundaryMessage | StatusMessage | ToolProgressMessage | HookResponseMessage | AuthStatusMessage | TaskNotificationMessage | HookStartedMessage | HookProgressMessage | ToolUseSummaryMessage | FilesPersistedEvent | TaskStartedMessage | TaskProgressMessage | RateLimitEvent | PromptSuggestionMessage | ElicitationCompleteMessage | LocalCommandOutputMessage | APIRetryMessage | GenericMessage
|
|
588
604
|
|
|
589
605
|
MESSAGE_TYPES: Array[Class]
|
|
590
606
|
|
|
@@ -1161,9 +1177,11 @@ module ClaudeAgent
|
|
|
1161
1177
|
attr_reader agent_id: String?
|
|
1162
1178
|
attr_reader signal: AbortSignal?
|
|
1163
1179
|
attr_reader description: String?
|
|
1180
|
+
attr_reader title: String?
|
|
1181
|
+
attr_reader display_name: String?
|
|
1164
1182
|
attr_reader request: PermissionRequest?
|
|
1165
1183
|
|
|
1166
|
-
def initialize: (?permission_suggestions: untyped, ?blocked_path: String?, ?decision_reason: String?, ?tool_use_id: String?, ?agent_id: String?, ?signal: AbortSignal?, ?description: String?, ?request: PermissionRequest?) -> void
|
|
1184
|
+
def initialize: (?permission_suggestions: untyped, ?blocked_path: String?, ?decision_reason: String?, ?tool_use_id: String?, ?agent_id: String?, ?signal: AbortSignal?, ?description: String?, ?title: String?, ?display_name: String?, ?request: PermissionRequest?) -> void
|
|
1167
1185
|
end
|
|
1168
1186
|
|
|
1169
1187
|
# Deferred permission request resolved from any thread
|