claude_agent 0.7.8 → 0.7.9
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 +57 -0
- data/README.md +551 -37
- data/SPEC.md +63 -28
- data/lib/claude_agent/client.rb +181 -7
- data/lib/claude_agent/content_blocks.rb +193 -5
- data/lib/claude_agent/control_protocol.rb +97 -11
- data/lib/claude_agent/conversation.rb +248 -0
- data/lib/claude_agent/cumulative_usage.rb +106 -0
- data/lib/claude_agent/event_handler.rb +152 -0
- data/lib/claude_agent/hooks.rb +104 -253
- data/lib/claude_agent/list_sessions.rb +508 -0
- data/lib/claude_agent/mcp/server.rb +3 -3
- data/lib/claude_agent/mcp/tool.rb +4 -4
- data/lib/claude_agent/message_parser.rb +201 -185
- data/lib/claude_agent/messages.rb +86 -13
- data/lib/claude_agent/options.rb +5 -4
- data/lib/claude_agent/permission_queue.rb +87 -0
- data/lib/claude_agent/permission_request.rb +151 -0
- data/lib/claude_agent/permissions.rb +4 -2
- data/lib/claude_agent/query.rb +34 -0
- data/lib/claude_agent/tool_activity.rb +78 -0
- data/lib/claude_agent/turn_result.rb +239 -0
- data/lib/claude_agent/types.rb +29 -0
- data/lib/claude_agent/version.rb +1 -1
- data/lib/claude_agent.rb +39 -1
- data/sig/claude_agent.rbs +271 -4
- metadata +9 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 90d9094d4e4428fc7dfc1e452759403a92f2e4badf5d1ac5f2f90e950c511255
|
|
4
|
+
data.tar.gz: fd2a8407c794aa672a4b03a774a6573dac3682bc09b8fe666170b90f5bd9f79a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ce7d705ebe01a38ad1ac86a8caeaabd700831e200e73f134c9adef507b6f7b695effece63ae902849ee408714c3ae576930012dbbefe2b05da403d0de8549317
|
|
7
|
+
data.tar.gz: 7f06c5b0b5ed5ad798442672ad8ca969a0fdefc414a4c273e86911df0e171d24d5a378b9a88117bd3c60092a6affb5219d06cc58dd0107245643b571e2236440
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,63 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.7.9] - 2026-02-25
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `Conversation` — high-level wrapper managing the full conversation lifecycle with auto-connect, multi-turn history, callbacks, and tool activity timeline
|
|
14
|
+
- `Conversation#say(prompt)` — send a message and receive a `TurnResult`, auto-connecting on first call
|
|
15
|
+
- `Conversation.open { |c| ... }` — block form with automatic cleanup
|
|
16
|
+
- `Conversation.resume(session_id)` — resume a previous conversation
|
|
17
|
+
- `Conversation` callbacks: `on_text`, `on_stream`, `on_tool_use`, `on_tool_result`, `on_thinking`, `on_result`, `on_message`, `on_permission`
|
|
18
|
+
- `Conversation#total_cost`, `#session_id`, `#usage`, `#pending_permission`, `#pending_permissions?` — convenience accessors
|
|
19
|
+
- `ClaudeAgent.conversation(**kwargs)` and `ClaudeAgent.resume_conversation(session_id)` — module-level convenience methods
|
|
20
|
+
- `ToolActivity` — immutable `Data.define` pairing a `ToolUseBlock` with its `ToolResultBlock`, turn index, and timing; delegates `name`, `display_label`, `summary`, `file_path`, `id` to the tool use block
|
|
21
|
+
- `Conversation#tool_activity` — unified timeline of all tool executions across turns with duration tracking
|
|
22
|
+
- `PermissionRequest` — deferred permission promise that can be resolved from any thread via `allow!` / `deny!`, with `defer!` for hybrid callback/queue mode
|
|
23
|
+
- `PermissionQueue` — thread-safe queue of pending `PermissionRequest` objects with `poll`, `pop(timeout:)`, and `drain!`
|
|
24
|
+
- `Client#permission_queue` — returns the queue; always available on connected clients
|
|
25
|
+
- `Client#pending_permission` — non-blocking poll for the next pending permission request
|
|
26
|
+
- `Client#pending_permissions?` — check if any permission requests are waiting
|
|
27
|
+
- `Options#permission_queue` — set to `true` to enable queue-based permissions (auto-sets `permission_prompt_tool_name: "stdio"`)
|
|
28
|
+
- `ToolPermissionContext#request` — access the `PermissionRequest` from within a `can_use_tool` callback for hybrid defer mode
|
|
29
|
+
- `ControlProtocol` now supports three permission modes: synchronous callback, queue-based, and hybrid (callback with selective `defer!`)
|
|
30
|
+
- `TurnResult` — represents a complete agent turn, accumulating all messages between sending a prompt and receiving the `ResultMessage`
|
|
31
|
+
- `TurnResult#text`, `#thinking` — concatenated text/thinking across all assistant messages
|
|
32
|
+
- `TurnResult#tool_uses`, `#tool_results`, `#tool_executions` — tool use blocks, result blocks, and matched use/result pairs
|
|
33
|
+
- `TurnResult#usage`, `#cost`, `#duration_ms`, `#session_id`, `#model`, `#success?`, `#error?` — convenient accessors from the result
|
|
34
|
+
- `Client#send_and_receive(content)` — send a message and receive the complete `TurnResult` in one call
|
|
35
|
+
- `Client#receive_turn` — like `receive_response` but returns a `TurnResult` instead of yielding raw messages
|
|
36
|
+
- `ClaudeAgent.query_turn(prompt:)` — one-shot query returning a `TurnResult`
|
|
37
|
+
- `EventHandler` — register typed event callbacks (`:text`, `:thinking`, `:tool_use`, `:tool_result`, `:result`, `:message`) instead of writing `case` statements over raw messages
|
|
38
|
+
- `Client#on(event, &block)` and `#on_text`, `#on_tool_use`, `#on_tool_result`, `#on_result`, etc. — register persistent event handlers that fire during `receive_turn` and `send_and_receive`
|
|
39
|
+
- `ClaudeAgent.query_turn` now accepts `events:` parameter for standalone `EventHandler` use
|
|
40
|
+
- `TaskProgressMessage` for real-time background task (subagent) progress reporting (TypeScript SDK v0.2.51 parity)
|
|
41
|
+
- `mcp_authenticate` control request on `ControlProtocol` and `Client` for MCP server OAuth authentication (TypeScript SDK v0.2.52 parity)
|
|
42
|
+
- `mcp_clear_auth` control request on `ControlProtocol` and `Client` for clearing MCP server credentials (TypeScript SDK v0.2.52 parity)
|
|
43
|
+
- RBS signatures for all new types and methods
|
|
44
|
+
- `CumulativeUsage` — built-in cumulative usage tracking across conversation turns; automatically updated by `Client` as `ResultMessage`s are received
|
|
45
|
+
- `Client#cumulative_usage` — returns the usage accumulator with `input_tokens`, `output_tokens`, `cache_read_input_tokens`, `cache_creation_input_tokens`, `total_cost_usd`, `num_turns`, `duration_ms`, `duration_api_ms`
|
|
46
|
+
- `GenericMessage` type — wraps unknown top-level message types instead of raising `MessageParseError`, with dynamic field access via `[]` and `method_missing`
|
|
47
|
+
- `GenericBlock` type — wraps unknown content block types instead of returning raw Hashes, with dynamic field access via `[]` and `method_missing`
|
|
48
|
+
- `ToolUseBlock#file_path` — returns the file path for file-based tools (`Read`, `Write`, `Edit`, `NotebookEdit`), nil otherwise
|
|
49
|
+
- `ToolUseBlock#display_label` — one-line human-readable label (e.g. `"Read lib/foo.rb"`, `"Bash: git status"`, `"WebFetch: example.com"`)
|
|
50
|
+
- `ToolUseBlock#summary(max:)` — detailed summary with truncation (e.g. `"Write: /path.rb (3 lines)"`, `"Grep: pattern in /path (*.rb)"`)
|
|
51
|
+
- `ServerToolUseBlock#file_path`, `#display_label`, `#summary(max:)` — same interface with server context (e.g. `"server_name/tool_name"`)
|
|
52
|
+
|
|
53
|
+
### Changed
|
|
54
|
+
- `BaseHookInput.define_input` — declarative macro for generating hook input subclasses from a single declaration; replaces 18 hand-written classes with one-line definitions
|
|
55
|
+
- `MessageParser` now uses a registry pattern (`MessageParser.register`) instead of nested `case` statements for message routing; adding a new message type is one `register` call
|
|
56
|
+
- `MessageParser#parse` no longer raises `MessageParseError` for unknown message types; returns `GenericMessage` instead
|
|
57
|
+
- `MessageParser#parse_content_block` no longer returns raw Hashes for unknown content block types; returns `GenericBlock` instead
|
|
58
|
+
- All parsed message hashes now use snake_case symbol keys throughout (e.g. `msg.usage[:input_tokens]`, `event.files.first[:filename]`, `event.event[:type]`)
|
|
59
|
+
- `MessageParser#parse` applies a single `deep_transform_keys` pass that normalizes camelCase→snake_case and string→symbol for the entire hash tree
|
|
60
|
+
- `can_use_tool` callbacks receive symbol-keyed `input` hashes
|
|
61
|
+
- Hook callbacks receive symbol-keyed `input` hashes
|
|
62
|
+
- MCP tool handlers receive symbol-keyed `arguments` hashes
|
|
63
|
+
|
|
64
|
+
### Removed
|
|
65
|
+
- `MessageParser#fetch_dual` — no longer needed now that keys are normalized at the entry point
|
|
66
|
+
|
|
10
67
|
## [0.7.8] - 2026-02-22
|
|
11
68
|
|
|
12
69
|
### Added
|