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.



62
63
64
65
66
# File 'lib/silas/connection.rb', line 62

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.



60
61
62
# File 'lib/silas/connection.rb', line 60

def session
  @session
end

Instance Method Details

#approval_policyObject



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

def approval_policy = @connection.approval

#call(**args) ⇒ Object



71
72
73
74
# File 'lib/silas/connection.rb', line 71

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

#effect_modeObject



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

def effect_mode     = @connection.effect