Agent/Permission.pm

filter: Statementstmt 100% 54 / 54 Branchbran 100% 8 / 8 Conditioncond 45.4% 5 / 11 MC/DCmcdc 14.2% 1 / 7 Subroutinesub 100% 14 / 14 Podpod 100% 3 / 3 totaltotal 87.6% 85 / 97 CC 9 SCAR 15.3
CC
9
Cov
92%
coerce
9.8
BEGIN
1.0
BEGIN
1.0
CRAP 4.6
« Agent/MCP/HeaderUtils.pm ↑ Summary Agent/Message/System.pm »
1 package Claude::Agent::Permission;
2  
3 10 ▶use 5.020;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 10 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 10 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 10 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 10 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 10 ▶use Const::XS qw(const);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 10 ▶use Claude::Agent::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 10 ▶use Claude::Agent::Permission::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 10 ▶use Claude::Agent::Permission::Result::Allow;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 10 ▶use Claude::Agent::Permission::Result::Deny;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 10 ▶use Claude::Agent::Permission::Context;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 10 const our $MODE_DEFAULT => 'default';
17 10 const our $MODE_ACCEPT_EDIT => 'acceptEdits';
18 10 const our $MODE_BYPASS => 'bypassPermissions';
19 10 const our $MODE_DONT_ASK => 'dontAsk';
20 10 const our $MODE_PLAN => 'plan';
21 10 const our $MODE_AUTO => 'auto';
22 10 const our $MODE_MANUAL => 'manual';
23  
24 10 our @EXPORT_OK = qw(
25 $MODE_DEFAULT $MODE_ACCEPT_EDIT $MODE_BYPASS $MODE_DONT_ASK
26 $MODE_PLAN $MODE_AUTO $MODE_MANUAL
27 );
28  
29 14 ▶sub allow {
Subroutine allow: called CC=1 SCAR=0.0
Pod documented
30 14 my ($class, %args) = @_;
31 return Claude::Agent::Permission::Result::Allow->new(
32 Claude::Agent::Types::defined_args(
33 updated_input => $args{updated_input},
34 updated_permissions => $args{updated_permissions},
35 )
36 14 );
37 }
38  
39 15 ▶sub deny {
Subroutine deny: called CC=1 SCAR=0.0
Pod documented
40 15 my ($class, %args) = @_;
41 return Claude::Agent::Permission::Result::Deny->new(
42 Claude::Agent::Types::defined_args(
43 message => $args{message},
44 interrupt => $args{interrupt},
45 )
46 15 );
47 }
48  
49 11 ▶sub coerce {
Subroutine coerce: called CC=9 SCAR=22.8
Pod documented
50 11 my ($class, $thing) = @_;
51 11 ▶ return $thing if blessed($thing) && $thing->isa('Claude::Agent::Permission::Result');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($thing) and $thing->isa("Claude::Agent::Permission::Result") 5 6 11
Condition66%2/3
builtin::blessed($thing) and $thing->isa("Claude::Agent::Permission::Result")
!ll&&!rl&&r
605
MC/DC50%1/2
builtin::blessed($thing) and $thing->isa("Claude::Agent::Permission::Result")
builtin::blessed($thing) $thing->isa("Claude::Agent::Permission::Result")
Truth table66%2/3
A and B
A= builtin::blessed($thing)B= $thing->isa("Claude::Agent::Permission::Result")
ABresult
0X0
100
111
52 6 ▶ return unless ref $thing eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $thing eq "HASH" 2 4 6
53 4 ▶ my $behavior = $thing->{behavior} // '';
Condition50%1/2
$thing->{"behavior"} // ""
l!l
40
MC/DC0%0/1
$thing->{"behavior"} // ""
$thing->{"behavior"}
Truth table50%1/2
A
A= $thing->{"behavior"}
Aresult
11
00
54 4 ▶ if ($behavior eq 'allow') {
Branch: 1 branch
BranchTrueFalseTotal
if ($behavior eq "allow") 1 3 4
55 return $class->allow(
56 updated_input => $thing->{updated_input} // $thing->{updatedInput},
57 updated_permissions => $thing->{updated_permissions} // $thing->{updatedPermissions},
58 1 ▶ );
Condition33%2/6
$thing->{"updated_input"} // $thing->{"updatedInput"}
l!l&&r!l&&!r
010
$thing->{"updated_permissions"} // $thing->{"updatedPermissions"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$thing->{"updated_input"} // $thing->{"updatedInput"}
$thing->{"updated_input"} $thing->{"updatedInput"}
MC/DC0%0/2
$thing->{"updated_permissions"} // $thing->{"updatedPermissions"}
$thing->{"updated_permissions"} $thing->{"updatedPermissions"}
Truth table33%1/3
A // B
A= $thing->{"updated_input"}B= $thing->{"updatedInput"}
ABresult
1X1
011
000
Truth table33%1/3
A // B
A= $thing->{"updated_permissions"}B= $thing->{"updatedPermissions"}
ABresult
1X1
011
000
59 }
60 3 ▶ if ($behavior eq 'deny') {
Branch: 1 branch
BranchTrueFalseTotal
if ($behavior eq "deny") 2 1 3
61 return $class->deny(
62 message => $thing->{message},
63 interrupt => $thing->{interrupt},
64 2 );
65 }
66 1 return;
67 }
68  
69 10 1;
70  
71 __END__
« Agent/MCP/HeaderUtils.pm ↑ Summary Agent/Message/System.pm »