Class: Ask::AppServer::EmittingApprovalQueue

Inherits:
Ask::Agent::ApprovalQueue
  • Object
show all
Defined in:
lib/ask/app_server/agent_adapter.rb

Overview

Approval queue that emits canonical approval events through the session's EventTranslator whenever actions are submitted or change status, so clients can stream approval state in real time.

The session wires its own apply/reject/submit callbacks onto the queue (see Session#build_approval); this subclass only adds observation hooks on top, using its own listeners so the session's on_submit (pending-tool registration) is never clobbered.

Instance Method Summary collapse

Constructor Details

#initialize(on_submit: nil, on_status: nil, **kwargs) ⇒ EmittingApprovalQueue

Returns a new instance of EmittingApprovalQueue.

Parameters:

  • on_submit (Proc, nil) (defaults to: nil)

    called with the new Action after submission (and after the auto-approval drain)

  • on_status (Proc, nil) (defaults to: nil)

    called with an Action whose status changed to :approved or :rejected



361
362
363
364
365
# File 'lib/ask/app_server/agent_adapter.rb', line 361

def initialize(on_submit: nil, on_status: nil, **kwargs)
  @on_action_submitted = on_submit
  @on_status = on_status
  super(**kwargs)
end

Instance Method Details

#submit(tool_call_id:, tool_name:, args: {}, auto_approvable: false, message: nil) ⇒ Object



367
368
369
370
371
# File 'lib/ask/app_server/agent_adapter.rb', line 367

def submit(tool_call_id:, tool_name:, args: {}, auto_approvable: false, message: nil)
  id = super
  @on_action_submitted&.call(self[id])
  id
end