Class: Phronomy::Agent::ToolInvocationSessionBuilder
- Inherits:
-
Object
- Object
- Phronomy::Agent::ToolInvocationSessionBuilder
- Defined in:
- lib/phronomy/agent/tool_invocation_session_builder.rb
Overview
Builds an FSMSession for one ToolInvocation. Async completion is represented only by explicit FSM events.
Constant Summary collapse
- AUTO_STATE_SET =
{idle: true, validating: true, queued: true}.freeze
- DECLARED_STATES =
%i[ idle validating authorizing awaiting_approval authorized queued running completed failed rejected cancelled ].freeze
- WAIT_STATES =
%i[awaiting_approval authorized].freeze
- EXTERNAL_EVENTS =
{ 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. }} ], 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
- .build(tool_invocation:, runtime: Phronomy::Runtime.instance) ⇒ Object
- .build_for_resume(tool_invocation:, resume_event:, resume_phase:, runtime: Phronomy::Runtime.instance) ⇒ Object
Class Method Details
.build(tool_invocation:, runtime: Phronomy::Runtime.instance) ⇒ Object
43 44 45 |
# File 'lib/phronomy/agent/tool_invocation_session_builder.rb', line 43 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
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/phronomy/agent/tool_invocation_session_builder.rb', line 47 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 |