refactor: Padronizar a passagem de argumentos para métodos de ferramentas Captain usando um hash flexível.

This commit is contained in:
Rodrigo Borba 2026-01-15 14:22:28 -03:00
parent 6d98ff0322
commit 445a7d663a
5 changed files with 10 additions and 5 deletions

View File

@ -14,7 +14,8 @@ module Captain
super(assistant, user: user)
end
def execute(emoji:)
def execute(args = {})
emoji = args[:emoji] || args['emoji']
return error_response('Conversation not found') unless @conversation.present?
return error_response('Emoji is required') if emoji.blank?

View File

@ -2,7 +2,8 @@ class Captain::Tools::AddContactNoteTool < Captain::Tools::BasePublicTool
description 'Add a note to a contact profile'
param :note, type: 'string', desc: 'The note content to add to the contact'
def perform(tool_context, note:)
def perform(tool_context, args = {})
note = args[:note] || args['note']
contact = find_contact(tool_context.state)
return 'Contact not found' unless contact

View File

@ -2,7 +2,8 @@ class Captain::Tools::AddLabelToConversationTool < Captain::Tools::BasePublicToo
description 'Add a label to a conversation'
param :label_name, type: 'string', desc: 'The name of the label to add'
def perform(tool_context, label_name:)
def perform(tool_context, args = {})
label_name = args[:label_name] || args['label_name']
conversation = find_conversation(tool_context.state)
return 'Conversation not found' unless conversation

View File

@ -2,7 +2,8 @@ class Captain::Tools::AddPrivateNoteTool < Captain::Tools::BasePublicTool
description 'Add a private note to a conversation'
param :note, type: 'string', desc: 'The private note content'
def perform(tool_context, note:)
def perform(tool_context, args = {})
note = args[:note] || args['note']
conversation = find_conversation(tool_context.state)
return 'Conversation not found' unless conversation

View File

@ -2,7 +2,8 @@ class Captain::Tools::UpdatePriorityTool < Captain::Tools::BasePublicTool
description 'Update the priority of a conversation'
param :priority, type: 'string', desc: 'The priority level: low, medium, high, urgent, or nil to remove priority'
def perform(tool_context, priority:)
def perform(tool_context, args = {})
priority = args[:priority] || args['priority']
@conversation = find_conversation(tool_context.state)
return 'Conversation not found' unless @conversation