Class: RubynCode::Tools::ReadInbox
- Defined in:
- lib/rubyn_code/tools/read_inbox.rb
Overview
Tool for reading unread messages from a teammate’s inbox.
Constant Summary collapse
- TOOL_NAME =
'read_inbox'- DESCRIPTION =
"Reads all unread messages from the agent's inbox and marks them as read."- PARAMETERS =
{ name: { type: :string, required: true, description: 'The agent name whose inbox to read' } }.freeze
- RISK_LEVEL =
:read- REQUIRES_CONFIRMATION =
false
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#execute(name:) ⇒ String
Reads and returns all unread messages for the given agent.
-
#initialize(project_root:, mailbox:) ⇒ ReadInbox
constructor
A new instance of ReadInbox.
Methods inherited from Base
description, parameters, requires_confirmation?, risk_level, #safe_path, summarize, to_schema, tool_name, #truncate
Constructor Details
#initialize(project_root:, mailbox:) ⇒ ReadInbox
Returns a new instance of ReadInbox.
20 21 22 23 |
# File 'lib/rubyn_code/tools/read_inbox.rb', line 20 def initialize(project_root:, mailbox:) super(project_root: project_root) @mailbox = mailbox end |
Instance Method Details
#execute(name:) ⇒ String
Reads and returns all unread messages for the given agent.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rubyn_code/tools/read_inbox.rb', line 29 def execute(name:) raise Error, 'Agent name is required' if name.nil? || name.strip.empty? = @mailbox.read_inbox(name) return "No unread messages for '#{name}'." if .empty? formatted = .map.with_index(1) do |msg, idx| (idx, msg) end header = "#{.size} message#{'s' if .size != 1} for '#{name}':\n" header + formatted.join("\n") end |