claude_agent 0.7.17 → 0.7.18
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 +6 -0
- data/SPEC.md +39 -73
- data/docs/hooks.md +8 -6
- data/docs/messages.md +23 -1
- data/lib/claude_agent/hook_registry.rb +1 -0
- data/lib/claude_agent/hooks.rb +5 -0
- data/lib/claude_agent/version.rb +1 -1
- data/sig/claude_agent.rbs +8 -0
- 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: 564803b88efd1e1690c1d44078c2dc9ddf10e8d74fc48cbacee1705843a50ef8
|
|
4
|
+
data.tar.gz: 03e53177abed5def635fad5152f7ec9046e9d16280df70200b9f1b53d8bd647b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a376e0f0ae1f9089500495998a00859c309c24c9256705df1c0310990534881a3faa3b469c1787dbb48ebb30714e40da3444ac8a5229e04c1de85a25332df7db
|
|
7
|
+
data.tar.gz: 35ae9feec317af0aac43cb5557d756442138889e0ada2eeff55b5536843f6a47120a1bc841575ca137734a5335266707c8766b0baf26750cb1031fcba256ab60
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.7.18] - 2026-03-20
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `StopFailure` hook event with `StopFailureInput` type (`error`, `error_details`, `last_assistant_message` fields) for handling API error-triggered stops (TypeScript SDK v0.2.80 parity)
|
|
14
|
+
- `on_stop_failure` DSL method on `HookRegistry` for the new event
|
|
15
|
+
|
|
10
16
|
## [0.7.17] - 2026-03-17
|
|
11
17
|
|
|
12
18
|
### 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: from GitHub (commit
|
|
6
|
+
- TypeScript SDK: v0.2.80 (npm package)
|
|
7
|
+
- Python SDK: from GitHub (commit 13e119a)
|
|
8
8
|
- Ruby SDK: This repository
|
|
9
9
|
|
|
10
|
-
**Last Updated:** 2026-03-
|
|
10
|
+
**Last Updated:** 2026-03-20
|
|
11
11
|
|
|
12
12
|
---
|
|
13
13
|
|
|
@@ -436,6 +436,7 @@ Event hooks for intercepting and modifying SDK behavior.
|
|
|
436
436
|
| `SessionStart` | ✅ | ✅ | ✅ | Session starts |
|
|
437
437
|
| `SessionEnd` | ✅ | ❌ | ✅ | Session ends |
|
|
438
438
|
| `Stop` | ✅ | ✅ | ✅ | Agent stops |
|
|
439
|
+
| `StopFailure` | ✅ | ❌ | ✅ | Agent stops due to API error |
|
|
439
440
|
| `SubagentStart` | ✅ | ✅ | ✅ | Subagent starts (Py v0.1.29) |
|
|
440
441
|
| `SubagentStop` | ✅ | ✅ | ✅ | Subagent stops |
|
|
441
442
|
| `PreCompact` | ✅ | ✅ | ✅ | Before compaction |
|
|
@@ -463,6 +464,7 @@ Event hooks for intercepting and modifying SDK behavior.
|
|
|
463
464
|
| `SessionStartHookInput` | ✅ | ❌ | ✅ |
|
|
464
465
|
| `SessionEndHookInput` | ✅ | ❌ | ✅ |
|
|
465
466
|
| `StopHookInput` | ✅ | ✅ | ✅ |
|
|
467
|
+
| `StopFailureHookInput` | ✅ | ❌ | ✅ |
|
|
466
468
|
| `SubagentStartHookInput` | ✅ | ✅ | ✅ |
|
|
467
469
|
| `SubagentStopHookInput` | ✅ | ✅ | ✅ |
|
|
468
470
|
| `PreCompactHookInput` | ✅ | ✅ | ✅ |
|
|
@@ -496,6 +498,14 @@ Event hooks for intercepting and modifying SDK behavior.
|
|
|
496
498
|
| `stop_hook_active` | ✅ | ✅ | ✅ | Whether stop hook is active |
|
|
497
499
|
| `last_assistant_message` | ✅ | ❌ | ✅ | Last assistant message text (v0.2.51+) |
|
|
498
500
|
|
|
501
|
+
#### StopFailureHookInput Fields
|
|
502
|
+
|
|
503
|
+
| Field | TypeScript | Python | Ruby | Notes |
|
|
504
|
+
|--------------------------|:----------:|:------:|:----:|----------------------------------------|
|
|
505
|
+
| `error` | ✅ | ❌ | ✅ | API error type (AssistantMessageError) |
|
|
506
|
+
| `error_details` | ✅ | ❌ | ✅ | Additional error details |
|
|
507
|
+
| `last_assistant_message` | ✅ | ❌ | ✅ | Last assistant message text |
|
|
508
|
+
|
|
499
509
|
#### SubagentStopHookInput Fields
|
|
500
510
|
|
|
501
511
|
| Field | TypeScript | Python | Ruby | Notes |
|
|
@@ -761,7 +771,7 @@ Session management and resumption.
|
|
|
761
771
|
|------------------------|:----------:|:------:|:----:|--------------------------------------------------|
|
|
762
772
|
| `listSessions()` | ✅ | ✅ | ✅ | List past sessions with metadata (v0.2.53) |
|
|
763
773
|
| `getSessionMessages()` | ✅ | ✅ | ✅ | Read session transcript messages (v0.2.59) |
|
|
764
|
-
| `getSessionInfo()` | ✅ |
|
|
774
|
+
| `getSessionInfo()` | ✅ | ✅ | ✅ | Get single session metadata (v0.2.75) |
|
|
765
775
|
| `renameSession()` | ✅ | ✅ | ✅ | Rename a session (v0.2.74) |
|
|
766
776
|
| `tagSession()` | ✅ | ✅ | ✅ | Tag a session (v0.2.75) |
|
|
767
777
|
| `forkSession()` | ✅ | ❌ | ✅ | Fork/branch a session (v0.2.76) |
|
|
@@ -805,8 +815,8 @@ Session management and resumption.
|
|
|
805
815
|
| `firstPrompt` | ✅ | ✅ | ✅ | First meaningful user prompt |
|
|
806
816
|
| `gitBranch` | ✅ | ✅ | ✅ | Git branch at end of session |
|
|
807
817
|
| `cwd` | ✅ | ✅ | ✅ | Working directory for session |
|
|
808
|
-
| `tag` | ✅ |
|
|
809
|
-
| `createdAt` | ✅ |
|
|
818
|
+
| `tag` | ✅ | ✅ | ✅ | User-set tag (v0.2.75) |
|
|
819
|
+
| `createdAt` | ✅ | ✅ | ✅ | Creation time in ms (v0.2.75) |
|
|
810
820
|
|
|
811
821
|
#### ForkSessionOptions
|
|
812
822
|
|
|
@@ -839,18 +849,18 @@ Custom subagent definitions.
|
|
|
839
849
|
|
|
840
850
|
### AgentDefinition
|
|
841
851
|
|
|
842
|
-
| Field | TypeScript | Python | Ruby | Notes
|
|
843
|
-
|
|
844
|
-
| `description` | ✅ | ✅ | ✅ | When to use agent
|
|
845
|
-
| `prompt` | ✅ | ✅ | ✅ | Agent system prompt
|
|
846
|
-
| `tools` | ✅ | ✅ | ✅ | Allowed tools
|
|
847
|
-
| `disallowedTools` | ✅ | ❌ | ✅ | Blocked tools
|
|
848
|
-
| `model` | ✅ | ✅ | ✅ | Model override (sonnet/opus/haiku/inherit)
|
|
849
|
-
| `mcpServers` | ✅ | ✅ | ✅ | Agent-specific MCP servers
|
|
850
|
-
| `criticalSystemReminder_EXPERIMENTAL` | ✅ | ❌ | ✅ | Critical reminder (experimental)
|
|
851
|
-
| `skills` | ✅ | ✅ | ✅ | Skills to preload into agent context
|
|
852
|
-
| `memory` | ❌ | ✅ | ❌ | Memory scope for agent (Python-only)
|
|
853
|
-
| `maxTurns` | ✅ | ❌ | ✅ | Max agentic turns before stopping
|
|
852
|
+
| Field | TypeScript | Python | Ruby | Notes |
|
|
853
|
+
|---------------------------------------|:----------:|:------:|:----:|----------------------------------------------|
|
|
854
|
+
| `description` | ✅ | ✅ | ✅ | When to use agent |
|
|
855
|
+
| `prompt` | ✅ | ✅ | ✅ | Agent system prompt |
|
|
856
|
+
| `tools` | ✅ | ✅ | ✅ | Allowed tools |
|
|
857
|
+
| `disallowedTools` | ✅ | ❌ | ✅ | Blocked tools |
|
|
858
|
+
| `model` | ✅ | ✅ | ✅ | Model override (sonnet/opus/haiku/inherit) |
|
|
859
|
+
| `mcpServers` | ✅ | ✅ | ✅ | Agent-specific MCP servers |
|
|
860
|
+
| `criticalSystemReminder_EXPERIMENTAL` | ✅ | ❌ | ✅ | Critical reminder (experimental) |
|
|
861
|
+
| `skills` | ✅ | ✅ | ✅ | Skills to preload into agent context |
|
|
862
|
+
| `memory` | ❌ | ✅ | ❌ | Memory scope for agent (Python-only v0.1.49) |
|
|
863
|
+
| `maxTurns` | ✅ | ❌ | ✅ | Max agentic turns before stopping |
|
|
854
864
|
|
|
855
865
|
---
|
|
856
866
|
|
|
@@ -938,7 +948,7 @@ Public API surface for SDK clients.
|
|
|
938
948
|
|------------------------|:----------:|:------:|:----:|--------------------------------------------|
|
|
939
949
|
| `listSessions()` | ✅ | ✅ | ✅ | List past sessions with metadata (v0.2.53) |
|
|
940
950
|
| `getSessionMessages()` | ✅ | ✅ | ✅ | Read session transcript (v0.2.59) |
|
|
941
|
-
| `getSessionInfo()` | ✅ |
|
|
951
|
+
| `getSessionInfo()` | ✅ | ✅ | ✅ | Get single session metadata (v0.2.75) |
|
|
942
952
|
| `renameSession()` | ✅ | ✅ | ✅ | Rename a session (v0.2.74) |
|
|
943
953
|
| `tagSession()` | ✅ | ✅ | ✅ | Tag a session (v0.2.75) |
|
|
944
954
|
| `forkSession()` | ✅ | ❌ | ✅ | Fork/branch a session (v0.2.76) |
|
|
@@ -1007,66 +1017,22 @@ Public API surface for SDK clients.
|
|
|
1007
1017
|
## Notes
|
|
1008
1018
|
|
|
1009
1019
|
### TypeScript SDK
|
|
1010
|
-
- Primary reference for API surface
|
|
1011
|
-
- Source is bundled/minified, but `sdk.d.ts` provides complete type definitions
|
|
1012
|
-
- Includes unstable V2 session API
|
|
1020
|
+
- Primary reference for API surface — `sdk.d.ts` provides complete type definitions
|
|
1013
1021
|
- `executable`/`executableArgs` are JS-specific (`node`/`bun`/`deno`)
|
|
1014
1022
|
- Does NOT have `user`, `init`/`initOnly`/`maintenance` as typed Options (use `extraArgs` or `settingSources`)
|
|
1015
|
-
- `
|
|
1016
|
-
- v0.2.45: Added `TaskStartedMessage`, `RateLimitEvent` message types
|
|
1017
|
-
- v0.2.47: Added `promptSuggestions` option and `PromptSuggestionMessage`
|
|
1018
|
-
- v0.2.49: Added `ConfigChange` hook event, `SandboxFilesystemConfig`, ModelInfo capability fields
|
|
1019
|
-
- v0.2.50: Added `WorktreeCreate`/`WorktreeRemove` hook events, `apply_flag_settings` control request
|
|
1020
|
-
- v0.2.51: Added `TaskProgressMessage`, `StopHookInput.last_assistant_message`, `SubagentStopHookInput.last_assistant_message`
|
|
1021
|
-
- v0.2.52: Added `mcp_authenticate`/`mcp_clear_auth` control requests for MCP server authentication
|
|
1022
|
-
- v0.2.53: Added `listSessions()` for discovering and listing past sessions with `SDKSessionInfo` metadata
|
|
1023
|
-
- v0.2.54 – v0.2.58: CLI parity updates (no new SDK-facing features)
|
|
1024
|
-
- v0.2.59: Added `getSessionMessages()` for reading session transcript history with pagination (limit/offset)
|
|
1025
|
-
- v0.2.61 – v0.2.62: CLI parity updates (no new SDK-facing features)
|
|
1026
|
-
- v0.2.63: Added `supportedAgents()` method on Query, fixed `pathToClaudeCodeExecutable` PATH resolution
|
|
1027
|
-
- v0.2.64 – v0.2.68: CLI parity updates (no new SDK-facing features)
|
|
1028
|
-
- v0.2.69: Added `toolConfig` option (askUserQuestion preview format), `supportsFastMode` in ModelInfo, `agent_id`/`agent_type` on BaseHookInput, `InstructionsLoaded` hook event
|
|
1029
|
-
- v0.2.70: Made `AgentToolInput.subagent_type` optional (defaults to general-purpose), fixed HTTP MCP servers
|
|
1030
|
-
- v0.2.71: CLI parity update; `settings` now a typed Option (string path or `Settings` object)
|
|
1031
|
-
- v0.2.72: Added `agentProgressSummaries` option for periodic AI-generated progress summaries
|
|
1032
|
-
- v0.2.73: Fixed `options.env` being overridden by `~/.claude/settings.json`
|
|
1033
|
-
- v0.2.74: Added `renameSession()` for renaming session files
|
|
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`
|
|
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`
|
|
1037
|
-
- Includes `Elicitation`/`ElicitationResult` hook events, `onElicitation` option, `ElicitationCompleteMessage`, `LocalCommandOutputMessage`, `FastModeState` (undocumented in changelog, present in types)
|
|
1023
|
+
- Some features present in types but undocumented in changelog: `StopFailure` hook, `Elicitation`/`ElicitationResult` hooks, `onElicitation` option, `ElicitationCompleteMessage`, `LocalCommandOutputMessage`, `FastModeState`
|
|
1038
1024
|
|
|
1039
1025
|
### Python SDK
|
|
1040
|
-
-
|
|
1041
|
-
-
|
|
1042
|
-
-
|
|
1043
|
-
-
|
|
1044
|
-
-
|
|
1045
|
-
-
|
|
1046
|
-
-
|
|
1047
|
-
- Has `agent_id`/`agent_type` on tool-lifecycle hook inputs (v0.1.46+)
|
|
1048
|
-
- Has `add_mcp_server()`/`remove_mcp_server()` client methods for runtime MCP management (v0.1.46+)
|
|
1049
|
-
- Has `include_worktrees` parameter on `list_sessions()` (v0.1.46+)
|
|
1050
|
-
- Missing hooks: SessionEnd, Setup, TeammateIdle, TaskCompleted, Elicitation, ElicitationResult, ConfigChange, WorktreeCreate, WorktreeRemove, InstructionsLoaded
|
|
1051
|
-
- Missing permission modes: `dontAsk`
|
|
1052
|
-
- Missing options: `allowDangerouslySkipPermissions`, `persistSession`, `resumeSessionAt`, `sessionId`, `strictMcpConfig`, `init`/`initOnly`/`maintenance`, `debug`/`debugFile`, `promptSuggestions`, `onElicitation`, `toolConfig`, `agentProgressSummaries`, `agent` (main thread agent)
|
|
1053
|
-
- `ToolPermissionContext` missing `blockedPath`, `decisionReason`, `toolUseID`, `agentID`, `description`
|
|
1054
|
-
- Has `rename_session()`/`tag_session()` for session mutation
|
|
1055
|
-
- Has `RateLimitEvent`/`RateLimitInfo` types with full field coverage
|
|
1056
|
-
- Has SDK MCP server support with `tool()` helper and annotations
|
|
1057
|
-
- Missing `getSessionInfo()`, `offset` on `list_sessions`, `tag`/`createdAt` on `SDKSessionInfo`
|
|
1058
|
-
- Added `thinking` config and `effort` option in v0.1.36
|
|
1059
|
-
- Handles `rate_limit_event` and unknown message types gracefully (v0.1.40)
|
|
1060
|
-
- Client has `get_server_info()` for accessing the initialization result (v0.1.31+)
|
|
1061
|
-
- v0.1.45 – v0.1.48: Major catch-up with TypeScript SDK (task messages, session APIs, MCP control methods, stop_reason)
|
|
1062
|
-
- v0.1.48: Fixed fine-grained tool streaming regression
|
|
1063
|
-
- Added `RateLimitEvent` message type with `RateLimitInfo`
|
|
1064
|
-
- Added `rename_session()` and `tag_session()` session management functions
|
|
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`
|
|
1026
|
+
- Partial control protocol: supports interrupt, setPermissionMode, setModel, rewindFiles, mcpStatus, reconnectMcp, toggleMcp, stopTask
|
|
1027
|
+
- Has `add_mcp_server()`/`remove_mcp_server()` client methods (not in TypeScript)
|
|
1028
|
+
- `AgentDefinition.memory` is Python-only (not in TypeScript or Ruby)
|
|
1029
|
+
- Missing hooks: SessionEnd, StopFailure, Setup, TeammateIdle, TaskCompleted, Elicitation, ElicitationResult, ConfigChange, WorktreeCreate, WorktreeRemove, InstructionsLoaded, PostCompact
|
|
1030
|
+
- Missing options: `allowDangerouslySkipPermissions`, `persistSession`, `resumeSessionAt`, `sessionId`, `strictMcpConfig`, `debug`/`debugFile`, `promptSuggestions`, `onElicitation`, `toolConfig`, `agentProgressSummaries`, `agent` (main thread agent), `dontAsk` permission mode
|
|
1031
|
+
- `ToolPermissionContext` missing `blockedPath`, `decisionReason`, `toolUseID`, `agentID`, `description`, `title`, `displayName`
|
|
1032
|
+
- Missing: `forkSession()`, `offset` on `list_sessions`, `cancel_async_message`, `get_settings`, `APIRetryMessage`
|
|
1067
1033
|
|
|
1068
1034
|
### Ruby SDK (This Repository)
|
|
1069
|
-
- Feature parity with TypeScript SDK v0.2.
|
|
1035
|
+
- Feature parity with TypeScript SDK v0.2.80
|
|
1070
1036
|
- Ruby-idiomatic patterns (Data.define, snake_case)
|
|
1071
1037
|
- Complete control protocol, hook, and V2 Session API support
|
|
1072
1038
|
- Dedicated Client class for multi-turn conversations
|
data/docs/hooks.md
CHANGED
|
@@ -64,11 +64,11 @@ When both global and per-conversation hooks are set, they are merged additively
|
|
|
64
64
|
|
|
65
65
|
Each hook method accepts an optional first argument that filters which tool names trigger the callback. The matcher is passed as the first positional argument, before any keyword arguments.
|
|
66
66
|
|
|
67
|
-
| Matcher type
|
|
68
|
-
|
|
69
|
-
| `nil` (omitted) | Catch-all, fires for every tool
|
|
70
|
-
| `String`
|
|
71
|
-
| `Regexp`
|
|
67
|
+
| Matcher type | Behavior | Example |
|
|
68
|
+
|-----------------|-----------------------------------|-----------------------------------------------------|
|
|
69
|
+
| `nil` (omitted) | Catch-all, fires for every tool | `h.before_tool_use { \|i, c\| ... }` |
|
|
70
|
+
| `String` | Treated as a regex pattern | `h.before_tool_use("Bash") { \|i, c\| ... }` |
|
|
71
|
+
| `Regexp` | Normalized to its `source` string | `h.before_tool_use(/Bash\|Write/) { \|i, c\| ... }` |
|
|
72
72
|
|
|
73
73
|
A `Regexp` is converted to its `.source` string internally so it can be serialized over the control protocol. This means flags like `Regexp::IGNORECASE` are not preserved.
|
|
74
74
|
|
|
@@ -133,7 +133,7 @@ end
|
|
|
133
133
|
|
|
134
134
|
## Event Mapping Table
|
|
135
135
|
|
|
136
|
-
All
|
|
136
|
+
All 23 hook events with their Ruby DSL method, CLI event name, and description:
|
|
137
137
|
|
|
138
138
|
| Ruby method | CLI event | Description |
|
|
139
139
|
|--------------------------|----------------------|-------------------------------------------------|
|
|
@@ -145,6 +145,7 @@ All 22 hook events with their Ruby DSL method, CLI event name, and description:
|
|
|
145
145
|
| `on_session_start` | `SessionStart` | When a session begins. |
|
|
146
146
|
| `on_session_end` | `SessionEnd` | When a session ends. |
|
|
147
147
|
| `on_stop` | `Stop` | When the agent stops. |
|
|
148
|
+
| `on_stop_failure` | `StopFailure` | When the agent stops due to an API error. |
|
|
148
149
|
| `on_subagent_start` | `SubagentStart` | When a subagent is spawned. |
|
|
149
150
|
| `on_subagent_stop` | `SubagentStop` | When a subagent stops. |
|
|
150
151
|
| `before_compact` | `PreCompact` | Before context compaction. |
|
|
@@ -190,6 +191,7 @@ All input types inherit these fields from `BaseHookInput`:
|
|
|
190
191
|
| `SessionStart` | `SessionStartInput` | `source`, `agent_type`, `model` |
|
|
191
192
|
| `SessionEnd` | `SessionEndInput` | `reason` |
|
|
192
193
|
| `Stop` | `StopInput` | `stop_hook_active`, `last_assistant_message` |
|
|
194
|
+
| `StopFailure` | `StopFailureInput` | `error`, `error_details`, `last_assistant_message` |
|
|
193
195
|
| `SubagentStart` | `SubagentStartInput` | `agent_id`, `agent_type` |
|
|
194
196
|
| `SubagentStop` | `SubagentStopInput` | `stop_hook_active`, `agent_id`, `agent_transcript_path`, `agent_type`, `last_assistant_message` |
|
|
195
197
|
| `PreCompact` | `PreCompactInput` | `trigger`, `custom_instructions` |
|
data/docs/messages.md
CHANGED
|
@@ -61,7 +61,7 @@ end
|
|
|
61
61
|
|
|
62
62
|
## Message Types
|
|
63
63
|
|
|
64
|
-
|
|
64
|
+
24 message types, grouped by category.
|
|
65
65
|
|
|
66
66
|
### Conversation Messages
|
|
67
67
|
|
|
@@ -223,6 +223,28 @@ Methods:
|
|
|
223
223
|
- `trigger` -- compaction trigger type (`"manual"` or `"auto"`)
|
|
224
224
|
- `pre_tokens` -- token count before compaction
|
|
225
225
|
|
|
226
|
+
#### APIRetryMessage
|
|
227
|
+
|
|
228
|
+
Emitted when an API request fails with a retryable error and will be retried.
|
|
229
|
+
|
|
230
|
+
```ruby
|
|
231
|
+
APIRetryMessage = Data.define(:uuid, :session_id, :attempt, :max_retries, :retry_delay_ms, :error_status, :error)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
| Field | Type | Default |
|
|
235
|
+
|------------------|----------------|---------|
|
|
236
|
+
| `uuid` | `String` | `""` |
|
|
237
|
+
| `session_id` | `String` | `""` |
|
|
238
|
+
| `attempt` | `Integer` | `0` |
|
|
239
|
+
| `max_retries` | `Integer` | `0` |
|
|
240
|
+
| `retry_delay_ms` | `Integer` | `0` |
|
|
241
|
+
| `error_status` | `Integer, nil` | `nil` |
|
|
242
|
+
| `error` | `String, nil` | `nil` |
|
|
243
|
+
|
|
244
|
+
Methods:
|
|
245
|
+
|
|
246
|
+
- `type` -- `:api_retry`
|
|
247
|
+
|
|
226
248
|
#### StatusMessage
|
|
227
249
|
|
|
228
250
|
Session status report (e.g., `"compacting"`).
|
data/lib/claude_agent/hooks.rb
CHANGED
|
@@ -11,6 +11,7 @@ module ClaudeAgent
|
|
|
11
11
|
SessionStart
|
|
12
12
|
SessionEnd
|
|
13
13
|
Stop
|
|
14
|
+
StopFailure
|
|
14
15
|
SubagentStart
|
|
15
16
|
SubagentStop
|
|
16
17
|
PreCompact
|
|
@@ -175,6 +176,10 @@ module ClaudeAgent
|
|
|
175
176
|
BaseHookInput.define_input "Stop",
|
|
176
177
|
optional: { stop_hook_active: false, last_assistant_message: nil }
|
|
177
178
|
|
|
179
|
+
BaseHookInput.define_input "StopFailure",
|
|
180
|
+
required: [ :error ],
|
|
181
|
+
optional: { error_details: nil, last_assistant_message: nil }
|
|
182
|
+
|
|
178
183
|
BaseHookInput.define_input "SubagentStart",
|
|
179
184
|
required: [ :agent_id, :agent_type ]
|
|
180
185
|
|
data/lib/claude_agent/version.rb
CHANGED
data/sig/claude_agent.rbs
CHANGED
|
@@ -1003,6 +1003,14 @@ module ClaudeAgent
|
|
|
1003
1003
|
def initialize: (?stop_hook_active: bool, ?last_assistant_message: String?, **untyped) -> void
|
|
1004
1004
|
end
|
|
1005
1005
|
|
|
1006
|
+
class StopFailureInput < BaseHookInput
|
|
1007
|
+
attr_reader error: String
|
|
1008
|
+
attr_reader error_details: String?
|
|
1009
|
+
attr_reader last_assistant_message: String?
|
|
1010
|
+
|
|
1011
|
+
def initialize: (error: String, ?error_details: String?, ?last_assistant_message: String?, **untyped) -> void
|
|
1012
|
+
end
|
|
1013
|
+
|
|
1006
1014
|
class SubagentStartInput < BaseHookInput
|
|
1007
1015
|
attr_reader agent_id: String
|
|
1008
1016
|
attr_reader agent_type: String
|