Class: Silas::Connection::RemoteTool

Inherits:
Object
  • Object
show all
Defined in:
lib/silas/connection.rb

Overview

One remote tool, resolved. Quacks like a resolved Silas::Tool for the Ledger (approval_policy / effect_mode / session= / call) without being a Silas::Tool subclass — its schema is the remote inputSchema.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection:, remote_name:, client: nil) ⇒ RemoteTool

Returns a new instance of RemoteTool.



78
79
80
81
82
# File 'lib/silas/connection.rb', line 78

def initialize(connection:, remote_name:, client: nil)
  @connection = connection
  @remote_name = remote_name
  @client = client || connection.client
end

Instance Attribute Details

#sessionObject

Returns the value of attribute session.



76
77
78
# File 'lib/silas/connection.rb', line 76

def session
  @session
end

Instance Method Details

#approval_policyObject



84
# File 'lib/silas/connection.rb', line 84

def approval_policy = @connection.approval

#call(**args) ⇒ Object



87
88
89
90
# File 'lib/silas/connection.rb', line 87

def call(**args)
  @client.call_tool(@remote_name, args.deep_stringify_keys) ||
    { "isError" => true, "content" => [ { "type" => "text", "text" => "no result" } ] }
end

#effect_modeObject



85
# File 'lib/silas/connection.rb', line 85

def effect_mode     = @connection.effect