Class: RubynCode::Tools::SendMessage

Inherits:
Base
  • Object
show all
Defined in:
lib/rubyn_code/tools/send_message.rb

Overview

Tool for sending messages to teammates via the team mailbox.

Constant Summary collapse

TOOL_NAME =
'send_message'
DESCRIPTION =
'Sends a message to a teammate. Used for inter-agent communication within a team.'
PARAMETERS =
{
  to: { type: :string, required: true, description: 'Name of the recipient teammate' },
  content: { type: :string, required: true, description: 'Message content to send' },
  message_type: { type: :string, required: false, default: 'message',
                  description: 'Type of message (default: "message")' }
}.freeze
RISK_LEVEL =
:write
REQUIRES_CONFIRMATION =
false

Instance Attribute Summary

Attributes inherited from Base

#project_root

Instance Method Summary collapse

Methods inherited from Base

description, parameters, requires_confirmation?, risk_level, #safe_path, summarize, to_schema, tool_name, #truncate

Constructor Details

#initialize(project_root:, mailbox:, sender_name:) ⇒ SendMessage

Returns a new instance of SendMessage.

Parameters:

  • project_root (String)
  • mailbox (Teams::Mailbox)

    the team mailbox instance

  • sender_name (String)

    the name of the sending agent



24
25
26
27
28
# File 'lib/rubyn_code/tools/send_message.rb', line 24

def initialize(project_root:, mailbox:, sender_name:)
  super(project_root: project_root)
  @mailbox = mailbox
  @sender_name = sender_name
end

Instance Method Details

#execute(to:, content:, message_type: 'message') ⇒ String

Sends a message to the specified teammate.

Parameters:

  • to (String)

    recipient name

  • content (String)

    message body

  • message_type (String) (defaults to: 'message')

    type of message

Returns:

  • (String)

    confirmation with the message id

Raises:



36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/rubyn_code/tools/send_message.rb', line 36

def execute(to:, content:, message_type: 'message')
  raise Error, 'Recipient name is required' if to.nil? || to.strip.empty?
  raise Error, 'Message content is required' if content.nil? || content.strip.empty?

  message_id = @mailbox.send(
    from: @sender_name,
    to: to,
    content: content,
    message_type: message_type
  )

  "Message sent to '#{to}' (id: #{message_id}, type: #{message_type})"
end