Class: Phronomy::Agent::ToolInvocationSessionBuilder Private

Inherits:
Object
  • Object
show all
Defined in:
lib/phronomy/agent/tool_invocation_session_builder.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Builds an FSMSession for one ToolInvocation.

Authorization and execution Tasks are observed by ToolInvocation-specific callbacks that post explicit FSM events. The generated phase machine does not await Tasks.

Constant Summary collapse

AUTO_STATE_SET =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  idle: true,
  validating: true,
  queued: true
}.freeze
DECLARED_STATES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[
  idle validating authorizing awaiting_approval authorized queued running
  completed failed rejected cancelled
].freeze
WAIT_STATES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%i[awaiting_approval authorized].freeze
EXTERNAL_EVENTS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

{
  authorization_completed: [
    {from: :authorizing, to: :cancelled, guard: ->(ctx) {
      ctx.cancelled?
    }},
    {from: :authorizing, to: :failed, guard: ->(ctx) {
      ctx.failed?
    }},
    {from: :authorizing, to: :rejected, guard: ->(ctx) {
      ctx.rejected?
    }},
    {from: :authorizing, to: :awaiting_approval, guard: ->(ctx) {
      ctx.awaiting_approval?
    }},
    {from: :authorizing, to: :authorized, guard: ->(ctx) {
      ctx.authorized?
    }}
  ],
  execution_completed: [
    {from: :running, to: :cancelled, guard: ->(ctx) {
      ctx.cancelled?
    }},
    {from: :running, to: :failed, guard: ->(ctx) {
      ctx.failed?
    }},
    {from: :running, to: :completed, guard: ->(ctx) {
      ctx.execution_completed?
    }}
  ],
  approve: [
    {from: :awaiting_approval, to: :authorized, guard: nil}
  ],
  reject: [
    {from: :awaiting_approval, to: :rejected, guard: nil}
  ],
  dispatch: [
    {from: :authorized, to: :queued, guard: nil}
  ],
  cancel: [
    {from: :awaiting_approval, to: :cancelled, guard: nil},
    {from: :authorized, to: :cancelled, guard: nil},
    {from: :queued, to: :cancelled, guard: nil},
    {from: :running, to: :cancelled, guard: nil}
  ]
}.freeze

Class Method Summary collapse

Class Method Details

.build(tool_invocation:, runtime: Phronomy::Runtime.instance) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



74
75
76
77
78
79
80
81
82
# File 'lib/phronomy/agent/tool_invocation_session_builder.rb', line 74

def self.build(
  tool_invocation:,
  runtime: Phronomy::Runtime.instance
)
  build_session(
    tool_invocation: tool_invocation,
    runtime: runtime
  )
end

.build_for_resume(tool_invocation:, resume_event:, resume_phase:, runtime: Phronomy::Runtime.instance) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/phronomy/agent/tool_invocation_session_builder.rb', line 84

def self.build_for_resume(
  tool_invocation:,
  resume_event:,
  resume_phase:,
  runtime: Phronomy::Runtime.instance
)
  build_session(
    tool_invocation: tool_invocation,
    runtime: runtime,
    resume_event: resume_event,
    resume_phase: resume_phase
  )
end