| 1 | package Praxo::Agent; | ||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Praxo::Json (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Praxo::Models (); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Praxo::Errors qw(praxo_error error_code); | ||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||
| 10 | 1 | our @EXPORT_OK = qw(run_agent); | |||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||
| 12 | package Praxo::Agent::FuncTool; | ||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||
| 15 | 0 | my ($class, $name, $description, $function, $parameters, $risk) = @_; | |||||||||||||||||||||||||||||||||||||
| 16 | 0 | ▶ | return bless { | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$name // ""
$description // ""
MC/DC0%0/1
$name // ""
$name
MC/DC0%0/1
$description // ""
$description
Truth table0%0/2
A
A= $name
Truth table0%0/2
A
A= $description
| |||||||||||||||||||||||||||||||||||||||
| 17 | name => $name // '', | ||||||||||||||||||||||||||||||||||||||
| 18 | description => $description // '', | ||||||||||||||||||||||||||||||||||||||
| 19 | function => $function, | ||||||||||||||||||||||||||||||||||||||
| 20 | parameters => $parameters, | ||||||||||||||||||||||||||||||||||||||
| 21 | risk => $risk, | ||||||||||||||||||||||||||||||||||||||
| 22 | }, $class; | ||||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||
| 25 | 0 | ▶ | sub name { $_[0]->{name} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
name: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | sub description { $_[0]->{description} } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
description: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub invoke { $_[0]->{function}->($_[1]) } | ||||||||||||||||||||||||||||||||||||
|
Subroutine
invoke: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||
| 29 | package Praxo::Agent::ToolRegistry; | ||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 32 | 0 | my ($class) = @_; | |||||||||||||||||||||||||||||||||||||
| 33 | 0 | return bless { tools => {} }, $class; | |||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | sub register { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
register: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 37 | 0 | my ($self, $tool) = @_; | |||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | my $name = ref($tool) ? $tool->name : $tool->{name}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 39 | 0 | $self->{tools}{$name} = $tool; | |||||||||||||||||||||||||||||||||||||
| 40 | 0 | return $tool; | |||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||
| 43 | 0 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 44 | 0 | my ($self, $name) = @_; | |||||||||||||||||||||||||||||||||||||
| 45 | Praxo::Errors::praxo_error('TOOL_NOT_FOUND', "tool not found: $name") | ||||||||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | unless exists $self->{tools}{$name}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 47 | 0 | return $self->{tools}{$name}; | |||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub specs { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
specs: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||
| 51 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||
| 52 | my @specs = map { | ||||||||||||||||||||||||||||||||||||||
| 53 | 0 | ▶ | my $name = ref($_) ? $_->name : $_->{name}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 54 | 0 | ▶ | my $description = ref($_) ? $_->description : $_->{description}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my ($parameters, $risk); | |||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | if (ref($_) && ref($_) ne 'HASH') { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $_ and ref $_ ne "HASH"
MC/DC0%0/2
ref $_ and ref $_ ne "HASH"
ref $_
ref $_ ne "HASH"
Truth table0%0/3
A and B
A= ref $_B= ref $_ ne "HASH"
| |||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $parameters = $_->can('parameters') ? $_->parameters : $_->{parameters}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | $risk = $_->can('risk') ? $_->risk : $_->{risk}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 59 | } else { | ||||||||||||||||||||||||||||||||||||||
| 60 | 0 | $parameters = $_->{parameters}; | |||||||||||||||||||||||||||||||||||||
| 61 | 0 | $risk = $_->{risk}; | |||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||
| 63 | 0 | Praxo::Models::tool_spec( | |||||||||||||||||||||||||||||||||||||
| 64 | name => $name, | ||||||||||||||||||||||||||||||||||||||
| 65 | description => $description, | ||||||||||||||||||||||||||||||||||||||
| 66 | parameters => $parameters, | ||||||||||||||||||||||||||||||||||||||
| 67 | risk => $risk, | ||||||||||||||||||||||||||||||||||||||
| 68 | ) | ||||||||||||||||||||||||||||||||||||||
| 69 | 0 | } values %{ $self->{tools} }; | |||||||||||||||||||||||||||||||||||||
| 70 | 0 | return [ sort { $a->{name} cmp $b->{name} } @specs ]; | |||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||
| 73 | package Praxo::Agent::AgentOptions; | ||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my ($class, $model) = @_; | |||||||||||||||||||||||||||||||||||||
| 77 | 0 | return bless { | |||||||||||||||||||||||||||||||||||||
| 78 | model => $model, | ||||||||||||||||||||||||||||||||||||||
| 79 | tools => undef, | ||||||||||||||||||||||||||||||||||||||
| 80 | events => undef, | ||||||||||||||||||||||||||||||||||||||
| 81 | policy => undef, | ||||||||||||||||||||||||||||||||||||||
| 82 | system_prompt => '', | ||||||||||||||||||||||||||||||||||||||
| 83 | context => undef, | ||||||||||||||||||||||||||||||||||||||
| 84 | max_steps => 8, | ||||||||||||||||||||||||||||||||||||||
| 85 | max_tokens => 0, | ||||||||||||||||||||||||||||||||||||||
| 86 | tool_choice => undef, | ||||||||||||||||||||||||||||||||||||||
| 87 | allowed_tools => [], | ||||||||||||||||||||||||||||||||||||||
| 88 | on_delta => undef, | ||||||||||||||||||||||||||||||||||||||
| 89 | require_policy => 0, | ||||||||||||||||||||||||||||||||||||||
| 90 | require_tool_scope => 0, | ||||||||||||||||||||||||||||||||||||||
| 91 | interrupt_on => [], | ||||||||||||||||||||||||||||||||||||||
| 92 | on_interrupt_decision => undef, | ||||||||||||||||||||||||||||||||||||||
| 93 | on_interrupt => undef, | ||||||||||||||||||||||||||||||||||||||
| 94 | }, $class; | ||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||
| 97 | package Praxo::Agent::StaticModel; | ||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my ($class, $content) = @_; | |||||||||||||||||||||||||||||||||||||
| 101 | 0 | ▶ | return bless { content => $content // '' }, $class; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$content // ""
MC/DC0%0/1
$content // ""
$content
Truth table0%0/2
A
A= $content
| |||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub generate { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
generate: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my ($self, $request) = @_; | |||||||||||||||||||||||||||||||||||||
| 106 | return Praxo::Models::response( | ||||||||||||||||||||||||||||||||||||||
| 107 | 0 | message => Praxo::Models::message_assistant($self->{content}), | |||||||||||||||||||||||||||||||||||||
| 108 | ); | ||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||
| 111 | package Praxo::Agent::Agent; | ||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my ($class, $options) = @_; | |||||||||||||||||||||||||||||||||||||
| 115 | Praxo::Errors::praxo_error( | ||||||||||||||||||||||||||||||||||||||
| 116 | 'AGENT_INVALID_OPTIONS', | ||||||||||||||||||||||||||||||||||||||
| 117 | 'agent: require policy: policy is required', | ||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | ) if $options->{require_policy} && !$options->{policy}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options->{"require_policy"} and not $options->{"policy"}
MC/DC0%0/2
$options->{"require_policy"} and not $options->{"policy"}
$options->{"require_policy"}
not $options->{"policy"}
Truth table0%0/3
A and not(B)
A= $options->{"require_policy"}B= not $options->{"policy"}
| |||||||||||||||||||||||||||||||||||||||
| 119 | Praxo::Errors::praxo_error( | ||||||||||||||||||||||||||||||||||||||
| 120 | 'AGENT_INVALID_OPTIONS', | ||||||||||||||||||||||||||||||||||||||
| 121 | 'agent: require tool scope: allowed_tools must not be empty', | ||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | ) if $options->{require_tool_scope} && !@{ $options->{allowed_tools} // [] }; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$options->{"require_tool_scope"} and not @{$options->{"allowed_tools"} // [];}
$options->{"allowed_tools"} // []
MC/DC0%0/2
$options->{"require_tool_scope"} and not @{$options->{"allowed_tools"} // [];}
$options->{"require_tool_scope"}
not @{$options->{"allowed_tools"} // [];}
MC/DC0%0/1
$options->{"allowed_tools"} // []
$options->{"allowed_tools"}
Truth table0%0/3
A and not(B)
A= $options->{"require_tool_scope"}B= not @{$options->{"allowed_tools"} // [];}
Truth table0%0/2
A
A= $options->{"allowed_tools"}
| |||||||||||||||||||||||||||||||||||||||
| 123 | 0 | return bless { options => $options }, $class; | |||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | sub run { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
run: not called CC=25 SCAR=64.8
| |||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my ($self, $session, $prompt) = @_; | |||||||||||||||||||||||||||||||||||||
| 128 | 0 | my $options = $self->{options}; | |||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | my $max_steps = ($options->{max_steps} // 0) > 0 ? $options->{max_steps} : 8; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$options->{"max_steps"} // 0
MC/DC0%0/1
$options->{"max_steps"} // 0
$options->{"max_steps"}
Truth table0%0/2
A
A= $options->{"max_steps"}
| |||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $run_id = 'run-' . int(time() * 1000); | |||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | my @messages = @{ $session->{messages} // [] }; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$session->{"messages"} // []
MC/DC0%0/1
$session->{"messages"} // []
$session->{"messages"}
Truth table0%0/2
A
A= $session->{"messages"}
| |||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if (length($options->{system_prompt} // '')) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$options->{"system_prompt"} // ""
MC/DC0%0/1
$options->{"system_prompt"} // ""
$options->{"system_prompt"}
Truth table0%0/2
A
A= $options->{"system_prompt"}
| |||||||||||||||||||||||||||||||||||||||
| 133 | unshift @messages, Praxo::Models::message_text( | ||||||||||||||||||||||||||||||||||||||
| 134 | Praxo::Models::SYSTEM, $options->{system_prompt}, | ||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ); | |||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | push @messages, Praxo::Models::message_text(Praxo::Models::USER, $prompt // ''); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$prompt // ""
MC/DC0%0/1
$prompt // ""
$prompt
Truth table0%0/2
A
A= $prompt
| |||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $usage = Praxo::Models::usage(); | |||||||||||||||||||||||||||||||||||||
| 139 | 0 | _emit($options, 'run.started', $session->{id}, $run_id); | |||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $step = 0; | |||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||
| 143 | 0 | for $step (1 .. $max_steps) { | |||||||||||||||||||||||||||||||||||||
| 144 | _authorize($options, Praxo::Models::action( | ||||||||||||||||||||||||||||||||||||||
| 145 | kind => 'model.generate', session_id => $session->{id}, | ||||||||||||||||||||||||||||||||||||||
| 146 | 0 | )); | |||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if ($options->{context}) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my ($compacted, $context_ok) = $options->{context}->compact(\@messages); | |||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | Praxo::Errors::praxo_error('AGENT_CONTEXT_BUDGET', 'context budget') unless $context_ok; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 150 | 0 | @messages = @$compacted; | |||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||
| 152 | my $request = Praxo::Models::request( | ||||||||||||||||||||||||||||||||||||||
| 153 | messages => \@messages, | ||||||||||||||||||||||||||||||||||||||
| 154 | tools => $options->{tools} ? $options->{tools}->specs() : [], | ||||||||||||||||||||||||||||||||||||||
| 155 | tool_choice => $options->{tool_choice}, | ||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 157 | my $response = $options->{on_delta} && $options->{model}->can('generate_stream') | ||||||||||||||||||||||||||||||||||||||
| 158 | ? $options->{model}->generate_stream($request, $options->{on_delta}) | ||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | : $options->{model}->generate($request); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$options->{"on_delta"} and $options->{"model"}->can("generate_stream")
MC/DC0%0/2
$options->{"on_delta"} and $options->{"model"}->can("generate_stream")
$options->{"on_delta"}
$options->{"model"}->can("generate_stream")
Truth table0%0/3
A and B
A= $options->{"on_delta"}B= $options->{"model"}->can("generate_stream")
| |||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $usage = Praxo::Models::usage_plus($usage, $response->{usage} // {}); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$response->{"usage"} // {}
MC/DC0%0/1
$response->{"usage"} // {}
$response->{"usage"}
Truth table0%0/2
A
A= $response->{"usage"}
| |||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | my $total = ($usage->{inputTokens} // 0) + ($usage->{outputTokens} // 0); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$usage->{"inputTokens"} // 0
$usage->{"outputTokens"} // 0
MC/DC0%0/1
$usage->{"inputTokens"} // 0
$usage->{"inputTokens"}
MC/DC0%0/1
$usage->{"outputTokens"} // 0
$usage->{"outputTokens"}
Truth table0%0/2
A
A= $usage->{"inputTokens"}
Truth table0%0/2
A
A= $usage->{"outputTokens"}
| |||||||||||||||||||||||||||||||||||||||
| 162 | Praxo::Errors::praxo_error('AGENT_MAX_TOKENS', 'token budget') | ||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if ($options->{max_tokens} // 0) > 0 && $total > $options->{max_tokens}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
($options->{"max_tokens"} // 0) > 0 and $total > $options->{"max_tokens"}
$options->{"max_tokens"} // 0
MC/DC0%0/2
($options->{"max_tokens"} // 0) > 0 and $total > $options->{"max_tokens"}
$options->{"max_tokens"}
$total > $options->{"max_tokens"}
Truth table0%0/3
A and B
A= $options->{"max_tokens"}B= $total > $options->{"max_tokens"}
| |||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $message = $response->{message}; | |||||||||||||||||||||||||||||||||||||
| 165 | 0 | push @messages, $message; | |||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | my $calls = $message->{toolCalls} // []; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$message->{"toolCalls"} // []
MC/DC0%0/1
$message->{"toolCalls"} // []
$message->{"toolCalls"}
Truth table0%0/2
A
A= $message->{"toolCalls"}
| |||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if (!@$calls) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 168 | 0 | _emit($options, 'run.completed', $session->{id}, $run_id); | |||||||||||||||||||||||||||||||||||||
| 169 | $result = Praxo::Models::run_result( | ||||||||||||||||||||||||||||||||||||||
| 170 | run_id => $run_id, | ||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | output => $message->{content} // '', | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$message->{"content"} // ""
MC/DC0%0/1
$message->{"content"} // ""
$message->{"content"}
Truth table0%0/2
A
A= $message->{"content"}
| |||||||||||||||||||||||||||||||||||||||
| 172 | steps => $step, | ||||||||||||||||||||||||||||||||||||||
| 173 | usage => $usage, | ||||||||||||||||||||||||||||||||||||||
| 174 | ); | ||||||||||||||||||||||||||||||||||||||
| 175 | 0 | last; | |||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||
| 177 | 0 | for my $call (@$calls) { | |||||||||||||||||||||||||||||||||||||
| 178 | 0 | push @messages, _invoke_tool($options, $call, $run_id, $session->{id}); | |||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | if (!$result) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 182 | 0 | Praxo::Errors::praxo_error('AGENT_MAX_STEPS', 'maximum steps'); | |||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||
| 184 | 0 | 1; | |||||||||||||||||||||||||||||||||||||
| 185 | }; | ||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my $error = $@; | |||||||||||||||||||||||||||||||||||||
| 188 | 0 | _emit($options, 'run.failed', $session->{id}, $run_id, { | |||||||||||||||||||||||||||||||||||||
| 189 | error => "$error", | ||||||||||||||||||||||||||||||||||||||
| 190 | }); | ||||||||||||||||||||||||||||||||||||||
| 191 | 0 | die $error; | |||||||||||||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||||||||||||
| 193 | 0 | return $result; | |||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||
| 196 | 0 | ▶ | sub _invoke_tool { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_invoke_tool: not called CC=14 SCAR=53.5
| |||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my ($options, $call, $run_id, $session_id) = @_; | |||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $original_name = $call->{name}; | |||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | my $original_arguments = _deep_copy($call->{arguments} // {}); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$call->{"arguments"} // {}
MC/DC0%0/1
$call->{"arguments"} // {}
$call->{"arguments"}
Truth table0%0/2
A
A= $call->{"arguments"}
| |||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | Praxo::Errors::praxo_error( | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 201 | 'AGENT_INVALID_OPTIONS', | ||||||||||||||||||||||||||||||||||||||
| 202 | "agent: tool $original_name is not allowed", | ||||||||||||||||||||||||||||||||||||||
| 203 | ) unless _tool_allowed($options, $original_name); | ||||||||||||||||||||||||||||||||||||||
| 204 | 0 | _authorize($options, Praxo::Models::action( | |||||||||||||||||||||||||||||||||||||
| 205 | kind => 'tool.invoke', session_id => $session_id, | ||||||||||||||||||||||||||||||||||||||
| 206 | tool_name => $original_name, arguments => $original_arguments, | ||||||||||||||||||||||||||||||||||||||
| 207 | )); | ||||||||||||||||||||||||||||||||||||||
| 208 | Praxo::Errors::praxo_error('TOOL_NOT_FOUND', 'tool is not registered') | ||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | unless $options->{tools}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 210 | Praxo::Errors::praxo_error( | ||||||||||||||||||||||||||||||||||||||
| 211 | 'AGENT_INVALID_OPTIONS', | ||||||||||||||||||||||||||||||||||||||
| 212 | "agent: tool $call->{name} is not allowed", | ||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | ) unless _tool_allowed($options, $call->{name}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 214 | 0 | my ($skip, $result) = _apply_interrupt( | |||||||||||||||||||||||||||||||||||||
| 215 | $options, $call, $run_id, $session_id, | ||||||||||||||||||||||||||||||||||||||
| 216 | ); | ||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | if ($skip) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 218 | return Praxo::Models::message_tool( | ||||||||||||||||||||||||||||||||||||||
| 219 | Praxo::Json::stringify($result // ''), | ||||||||||||||||||||||||||||||||||||||
| 220 | 0 | ▶ | $call->{id} // '', | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$result // ""
$call->{"id"} // ""
MC/DC0%0/1
$result // ""
$result
MC/DC0%0/1
$call->{"id"} // ""
$call->{"id"}
Truth table0%0/2
A
A= $result
Truth table0%0/2
A
A= $call->{"id"}
| |||||||||||||||||||||||||||||||||||||||
| 221 | ); | ||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | if ($call->{name} ne $original_name | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$call->{"name"} ne $original_name or not Praxo::Json::equals($call->{"arguments"} // {}, $original_arguments)
$call->{"arguments"} // {}
MC/DC0%0/2
$call->{"name"} ne $original_name or not Praxo::Json::equals($call->{"arguments"} // {}, $original_arguments)
$call->{"name"} ne $original_name
not Praxo::Json::equals($call->{"arguments"} // {}, $original_arguments)
MC/DC0%0/1
$call->{"arguments"} // {}
$call->{"arguments"}
Truth table0%0/3
A or not(B)
A= $call->{"name"} ne $original_nameB= not Praxo::Json::equals($call->{"arguments"} // {}, $original_arguments)
Truth table0%0/2
A
A= $call->{"arguments"}
| |||||||||||||||||||||||||||||||||||||||
| 224 | || !Praxo::Json::equals($call->{arguments} // {}, $original_arguments)) { | ||||||||||||||||||||||||||||||||||||||
| 225 | _authorize($options, Praxo::Models::action( | ||||||||||||||||||||||||||||||||||||||
| 226 | kind => 'tool.invoke', session_id => $session_id, | ||||||||||||||||||||||||||||||||||||||
| 227 | tool_name => $call->{name}, arguments => $call->{arguments}, | ||||||||||||||||||||||||||||||||||||||
| 228 | 0 | )); | |||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||
| 230 | 0 | my $tool = $options->{tools}->get($call->{name}); | |||||||||||||||||||||||||||||||||||||
| 231 | _emit($options, 'tool.call', $session_id, $run_id, { | ||||||||||||||||||||||||||||||||||||||
| 232 | name => $call->{name}, arguments => $call->{arguments} // {}, | ||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | }); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$call->{"arguments"} // {}
MC/DC0%0/1
$call->{"arguments"} // {}
$call->{"arguments"}
Truth table0%0/2
A
A= $call->{"arguments"}
| |||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | my $value = $tool->invoke($call->{arguments} // {}); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$call->{"arguments"} // {}
MC/DC0%0/1
$call->{"arguments"} // {}
$call->{"arguments"}
Truth table0%0/2
A
A= $call->{"arguments"}
| |||||||||||||||||||||||||||||||||||||||
| 235 | return Praxo::Models::message_tool( | ||||||||||||||||||||||||||||||||||||||
| 236 | Praxo::Json::stringify($value), | ||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | $call->{id} // '', | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$call->{"id"} // ""
MC/DC0%0/1
$call->{"id"} // ""
$call->{"id"}
Truth table0%0/2
A
A= $call->{"id"}
| |||||||||||||||||||||||||||||||||||||||
| 238 | ); | ||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub _apply_interrupt { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_interrupt: not called CC=16 SCAR=56.1
| |||||||||||||||||||||||||||||||||||||||
| 242 | 0 | my ($options, $call, $run_id, $session_id) = @_; | |||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | return (0, undef) unless _interrupt_on($options, $call->{name}); | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $handler = $options->{on_interrupt_decision}; | |||||||||||||||||||||||||||||||||||||
| 245 | 0 | my $approval = $options->{on_interrupt}; | |||||||||||||||||||||||||||||||||||||
| 246 | Praxo::Errors::praxo_error( | ||||||||||||||||||||||||||||||||||||||
| 247 | 'AGENT_INTERRUPT_UNHANDLED', | ||||||||||||||||||||||||||||||||||||||
| 248 | 'agent: approval handler not configured: ' . $call->{name}, | ||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | ) unless $handler || $approval; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$handler or $approval
MC/DC0%0/2
$handler or $approval
$handler
$approval
Truth table0%0/3
A or B
A= $handlerB= $approval
| |||||||||||||||||||||||||||||||||||||||
| 250 | _emit($options, 'tool.interrupt', $session_id, $run_id, { | ||||||||||||||||||||||||||||||||||||||
| 251 | name => $call->{name}, | ||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | arguments => _deep_copy($call->{arguments} // {}), | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$call->{"arguments"} // {}
MC/DC0%0/1
$call->{"arguments"} // {}
$call->{"arguments"}
Truth table0%0/2
A
A= $call->{"arguments"}
| |||||||||||||||||||||||||||||||||||||||
| 253 | }); | ||||||||||||||||||||||||||||||||||||||
| 254 | 0 | my $interrupt = Praxo::Models::interrupt( | |||||||||||||||||||||||||||||||||||||
| 255 | run_id => $run_id, | ||||||||||||||||||||||||||||||||||||||
| 256 | session_id => $session_id, | ||||||||||||||||||||||||||||||||||||||
| 257 | call => $call, | ||||||||||||||||||||||||||||||||||||||
| 258 | ); | ||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if ($handler) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $decision = $handler->($interrupt); | |||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | Praxo::Errors::praxo_error( | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 262 | 'AGENT_INTERRUPT_DECISION_INVALID', | ||||||||||||||||||||||||||||||||||||||
| 263 | 'agent: invalid interrupt decision', | ||||||||||||||||||||||||||||||||||||||
| 264 | ) unless ref($decision) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | my $action = $decision->{action} // ''; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$decision->{"action"} // ""
MC/DC0%0/1
$decision->{"action"} // ""
$decision->{"action"}
Truth table0%0/2
A
A= $decision->{"action"}
| |||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ($action eq Praxo::Models::INTERRUPT_APPROVE()) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 267 | 0 | return (0, undef); | |||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if ($action eq Praxo::Models::INTERRUPT_EDIT()) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 270 | Praxo::Errors::praxo_error( | ||||||||||||||||||||||||||||||||||||||
| 271 | 'AGENT_INTERRUPT_DECISION_INVALID', | ||||||||||||||||||||||||||||||||||||||
| 272 | 'agent: edit requires arguments', | ||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | ) unless defined $decision->{arguments}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $call->{arguments} = _deep_copy($decision->{arguments}); | |||||||||||||||||||||||||||||||||||||
| 275 | 0 | return (0, undef); | |||||||||||||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ($action eq Praxo::Models::INTERRUPT_REJECT()) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 278 | Praxo::Errors::praxo_error( | ||||||||||||||||||||||||||||||||||||||
| 279 | 'AGENT_APPROVAL_DENIED', | ||||||||||||||||||||||||||||||||||||||
| 280 | 'agent: tool call denied by approval: ' . $call->{name} | ||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | . ': ' . ($decision->{reason} // ''), | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$decision->{"reason"} // ""
MC/DC0%0/1
$decision->{"reason"} // ""
$decision->{"reason"}
Truth table0%0/2
A
A= $decision->{"reason"}
| |||||||||||||||||||||||||||||||||||||||
| 282 | ); | ||||||||||||||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | if ($action eq Praxo::Models::INTERRUPT_RESPOND()) { | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | return (1, $decision->{response} // ''); | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$decision->{"response"} // ""
MC/DC0%0/1
$decision->{"response"} // ""
$decision->{"response"}
Truth table0%0/2
A
A= $decision->{"response"}
| |||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||
| 287 | Praxo::Errors::praxo_error( | ||||||||||||||||||||||||||||||||||||||
| 288 | 0 | 'AGENT_INTERRUPT_DECISION_INVALID', | |||||||||||||||||||||||||||||||||||||
| 289 | 'agent: invalid interrupt decision: ' . $action, | ||||||||||||||||||||||||||||||||||||||
| 290 | ); | ||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $approved = $approval->($interrupt); | |||||||||||||||||||||||||||||||||||||
| 293 | Praxo::Errors::praxo_error( | ||||||||||||||||||||||||||||||||||||||
| 294 | 'AGENT_APPROVAL_DENIED', | ||||||||||||||||||||||||||||||||||||||
| 295 | 'agent: tool call denied by approval: ' . $call->{name}, | ||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | ) unless $approved; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 297 | 0 | return (0, undef); | |||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | sub _tool_allowed { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_tool_allowed: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 301 | 0 | my ($options, $name) = @_; | |||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | my $allowed = $options->{allowed_tools} // []; | ||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options->{"allowed_tools"} // []
MC/DC0%0/1
$options->{"allowed_tools"} // []
$options->{"allowed_tools"}
Truth table0%0/2
A
A= $options->{"allowed_tools"}
| |||||||||||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | return 1 unless ref($allowed) eq 'ARRAY' && @$allowed; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $allowed eq "ARRAY" and @$allowed
MC/DC0%0/2
ref $allowed eq "ARRAY" and @$allowed
ref $allowed eq "ARRAY"
@$allowed
Truth table0%0/3
A and B
A= ref $allowed eq "ARRAY"B= @$allowed
| |||||||||||||||||||||||||||||||||||||||
| 304 | 0 | return scalar grep { $_ eq $name } @$allowed; | |||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | sub _interrupt_on { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_interrupt_on: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my ($options, $name) = @_; | |||||||||||||||||||||||||||||||||||||
| 309 | 0 | my $on = $options->{interrupt_on}; | |||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | return 0 unless defined $on; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | return exists $on->{$name} ? 1 : 0 if ref($on) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | return scalar grep { $_ eq $name } @$on if ref($on) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | return $on eq $name ? 1 : 0 unless ref($on); | ||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||
| 314 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | sub _deep_copy { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_deep_copy: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | return undef unless defined $value; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 320 | 0 | return Praxo::Json::parse(Praxo::Json::stringify($value)); | |||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | sub _authorize { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_authorize: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my ($options, $action) = @_; | |||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | return unless $options->{policy}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $decision = $options->{policy}->($action); | |||||||||||||||||||||||||||||||||||||
| 327 | Praxo::Errors::praxo_error('POLICY_ERROR', 'policy denied the action') | ||||||||||||||||||||||||||||||||||||||
| 328 | 0 | ▶ | unless ref($decision) eq 'HASH' && $decision->{allowed}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $decision eq "HASH" and $decision->{"allowed"}
MC/DC0%0/2
ref $decision eq "HASH" and $decision->{"allowed"}
ref $decision eq "HASH"
$decision->{"allowed"}
Truth table0%0/3
A and B
A= ref $decision eq "HASH"B= $decision->{"allowed"}
| |||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub _emit { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
_emit: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||
| 332 | 0 | my ($options, $type, $session_id, $run_id, $data) = @_; | |||||||||||||||||||||||||||||||||||||
| 333 | 0 | ▶ | return unless $options->{events}; | ||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $options->{events}->emit(Praxo::Models::event( | |||||||||||||||||||||||||||||||||||||
| 335 | type => $type, session_id => $session_id, run_id => $run_id, data => $data, | ||||||||||||||||||||||||||||||||||||||
| 336 | )); | ||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||
| 339 | package Praxo::Agent; | ||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||
| 341 | 0 | ▶ | sub run_agent { | ||||||||||||||||||||||||||||||||||||
|
Subroutine
run_agent: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my ($options, $session, $prompt) = @_; | |||||||||||||||||||||||||||||||||||||
| 343 | 0 | return Praxo::Agent::Agent->new($options)->run($session, $prompt); | |||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||
| 346 | 1 | 1; | |||||||||||||||||||||||||||||||||||||