Class: AgentCliRuntime::NormalizedOutcome

Inherits:
Data
  • Object
show all
Defined in:
lib/agent_cli_runtime/values.rb

Constant Summary collapse

KINDS =
%i[
  completed authentication_failure configuration_failure cli_failure
  malformed_output cancelled timed_out
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider:, launcher_identity:, kind:, termination:, final_message: nil, identity:, usage: nil, diagnostic: nil, unknown_events: [], session_id: nil, message_id: nil, final_message_truncated: false) ⇒ NormalizedOutcome

Returns a new instance of NormalizedOutcome.



569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
# File 'lib/agent_cli_runtime/values.rb', line 569

def initialize(provider:, launcher_identity:, kind:, termination:,
               final_message: nil, identity:, usage: nil, diagnostic: nil,
               unknown_events: [], session_id: nil, message_id: nil,
               final_message_truncated: false)
  normalized_kind = kind.to_sym
  unless KINDS.include?(normalized_kind)
    raise ArgumentError, "invalid normalized outcome kind"
  end
  unless termination.is_a?(TerminationEvidence)
    raise ArgumentError, "termination must be TerminationEvidence"
  end
  unless identity.is_a?(RouteIdentity)
    raise ArgumentError, "identity must be RouteIdentity"
  end
  unless usage.nil? || usage.is_a?(NormalizedUsage)
    raise ArgumentError, "usage must be NormalizedUsage or nil"
  end

  super(
    provider: provider.to_sym,
    launcher_identity: Immutable.string(launcher_identity),
    kind: normalized_kind,
    termination: termination,
    final_message:
      final_message.nil? ? nil : Immutable.string(final_message),
    final_message_truncated: final_message_truncated == true,
    identity: identity,
    usage: usage,
    diagnostic: diagnostic.nil? ? nil : Immutable.string(diagnostic),
    unknown_events: Immutable.strings(unknown_events),
    session_id: session_id.nil? ? nil : Immutable.string(session_id),
    message_id: message_id.nil? ? nil : Immutable.string(message_id)
  )
end

Instance Attribute Details

#diagnosticObject (readonly)

Returns the value of attribute diagnostic

Returns:

  • (Object)

    the current value of diagnostic



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def diagnostic
  @diagnostic
end

#final_messageObject (readonly)

Returns the value of attribute final_message

Returns:

  • (Object)

    the current value of final_message



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def final_message
  @final_message
end

#final_message_truncatedObject (readonly)

Returns the value of attribute final_message_truncated

Returns:

  • (Object)

    the current value of final_message_truncated



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def final_message_truncated
  @final_message_truncated
end

#identityObject (readonly)

Returns the value of attribute identity

Returns:

  • (Object)

    the current value of identity



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def identity
  @identity
end

#kindObject (readonly)

Returns the value of attribute kind

Returns:

  • (Object)

    the current value of kind



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def kind
  @kind
end

#launcher_identityObject (readonly)

Returns the value of attribute launcher_identity

Returns:

  • (Object)

    the current value of launcher_identity



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def launcher_identity
  @launcher_identity
end

#message_idObject (readonly)

Returns the value of attribute message_id

Returns:

  • (Object)

    the current value of message_id



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def message_id
  @message_id
end

#providerObject (readonly)

Returns the value of attribute provider

Returns:

  • (Object)

    the current value of provider



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def provider
  @provider
end

#session_idObject (readonly)

Returns the value of attribute session_id

Returns:

  • (Object)

    the current value of session_id



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def session_id
  @session_id
end

#terminationObject (readonly)

Returns the value of attribute termination

Returns:

  • (Object)

    the current value of termination



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def termination
  @termination
end

#unknown_eventsObject (readonly)

Returns the value of attribute unknown_events

Returns:

  • (Object)

    the current value of unknown_events



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def unknown_events
  @unknown_events
end

#usageObject (readonly)

Returns the value of attribute usage

Returns:

  • (Object)

    the current value of usage



559
560
561
# File 'lib/agent_cli_runtime/values.rb', line 559

def usage
  @usage
end

Instance Method Details

#completed?Boolean

Returns:

  • (Boolean)


604
605
606
# File 'lib/agent_cli_runtime/values.rb', line 604

def completed?
  kind == :completed
end