Class: Nexo::Tools::Glob

Inherits:
RubyLLM::Tool
  • Object
show all
Defined in:
lib/nexo/tools/glob.rb

Overview

Lists workspace files matching a glob pattern. Authorizes :glob first; a denial is returned as { error: ... }.

Instance Method Summary collapse

Constructor Details

#initialize(sandbox:, permissions:) ⇒ Glob

sandbox performs the match; permissions gates the :glob capability.



12
13
14
15
16
# File 'lib/nexo/tools/glob.rb', line 12

def initialize(sandbox:, permissions:)
  @sandbox = sandbox
  @permissions = permissions
  super()
end

Instance Method Details

#execute(pattern:) ⇒ Object

Authorizes :glob, then returns { files: [...] } matching pattern — or { error: ... } on a denial.



20
21
22
23
24
25
# File 'lib/nexo/tools/glob.rb', line 20

def execute(pattern:)
  @permissions.authorize!(:glob, pattern)
  {files: @sandbox.glob(pattern)}
rescue Permissions::Denied => e
  {error: e.message}
end