claude_agent 0.7.6 → 0.7.8
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/.worktreeinclude +13 -0
- data/CHANGELOG.md +18 -0
- data/SPEC.md +33 -9
- data/lib/claude_agent/client.rb +16 -0
- data/lib/claude_agent/control_protocol.rb +15 -0
- data/lib/claude_agent/hooks.rb +56 -0
- data/lib/claude_agent/message_parser.rb +34 -1
- data/lib/claude_agent/messages.rb +98 -1
- data/lib/claude_agent/options.rb +4 -2
- data/lib/claude_agent/sandbox_settings.rb +28 -2
- data/lib/claude_agent/version.rb +1 -1
- data/sig/claude_agent.rbs +72 -2
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e9304128d18cec59aa0b0221f199b2674d60a5a2813141562b9df51b88057987
|
|
4
|
+
data.tar.gz: 8bd6696b854f8660e21744bc02d178e3e402a734119554c2869cc4fbb188a75d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ad2321250e0967d302d41d23724fe6f368f3e8fe6cb4461f483f6d13d3b9b35368189cce06dd28f5fa427013a9a272c6a4e1b3e94ee75b8a38dd7ed422c5068
|
|
7
|
+
data.tar.gz: d17257cfcabecbb033ce1427a0237456e5ecbeb0c1c3bedb9bc21dac1336be6a21b96a85ffc96919f7c4774a3f51498a4876f31d11249a05f327966af23f0ae8
|
data/.worktreeinclude
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Files to copy to new worktrees (must also be in .gitignore)
|
|
2
|
+
|
|
3
|
+
# Claude Configs
|
|
4
|
+
.claude/settings.local.json
|
|
5
|
+
.claude/**/local-*
|
|
6
|
+
.claude/**/local/
|
|
7
|
+
|
|
8
|
+
# MCP server configuration
|
|
9
|
+
.mcp.json
|
|
10
|
+
|
|
11
|
+
# Local dependencies and temp files
|
|
12
|
+
/tmp/**
|
|
13
|
+
/vendor/**
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.7.8] - 2026-02-22
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `WorktreeCreate` hook event with `WorktreeCreateInput` class (TypeScript SDK v0.2.50 parity)
|
|
14
|
+
- `WorktreeRemove` hook event with `WorktreeRemoveInput` class (TypeScript SDK v0.2.50 parity)
|
|
15
|
+
- `apply_flag_settings` control request on `ControlProtocol` and `Client` for merging settings into the flag layer (TypeScript SDK v0.2.50 parity)
|
|
16
|
+
- RBS signatures for all new types
|
|
17
|
+
|
|
18
|
+
## [0.7.7] - 2026-02-20
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- `TaskStartedMessage` for background task start notifications (TypeScript SDK v0.2.43 parity)
|
|
22
|
+
- `RateLimitEvent` message type for rate limit visibility (TypeScript SDK v0.2.44 parity)
|
|
23
|
+
- `PromptSuggestionMessage` type and `prompt_suggestions` option for suggested follow-up prompts (TypeScript SDK v0.2.46 parity)
|
|
24
|
+
- `ConfigChange` hook event with `ConfigChangeInput` class (TypeScript SDK v0.2.47 parity)
|
|
25
|
+
- `SandboxFilesystemConfig` with `allow_write`, `deny_write`, `deny_read` fields (TypeScript SDK v0.2.49 parity)
|
|
26
|
+
- RBS signatures for all new types
|
|
27
|
+
|
|
10
28
|
## [0.7.6] - 2026-02-13
|
|
11
29
|
|
|
12
30
|
### Added
|
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.50 (npm package)
|
|
7
|
+
- Python SDK: v0.1.39 from GitHub (commit 146e3d6)
|
|
8
8
|
- Ruby SDK: This repository
|
|
9
9
|
|
|
10
|
-
**Last Updated:** 2026-02-
|
|
10
|
+
**Last Updated:** 2026-02-22
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
@@ -41,7 +41,7 @@ Configuration options for SDK queries and clients.
|
|
|
41
41
|
| `tools` | ✅ | ✅ | ✅ | Array or preset |
|
|
42
42
|
| `allowedTools` | ✅ | ✅ | ✅ | Auto-allowed tools |
|
|
43
43
|
| `disallowedTools` | ✅ | ✅ | ✅ | Blocked tools |
|
|
44
|
-
| `permissionMode` | ✅ | ✅ | ✅ | default/acceptEdits/plan/bypassPermissions/
|
|
44
|
+
| `permissionMode` | ✅ | ✅ | ✅ | default/acceptEdits/plan/bypassPermissions/dontAsk |
|
|
45
45
|
| `allowDangerouslySkipPermissions` | ✅ | ❌ | ✅ | Required for bypassPermissions |
|
|
46
46
|
| `canUseTool` | ✅ | ✅ | ✅ | Permission callback |
|
|
47
47
|
| `permissionPromptToolName` | ✅ | ✅ | ✅ | MCP tool for permission prompts |
|
|
@@ -83,6 +83,7 @@ Configuration options for SDK queries and clients.
|
|
|
83
83
|
| `init` | ✅ | ❌ | ✅ | Run Setup hooks (init trigger), then continue (hidden CLI) |
|
|
84
84
|
| `initOnly` | ✅ | ❌ | ✅ | Run Setup hooks (init trigger), then exit (hidden CLI) |
|
|
85
85
|
| `maintenance` | ✅ | ❌ | ✅ | Run Setup hooks (maintenance trigger), continue (hidden CLI) |
|
|
86
|
+
| `promptSuggestions` | ✅ | ❌ | ✅ | Enable prompt suggestion after each turn (v0.2.47) |
|
|
86
87
|
| `debug` | ✅ | ❌ | ✅ | Enable verbose debug logging |
|
|
87
88
|
| `debugFile` | ✅ | ❌ | ✅ | Write debug logs to specific file path |
|
|
88
89
|
|
|
@@ -109,6 +110,9 @@ Messages exchanged between SDK and CLI.
|
|
|
109
110
|
| `AuthStatusMessage` | ✅ | ❌ | ✅ | Authentication status |
|
|
110
111
|
| `TaskNotificationMessage` | ✅ | ❌ | ✅ | Background task completion |
|
|
111
112
|
| `ToolUseSummaryMessage` | ✅ | ❌ | ✅ | Summary of tool use (collapsed) |
|
|
113
|
+
| `TaskStartedMessage` | ✅ | ❌ | ✅ | Subagent task registered (v0.2.45) |
|
|
114
|
+
| `RateLimitEvent` | ✅ | ❌ | ✅ | Rate limit status changes |
|
|
115
|
+
| `PromptSuggestionMessage` | ✅ | ❌ | ✅ | Suggested next prompt (v0.2.47) |
|
|
112
116
|
| `FilesPersistedEvent` | ✅ | ❌ | ✅ | File persistence confirmation |
|
|
113
117
|
|
|
114
118
|
### Message Fields
|
|
@@ -231,6 +235,7 @@ Bidirectional control protocol for SDK-CLI communication.
|
|
|
231
235
|
| `supported_commands` | ✅ | ❌ | ✅ | Get available slash commands |
|
|
232
236
|
| `supported_models` | ✅ | ❌ | ✅ | Get available models |
|
|
233
237
|
| `account_info` | ✅ | ❌ | ✅ | Get account information |
|
|
238
|
+
| `apply_flag_settings` | ✅ | ❌ | ✅ | Merge settings into flag layer |
|
|
234
239
|
|
|
235
240
|
### Return Types
|
|
236
241
|
|
|
@@ -269,6 +274,9 @@ Event hooks for intercepting and modifying SDK behavior.
|
|
|
269
274
|
| `Setup` | ✅ | ❌ | ✅ | Initial setup/maintenance |
|
|
270
275
|
| `TeammateIdle` | ✅ | ❌ | ✅ | Teammate idle (v0.2.33) |
|
|
271
276
|
| `TaskCompleted` | ✅ | ❌ | ✅ | Task completed (v0.2.33) |
|
|
277
|
+
| `ConfigChange` | ✅ | ❌ | ✅ | Config file changed (v0.2.49) |
|
|
278
|
+
| `WorktreeCreate` | ✅ | ❌ | ✅ | Worktree creation (v0.2.50) |
|
|
279
|
+
| `WorktreeRemove` | ✅ | ❌ | ✅ | Worktree removal (v0.2.50) |
|
|
272
280
|
|
|
273
281
|
### Hook Input Types
|
|
274
282
|
|
|
@@ -289,6 +297,9 @@ Event hooks for intercepting and modifying SDK behavior.
|
|
|
289
297
|
| `SetupHookInput` | ✅ | ❌ | ✅ |
|
|
290
298
|
| `TeammateIdleHookInput` | ✅ | ❌ | ✅ |
|
|
291
299
|
| `TaskCompletedHookInput` | ✅ | ❌ | ✅ |
|
|
300
|
+
| `ConfigChangeHookInput` | ✅ | ❌ | ✅ |
|
|
301
|
+
| `WorktreeCreateHookInput` | ✅ | ❌ | ✅ |
|
|
302
|
+
| `WorktreeRemoveHookInput` | ✅ | ❌ | ✅ |
|
|
292
303
|
|
|
293
304
|
### Hook Output Types
|
|
294
305
|
|
|
@@ -388,7 +399,6 @@ Permission handling and updates.
|
|
|
388
399
|
| `acceptEdits` | ✅ | ✅ | ✅ | Auto-accept edits |
|
|
389
400
|
| `plan` | ✅ | ✅ | ✅ | Planning mode |
|
|
390
401
|
| `bypassPermissions` | ✅ | ✅ | ✅ | Skip all checks |
|
|
391
|
-
| `delegate` | ✅ | ❌ | ✅ | Delegate mode |
|
|
392
402
|
| `dontAsk` | ✅ | ❌ | ✅ | Never prompt |
|
|
393
403
|
|
|
394
404
|
### Permission Result Types
|
|
@@ -556,6 +566,15 @@ Sandbox configuration for command execution isolation.
|
|
|
556
566
|
| `ignoreViolations` | ✅ | ✅ | ✅ |
|
|
557
567
|
| `enableWeakerNestedSandbox` | ✅ | ✅ | ✅ |
|
|
558
568
|
| `ripgrep` | ✅ | ❌ | ✅ |
|
|
569
|
+
| `filesystem` | ✅ | ❌ | ✅ |
|
|
570
|
+
|
|
571
|
+
### SandboxFilesystemConfig
|
|
572
|
+
|
|
573
|
+
| Field | TypeScript | Python | Ruby |
|
|
574
|
+
|--------------|:----------:|:------:|:----:|
|
|
575
|
+
| `allowWrite` | ✅ | ❌ | ✅ |
|
|
576
|
+
| `denyWrite` | ✅ | ❌ | ✅ |
|
|
577
|
+
| `denyRead` | ✅ | ❌ | ✅ |
|
|
559
578
|
|
|
560
579
|
### SandboxNetworkConfig
|
|
561
580
|
|
|
@@ -673,19 +692,24 @@ Public API surface for SDK clients.
|
|
|
673
692
|
- Source is bundled/minified, but `sdk.d.ts` provides complete type definitions
|
|
674
693
|
- Includes unstable V2 session API
|
|
675
694
|
- `executable`/`executableArgs` are JS-specific (`node`/`bun`/`deno`)
|
|
695
|
+
- v0.2.45: Added `TaskStartedMessage`, `RateLimitEvent` message types
|
|
696
|
+
- v0.2.47: Added `promptSuggestions` option and `PromptSuggestionMessage`
|
|
697
|
+
- v0.2.49: Added `ConfigChange` hook event, `SandboxFilesystemConfig`
|
|
698
|
+
- v0.2.50: Added `WorktreeCreate`/`WorktreeRemove` hook events, `apply_flag_settings` control request
|
|
676
699
|
|
|
677
700
|
### Python SDK
|
|
678
701
|
- Full source available with `Transport` abstract class
|
|
679
702
|
- Partial control protocol: query and client support interrupt, setPermissionMode, setModel, rewindFiles, mcpStatus
|
|
680
|
-
- Missing hooks: SessionStart, SessionEnd, Setup, TeammateIdle, TaskCompleted
|
|
681
|
-
- Missing permission modes: `
|
|
682
|
-
- Missing options: `allowDangerouslySkipPermissions`, `persistSession`, `resumeSessionAt`, `sessionId`, `strictMcpConfig`, `init`/`initOnly`/`maintenance`, `debug`/`debugFile`
|
|
703
|
+
- Missing hooks: SessionStart, SessionEnd, Setup, TeammateIdle, TaskCompleted, ConfigChange, WorktreeCreate, WorktreeRemove
|
|
704
|
+
- Missing permission modes: `dontAsk`
|
|
705
|
+
- Missing options: `allowDangerouslySkipPermissions`, `persistSession`, `resumeSessionAt`, `sessionId`, `strictMcpConfig`, `init`/`initOnly`/`maintenance`, `debug`/`debugFile`, `promptSuggestions`
|
|
683
706
|
- `ToolPermissionContext` missing `blockedPath`, `decisionReason`, `toolUseID`, `agentID`, `description`
|
|
684
707
|
- Has SDK MCP server support with `tool()` helper and annotations
|
|
685
708
|
- Added `thinking` config and `effort` option in v0.1.36
|
|
709
|
+
- Handles `rate_limit_event` and unknown message types gracefully (v0.1.39)
|
|
686
710
|
|
|
687
711
|
### Ruby SDK (This Repository)
|
|
688
|
-
-
|
|
712
|
+
- Feature parity with TypeScript SDK v0.2.50
|
|
689
713
|
- Ruby-idiomatic patterns (Data.define, snake_case)
|
|
690
714
|
- Complete control protocol, hook, and V2 Session API support
|
|
691
715
|
- Dedicated Client class for multi-turn conversations
|
data/lib/claude_agent/client.rb
CHANGED
|
@@ -298,6 +298,22 @@ module ClaudeAgent
|
|
|
298
298
|
@protocol.stop_task(task_id)
|
|
299
299
|
end
|
|
300
300
|
|
|
301
|
+
# Apply flag settings (TypeScript SDK v0.2.50 parity)
|
|
302
|
+
#
|
|
303
|
+
# Merges the provided settings into the flag settings layer.
|
|
304
|
+
#
|
|
305
|
+
# @param settings [Hash] Settings to merge into the flag layer
|
|
306
|
+
# @return [Hash] Response from the CLI
|
|
307
|
+
#
|
|
308
|
+
# @example
|
|
309
|
+
# client.apply_flag_settings({ "model" => "claude-sonnet-4-5-20250514" })
|
|
310
|
+
#
|
|
311
|
+
def apply_flag_settings(settings)
|
|
312
|
+
require_connection!
|
|
313
|
+
|
|
314
|
+
@protocol.apply_flag_settings(settings)
|
|
315
|
+
end
|
|
316
|
+
|
|
301
317
|
# Dynamically set MCP servers for this session (TypeScript SDK parity)
|
|
302
318
|
#
|
|
303
319
|
# This replaces the current set of dynamically-added MCP servers.
|
|
@@ -458,6 +458,20 @@ module ClaudeAgent
|
|
|
458
458
|
send_control_request(subtype: "stop_task", task_id: task_id)
|
|
459
459
|
end
|
|
460
460
|
|
|
461
|
+
# Apply flag settings (TypeScript SDK v0.2.50 parity)
|
|
462
|
+
#
|
|
463
|
+
# Merges the provided settings into the flag settings layer.
|
|
464
|
+
#
|
|
465
|
+
# @param settings [Hash] Settings to merge into the flag layer
|
|
466
|
+
# @return [Hash] Response from the CLI
|
|
467
|
+
#
|
|
468
|
+
# @example
|
|
469
|
+
# protocol.apply_flag_settings({ "model" => "claude-sonnet-4-5-20250514" })
|
|
470
|
+
#
|
|
471
|
+
def apply_flag_settings(settings)
|
|
472
|
+
send_control_request(subtype: "apply_flag_settings", settings: settings)
|
|
473
|
+
end
|
|
474
|
+
|
|
461
475
|
# Dynamically set MCP servers for this session (TypeScript SDK parity)
|
|
462
476
|
#
|
|
463
477
|
# This replaces the current set of dynamically-added MCP servers.
|
|
@@ -532,6 +546,7 @@ module ClaudeAgent
|
|
|
532
546
|
|
|
533
547
|
request = { subtype: "initialize" }
|
|
534
548
|
request[:hooks] = hooks_config if hooks_config
|
|
549
|
+
request[:promptSuggestions] = true if options.prompt_suggestions
|
|
535
550
|
|
|
536
551
|
send_control_request(**request)
|
|
537
552
|
end
|
data/lib/claude_agent/hooks.rb
CHANGED
|
@@ -18,6 +18,9 @@ module ClaudeAgent
|
|
|
18
18
|
Setup
|
|
19
19
|
TeammateIdle
|
|
20
20
|
TaskCompleted
|
|
21
|
+
ConfigChange
|
|
22
|
+
WorktreeCreate
|
|
23
|
+
WorktreeRemove
|
|
21
24
|
].freeze
|
|
22
25
|
|
|
23
26
|
# Matcher configuration for hooks
|
|
@@ -278,6 +281,59 @@ module ClaudeAgent
|
|
|
278
281
|
end
|
|
279
282
|
end
|
|
280
283
|
|
|
284
|
+
# Input for ConfigChange hook (TypeScript SDK v0.2.49 parity)
|
|
285
|
+
#
|
|
286
|
+
# Fired when a configuration file changes.
|
|
287
|
+
#
|
|
288
|
+
# @example
|
|
289
|
+
# input = ConfigChangeInput.new(
|
|
290
|
+
# source: "user_settings",
|
|
291
|
+
# file_path: "~/.claude/settings.json",
|
|
292
|
+
# session_id: "sess-123"
|
|
293
|
+
# )
|
|
294
|
+
#
|
|
295
|
+
class ConfigChangeInput < BaseHookInput
|
|
296
|
+
attr_reader :source, :file_path
|
|
297
|
+
|
|
298
|
+
SOURCES = %w[user_settings project_settings local_settings policy_settings skills].freeze
|
|
299
|
+
|
|
300
|
+
# @param source [String] One of SOURCES
|
|
301
|
+
# @param file_path [String, nil] Path to the changed file
|
|
302
|
+
def initialize(source:, file_path: nil, **kwargs)
|
|
303
|
+
super(hook_event_name: "ConfigChange", **kwargs)
|
|
304
|
+
@source = source
|
|
305
|
+
@file_path = file_path
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
# Input for WorktreeCreate hook (TypeScript SDK v0.2.50 parity)
|
|
310
|
+
#
|
|
311
|
+
# Fired when a worktree is created.
|
|
312
|
+
#
|
|
313
|
+
class WorktreeCreateInput < BaseHookInput
|
|
314
|
+
attr_reader :name
|
|
315
|
+
|
|
316
|
+
# @param name [String] Worktree name
|
|
317
|
+
def initialize(name:, **kwargs)
|
|
318
|
+
super(hook_event_name: "WorktreeCreate", **kwargs)
|
|
319
|
+
@name = name
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
# Input for WorktreeRemove hook (TypeScript SDK v0.2.50 parity)
|
|
324
|
+
#
|
|
325
|
+
# Fired when a worktree is removed.
|
|
326
|
+
#
|
|
327
|
+
class WorktreeRemoveInput < BaseHookInput
|
|
328
|
+
attr_reader :worktree_path
|
|
329
|
+
|
|
330
|
+
# @param worktree_path [String] Path to the worktree
|
|
331
|
+
def initialize(worktree_path:, **kwargs)
|
|
332
|
+
super(hook_event_name: "WorktreeRemove", **kwargs)
|
|
333
|
+
@worktree_path = worktree_path
|
|
334
|
+
end
|
|
335
|
+
end
|
|
336
|
+
|
|
281
337
|
# Input for TaskCompleted hook (TypeScript SDK v0.2.33 parity)
|
|
282
338
|
#
|
|
283
339
|
# Fired when a task completes.
|
|
@@ -16,7 +16,7 @@ module ClaudeAgent
|
|
|
16
16
|
# Parse a raw message hash into a typed message object
|
|
17
17
|
#
|
|
18
18
|
# @param raw [Hash] Raw message from CLI
|
|
19
|
-
# @return [UserMessage, UserMessageReplay, AssistantMessage, SystemMessage, ResultMessage, StreamEvent, CompactBoundaryMessage, StatusMessage, ToolProgressMessage, HookResponseMessage, AuthStatusMessage, TaskNotificationMessage, HookStartedMessage, HookProgressMessage, ToolUseSummaryMessage, FilesPersistedEvent]
|
|
19
|
+
# @return [UserMessage, UserMessageReplay, AssistantMessage, SystemMessage, ResultMessage, StreamEvent, CompactBoundaryMessage, StatusMessage, ToolProgressMessage, HookResponseMessage, AuthStatusMessage, TaskNotificationMessage, HookStartedMessage, HookProgressMessage, ToolUseSummaryMessage, FilesPersistedEvent, TaskStartedMessage, RateLimitEvent, PromptSuggestionMessage]
|
|
20
20
|
# @raise [MessageParseError] If message cannot be parsed
|
|
21
21
|
def parse(raw)
|
|
22
22
|
type = raw["type"]
|
|
@@ -44,6 +44,8 @@ module ClaudeAgent
|
|
|
44
44
|
parse_hook_progress_message(raw)
|
|
45
45
|
when "files_persisted"
|
|
46
46
|
parse_files_persisted_event(raw)
|
|
47
|
+
when "task_started"
|
|
48
|
+
parse_task_started_message(raw)
|
|
47
49
|
else
|
|
48
50
|
parse_system_message(raw)
|
|
49
51
|
end
|
|
@@ -57,6 +59,10 @@ module ClaudeAgent
|
|
|
57
59
|
parse_auth_status_message(raw)
|
|
58
60
|
when "tool_use_summary"
|
|
59
61
|
parse_tool_use_summary_message(raw)
|
|
62
|
+
when "rate_limit_event"
|
|
63
|
+
parse_rate_limit_event(raw)
|
|
64
|
+
when "prompt_suggestion"
|
|
65
|
+
parse_prompt_suggestion_message(raw)
|
|
60
66
|
else
|
|
61
67
|
logger.error("parser") { "Unknown message type: #{type}" }
|
|
62
68
|
raise MessageParseError.new("Unknown message type: #{type}", raw_message: raw)
|
|
@@ -336,5 +342,32 @@ module ClaudeAgent
|
|
|
336
342
|
processed_at: fetch_dual(raw, :processed_at)
|
|
337
343
|
)
|
|
338
344
|
end
|
|
345
|
+
|
|
346
|
+
def parse_task_started_message(raw)
|
|
347
|
+
TaskStartedMessage.new(
|
|
348
|
+
uuid: raw["uuid"] || "",
|
|
349
|
+
session_id: fetch_dual(raw, :session_id, ""),
|
|
350
|
+
task_id: fetch_dual(raw, :task_id, ""),
|
|
351
|
+
tool_use_id: fetch_dual(raw, :tool_use_id),
|
|
352
|
+
description: raw["description"],
|
|
353
|
+
task_type: fetch_dual(raw, :task_type)
|
|
354
|
+
)
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
def parse_rate_limit_event(raw)
|
|
358
|
+
RateLimitEvent.new(
|
|
359
|
+
rate_limit_info: fetch_dual(raw, :rate_limit_info, {}),
|
|
360
|
+
uuid: raw["uuid"] || "",
|
|
361
|
+
session_id: fetch_dual(raw, :session_id, "")
|
|
362
|
+
)
|
|
363
|
+
end
|
|
364
|
+
|
|
365
|
+
def parse_prompt_suggestion_message(raw)
|
|
366
|
+
PromptSuggestionMessage.new(
|
|
367
|
+
uuid: raw["uuid"] || "",
|
|
368
|
+
session_id: fetch_dual(raw, :session_id, ""),
|
|
369
|
+
suggestion: raw["suggestion"] || ""
|
|
370
|
+
)
|
|
371
|
+
end
|
|
339
372
|
end
|
|
340
373
|
end
|
|
@@ -616,6 +616,100 @@ module ClaudeAgent
|
|
|
616
616
|
end
|
|
617
617
|
end
|
|
618
618
|
|
|
619
|
+
# Task started message (TypeScript SDK v0.2.45 parity)
|
|
620
|
+
#
|
|
621
|
+
# Sent when a new task (subagent) is started.
|
|
622
|
+
#
|
|
623
|
+
# @example
|
|
624
|
+
# msg = TaskStartedMessage.new(
|
|
625
|
+
# uuid: "msg-123",
|
|
626
|
+
# session_id: "session-abc",
|
|
627
|
+
# task_id: "task-456",
|
|
628
|
+
# tool_use_id: "tool-789",
|
|
629
|
+
# description: "Running tests",
|
|
630
|
+
# task_type: "bash"
|
|
631
|
+
# )
|
|
632
|
+
#
|
|
633
|
+
TaskStartedMessage = Data.define(
|
|
634
|
+
:uuid,
|
|
635
|
+
:session_id,
|
|
636
|
+
:task_id,
|
|
637
|
+
:tool_use_id,
|
|
638
|
+
:description,
|
|
639
|
+
:task_type
|
|
640
|
+
) do
|
|
641
|
+
def initialize(
|
|
642
|
+
uuid:,
|
|
643
|
+
session_id:,
|
|
644
|
+
task_id:,
|
|
645
|
+
tool_use_id: nil,
|
|
646
|
+
description: nil,
|
|
647
|
+
task_type: nil
|
|
648
|
+
)
|
|
649
|
+
super
|
|
650
|
+
end
|
|
651
|
+
|
|
652
|
+
def type
|
|
653
|
+
:task_started
|
|
654
|
+
end
|
|
655
|
+
end
|
|
656
|
+
|
|
657
|
+
# Rate limit event (TypeScript SDK v0.2.45 parity)
|
|
658
|
+
#
|
|
659
|
+
# Reports rate limit status and utilization information.
|
|
660
|
+
#
|
|
661
|
+
# @example
|
|
662
|
+
# msg = RateLimitEvent.new(
|
|
663
|
+
# uuid: "msg-123",
|
|
664
|
+
# session_id: "session-abc",
|
|
665
|
+
# rate_limit_info: {
|
|
666
|
+
# "status" => "allowed_warning",
|
|
667
|
+
# "resetsAt" => 1700000000,
|
|
668
|
+
# "rateLimitType" => "five_hour",
|
|
669
|
+
# "utilization" => 0.85,
|
|
670
|
+
# "isUsingOverage" => false,
|
|
671
|
+
# "overageStatus" => "available"
|
|
672
|
+
# }
|
|
673
|
+
# )
|
|
674
|
+
# msg.status # => "allowed_warning"
|
|
675
|
+
#
|
|
676
|
+
RateLimitEvent = Data.define(:rate_limit_info, :uuid, :session_id) do
|
|
677
|
+
def initialize(rate_limit_info:, uuid: nil, session_id: nil)
|
|
678
|
+
super
|
|
679
|
+
end
|
|
680
|
+
|
|
681
|
+
def type
|
|
682
|
+
:rate_limit_event
|
|
683
|
+
end
|
|
684
|
+
|
|
685
|
+
# Get the rate limit status
|
|
686
|
+
# @return [String, nil]
|
|
687
|
+
def status
|
|
688
|
+
rate_limit_info["status"] || rate_limit_info[:status]
|
|
689
|
+
end
|
|
690
|
+
end
|
|
691
|
+
|
|
692
|
+
# Prompt suggestion message (TypeScript SDK v0.2.47 parity)
|
|
693
|
+
#
|
|
694
|
+
# Contains a suggested prompt for the user.
|
|
695
|
+
#
|
|
696
|
+
# @example
|
|
697
|
+
# msg = PromptSuggestionMessage.new(
|
|
698
|
+
# uuid: "msg-123",
|
|
699
|
+
# session_id: "session-abc",
|
|
700
|
+
# suggestion: "Tell me about this project"
|
|
701
|
+
# )
|
|
702
|
+
#
|
|
703
|
+
PromptSuggestionMessage = Data.define(:uuid, :session_id, :suggestion) do
|
|
704
|
+
def initialize(uuid: nil, session_id: nil, suggestion:)
|
|
705
|
+
super
|
|
706
|
+
end
|
|
707
|
+
|
|
708
|
+
def type
|
|
709
|
+
:prompt_suggestion
|
|
710
|
+
end
|
|
711
|
+
end
|
|
712
|
+
|
|
619
713
|
# Files persisted event (TypeScript SDK v0.2.25 parity)
|
|
620
714
|
#
|
|
621
715
|
# Sent when files are persisted to storage during a session.
|
|
@@ -670,6 +764,9 @@ module ClaudeAgent
|
|
|
670
764
|
HookStartedMessage,
|
|
671
765
|
HookProgressMessage,
|
|
672
766
|
ToolUseSummaryMessage,
|
|
673
|
-
FilesPersistedEvent
|
|
767
|
+
FilesPersistedEvent,
|
|
768
|
+
TaskStartedMessage,
|
|
769
|
+
RateLimitEvent,
|
|
770
|
+
PromptSuggestionMessage
|
|
674
771
|
].freeze
|
|
675
772
|
end
|
data/lib/claude_agent/options.rb
CHANGED
|
@@ -4,7 +4,7 @@ require "json"
|
|
|
4
4
|
|
|
5
5
|
module ClaudeAgent
|
|
6
6
|
# Permission modes for tool execution (TypeScript SDK parity)
|
|
7
|
-
PERMISSION_MODES = %w[default acceptEdits plan bypassPermissions
|
|
7
|
+
PERMISSION_MODES = %w[default acceptEdits plan bypassPermissions dontAsk].freeze
|
|
8
8
|
|
|
9
9
|
# Configuration options for ClaudeAgent queries and clients
|
|
10
10
|
#
|
|
@@ -42,6 +42,7 @@ module ClaudeAgent
|
|
|
42
42
|
init: false,
|
|
43
43
|
init_only: false,
|
|
44
44
|
maintenance: false,
|
|
45
|
+
prompt_suggestions: false,
|
|
45
46
|
debug: false,
|
|
46
47
|
debug_file: nil
|
|
47
48
|
}.freeze
|
|
@@ -61,7 +62,7 @@ module ClaudeAgent
|
|
|
61
62
|
settings sandbox cwd add_dirs env user agent
|
|
62
63
|
cli_path extra_args agents setting_sources plugins
|
|
63
64
|
include_partial_messages output_format enable_file_checkpointing
|
|
64
|
-
persist_session betas max_buffer_size stderr_callback
|
|
65
|
+
persist_session prompt_suggestions betas max_buffer_size stderr_callback
|
|
65
66
|
abort_controller spawn_claude_code_process
|
|
66
67
|
init init_only maintenance
|
|
67
68
|
debug debug_file
|
|
@@ -260,6 +261,7 @@ module ClaudeAgent
|
|
|
260
261
|
args.push("--no-persist-session") if persist_session == false
|
|
261
262
|
args.push("--json-schema", JSON.generate(output_format)) if output_format
|
|
262
263
|
args.push("--include-partial-messages") if include_partial_messages
|
|
264
|
+
args.push("--prompt-suggestions") if prompt_suggestions
|
|
263
265
|
if agents
|
|
264
266
|
agents_hash = agents.transform_values(&:to_h)
|
|
265
267
|
args.push("--agents", JSON.generate(agents_hash))
|
|
@@ -85,6 +85,29 @@ module ClaudeAgent
|
|
|
85
85
|
end
|
|
86
86
|
end
|
|
87
87
|
|
|
88
|
+
# Filesystem-specific configuration for sandbox mode (TypeScript SDK v0.2.49 parity)
|
|
89
|
+
#
|
|
90
|
+
# @example
|
|
91
|
+
# filesystem = SandboxFilesystemConfig.new(
|
|
92
|
+
# allow_write: ["/tmp/*"],
|
|
93
|
+
# deny_write: ["/etc/*"],
|
|
94
|
+
# deny_read: ["/secrets/*"]
|
|
95
|
+
# )
|
|
96
|
+
#
|
|
97
|
+
SandboxFilesystemConfig = Data.define(:allow_write, :deny_write, :deny_read) do
|
|
98
|
+
def initialize(allow_write: [], deny_write: [], deny_read: [])
|
|
99
|
+
super
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def to_h
|
|
103
|
+
result = {}
|
|
104
|
+
result[:allowWrite] = allow_write unless allow_write.empty?
|
|
105
|
+
result[:denyWrite] = deny_write unless deny_write.empty?
|
|
106
|
+
result[:denyRead] = deny_read unless deny_read.empty?
|
|
107
|
+
result
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
88
111
|
# Sandbox configuration for command execution (TypeScript SDK parity)
|
|
89
112
|
#
|
|
90
113
|
# @example Basic sandbox
|
|
@@ -112,7 +135,8 @@ module ClaudeAgent
|
|
|
112
135
|
:network,
|
|
113
136
|
:ignore_violations,
|
|
114
137
|
:enable_weaker_nested_sandbox,
|
|
115
|
-
:ripgrep
|
|
138
|
+
:ripgrep,
|
|
139
|
+
:filesystem
|
|
116
140
|
) do
|
|
117
141
|
def initialize(
|
|
118
142
|
enabled: false,
|
|
@@ -122,7 +146,8 @@ module ClaudeAgent
|
|
|
122
146
|
network: nil,
|
|
123
147
|
ignore_violations: nil,
|
|
124
148
|
enable_weaker_nested_sandbox: false,
|
|
125
|
-
ripgrep: nil
|
|
149
|
+
ripgrep: nil,
|
|
150
|
+
filesystem: nil
|
|
126
151
|
)
|
|
127
152
|
super
|
|
128
153
|
end
|
|
@@ -136,6 +161,7 @@ module ClaudeAgent
|
|
|
136
161
|
result[:ignoreViolations] = ignore_violations.to_h if ignore_violations && !ignore_violations.to_h.empty?
|
|
137
162
|
result[:enableWeakerNestedSandbox] = enable_weaker_nested_sandbox if enable_weaker_nested_sandbox
|
|
138
163
|
result[:ripgrep] = ripgrep.to_h if ripgrep
|
|
164
|
+
result[:filesystem] = filesystem.to_h if filesystem && !filesystem.to_h.empty?
|
|
139
165
|
result
|
|
140
166
|
end
|
|
141
167
|
end
|
data/lib/claude_agent/version.rb
CHANGED
data/sig/claude_agent.rbs
CHANGED
|
@@ -231,6 +231,15 @@ module ClaudeAgent
|
|
|
231
231
|
def to_h: () -> Hash[Symbol, untyped]
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
+
class SandboxFilesystemConfig
|
|
235
|
+
attr_reader allow_write: Array[String]
|
|
236
|
+
attr_reader deny_write: Array[String]
|
|
237
|
+
attr_reader deny_read: Array[String]
|
|
238
|
+
|
|
239
|
+
def initialize: (?allow_write: Array[String], ?deny_write: Array[String], ?deny_read: Array[String]) -> void
|
|
240
|
+
def to_h: () -> Hash[Symbol, untyped]
|
|
241
|
+
end
|
|
242
|
+
|
|
234
243
|
class SandboxSettings
|
|
235
244
|
attr_reader enabled: bool
|
|
236
245
|
attr_reader auto_allow_bash_if_sandboxed: bool
|
|
@@ -240,8 +249,9 @@ module ClaudeAgent
|
|
|
240
249
|
attr_reader ignore_violations: SandboxIgnoreViolations?
|
|
241
250
|
attr_reader enable_weaker_nested_sandbox: bool
|
|
242
251
|
attr_reader ripgrep: SandboxRipgrepConfig?
|
|
252
|
+
attr_reader filesystem: SandboxFilesystemConfig?
|
|
243
253
|
|
|
244
|
-
def initialize: (?enabled: bool, ?auto_allow_bash_if_sandboxed: bool, ?excluded_commands: Array[String], ?allow_unsandboxed_commands: bool, ?network: SandboxNetworkConfig?, ?ignore_violations: SandboxIgnoreViolations?, ?enable_weaker_nested_sandbox: bool, ?ripgrep: SandboxRipgrepConfig?) -> void
|
|
254
|
+
def initialize: (?enabled: bool, ?auto_allow_bash_if_sandboxed: bool, ?excluded_commands: Array[String], ?allow_unsandboxed_commands: bool, ?network: SandboxNetworkConfig?, ?ignore_violations: SandboxIgnoreViolations?, ?enable_weaker_nested_sandbox: bool, ?ripgrep: SandboxRipgrepConfig?, ?filesystem: SandboxFilesystemConfig?) -> void
|
|
245
255
|
def to_h: () -> Hash[Symbol, untyped]
|
|
246
256
|
end
|
|
247
257
|
|
|
@@ -332,6 +342,9 @@ module ClaudeAgent
|
|
|
332
342
|
attr_accessor output_format: Hash[String, untyped]?
|
|
333
343
|
attr_accessor enable_file_checkpointing: bool
|
|
334
344
|
|
|
345
|
+
# Prompt suggestions
|
|
346
|
+
attr_accessor prompt_suggestions: bool
|
|
347
|
+
|
|
335
348
|
# Beta features
|
|
336
349
|
attr_accessor betas: Array[String]
|
|
337
350
|
|
|
@@ -436,7 +449,7 @@ module ClaudeAgent
|
|
|
436
449
|
CONTENT_BLOCK_TYPES: Array[Class]
|
|
437
450
|
|
|
438
451
|
# Message types
|
|
439
|
-
type message = UserMessage | UserMessageReplay | AssistantMessage | SystemMessage | ResultMessage | StreamEvent | CompactBoundaryMessage | StatusMessage | ToolProgressMessage | HookResponseMessage | AuthStatusMessage | TaskNotificationMessage | HookStartedMessage | HookProgressMessage | ToolUseSummaryMessage | FilesPersistedEvent
|
|
452
|
+
type message = UserMessage | UserMessageReplay | AssistantMessage | SystemMessage | ResultMessage | StreamEvent | CompactBoundaryMessage | StatusMessage | ToolProgressMessage | HookResponseMessage | AuthStatusMessage | TaskNotificationMessage | HookStartedMessage | HookProgressMessage | ToolUseSummaryMessage | FilesPersistedEvent | TaskStartedMessage | RateLimitEvent | PromptSuggestionMessage
|
|
440
453
|
|
|
441
454
|
MESSAGE_TYPES: Array[Class]
|
|
442
455
|
|
|
@@ -673,6 +686,40 @@ module ClaudeAgent
|
|
|
673
686
|
def type: () -> :files_persisted
|
|
674
687
|
end
|
|
675
688
|
|
|
689
|
+
# Task started message (TypeScript SDK v0.2.45 parity)
|
|
690
|
+
class TaskStartedMessage
|
|
691
|
+
attr_reader uuid: String
|
|
692
|
+
attr_reader session_id: String
|
|
693
|
+
attr_reader task_id: String
|
|
694
|
+
attr_reader tool_use_id: String?
|
|
695
|
+
attr_reader description: String?
|
|
696
|
+
attr_reader task_type: String?
|
|
697
|
+
|
|
698
|
+
def initialize: (uuid: String, session_id: String, task_id: String, ?tool_use_id: String?, ?description: String?, ?task_type: String?) -> void
|
|
699
|
+
def type: () -> :task_started
|
|
700
|
+
end
|
|
701
|
+
|
|
702
|
+
# Rate limit event (TypeScript SDK v0.2.45 parity)
|
|
703
|
+
class RateLimitEvent
|
|
704
|
+
attr_reader rate_limit_info: Hash[String, untyped]
|
|
705
|
+
attr_reader uuid: String?
|
|
706
|
+
attr_reader session_id: String?
|
|
707
|
+
|
|
708
|
+
def initialize: (rate_limit_info: Hash[String, untyped], ?uuid: String?, ?session_id: String?) -> void
|
|
709
|
+
def type: () -> :rate_limit_event
|
|
710
|
+
def status: () -> String?
|
|
711
|
+
end
|
|
712
|
+
|
|
713
|
+
# Prompt suggestion message (TypeScript SDK v0.2.47 parity)
|
|
714
|
+
class PromptSuggestionMessage
|
|
715
|
+
attr_reader uuid: String?
|
|
716
|
+
attr_reader session_id: String?
|
|
717
|
+
attr_reader suggestion: String
|
|
718
|
+
|
|
719
|
+
def initialize: (?uuid: String?, ?session_id: String?, suggestion: String) -> void
|
|
720
|
+
def type: () -> :prompt_suggestion
|
|
721
|
+
end
|
|
722
|
+
|
|
676
723
|
# Message parser
|
|
677
724
|
class MessageParser
|
|
678
725
|
def initialize: (?logger: Logger?) -> void
|
|
@@ -823,6 +870,27 @@ module ClaudeAgent
|
|
|
823
870
|
def initialize: (task_id: String, task_subject: String, ?task_description: String?, ?teammate_name: String?, ?team_name: String?, **untyped) -> void
|
|
824
871
|
end
|
|
825
872
|
|
|
873
|
+
class ConfigChangeInput < BaseHookInput
|
|
874
|
+
attr_reader source: String
|
|
875
|
+
attr_reader file_path: String?
|
|
876
|
+
|
|
877
|
+
SOURCES: Array[String]
|
|
878
|
+
|
|
879
|
+
def initialize: (source: String, ?file_path: String?, **untyped) -> void
|
|
880
|
+
end
|
|
881
|
+
|
|
882
|
+
class WorktreeCreateInput < BaseHookInput
|
|
883
|
+
attr_reader name: String
|
|
884
|
+
|
|
885
|
+
def initialize: (name: String, **untyped) -> void
|
|
886
|
+
end
|
|
887
|
+
|
|
888
|
+
class WorktreeRemoveInput < BaseHookInput
|
|
889
|
+
attr_reader worktree_path: String
|
|
890
|
+
|
|
891
|
+
def initialize: (worktree_path: String, **untyped) -> void
|
|
892
|
+
end
|
|
893
|
+
|
|
826
894
|
# Permission types
|
|
827
895
|
type permission_result = PermissionResultAllow | PermissionResultDeny
|
|
828
896
|
|
|
@@ -911,6 +979,7 @@ module ClaudeAgent
|
|
|
911
979
|
def mcp_reconnect: (String server_name) -> Hash[String, untyped]
|
|
912
980
|
def mcp_toggle: (String server_name, enabled: bool) -> Hash[String, untyped]
|
|
913
981
|
def stop_task: (String task_id) -> Hash[String, untyped]
|
|
982
|
+
def apply_flag_settings: (Hash[String, untyped] settings) -> Hash[String, untyped]
|
|
914
983
|
def supported_commands: () -> Array[SlashCommand]
|
|
915
984
|
def supported_models: () -> Array[ModelInfo]
|
|
916
985
|
def mcp_server_status: () -> Array[McpServerStatus]
|
|
@@ -948,6 +1017,7 @@ module ClaudeAgent
|
|
|
948
1017
|
def mcp_reconnect: (String server_name) -> Hash[String, untyped]
|
|
949
1018
|
def mcp_toggle: (String server_name, enabled: bool) -> Hash[String, untyped]
|
|
950
1019
|
def stop_task: (String task_id) -> Hash[String, untyped]
|
|
1020
|
+
def apply_flag_settings: (Hash[String, untyped] settings) -> Hash[String, untyped]
|
|
951
1021
|
def supported_commands: () -> Array[SlashCommand]
|
|
952
1022
|
def supported_models: () -> Array[ModelInfo]
|
|
953
1023
|
def mcp_server_status: () -> Array[McpServerStatus]
|
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.7.
|
|
4
|
+
version: 0.7.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Thomas Carr
|
|
@@ -43,6 +43,7 @@ files:
|
|
|
43
43
|
- ".claude/skills/spec/SKILL.md"
|
|
44
44
|
- ".claude/skills/spec/commands/complete.md"
|
|
45
45
|
- ".claude/skills/spec/commands/update.md"
|
|
46
|
+
- ".worktreeinclude"
|
|
46
47
|
- CHANGELOG.md
|
|
47
48
|
- CLAUDE.md
|
|
48
49
|
- LICENSE.txt
|