Exception: Nexo::ApprovalRequired

Inherits:
StandardError
  • Object
show all
Defined in:
lib/nexo.rb

Overview

Control-flow signal raised by the :approve permission gate (Spec 16) when a capability needs a human decision and none has been threaded in yet. Unlike Permissions::Denied ("no, adapt" — tools rescue it into {error:}), ApprovalRequired means "pause and ask a human": tools must not rescue it, so it propagates out of the ruby_llm tool loop and out of Agent#prompt, where Workflow#run_agent catches it and turns it into a durable Workflow#suspend!. It subclasses StandardError directly (not Error), mirroring Permissions::Denied's base — it is a signal, not a library-misuse error. Carries the pending call's capability, detail (the tool/path), and args so a host can render the approval prompt from run.state["__approval__"].

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(capability, detail = nil, args = nil) ⇒ ApprovalRequired

Builds the signal for capability acting on detail with args; the message reads "approval required for ()".



51
52
53
54
55
56
# File 'lib/nexo.rb', line 51

def initialize(capability, detail = nil, args = nil)
  @capability = capability
  @detail = detail
  @args = args
  super("approval required for #{capability} (#{detail})")
end

Instance Attribute Details

#argsObject (readonly)

The pending call's capability (e.g. :write), its detail (the tool/path), and the tool args — enough for a host to render the approval prompt.



47
48
49
# File 'lib/nexo.rb', line 47

def args
  @args
end

#capabilityObject (readonly)

The pending call's capability (e.g. :write), its detail (the tool/path), and the tool args — enough for a host to render the approval prompt.



47
48
49
# File 'lib/nexo.rb', line 47

def capability
  @capability
end

#detailObject (readonly)

The pending call's capability (e.g. :write), its detail (the tool/path), and the tool args — enough for a host to render the approval prompt.



47
48
49
# File 'lib/nexo.rb', line 47

def detail
  @detail
end