Agent/Options.pm

filter: Statementstmt 93.9% 62 / 66 Branchbran 86.6% 26 / 30 Conditioncond 68.7% 11 / 16 MC/DCmcdc 25.0% 2 / 8 Subroutinesub 100% 11 / 11 Podpod 75.0% 3 / 4 totaltotal 85.1% 115 / 135 CC 26 SCAR 22.1
CC
26
Cov
88%
BUILD
14.2
to_hash
10.6
with
5.0
CRAP 9.1
« Agent/MCP/StdioServer.pm ↑ Summary Agent/Logger.pm »
1 package Claude::Agent::Options;
2  
3 11 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 11 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use Object::Proto ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use Claude::Agent::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 11 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
12 11 Object::Proto::define('Claude::Agent::Options',
13 'allowed_tools:StrList:predicate',
14 'disallowed_tools:StrList:predicate',
15 'tools:predicate',
16 'system_prompt:StrOrHashRef:predicate',
17 'permission_mode:PermissionMode:predicate',
18 'permission_prompt_tool_name:Str:predicate',
19 'can_use_tool:CodeRef:predicate',
20 'mcp_servers:HashRef:predicate',
21 'strict_mcp_config:Bool:predicate',
22 'hooks:HashRef:predicate',
23 'agents:HashRef:predicate',
24 'cwd:Str:predicate',
25 'add_dirs:StrList:predicate',
26 'env:HashRef:predicate',
27 'model:Str:predicate',
28 'fallback_model:Str:predicate',
29 'effort:Effort:predicate',
30 'thinking:HashRef:predicate',
31 'max_thinking_tokens:Int:predicate',
32 'betas:StrList:predicate',
33 'max_turns:Int:predicate',
34 'max_budget_usd:Num:predicate',
35 'resume:Str:predicate',
36 'continue_conversation:Bool:predicate',
37 'session_id:Str:predicate',
38 'fork_session:Bool:predicate',
39 'output_format:predicate',
40 'settings:StrOrHashRef:predicate',
41 'setting_sources:StrList:predicate',
42 'sandbox:HashRef:predicate',
43 'plugins:ArrayRef:predicate',
44 'include_partial_messages:Bool:predicate',
45 'include_hook_events:Bool:predicate',
46 'forward_subagent_text:Bool:predicate',
47 'enable_file_checkpointing:Bool:predicate',
48 'extra_args:HashRef:predicate',
49 'stderr:CodeRef:predicate',
50 'cli_path:Str:predicate',
51 'query_timeout:Int:default(600):predicate',
52 'dry_run:Bool:predicate',
53 'on_dry_run:CodeRef:predicate',
54 );
55 }
56  
57 11 my %CAMEL = (
58 allowed_tools => 'allowedTools',
59 disallowed_tools => 'disallowedTools',
60 system_prompt => 'systemPrompt',
61 permission_mode => 'permissionMode',
62 permission_prompt_tool_name => 'permissionPromptToolName',
63 strict_mcp_config => 'strictMcpConfig',
64 add_dirs => 'addDirs',
65 fallback_model => 'fallbackModel',
66 max_thinking_tokens => 'maxThinkingTokens',
67 max_turns => 'maxTurns',
68 max_budget_usd => 'maxBudgetUsd',
69 continue_conversation => 'continueConversation',
70 session_id => 'sessionId',
71 fork_session => 'forkSession',
72 output_format => 'outputFormat',
73 setting_sources => 'settingSources',
74 include_partial_messages => 'includePartialMessages',
75 include_hook_events => 'includeHookEvents',
76 forward_subagent_text => 'forwardSubagentText',
77 enable_file_checkpointing => 'enableFileCheckpointing',
78 extra_args => 'extraArgs',
79 cli_path => 'cliPath',
80 query_timeout => 'queryTimeout',
81 dry_run => 'dryRun',
82 );
83  
84 11 my %SKIP_IN_HASH = map { $_ => 1 } qw(can_use_tool hooks stderr on_dry_run);
85  
86 104 ▶sub BUILD {
Subroutine BUILD: called CC=14 SCAR=26.5
Pod undocumented
87 104 my ($self) = @_;
88 104 ▶ if ($self->has_session_id) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_session_id) 3 101 104
89 3 my $id = $self->session_id;
90 3 ▶ Carp::croak("session_id must be a UUID, not '$id'")
Branch: 1 branch
BranchTrueFalseTotal
unless $id =~ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu 1 2 3
91 unless $id =~ /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
92 }
93 103 ▶ if ($self->has_can_use_tool && $self->has_permission_prompt_tool_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_can_use_tool and $self->has_permission_prompt_tool_name) 1 102 103
Condition100%3/3
$self->has_can_use_tool and $self->has_permission_prompt_tool_name
!ll&&!rl&&r
9481
MC/DC100%2/2
$self->has_can_use_tool and $self->has_permission_prompt_tool_name
$self->has_can_use_tool $self->has_permission_prompt_tool_name
Truth table100%3/3
A and B
A= $self->has_can_use_toolB= $self->has_permission_prompt_tool_name
ABresult
0X0
100
111
94 1 Carp::croak("can_use_tool and permission_prompt_tool_name cannot both be set");
95 }
96 102 ▶ if ($self->has_thinking) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_thinking) 5 97 102
97 5 ▶ my $type = $self->thinking->{type} // '';
Condition50%1/2
$self->thinking->{"type"} // ""
l!l
50
MC/DC0%0/1
$self->thinking->{"type"} // ""
$self->thinking->{"type"}
Truth table50%1/2
A
A= $self->thinking->{"type"}
Aresult
11
00
98 5 ▶ Carp::croak("thinking->{type} must be adaptive, enabled or disabled, not '$type'")
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /^(?:adaptive|enabled|disabled)$/u 1 4 5
99 unless $type =~ /^(?:adaptive|enabled|disabled)$/;
100 }
101 101 ▶ if ($self->has_plugins) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_plugins) 3 98 101
102 3 for my $plugin (@{$self->plugins}) {
103 Carp::croak("plugins entries are hashrefs with type => 'local' and a path")
104 unless ref $plugin eq 'HASH'
105 && ($plugin->{type} // 'local') eq 'local'
106 4 ▶ && defined $plugin->{path};
Branch: 1 branch
BranchTrueFalseTotal
unless ref $plugin eq "HASH" and ($plugin->{"type"} // "local") eq "local" and defined $plugin->{"path"} 1 3 4
Condition62%5/8
ref $plugin eq "HASH" and ($plugin->{"type"} // "local") eq "local" and defined $plugin->{"path"}
!ll&&!rl&&r
103
ref $plugin eq "HASH" and ($plugin->{"type"} // "local") eq "local"
!ll&&!rl&&r
013
$plugin->{"type"} // "local"
l!l
40
MC/DC0%0/3
ref $plugin eq "HASH" and ($plugin->{"type"} // "local") eq "local" and defined $plugin->{"path"}
ref $plugin eq "HASH" $plugin->{"type"} defined $plugin->{"path"}
Truth table25%1/4
A and B and C
A= ref $plugin eq "HASH"B= $plugin->{"type"}C= defined $plugin->{"path"}
ABCresult
0XX0
10X0
1100
1111
107 }
108 }
109 100 return;
110 }
111  
112 6 ▶sub create {
Subroutine create: called CC=1 SCAR=0.0
Pod documented
113 6 my ($class, %args) = @_;
114 6 return $class->new(Claude::Agent::Types::check_args($class, %args));
115 }
116  
117 3 ▶sub with {
Subroutine with: called CC=5 SCAR=16.1
Pod documented
118 3 my ($self, %overrides) = @_;
119 3 my %args;
120 3 for my $name (Object::Proto::properties(ref $self)) {
121 123 my $has = "has_$name";
122 123 ▶ $args{$name} = $self->$name if $self->$has;
Branch: 1 branch
BranchTrueFalseTotal
if $self->$has 7 116 123
123 }
124 3 for my $name (keys %overrides) {
125 6 ▶ if (defined $overrides{$name}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $overrides{$name}) { } 5 1 6
126 5 $args{$name} = $overrides{$name};
127 }
128 else {
129 1 delete $args{$name};
130 }
131 }
132 3 return (ref $self)->create(%args);
133 }
134  
135 4 ▶sub to_hash {
Subroutine to_hash: called CC=9 SCAR=23.6
Pod documented
136 4 my ($self) = @_;
137  
138 4 my %hash;
139 4 for my $name (Object::Proto::properties(ref $self)) {
140 164 ▶ next if $SKIP_IN_HASH{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $SKIP_IN_HASH{$name} 16 148 164
141 148 my $has = "has_$name";
142 148 ▶ next unless $self->$has;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->$has 117 31 148
143 31 ▶ $hash{ $CAMEL{$name} // $name } = $self->$name;
Condition66%2/3
$CAMEL{$name} // $name
l!l&&r!l&&!r
2290
MC/DC0%0/2
$CAMEL{$name} // $name
$CAMEL{$name} $name
Truth table66%2/3
A // B
A= $CAMEL{$name}B= $name
ABresult
1X1
011
000
144 }
145  
146 4 ▶ if ($self->has_mcp_servers) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_mcp_servers) 0 4 4
147 $hash{mcpServers} = {
148 map {
149 0 my $server = $self->mcp_servers->{$_};
150 0 ▶ $_ => ($server->can('to_hash') ? $server->to_hash : $server)
Branch: 1 branch
BranchTrueFalseTotal
$server->can('to_hash') ? : 0 0 0
151 0 } keys %{$self->mcp_servers}
152 };
153 }
154  
155 4 ▶ if ($self->has_agents) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_agents) 1 3 4
156 $hash{agents} = {
157 map {
158 3 my $agent = $self->agents->{$_};
159 3 ▶ $_ => ($agent->can('to_hash') ? $agent->to_hash : $agent)
Branch: 1 branch
BranchTrueFalseTotal
$agent->can('to_hash') ? : 3 0 3
160 1 } keys %{$self->agents}
161 };
162 }
163  
164 4 return \%hash;
165 }
166  
167 11 1;
168  
169 __END__
« Agent/MCP/StdioServer.pm ↑ Summary Agent/Logger.pm »