claude_agent 0.5.0 → 0.7.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 +4 -4
- data/.claude/skills/spec/SKILL.md +45 -0
- data/.claude/{commands/spec → skills/spec/commands}/complete.md +14 -41
- data/.claude/skills/spec/commands/update.md +48 -0
- data/CHANGELOG.md +20 -0
- data/CLAUDE.md +1 -30
- data/README.md +90 -1
- data/SPEC.md +67 -46
- data/lib/claude_agent/mcp/server.rb +2 -2
- data/lib/claude_agent/mcp/tool.rb +7 -3
- data/lib/claude_agent/message_parser.rb +13 -1
- data/lib/claude_agent/messages.rb +39 -1
- data/lib/claude_agent/version.rb +1 -1
- data/sig/claude_agent.rbs +16 -3
- metadata +4 -3
- data/.claude/commands/spec/update.md +0 -95
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 72db3aeea7a724d0271a3fc8bb0bd7900425a34e7114e526e9bfe8bbbe26e19f
|
|
4
|
+
data.tar.gz: a31e9321dc56507d0a05d8319e50fded02aaa420a9709a0970a298826ea2f4ad
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54d586a6a4e368adf4b64ec8afdbf4b04ad165473e81bcf8e0c244c7c04ac5c524b6c1186e34dd7bf6c31cc3b521da6d5526b187a30d147c3839ba5b708056ae
|
|
7
|
+
data.tar.gz: 4af34d4756c9559570ea9c8d0ed9819ae98827773eed4332d9cc7bc50c8b5edc6584c0ee25fbfa197c3bc79513acace10ee88ec3bf1674141afcfe213ead2f02
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spec
|
|
3
|
+
description: Manage the SDK feature parity specification. Use 'update' to regenerate SPEC.md from current implementations, or 'complete' to implement missing features.
|
|
4
|
+
argument-hint: [update|complete]
|
|
5
|
+
disable-model-invocation: true
|
|
6
|
+
allowed-tools: Bash, Read, Glob, Grep, Write, Edit, TodoWrite, Task, AskUserQuestion, EnterPlanMode
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# SDK Feature Parity Management
|
|
10
|
+
|
|
11
|
+
Manage the feature parity specification for the TypeScript, Python, and Ruby Claude Agent SDKs.
|
|
12
|
+
|
|
13
|
+
## Reference SDKs
|
|
14
|
+
|
|
15
|
+
Ensure reference SDKs are current before starting any workflow:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
bin/update-reference-sdks
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This clones/updates:
|
|
22
|
+
- Python SDK from GitHub -> `vendor/claude-agent-sdk-python`
|
|
23
|
+
- TypeScript SDK from npm -> `vendor/claude-agent-sdk-npm`
|
|
24
|
+
- TypeScript SDK repo from GitHub -> `vendor/claude-agent-sdk-typescript` (changelog/releases)
|
|
25
|
+
|
|
26
|
+
## Key Source Files
|
|
27
|
+
|
|
28
|
+
**TypeScript SDK (Primary Reference)**
|
|
29
|
+
- `vendor/claude-agent-sdk-npm/sdk.d.ts` - Complete API surface with all types
|
|
30
|
+
- `vendor/claude-agent-sdk-typescript/CHANGELOG.md` - Release changelog
|
|
31
|
+
|
|
32
|
+
**Python SDK**
|
|
33
|
+
- `vendor/claude-agent-sdk-python/src/claude_agent_sdk/types.py` - Type definitions
|
|
34
|
+
- `vendor/claude-agent-sdk-python/src/claude_agent_sdk/_internal/` - Internal implementation
|
|
35
|
+
|
|
36
|
+
**Ruby SDK (This Repository)**
|
|
37
|
+
- `lib/claude_agent/` - All implementation files
|
|
38
|
+
|
|
39
|
+
## Mode Selection
|
|
40
|
+
|
|
41
|
+
Based on the first argument:
|
|
42
|
+
|
|
43
|
+
- **update**: Follow the workflow in [commands/update.md](commands/update.md)
|
|
44
|
+
- **complete**: Follow the workflow in [commands/complete.md](commands/complete.md)
|
|
45
|
+
- If no argument or unrecognized: ask the user which mode they want
|
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Implement missing Ruby SDK features identified in SPEC.md to achieve full parity with TypeScript/Python SDKs
|
|
3
|
-
allowed-tools: Bash, Read, Glob, Grep, Write, Edit, TodoWrite, Task, AskUserQuestion, EnterPlanMode
|
|
4
|
-
---
|
|
5
|
-
|
|
6
1
|
# Complete SDK Feature Parity
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
Implement missing features in the Ruby SDK to achieve full parity with the official TypeScript and Python Claude Agent SDKs.
|
|
9
4
|
|
|
10
5
|
## Step 1: Identify Missing Features
|
|
11
6
|
|
|
12
|
-
Read SPEC.md and identify all features where the Ruby SDK
|
|
13
|
-
|
|
14
|
-
```
|
|
15
|
-
Read SPEC.md
|
|
16
|
-
```
|
|
7
|
+
Read SPEC.md and identify all features where the Ruby SDK is not implemented.
|
|
17
8
|
|
|
18
|
-
Create a prioritized list
|
|
9
|
+
Create a prioritized list:
|
|
19
10
|
1. **High Priority** - Features implemented in BOTH TypeScript and Python SDKs
|
|
20
11
|
2. **Medium Priority** - Features only in TypeScript SDK (Python also missing)
|
|
21
12
|
3. **Low Priority** - TypeScript-only features that may be JS-specific
|
|
@@ -24,31 +15,23 @@ Use TodoWrite to track the features to implement.
|
|
|
24
15
|
|
|
25
16
|
## Step 2: Research Each Feature
|
|
26
17
|
|
|
27
|
-
|
|
18
|
+
Gather complete context before planning:
|
|
28
19
|
|
|
29
20
|
### 2a. Official Documentation
|
|
30
21
|
|
|
31
|
-
Use the `claude-code-guide` agent to understand
|
|
22
|
+
Use the `claude-code-guide` agent to understand each feature's intended behavior:
|
|
32
23
|
|
|
33
24
|
```
|
|
34
25
|
Task(subagent_type: "claude-code-guide", prompt: "How does [feature] work in the Claude Agent SDK? What are all the options, behaviors, and edge cases?")
|
|
35
26
|
```
|
|
36
27
|
|
|
37
|
-
### 2b.
|
|
38
|
-
|
|
39
|
-
Read the TypeScript type definitions to understand the API surface:
|
|
40
|
-
- `vendor/claude-agent-sdk-npm/sdk.d.ts`
|
|
41
|
-
|
|
42
|
-
### 2c. Python Implementation (if available)
|
|
28
|
+
### 2b. Reference Implementations
|
|
43
29
|
|
|
44
|
-
If Python has the feature, read their implementation for patterns
|
|
45
|
-
- `vendor/claude-agent-sdk-python/src/claude_agent_sdk/types.py`
|
|
46
|
-
- `vendor/claude-agent-sdk-python/src/claude_agent_sdk/_internal/`
|
|
30
|
+
Read the TypeScript type definitions and changelog listed in SKILL.md to understand the API surface and when features were added. If Python has the feature, read their implementation for patterns.
|
|
47
31
|
|
|
48
32
|
## Step 3: Clarify Requirements
|
|
49
33
|
|
|
50
|
-
Use AskUserQuestion to resolve
|
|
51
|
-
|
|
34
|
+
Use AskUserQuestion to resolve ambiguities:
|
|
52
35
|
- Implementation approach choices
|
|
53
36
|
- Ruby-specific design decisions
|
|
54
37
|
- Whether certain features should be skipped (e.g., JS-specific)
|
|
@@ -56,15 +39,9 @@ Use AskUserQuestion to resolve any ambiguities:
|
|
|
56
39
|
|
|
57
40
|
## Step 4: Enter Plan Mode
|
|
58
41
|
|
|
59
|
-
Enter plan mode to design the implementation:
|
|
60
|
-
|
|
61
|
-
```
|
|
62
|
-
EnterPlanMode
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
The plan should include:
|
|
42
|
+
Enter plan mode to design the implementation. The plan should include:
|
|
66
43
|
- Which files to create or modify
|
|
67
|
-
- Data structures
|
|
44
|
+
- Data structures
|
|
68
45
|
- Public API design
|
|
69
46
|
- Test coverage requirements
|
|
70
47
|
- Any breaking changes or deprecations
|
|
@@ -80,26 +57,22 @@ After plan approval, implement each feature:
|
|
|
80
57
|
5. Update RBS type signatures in `sig/` directory
|
|
81
58
|
6. Write unit tests in `test/claude_agent/`
|
|
82
59
|
7. Write integration tests in `test/integration/` for features that interact with CLI/API
|
|
83
|
-
8. Update SPEC.md to mark feature as
|
|
60
|
+
8. Update SPEC.md to mark feature as complete
|
|
84
61
|
|
|
85
62
|
### Testing Requirements
|
|
86
63
|
|
|
87
64
|
- **Unit tests** - For all new types, data structures, and internal logic
|
|
88
|
-
- **Integration tests** - Required for anything that
|
|
89
|
-
- Spawns the CLI subprocess
|
|
90
|
-
- Sends/receives messages via the control protocol
|
|
91
|
-
- Interacts with MCP servers
|
|
92
|
-
- Uses file checkpointing or session management
|
|
65
|
+
- **Integration tests** - Required for anything that spawns the CLI subprocess, sends/receives messages via the control protocol, interacts with MCP servers, or uses file checkpointing/session management
|
|
93
66
|
|
|
94
67
|
## Step 6: Update Specification
|
|
95
68
|
|
|
96
|
-
After implementing features, run `/spec
|
|
69
|
+
After implementing features, run `/spec update` to refresh SPEC.md with the new implementation status.
|
|
97
70
|
|
|
98
71
|
## Output
|
|
99
72
|
|
|
100
73
|
Provide a summary of:
|
|
101
74
|
- Features implemented
|
|
102
|
-
-
|
|
75
|
+
- Features skipped (with reasons)
|
|
103
76
|
- Breaking changes introduced
|
|
104
77
|
- Test coverage added
|
|
105
78
|
- Remaining gaps (if any)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Update SDK Specification
|
|
2
|
+
|
|
3
|
+
Update SPEC.md to reflect the current feature parity between the TypeScript, Python, and Ruby Claude Agent SDKs.
|
|
4
|
+
|
|
5
|
+
## Step 1: Update Reference SDKs
|
|
6
|
+
|
|
7
|
+
Run `bin/update-reference-sdks` to ensure all reference SDKs are current.
|
|
8
|
+
|
|
9
|
+
## Step 2: Research Official Documentation
|
|
10
|
+
|
|
11
|
+
Use the `claude-code-guide` agent to check for new or updated SDK features:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
Task(subagent_type: "claude-code-guide", prompt: "What are all the features and options in the Claude Agent SDK? Include configuration options, hooks, permissions, MCP support, and control protocol methods.")
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
This helps catch features documented but not yet in SDK source files.
|
|
18
|
+
|
|
19
|
+
## Step 3: Analyze All Three SDKs
|
|
20
|
+
|
|
21
|
+
Read and compare the key source files listed in SKILL.md. Pay special attention to:
|
|
22
|
+
- TypeScript `sdk.d.ts` as the authoritative API surface
|
|
23
|
+
- TypeScript `CHANGELOG.md` for recently added features
|
|
24
|
+
- Python `types.py` for implementation patterns
|
|
25
|
+
- All Ruby SDK files for current implementation status
|
|
26
|
+
|
|
27
|
+
## Step 4: Update SPEC.md
|
|
28
|
+
|
|
29
|
+
1. **Reference Versions** - Update TypeScript SDK version and Python SDK commit
|
|
30
|
+
2. **Feature Tables** - Update all markers based on current implementations
|
|
31
|
+
3. **New Features** - Add any new features found in the TypeScript SDK
|
|
32
|
+
4. **Removed Features** - Remove any deprecated features
|
|
33
|
+
|
|
34
|
+
## Guidelines
|
|
35
|
+
|
|
36
|
+
- Check every field and option in each SDK
|
|
37
|
+
- TypeScript sdk.d.ts is the authoritative reference
|
|
38
|
+
- Preserve the existing table structure and markdown formatting
|
|
39
|
+
- Always update the reference version info at the top
|
|
40
|
+
- Note significant changes after updating
|
|
41
|
+
|
|
42
|
+
## Output
|
|
43
|
+
|
|
44
|
+
Provide a brief summary of:
|
|
45
|
+
- SDK versions checked
|
|
46
|
+
- New features added to the spec
|
|
47
|
+
- Features removed from the spec
|
|
48
|
+
- Notable gaps in the Ruby SDK
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.7.0] - 2026-01-31
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- MCP tool annotations support (`readOnlyHint`, `destructiveHint`, `idempotentHint`, `openWorldHint`, `title`) on `MCP::Tool` and `MCP.tool` convenience method (TypeScript SDK v0.2.27 parity)
|
|
14
|
+
- README documentation for `UserMessageReplay`, `HookStartedMessage`, `HookProgressMessage`, `ToolUseSummaryMessage`, `FilesPersistedEvent` message types
|
|
15
|
+
- README documentation for `mcp_reconnect` and `mcp_toggle` client methods
|
|
16
|
+
- README documentation for MCP tool annotations
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Updated SPEC.md to reference TypeScript SDK v0.2.27 and Python SDK v0.1.26
|
|
20
|
+
|
|
21
|
+
## [0.6.0] - 2026-01-30
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- `FilesPersistedEvent` message type for file persistence confirmation (TypeScript SDK v0.2.25 parity)
|
|
25
|
+
- `claudeai-proxy` MCP server type support via Hash-based config passthrough
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
- Updated SPEC.md to reference TypeScript SDK v0.2.25 and Python SDK v0.1.25
|
|
29
|
+
|
|
10
30
|
## [0.5.0] - 2026-01-25
|
|
11
31
|
|
|
12
32
|
### Added
|
data/CLAUDE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ClaudeAgent Ruby SDK
|
|
2
2
|
|
|
3
|
-
Ruby SDK for building autonomous AI agents that interact with Claude Code CLI.
|
|
3
|
+
Ruby SDK for building autonomous AI agents that interact with Claude Code CLI. See [README.md](README.md) for API usage, message types, configuration, and examples.
|
|
4
4
|
|
|
5
5
|
## Stack
|
|
6
6
|
|
|
@@ -32,16 +32,6 @@ bin/rbs-validate # Validate RBS signatures
|
|
|
32
32
|
bin/release VERSION # Release gem (e.g., bin/release 1.2.0)
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
## Architecture
|
|
36
|
-
|
|
37
|
-
| Component | Purpose |
|
|
38
|
-
|-----------------------------|----------------------------------------------------|
|
|
39
|
-
| `Query` | One-shot stateless prompts |
|
|
40
|
-
| `Client` | Multi-turn bidirectional conversations |
|
|
41
|
-
| `ControlProtocol` | Handles handshake, hooks, permissions, MCP routing |
|
|
42
|
-
| `Transport::Subprocess` | Spawns CLI, manages stdin/stdout |
|
|
43
|
-
| `MCP::Tool` / `MCP::Server` | Custom tool definitions |
|
|
44
|
-
|
|
45
35
|
## Conventions
|
|
46
36
|
|
|
47
37
|
- **Immutable data types**: All messages and options use `Data.define`
|
|
@@ -50,25 +40,6 @@ bin/release VERSION # Release gem (e.g., bin/release 1.2.0)
|
|
|
50
40
|
- **Error hierarchy**: All errors inherit from `ClaudeAgent::Error` with context (exit code, stderr, etc.)
|
|
51
41
|
- **Protocol flow**: Transport → ControlProtocol → MessageParser → typed message objects
|
|
52
42
|
|
|
53
|
-
## Key Patterns
|
|
54
|
-
|
|
55
|
-
```ruby
|
|
56
|
-
# One-shot query
|
|
57
|
-
result = ClaudeAgent.query("prompt", model: "sonnet")
|
|
58
|
-
|
|
59
|
-
# Interactive client
|
|
60
|
-
client = ClaudeAgent::Client.new(options)
|
|
61
|
-
client.send_message("prompt") { |msg| handle(msg) }
|
|
62
|
-
|
|
63
|
-
# Content blocks are polymorphic
|
|
64
|
-
message.content.each do |block|
|
|
65
|
-
case block
|
|
66
|
-
when ClaudeAgent::TextBlock then ...
|
|
67
|
-
when ClaudeAgent::ToolUseBlock then ...
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
```
|
|
71
|
-
|
|
72
43
|
## Testing Notes
|
|
73
44
|
|
|
74
45
|
- Unit tests in `test/claude_agent/` - run without Claude CLI
|
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@ Ruby gem for building AI-powered applications with the [Claude Agent SDK](https:
|
|
|
5
5
|
## Requirements
|
|
6
6
|
|
|
7
7
|
- Ruby 3.2+ (uses `Data.define`)
|
|
8
|
-
- [Claude Code CLI](https://
|
|
8
|
+
- [Claude Code CLI](https://code.claude.com/docs/en/getting-started) v2.0.0+
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -226,6 +226,19 @@ result.errors # Array of error messages (if any)
|
|
|
226
226
|
result.permission_denials # Array of SDKPermissionDenial (if any)
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
+
### UserMessageReplay
|
|
230
|
+
|
|
231
|
+
Replayed user messages when resuming a session with existing history:
|
|
232
|
+
|
|
233
|
+
```ruby
|
|
234
|
+
replay.content # Message content
|
|
235
|
+
replay.uuid # Message UUID
|
|
236
|
+
replay.session_id # Session identifier
|
|
237
|
+
replay.parent_tool_use_id # Parent tool use ID (if tool result)
|
|
238
|
+
replay.replay? # true if this is a replayed message
|
|
239
|
+
replay.synthetic? # true if this is a synthetic message
|
|
240
|
+
```
|
|
241
|
+
|
|
229
242
|
### SystemMessage
|
|
230
243
|
|
|
231
244
|
Internal system events:
|
|
@@ -289,6 +302,48 @@ hook_response.stderr # Hook stderr
|
|
|
289
302
|
hook_response.exit_code # Exit code
|
|
290
303
|
```
|
|
291
304
|
|
|
305
|
+
### HookStartedMessage
|
|
306
|
+
|
|
307
|
+
Hook execution start notification:
|
|
308
|
+
|
|
309
|
+
```ruby
|
|
310
|
+
hook_started.hook_id # Hook identifier
|
|
311
|
+
hook_started.hook_name # Hook name
|
|
312
|
+
hook_started.hook_event # Hook event type
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
### HookProgressMessage
|
|
316
|
+
|
|
317
|
+
Progress during hook execution:
|
|
318
|
+
|
|
319
|
+
```ruby
|
|
320
|
+
hook_progress.hook_id # Hook identifier
|
|
321
|
+
hook_progress.hook_name # Hook name
|
|
322
|
+
hook_progress.hook_event # Hook event type
|
|
323
|
+
hook_progress.stdout # Hook stdout so far
|
|
324
|
+
hook_progress.stderr # Hook stderr so far
|
|
325
|
+
hook_progress.output # Combined output
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
### ToolUseSummaryMessage
|
|
329
|
+
|
|
330
|
+
Summary of tool use for collapsed display:
|
|
331
|
+
|
|
332
|
+
```ruby
|
|
333
|
+
summary.summary # Human-readable summary text
|
|
334
|
+
summary.preceding_tool_use_ids # Tool use IDs this summarizes
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### FilesPersistedEvent
|
|
338
|
+
|
|
339
|
+
Files persisted to storage during a session:
|
|
340
|
+
|
|
341
|
+
```ruby
|
|
342
|
+
persisted.files # Array of successfully persisted file paths
|
|
343
|
+
persisted.failed # Array of files that failed to persist
|
|
344
|
+
persisted.processed_at # Timestamp of persistence
|
|
345
|
+
```
|
|
346
|
+
|
|
292
347
|
### AuthStatusMessage
|
|
293
348
|
|
|
294
349
|
Authentication status during login:
|
|
@@ -413,6 +468,33 @@ schema: {
|
|
|
413
468
|
}
|
|
414
469
|
```
|
|
415
470
|
|
|
471
|
+
### Tool Annotations
|
|
472
|
+
|
|
473
|
+
Annotate tools with hints about their behavior:
|
|
474
|
+
|
|
475
|
+
```ruby
|
|
476
|
+
tool = ClaudeAgent::MCP::Tool.new(
|
|
477
|
+
name: "search",
|
|
478
|
+
description: "Search the web",
|
|
479
|
+
schema: { query: String },
|
|
480
|
+
annotations: {
|
|
481
|
+
readOnlyHint: true, # Tool only reads data, no side effects
|
|
482
|
+
destructiveHint: false, # Tool does not destroy/delete data
|
|
483
|
+
idempotentHint: true, # Repeated calls with same args have same effect
|
|
484
|
+
openWorldHint: true, # Tool interacts with external systems
|
|
485
|
+
title: "Web Search" # Human-readable display name
|
|
486
|
+
}
|
|
487
|
+
) { |args| "Results for #{args['query']}" }
|
|
488
|
+
|
|
489
|
+
# Or with the convenience method
|
|
490
|
+
tool = ClaudeAgent::MCP.tool(
|
|
491
|
+
"search", "Search the web", { query: String },
|
|
492
|
+
annotations: { readOnlyHint: true, openWorldHint: true }
|
|
493
|
+
) { |args| "Results" }
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
All annotation fields are optional hints — omit any that don't apply.
|
|
497
|
+
|
|
416
498
|
### Tool Return Values
|
|
417
499
|
|
|
418
500
|
Tools can return various formats:
|
|
@@ -622,6 +704,13 @@ result = client.set_mcp_servers({
|
|
|
622
704
|
})
|
|
623
705
|
puts "Added: #{result.added}, Removed: #{result.removed}"
|
|
624
706
|
|
|
707
|
+
# Reconnect a disconnected MCP server
|
|
708
|
+
client.mcp_reconnect("my-server")
|
|
709
|
+
|
|
710
|
+
# Enable or disable an MCP server
|
|
711
|
+
client.mcp_toggle("my-server", enabled: false) # Disable
|
|
712
|
+
client.mcp_toggle("my-server", enabled: true) # Re-enable
|
|
713
|
+
|
|
625
714
|
# Query capabilities
|
|
626
715
|
client.supported_commands.each { |cmd| puts "#{cmd.name}: #{cmd.description}" }
|
|
627
716
|
client.supported_models.each { |model| puts "#{model.value}: #{model.display_name}" }
|
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: v0.1.
|
|
6
|
+
- TypeScript SDK: v0.2.27 (npm package)
|
|
7
|
+
- Python SDK: v0.1.26 from GitHub (commit 438ddf7)
|
|
8
8
|
- Ruby SDK: This repository
|
|
9
9
|
|
|
10
|
-
**Last Updated:**
|
|
10
|
+
**Last Updated:** 2026-01-31
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
@@ -65,7 +65,7 @@ Configuration options for SDK queries and clients.
|
|
|
65
65
|
| `additionalDirectories` | ✅ | ✅ | ✅ | Extra allowed directories |
|
|
66
66
|
| `env` | ✅ | ✅ | ✅ | Environment variables |
|
|
67
67
|
| `sandbox` | ✅ | ✅ | ✅ | Sandbox settings |
|
|
68
|
-
| `settings` | ✅ |
|
|
68
|
+
| `settings` | ✅ | ✅ | ✅ | Settings file path or JSON string (e.g., plansDirectory) |
|
|
69
69
|
| `settingSources` | ✅ | ✅ | ✅ | Which settings to load |
|
|
70
70
|
| `plugins` | ✅ | ✅ | ✅ | Plugin configurations |
|
|
71
71
|
| `betas` | ✅ | ✅ | ✅ | Beta features (e.g., context-1m-2025-08-07) |
|
|
@@ -104,6 +104,7 @@ Messages exchanged between SDK and CLI.
|
|
|
104
104
|
| `AuthStatusMessage` | ✅ | ❌ | ✅ | Authentication status |
|
|
105
105
|
| `TaskNotificationMessage` | ✅ | ❌ | ✅ | Background task completion |
|
|
106
106
|
| `ToolUseSummaryMessage` | ✅ | ❌ | ✅ | Summary of tool use (collapsed) |
|
|
107
|
+
| `FilesPersistedEvent` | ✅ | ❌ | ✅ | File persistence confirmation |
|
|
107
108
|
|
|
108
109
|
### Message Fields
|
|
109
110
|
|
|
@@ -212,12 +213,12 @@ Bidirectional control protocol for SDK-CLI communication.
|
|
|
212
213
|
| `can_use_tool` | ✅ | ✅ | ✅ | Permission callback |
|
|
213
214
|
| `hook_callback` | ✅ | ✅ | ✅ | Execute hook callback |
|
|
214
215
|
| `set_permission_mode` | ✅ | ✅ | ✅ | Change permission mode |
|
|
215
|
-
| `set_model` | ✅ |
|
|
216
|
+
| `set_model` | ✅ | ✅ | ✅ | Change model |
|
|
216
217
|
| `set_max_thinking_tokens` | ✅ | ❌ | ✅ | Change thinking tokens limit |
|
|
217
218
|
| `rewind_files` | ✅ | ✅ | ✅ | Rewind file checkpoints |
|
|
218
219
|
| `mcp_message` | ✅ | ✅ | ✅ | Route MCP message |
|
|
219
220
|
| `mcp_set_servers` | ✅ | ❌ | ✅ | Dynamically set MCP servers |
|
|
220
|
-
| `mcp_status` | ✅ |
|
|
221
|
+
| `mcp_status` | ✅ | ✅ | ✅ | Get MCP server status |
|
|
221
222
|
| `mcp_reconnect` | ✅ | ❌ | ✅ | Reconnect to MCP server |
|
|
222
223
|
| `mcp_toggle` | ✅ | ❌ | ✅ | Enable/disable MCP server |
|
|
223
224
|
| `supported_commands` | ✅ | ❌ | ✅ | Get available slash commands |
|
|
@@ -247,7 +248,7 @@ Event hooks for intercepting and modifying SDK behavior.
|
|
|
247
248
|
|----------------------|:----------:|:------:|:----:|---------------------------|
|
|
248
249
|
| `PreToolUse` | ✅ | ✅ | ✅ | Before tool execution |
|
|
249
250
|
| `PostToolUse` | ✅ | ✅ | ✅ | After tool execution |
|
|
250
|
-
| `PostToolUseFailure` | ✅ |
|
|
251
|
+
| `PostToolUseFailure` | ✅ | ✅ | ✅ | After tool failure |
|
|
251
252
|
| `Notification` | ✅ | ❌ | ✅ | System notifications |
|
|
252
253
|
| `UserPromptSubmit` | ✅ | ✅ | ✅ | User message submitted |
|
|
253
254
|
| `SessionStart` | ✅ | ❌ | ✅ | Session starts |
|
|
@@ -265,7 +266,7 @@ Event hooks for intercepting and modifying SDK behavior.
|
|
|
265
266
|
|-------------------------------|:----------:|:------:|:----:|
|
|
266
267
|
| `PreToolUseHookInput` | ✅ | ✅ | ✅ |
|
|
267
268
|
| `PostToolUseHookInput` | ✅ | ✅ | ✅ |
|
|
268
|
-
| `PostToolUseFailureHookInput` | ✅ |
|
|
269
|
+
| `PostToolUseFailureHookInput` | ✅ | ✅ | ✅ |
|
|
269
270
|
| `NotificationHookInput` | ✅ | ❌ | ✅ |
|
|
270
271
|
| `UserPromptSubmitHookInput` | ✅ | ✅ | ✅ |
|
|
271
272
|
| `SessionStartHookInput` | ✅ | ❌ | ✅ |
|
|
@@ -300,7 +301,7 @@ Event-specific fields returned via `hookSpecificOutput`:
|
|
|
300
301
|
| Field | TypeScript | Python | Ruby | Notes |
|
|
301
302
|
|----------------------------|:----------:|:------:|:----:|------------------------------------|
|
|
302
303
|
| `permissionDecision` | ✅ | ✅ | ✅ | `allow`, `deny`, or `ask` |
|
|
303
|
-
| `permissionDecisionReason` | ✅ |
|
|
304
|
+
| `permissionDecisionReason` | ✅ | ✅ | ✅ | Reason for permission decision |
|
|
304
305
|
| `updatedInput` | ✅ | ✅ | ✅ | Modified tool input |
|
|
305
306
|
| `additionalContext` | ✅ | ❌ | ✅ | Context string returned to model |
|
|
306
307
|
|
|
@@ -315,7 +316,7 @@ Event-specific fields returned via `hookSpecificOutput`:
|
|
|
315
316
|
|
|
316
317
|
| Field | TypeScript | Python | Ruby | Notes |
|
|
317
318
|
|---------------------|:----------:|:------:|:----:|----------------------------------|
|
|
318
|
-
| `additionalContext` | ✅ |
|
|
319
|
+
| `additionalContext` | ✅ | ✅ | ✅ | Context string returned to model |
|
|
319
320
|
|
|
320
321
|
#### SessionStartHookSpecificOutput
|
|
321
322
|
|
|
@@ -423,7 +424,7 @@ Permission handling and updates.
|
|
|
423
424
|
|------------------|:----------:|:------:|:----:|---------------------------|
|
|
424
425
|
| `signal` | ✅ | ✅ | ✅ | Abort signal |
|
|
425
426
|
| `suggestions` | ✅ | ✅ | ✅ | Permission suggestions |
|
|
426
|
-
| `blockedPath` | ✅ |
|
|
427
|
+
| `blockedPath` | ✅ | ❌ | ✅ | Blocked file path |
|
|
427
428
|
| `decisionReason` | ✅ | ❌ | ✅ | Why permission triggered |
|
|
428
429
|
| `toolUseID` | ✅ | ❌ | ✅ | Tool call ID |
|
|
429
430
|
| `agentID` | ✅ | ❌ | ✅ | Subagent ID if applicable |
|
|
@@ -436,12 +437,13 @@ Model Context Protocol server support.
|
|
|
436
437
|
|
|
437
438
|
### MCP Server Types
|
|
438
439
|
|
|
439
|
-
| Type
|
|
440
|
-
|
|
441
|
-
| `stdio`
|
|
442
|
-
| `sse`
|
|
443
|
-
| `http`
|
|
444
|
-
| `sdk`
|
|
440
|
+
| Type | TypeScript | Python | Ruby | Notes |
|
|
441
|
+
|------------------|:----------:|:------:|:----:|----------------------------------|
|
|
442
|
+
| `stdio` | ✅ | ✅ | ✅ | Subprocess with stdio |
|
|
443
|
+
| `sse` | ✅ | ✅ | ✅ | Server-sent events |
|
|
444
|
+
| `http` | ✅ | ✅ | ✅ | HTTP transport |
|
|
445
|
+
| `sdk` | ✅ | ✅ | ✅ | In-process SDK server |
|
|
446
|
+
| `claudeai-proxy` | ✅ | ❌ | ✅ | Claude.ai proxy server (managed) |
|
|
445
447
|
|
|
446
448
|
### MCP Server Config Fields
|
|
447
449
|
|
|
@@ -472,11 +474,12 @@ Model Context Protocol server support.
|
|
|
472
474
|
|
|
473
475
|
### SDK MCP Server
|
|
474
476
|
|
|
475
|
-
| Feature | TypeScript | Python | Ruby | Notes
|
|
476
|
-
|
|
477
|
-
| `createSdkMcpServer` | ✅ | ❌ | ✅ | Create SDK server
|
|
478
|
-
| `tool()` helper | ✅ | ❌ | ✅ | Create tool definition
|
|
479
|
-
| Tool input schema | ✅ (Zod) | ❌ | ✅ (Hash/JSON Schema) | Schema definition
|
|
477
|
+
| Feature | TypeScript | Python | Ruby | Notes |
|
|
478
|
+
|----------------------|:----------:|:------:|:--------------------:|--------------------------|
|
|
479
|
+
| `createSdkMcpServer` | ✅ | ❌ | ✅ | Create SDK server |
|
|
480
|
+
| `tool()` helper | ✅ | ❌ | ✅ | Create tool definition |
|
|
481
|
+
| Tool input schema | ✅ (Zod) | ❌ | ✅ (Hash/JSON Schema) | Schema definition |
|
|
482
|
+
| Tool annotations | ✅ | ❌ | ✅ | MCP tool hints (v0.2.27) |
|
|
480
483
|
|
|
481
484
|
---
|
|
482
485
|
|
|
@@ -595,41 +598,43 @@ Public API surface for SDK clients.
|
|
|
595
598
|
| One-shot query function | ✅ `query()` | ✅ `query()` | ✅ `ClaudeAgent.query()` | Simple prompts |
|
|
596
599
|
| Returns async generator | ✅ | ✅ | ✅ (Enumerator) | Streaming messages |
|
|
597
600
|
|
|
598
|
-
### Query Control Methods
|
|
601
|
+
### Query Control Methods
|
|
599
602
|
|
|
600
603
|
| Method | TypeScript | Python | Ruby | Notes |
|
|
601
604
|
|--------------------------|:----------:|:------:|:----:|------------------------|
|
|
602
|
-
| `interrupt()` | ✅ |
|
|
603
|
-
| `setPermissionMode()` | ✅ |
|
|
604
|
-
| `setModel()` | ✅ |
|
|
605
|
+
| `interrupt()` | ✅ | ✅ | ✅ | Interrupt execution |
|
|
606
|
+
| `setPermissionMode()` | ✅ | ✅ | ✅ | Change permission mode |
|
|
607
|
+
| `setModel()` | ✅ | ✅ | ✅ | Change model |
|
|
605
608
|
| `setMaxThinkingTokens()` | ✅ | ❌ | ✅ | Set thinking limit |
|
|
606
609
|
| `supportedCommands()` | ✅ | ❌ | ✅ | Get slash commands |
|
|
607
610
|
| `supportedModels()` | ✅ | ❌ | ✅ | Get available models |
|
|
608
|
-
| `mcpServerStatus()` | ✅ |
|
|
611
|
+
| `mcpServerStatus()` | ✅ | ✅ | ✅ | Get MCP status |
|
|
609
612
|
| `accountInfo()` | ✅ | ❌ | ✅ | Get account info |
|
|
610
613
|
| `rewindFiles()` | ✅ | ✅ | ✅ | Rewind file changes |
|
|
611
614
|
| `setMcpServers()` | ✅ | ❌ | ✅ | Dynamic MCP servers |
|
|
612
|
-
| `
|
|
613
|
-
| `
|
|
615
|
+
| `reconnectMcpServer()` | ✅ | ❌ | ✅ | Reconnect MCP server |
|
|
616
|
+
| `toggleMcpServer()` | ✅ | ❌ | ✅ | Enable/disable MCP |
|
|
617
|
+
| `streamInput()` | ✅ | ✅ | ✅ | Stream user input |
|
|
618
|
+
| `close()` | ✅ | ✅ | ✅ | Close query/session |
|
|
614
619
|
|
|
615
620
|
### Client Class
|
|
616
621
|
|
|
617
|
-
| Feature | TypeScript | Python | Ruby | Notes
|
|
618
|
-
|
|
619
|
-
| Multi-turn client | ❌ | ✅ `ClaudeSDKClient` | ✅ `ClaudeAgent::Client` | Interactive sessions
|
|
620
|
-
| `connect()` | N/A | ✅ | ✅ | Start session
|
|
621
|
-
| `disconnect()` | N/A | ✅ | ✅ | End session
|
|
622
|
-
| `send_message()` | N/A | ✅ | ✅ | Send user message
|
|
623
|
-
| `receive_response()` | N/A | ✅ | ✅ | Receive until result
|
|
624
|
-
| `stream_input()` | N/A | ❌ | ✅ | Stream input messages
|
|
625
|
-
| `abort!()` | N/A | ❌ | ✅ | Abort operations
|
|
626
|
-
| Control methods | N/A | Partial | ✅ |
|
|
622
|
+
| Feature | TypeScript | Python | Ruby | Notes |
|
|
623
|
+
|----------------------|:----------:|:-------------------:|:-----------------------:|----------------------------------------------------------------------------------|
|
|
624
|
+
| Multi-turn client | ❌ | ✅ `ClaudeSDKClient` | ✅ `ClaudeAgent::Client` | Interactive sessions |
|
|
625
|
+
| `connect()` | N/A | ✅ | ✅ | Start session |
|
|
626
|
+
| `disconnect()` | N/A | ✅ | ✅ | End session |
|
|
627
|
+
| `send_message()` | N/A | ✅ | ✅ | Send user message |
|
|
628
|
+
| `receive_response()` | N/A | ✅ | ✅ | Receive until result |
|
|
629
|
+
| `stream_input()` | N/A | ❌ | ✅ | Stream input messages |
|
|
630
|
+
| `abort!()` | N/A | ❌ | ✅ | Abort operations |
|
|
631
|
+
| Control methods | N/A | Partial | ✅ | interrupt, setPermissionMode, setModel, rewindFiles (Python); all methods (Ruby) |
|
|
627
632
|
|
|
628
633
|
### Transport
|
|
629
634
|
|
|
630
635
|
| Feature | TypeScript | Python | Ruby | Notes |
|
|
631
636
|
|-----------------------|:----------:|:------:|:----:|--------------------------|
|
|
632
|
-
| `Transport` interface | ✅ |
|
|
637
|
+
| `Transport` interface | ✅ | ✅ | ✅ | Transport abstraction |
|
|
633
638
|
| Process transport | ✅ | ✅ | ✅ | Subprocess communication |
|
|
634
639
|
| Custom spawn | ✅ | ❌ | ✅ | VM/container support |
|
|
635
640
|
|
|
@@ -659,21 +664,37 @@ Public API surface for SDK clients.
|
|
|
659
664
|
- v0.2.12+ adds `user` option to SDKSessionOptions
|
|
660
665
|
- v0.2.19 adds `mcp_reconnect` and `mcp_toggle` control requests
|
|
661
666
|
- v0.2.19 adds `HookStartedMessage`, `HookProgressMessage`, and `ToolUseSummaryMessage`
|
|
667
|
+
- v0.2.25 adds `SDKFilesPersistedEvent` message type for file persistence confirmation
|
|
668
|
+
- v0.2.25 adds `McpClaudeAIProxyServerConfig` (`claudeai-proxy` type) for managed proxy servers
|
|
669
|
+
- v0.2.21 adds `reconnectMcpServer()` and `toggleMcpServer()` query methods
|
|
670
|
+
- v0.2.21 adds `config`, `scope`, `tools` fields and `disabled` status to `McpServerStatus`
|
|
671
|
+
- v0.2.27 adds optional `annotations` support to `tool()` helper for MCP tool hints
|
|
662
672
|
|
|
663
673
|
### Python SDK
|
|
664
|
-
- Full source available (v0.1.
|
|
665
|
-
-
|
|
666
|
-
-
|
|
674
|
+
- Full source available (v0.1.26)
|
|
675
|
+
- Now has `Transport` abstract class and several query control methods
|
|
676
|
+
- Supports `interrupt()`, `set_permission_mode()`, `set_model()`, `rewind_files()`, `stream_input()`, `close()`, `get_mcp_status()` in query
|
|
677
|
+
- Client also supports `interrupt()`, `set_permission_mode()`, `set_model()`, `rewind_files()`
|
|
678
|
+
- Does not support SessionStart/SessionEnd/Notification/SubagentStart/PermissionRequest/Setup hooks
|
|
667
679
|
- Missing several permission modes (delegate, dontAsk)
|
|
680
|
+
- Missing `allowDangerouslySkipPermissions`, `persistSession`, `resumeSessionAt`, `strictMcpConfig`
|
|
681
|
+
- Missing `init`/`initOnly`/`maintenance` Setup hook options
|
|
668
682
|
- `excludedCommands` in sandbox now supported
|
|
669
|
-
- `
|
|
670
|
-
- `
|
|
683
|
+
- v0.1.25 adds `PostToolUseFailure` hook event support
|
|
684
|
+
- v0.1.25 adds `permissionDecisionReason` to `PreToolUseHookSpecificOutput`
|
|
685
|
+
- v0.1.26 bumps bundled CLI to v2.1.27 (no new SDK features beyond PostToolUseFailure)
|
|
686
|
+
- `additionalContext` supported in `UserPromptSubmitHookSpecificOutput`
|
|
687
|
+
- `PreToolUseHookInput` does not include `tool_use_id` (unlike TypeScript)
|
|
688
|
+
- `ToolPermissionContext` missing `blockedPath`, `decisionReason`, `toolUseID`, `agentID`
|
|
671
689
|
|
|
672
690
|
### Ruby SDK (This Repository)
|
|
673
|
-
-
|
|
691
|
+
- Full TypeScript SDK feature parity
|
|
674
692
|
- Ruby-idiomatic patterns (Data.define, snake_case)
|
|
675
693
|
- Complete control protocol support
|
|
676
694
|
- Dedicated Client class for multi-turn conversations
|
|
677
695
|
- Full hook event support including all 13 events
|
|
678
696
|
- Full V2 Session API support (unstable)
|
|
679
697
|
- `executable`/`executableArgs` marked N/A (JS runtime options not applicable to Ruby)
|
|
698
|
+
- Added: `FilesPersistedEvent` message type (new in TS v0.2.25)
|
|
699
|
+
- `claudeai-proxy` MCP server type handled transparently via Hash-based config passthrough (new in TS v0.2.25)
|
|
700
|
+
- Added: MCP tool `annotations` support (new in TS v0.2.27)
|
|
@@ -150,8 +150,8 @@ module ClaudeAgent
|
|
|
150
150
|
# "Hello, #{args['name']}!"
|
|
151
151
|
# end
|
|
152
152
|
#
|
|
153
|
-
def self.tool(name, description, schema = {}, &handler)
|
|
154
|
-
Tool.new(name: name, description: description, schema: schema, &handler)
|
|
153
|
+
def self.tool(name, description, schema = {}, annotations: nil, &handler)
|
|
154
|
+
Tool.new(name: name, description: description, schema: schema, annotations: annotations, &handler)
|
|
155
155
|
end
|
|
156
156
|
|
|
157
157
|
# Convenience method to create a server
|
|
@@ -34,16 +34,18 @@ module ClaudeAgent
|
|
|
34
34
|
# end
|
|
35
35
|
#
|
|
36
36
|
class Tool
|
|
37
|
-
attr_reader :name, :description, :schema, :handler
|
|
37
|
+
attr_reader :name, :description, :schema, :annotations, :handler
|
|
38
38
|
|
|
39
39
|
# @param name [String] Tool name (must be unique within server)
|
|
40
40
|
# @param description [String] Description of what the tool does
|
|
41
41
|
# @param schema [Hash] Input schema (simple Ruby types or JSON Schema)
|
|
42
|
+
# @param annotations [Hash, nil] MCP tool annotations (readOnlyHint, destructiveHint, etc.)
|
|
42
43
|
# @param handler [Proc] Block to execute when tool is called
|
|
43
|
-
def initialize(name:, description:, schema: {}, &handler)
|
|
44
|
+
def initialize(name:, description:, schema: {}, annotations: nil, &handler)
|
|
44
45
|
@name = name.to_s
|
|
45
46
|
@description = description.to_s
|
|
46
47
|
@schema = normalize_schema(schema)
|
|
48
|
+
@annotations = annotations
|
|
47
49
|
@handler = handler || ->(args) { raise "No handler defined for tool #{name}" }
|
|
48
50
|
end
|
|
49
51
|
|
|
@@ -60,11 +62,13 @@ module ClaudeAgent
|
|
|
60
62
|
# Convert to MCP tool definition format
|
|
61
63
|
# @return [Hash]
|
|
62
64
|
def to_mcp_definition
|
|
63
|
-
{
|
|
65
|
+
definition = {
|
|
64
66
|
name: @name,
|
|
65
67
|
description: @description,
|
|
66
68
|
inputSchema: @schema
|
|
67
69
|
}
|
|
70
|
+
definition[:annotations] = @annotations if @annotations.present?
|
|
71
|
+
definition
|
|
68
72
|
end
|
|
69
73
|
|
|
70
74
|
private
|
|
@@ -11,7 +11,7 @@ module ClaudeAgent
|
|
|
11
11
|
# Parse a raw message hash into a typed message object
|
|
12
12
|
#
|
|
13
13
|
# @param raw [Hash] Raw message from CLI
|
|
14
|
-
# @return [UserMessage, UserMessageReplay, AssistantMessage, SystemMessage, ResultMessage, StreamEvent, CompactBoundaryMessage, StatusMessage, ToolProgressMessage, HookResponseMessage, AuthStatusMessage, TaskNotificationMessage, HookStartedMessage, HookProgressMessage, ToolUseSummaryMessage]
|
|
14
|
+
# @return [UserMessage, UserMessageReplay, AssistantMessage, SystemMessage, ResultMessage, StreamEvent, CompactBoundaryMessage, StatusMessage, ToolProgressMessage, HookResponseMessage, AuthStatusMessage, TaskNotificationMessage, HookStartedMessage, HookProgressMessage, ToolUseSummaryMessage, FilesPersistedEvent]
|
|
15
15
|
# @raise [MessageParseError] If message cannot be parsed
|
|
16
16
|
def parse(raw)
|
|
17
17
|
type = raw["type"]
|
|
@@ -36,6 +36,8 @@ module ClaudeAgent
|
|
|
36
36
|
parse_hook_started_message(raw)
|
|
37
37
|
when "hook_progress"
|
|
38
38
|
parse_hook_progress_message(raw)
|
|
39
|
+
when "files_persisted"
|
|
40
|
+
parse_files_persisted_event(raw)
|
|
39
41
|
else
|
|
40
42
|
parse_system_message(raw)
|
|
41
43
|
end
|
|
@@ -312,5 +314,15 @@ module ClaudeAgent
|
|
|
312
314
|
preceding_tool_use_ids: fetch_dual(raw, :preceding_tool_use_ids, [])
|
|
313
315
|
)
|
|
314
316
|
end
|
|
317
|
+
|
|
318
|
+
def parse_files_persisted_event(raw)
|
|
319
|
+
FilesPersistedEvent.new(
|
|
320
|
+
uuid: raw["uuid"] || "",
|
|
321
|
+
session_id: fetch_dual(raw, :session_id, ""),
|
|
322
|
+
files: raw["files"] || [],
|
|
323
|
+
failed: raw["failed"] || [],
|
|
324
|
+
processed_at: fetch_dual(raw, :processed_at)
|
|
325
|
+
)
|
|
326
|
+
end
|
|
315
327
|
end
|
|
316
328
|
end
|
|
@@ -614,6 +614,43 @@ module ClaudeAgent
|
|
|
614
614
|
end
|
|
615
615
|
end
|
|
616
616
|
|
|
617
|
+
# Files persisted event (TypeScript SDK v0.2.25 parity)
|
|
618
|
+
#
|
|
619
|
+
# Sent when files are persisted to storage during a session.
|
|
620
|
+
# Contains lists of successfully persisted files and any failures.
|
|
621
|
+
#
|
|
622
|
+
# @example
|
|
623
|
+
# msg = FilesPersistedEvent.new(
|
|
624
|
+
# uuid: "msg-123",
|
|
625
|
+
# session_id: "session-abc",
|
|
626
|
+
# files: [{ "filename" => "test.rb", "file_id" => "file-456" }],
|
|
627
|
+
# failed: [],
|
|
628
|
+
# processed_at: "2026-01-30T12:00:00Z"
|
|
629
|
+
# )
|
|
630
|
+
# msg.files.first["filename"] # => "test.rb"
|
|
631
|
+
#
|
|
632
|
+
FilesPersistedEvent = Data.define(
|
|
633
|
+
:uuid,
|
|
634
|
+
:session_id,
|
|
635
|
+
:files,
|
|
636
|
+
:failed,
|
|
637
|
+
:processed_at
|
|
638
|
+
) do
|
|
639
|
+
def initialize(
|
|
640
|
+
uuid:,
|
|
641
|
+
session_id:,
|
|
642
|
+
files: [],
|
|
643
|
+
failed: [],
|
|
644
|
+
processed_at: nil
|
|
645
|
+
)
|
|
646
|
+
super
|
|
647
|
+
end
|
|
648
|
+
|
|
649
|
+
def type
|
|
650
|
+
:files_persisted
|
|
651
|
+
end
|
|
652
|
+
end
|
|
653
|
+
|
|
617
654
|
# All message types
|
|
618
655
|
MESSAGE_TYPES = [
|
|
619
656
|
UserMessage,
|
|
@@ -630,6 +667,7 @@ module ClaudeAgent
|
|
|
630
667
|
TaskNotificationMessage,
|
|
631
668
|
HookStartedMessage,
|
|
632
669
|
HookProgressMessage,
|
|
633
|
-
ToolUseSummaryMessage
|
|
670
|
+
ToolUseSummaryMessage,
|
|
671
|
+
FilesPersistedEvent
|
|
634
672
|
].freeze
|
|
635
673
|
end
|
data/lib/claude_agent/version.rb
CHANGED
data/sig/claude_agent.rbs
CHANGED
|
@@ -393,7 +393,7 @@ module ClaudeAgent
|
|
|
393
393
|
CONTENT_BLOCK_TYPES: Array[Class]
|
|
394
394
|
|
|
395
395
|
# Message types
|
|
396
|
-
type message = UserMessage | UserMessageReplay | AssistantMessage | SystemMessage | ResultMessage | StreamEvent | CompactBoundaryMessage | StatusMessage | ToolProgressMessage | HookResponseMessage | AuthStatusMessage | TaskNotificationMessage | HookStartedMessage | HookProgressMessage | ToolUseSummaryMessage
|
|
396
|
+
type message = UserMessage | UserMessageReplay | AssistantMessage | SystemMessage | ResultMessage | StreamEvent | CompactBoundaryMessage | StatusMessage | ToolProgressMessage | HookResponseMessage | AuthStatusMessage | TaskNotificationMessage | HookStartedMessage | HookProgressMessage | ToolUseSummaryMessage | FilesPersistedEvent
|
|
397
397
|
|
|
398
398
|
MESSAGE_TYPES: Array[Class]
|
|
399
399
|
|
|
@@ -616,6 +616,18 @@ module ClaudeAgent
|
|
|
616
616
|
def type: () -> :tool_use_summary
|
|
617
617
|
end
|
|
618
618
|
|
|
619
|
+
# Files persisted event (TypeScript SDK v0.2.25 parity)
|
|
620
|
+
class FilesPersistedEvent
|
|
621
|
+
attr_reader uuid: String
|
|
622
|
+
attr_reader session_id: String
|
|
623
|
+
attr_reader files: Array[Hash[String, String]]
|
|
624
|
+
attr_reader failed: Array[Hash[String, String]]
|
|
625
|
+
attr_reader processed_at: String?
|
|
626
|
+
|
|
627
|
+
def initialize: (uuid: String, session_id: String, ?files: Array[Hash[String, String]], ?failed: Array[Hash[String, String]], ?processed_at: String?) -> void
|
|
628
|
+
def type: () -> :files_persisted
|
|
629
|
+
end
|
|
630
|
+
|
|
619
631
|
# Message parser
|
|
620
632
|
class MessageParser
|
|
621
633
|
def initialize: () -> void
|
|
@@ -955,15 +967,16 @@ module ClaudeAgent
|
|
|
955
967
|
|
|
956
968
|
# MCP module
|
|
957
969
|
module MCP
|
|
958
|
-
def self.tool: (String name, String description, ?Hash[Symbol, untyped] schema) { (Hash[String, untyped]) -> untyped } -> Tool
|
|
970
|
+
def self.tool: (String name, String description, ?Hash[Symbol, untyped] schema, ?annotations: Hash[Symbol, untyped]?) { (Hash[String, untyped]) -> untyped } -> Tool
|
|
959
971
|
def self.create_server: (name: String, ?tools: Array[Tool]) -> Server
|
|
960
972
|
|
|
961
973
|
class Tool
|
|
962
974
|
attr_reader name: String
|
|
963
975
|
attr_reader description: String
|
|
964
976
|
attr_reader schema: Hash[Symbol, untyped]
|
|
977
|
+
attr_reader annotations: Hash[Symbol, untyped]?
|
|
965
978
|
|
|
966
|
-
def initialize: (name: String, description: String, ?schema: Hash[Symbol, untyped]) { (Hash[String, untyped]) -> untyped } -> void
|
|
979
|
+
def initialize: (name: String, description: String, ?schema: Hash[Symbol, untyped], ?annotations: Hash[Symbol, untyped]?) { (Hash[String, untyped]) -> untyped } -> void
|
|
967
980
|
def call: (Hash[String, untyped] arguments) -> Hash[Symbol, untyped]
|
|
968
981
|
def to_mcp_definition: () -> Hash[Symbol, untyped]
|
|
969
982
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: claude_agent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Carr
|
|
@@ -34,14 +34,15 @@ executables: []
|
|
|
34
34
|
extensions: []
|
|
35
35
|
extra_rdoc_files: []
|
|
36
36
|
files:
|
|
37
|
-
- ".claude/commands/spec/complete.md"
|
|
38
|
-
- ".claude/commands/spec/update.md"
|
|
39
37
|
- ".claude/rules/conventions.md"
|
|
40
38
|
- ".claude/rules/git.md"
|
|
41
39
|
- ".claude/rules/pull-requests.md"
|
|
42
40
|
- ".claude/rules/releases.md"
|
|
43
41
|
- ".claude/rules/testing.md"
|
|
44
42
|
- ".claude/settings.json"
|
|
43
|
+
- ".claude/skills/spec/SKILL.md"
|
|
44
|
+
- ".claude/skills/spec/commands/complete.md"
|
|
45
|
+
- ".claude/skills/spec/commands/update.md"
|
|
45
46
|
- CHANGELOG.md
|
|
46
47
|
- CLAUDE.md
|
|
47
48
|
- LICENSE.txt
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
description: Update SPEC.md with latest feature parity comparison across TypeScript, Python, and Ruby SDKs
|
|
3
|
-
allowed-tools: Bash, Read, Glob, Grep, Write, Edit, TodoWrite, Task
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Update SDK Specification Document
|
|
7
|
-
|
|
8
|
-
You are updating the SPEC.md file to reflect the current feature parity between the TypeScript, Python, and Ruby Claude Agent SDKs.
|
|
9
|
-
|
|
10
|
-
## Step 1: Update Reference SDKs
|
|
11
|
-
|
|
12
|
-
First, ensure the reference SDKs are up to date:
|
|
13
|
-
|
|
14
|
-
```bash
|
|
15
|
-
bin/update-reference-sdks
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
This clones/updates:
|
|
19
|
-
- Python SDK from GitHub → `vendor/claude-agent-sdk-python`
|
|
20
|
-
- TypeScript SDK from npm → `vendor/claude-agent-sdk-npm`
|
|
21
|
-
|
|
22
|
-
## Step 2: Research Official Documentation
|
|
23
|
-
|
|
24
|
-
Use the `claude-code-guide` agent to check for any new or updated SDK features:
|
|
25
|
-
|
|
26
|
-
```
|
|
27
|
-
Task(subagent_type: "claude-code-guide", prompt: "What are all the features and options in the Claude Agent SDK? Include configuration options, hooks, permissions, MCP support, and control protocol methods.")
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
This helps catch features that may be documented but not yet in the SDK source files.
|
|
31
|
-
|
|
32
|
-
## Step 3: Analyze All Three SDKs
|
|
33
|
-
|
|
34
|
-
Read and compare the following files:
|
|
35
|
-
|
|
36
|
-
### TypeScript SDK (Primary Reference)
|
|
37
|
-
- `vendor/claude-agent-sdk-npm/sdk.d.ts` - Complete API surface with all types
|
|
38
|
-
|
|
39
|
-
### Python SDK
|
|
40
|
-
- `vendor/claude-agent-sdk-python/src/claude_agent_sdk/types.py` - Type definitions
|
|
41
|
-
|
|
42
|
-
### Ruby SDK (This Repository)
|
|
43
|
-
Key files to check:
|
|
44
|
-
- `lib/claude_agent/options.rb` - Configuration options
|
|
45
|
-
- `lib/claude_agent/messages.rb` - Message types
|
|
46
|
-
- `lib/claude_agent/content_blocks.rb` - Content block types
|
|
47
|
-
- `lib/claude_agent/types.rb` - Additional types
|
|
48
|
-
- `lib/claude_agent/hooks.rb` - Hook types
|
|
49
|
-
- `lib/claude_agent/permissions.rb` - Permission types
|
|
50
|
-
- `lib/claude_agent/control_protocol.rb` - Control protocol
|
|
51
|
-
- `lib/claude_agent/sandbox_settings.rb` - Sandbox config
|
|
52
|
-
- `lib/claude_agent/mcp/server.rb` - MCP server
|
|
53
|
-
- `lib/claude_agent/mcp/tool.rb` - MCP tools
|
|
54
|
-
- `lib/claude_agent/client.rb` - Client class
|
|
55
|
-
- `lib/claude_agent/errors.rb` - Error types
|
|
56
|
-
|
|
57
|
-
## Step 4: Update SPEC.md
|
|
58
|
-
|
|
59
|
-
Update the existing SPEC.md file with:
|
|
60
|
-
|
|
61
|
-
1. **Reference Versions** - Update TypeScript SDK version and Python SDK commit
|
|
62
|
-
2. **Feature Tables** - Update all ✅/❌ markers based on current implementations
|
|
63
|
-
3. **New Features** - Add any new features found in the TypeScript SDK
|
|
64
|
-
4. **Removed Features** - Remove any deprecated features
|
|
65
|
-
|
|
66
|
-
### Categories to Compare
|
|
67
|
-
|
|
68
|
-
1. Options/Configuration
|
|
69
|
-
2. Message Types
|
|
70
|
-
3. Content Blocks
|
|
71
|
-
4. Control Protocol
|
|
72
|
-
5. Hooks
|
|
73
|
-
6. Permissions
|
|
74
|
-
7. MCP Support
|
|
75
|
-
8. Sessions
|
|
76
|
-
9. Subagents
|
|
77
|
-
10. Sandbox Settings
|
|
78
|
-
11. Error Handling
|
|
79
|
-
12. Client API
|
|
80
|
-
|
|
81
|
-
## Guidelines
|
|
82
|
-
|
|
83
|
-
- **Be thorough** - Check every field and option in each SDK
|
|
84
|
-
- **TypeScript is authoritative** - The TypeScript sdk.d.ts is the most complete reference
|
|
85
|
-
- **Preserve format** - Keep the existing table structure and markdown formatting
|
|
86
|
-
- **Update versions** - Always update the reference version info at the top
|
|
87
|
-
- **Note changes** - If significant changes are found, mention them after updating
|
|
88
|
-
|
|
89
|
-
## Output
|
|
90
|
-
|
|
91
|
-
After updating SPEC.md, provide a brief summary of:
|
|
92
|
-
- SDK versions checked
|
|
93
|
-
- Any new features added to the spec
|
|
94
|
-
- Any features removed from the spec
|
|
95
|
-
- Any notable gaps in the Ruby SDK
|