blib/lib/Langertha/Tool.pm

filter: Statementstmt 67.1% 219 / 326 Branchbran 51.0% 144 / 282 Conditioncond 45.5% 127 / 279 MC/DCmcdc 31.9% 45 / 141 Subroutinesub 72.9% 35 / 48 Podpod 21.4% 6 / 28 totaltotal 52.1% 576 / 1104 CC 309 SCAR 36.3
CC
309
Cov
55%
classify
127.6
classify
127.6
_builtin_kind
79.1
CRAP 37.7
« blib/lib/Langertha/Role/Tools.pm ↑ Summary blib/lib/Langertha/Engine/LMStudio.pm »
1 package Langertha::Tool;
2 # ABSTRACT: Immutable canonical tool definition with cross-provider format conversion
3 204 our $VERSION = '0.505';
4 204 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 204 ▶use Carp qw( croak carp );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 204 ▶use JSON::MaybeXS;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 204 ▶use Scalar::Util qw( blessed );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 204 has name => (
10 is => 'ro',
11 isa => 'Str',
12 required => 1,
13 );
14  
15 204 has description => (
16 is => 'ro',
17 isa => 'Str',
18 default => '',
19 );
20  
21 has input_schema => (
22 is => 'ro',
23 isa => 'HashRef',
24 3 ▶ default => sub { { type => 'object', properties => {} } },
Subroutine __ANON__: called CC=1 SCAR=0.0
25 204 );
26  
27 14 ▶sub _empty_schema { { type => 'object', properties => {} } }
Subroutine _empty_schema: called CC=1 SCAR=0.0
28  
29 # --- Constructors from wire-format hashes ---
30  
31 40 ▶sub from_openai {
Subroutine from_openai: called CC=9 SCAR=33.6
Pod undocumented
32 0 ▶ my ($class, $hash) = @_;
Subroutine from_openai: not called CC=9 SCAR=33.6
Pod undocumented
33 0 ▶ return undef unless ref($hash) eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $hash eq "HASH" 0 40 40
unless ref $hash eq "HASH" 0 0 0
34 0 ▶ return undef unless ($hash->{type} // '') eq 'function';
Branch: 2 branches
BranchTrueFalseTotal
unless ($hash->{"type"} // "") eq "function" 0 40 40
unless ($$hash{"type"} // "") eq "function" 0 0 0
Condition25%1/4
$hash->{"type"} // ""
l!l
400
$$hash{"type"} // ""
l!l
00
MC/DC0%0/1
$hash->{"type"} // ""
$hash->{"type"}
MC/DC0%0/1
$$hash{"type"} // ""
$$hash{"type"}
Truth table50%1/2
A
A= $hash->{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $$hash{"type"}
Aresult
11
00
35 # Chat Completions nests the function fields under `function`; the
36 # Responses API's flat form puts name/description/parameters directly on
37 # the tool hash (k217). Normalize both here (ADR 0018 tier 1: the
38 # value-object inbound door), so the nested shape still wins whenever it
39 # is actually present.
40 0 ▶ my $fn = ref( $hash->{function} ) eq 'HASH' ? $hash->{function} : $hash;
Branch: 2 branches
BranchTrueFalseTotal
ref $hash->{'function'} eq 'HASH' ? : 26 14 40
ref $$hash{'function'} eq 'HASH' ? : 0 0 0
41 0 ▶ my $name = $fn->{name} // '';
Condition25%1/4
$fn->{"name"} // ""
l!l
400
$$fn{"name"} // ""
l!l
00
MC/DC0%0/1
$fn->{"name"} // ""
$fn->{"name"}
MC/DC0%0/1
$$fn{"name"} // ""
$$fn{"name"}
Truth table50%1/2
A
A= $fn->{"name"}
Aresult
11
00
Truth table0%0/2
A
A= $$fn{"name"}
Aresult
11
00
42 0 ▶ return undef unless length $name;
Branch: 2 branches
BranchTrueFalseTotal
unless length $name 0 40 40
unless length $name 0 0 0
43 return $class->new(
44 name => $name,
45 description => ( $fn->{description} // '' ),
46 0 ▶ input_schema => ( $fn->{parameters} || $class->_empty_schema ),
Condition40%4/10
$fn->{"description"} // ""
l!l
373
$fn->{'parameters'} || $class->_empty_schema
l!l&&r!l&&!r
3730
$$fn{"description"} // ""
l!l
00
$$fn{'parameters'} || $class->_empty_schema
l!l&&r!l&&!r
000
MC/DC100%1/1
$fn->{"description"} // ""
$fn->{"description"}
MC/DC0%0/2
$fn->{'parameters'} || $class->_empty_schema
$fn->{'parameters'} $class->_empty_schema
MC/DC0%0/1
$$fn{"description"} // ""
$$fn{"description"}
MC/DC0%0/2
$$fn{'parameters'} || $class->_empty_schema
$$fn{'parameters'} $class->_empty_schema
Truth table100%2/2
A
A= $fn->{"description"}
Aresult
11
00
Truth table66%2/3
A || B
A= $fn->{'parameters'}B= $class->_empty_schema
ABresult
1X1
011
000
Truth table0%0/2
A
A= $$fn{"description"}
Aresult
11
00
Truth table0%0/3
A || B
A= $$fn{'parameters'}B= $class->_empty_schema
ABresult
1X1
011
000
47 );
48 }
49  
50 66 ▶sub from_anthropic {
Subroutine from_anthropic: called CC=7 SCAR=29.6
Pod undocumented
51 0 ▶ my ($class, $hash) = @_;
Subroutine from_anthropic: not called CC=7 SCAR=29.6
Pod undocumented
52 0 ▶ return undef unless ref($hash) eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $hash eq "HASH" 0 66 66
unless ref $hash eq "HASH" 0 0 0
53 0 ▶ my $name = $hash->{name} // '';
Condition25%1/4
$hash->{"name"} // ""
l!l
660
$$hash{"name"} // ""
l!l
00
MC/DC0%0/1
$hash->{"name"} // ""
$hash->{"name"}
MC/DC0%0/1
$$hash{"name"} // ""
$$hash{"name"}
Truth table50%1/2
A
A= $hash->{"name"}
Aresult
11
00
Truth table0%0/2
A
A= $$hash{"name"}
Aresult
11
00
54 0 ▶ return undef unless length $name;
Branch: 2 branches
BranchTrueFalseTotal
unless length $name 0 66 66
unless length $name 0 0 0
55 return $class->new(
56 name => $name,
57 description => ( $hash->{description} // '' ),
58 0 ▶ input_schema => ( $hash->{input_schema} || $hash->{parameters} || $class->_empty_schema ),
Condition37%6/16
$hash->{"description"} // ""
l!l
624
$hash->{'input_schema'} || $hash->{'parameters'} || $class->_empty_schema
l!l&&r!l&&!r
55110
$hash->{"input_schema"} or $hash->{"parameters"}
l!l&&r!l&&!r
55011
$$hash{"description"} // ""
l!l
00
$$hash{'input_schema'} || $$hash{'parameters'} || $class->_empty_schema
l!l&&r!l&&!r
000
$$hash{"input_schema"} or $$hash{"parameters"}
l!l&&r!l&&!r
000
MC/DC100%1/1
$hash->{"description"} // ""
$hash->{"description"}
MC/DC0%0/3
$hash->{'input_schema'} || $hash->{'parameters'} || $class->_empty_schema
$hash->{"input_schema"} $hash->{"parameters"} $class->_empty_schema
MC/DC0%0/1
$$hash{"description"} // ""
$$hash{"description"}
MC/DC0%0/3
$$hash{'input_schema'} || $$hash{'parameters'} || $class->_empty_schema
$$hash{"input_schema"} $$hash{"parameters"} $class->_empty_schema
Truth table100%2/2
A
A= $hash->{"description"}
Aresult
11
00
Truth table50%2/4
A or B || C
A= $hash->{"input_schema"}B= $hash->{"parameters"}C= $class->_empty_schema
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/2
A
A= $$hash{"description"}
Aresult
11
00
Truth table0%0/4
A or B || C
A= $$hash{"input_schema"}B= $$hash{"parameters"}C= $class->_empty_schema
ABCresult
1XX1
01X1
0011
0000
59 );
60 }
61  
62 # MCP server tool definition: name + description + inputSchema (camelCase).
63 764 ▶sub from_mcp {
Subroutine from_mcp: called CC=7 SCAR=32.0
Pod undocumented
64 0 ▶ my ($class, $hash) = @_;
Subroutine from_mcp: not called CC=7 SCAR=32.0
Pod undocumented
65 0 ▶ return undef unless ref($hash) eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $hash eq "HASH" 0 764 764
unless ref $hash eq "HASH" 0 0 0
66 0 ▶ my $name = $hash->{name} // '';
Condition25%1/4
$hash->{"name"} // ""
l!l
7640
$$hash{"name"} // ""
l!l
00
MC/DC0%0/1
$hash->{"name"} // ""
$hash->{"name"}
MC/DC0%0/1
$$hash{"name"} // ""
$$hash{"name"}
Truth table50%1/2
A
A= $hash->{"name"}
Aresult
11
00
Truth table0%0/2
A
A= $$hash{"name"}
Aresult
11
00
67 0 ▶ return undef unless length $name;
Branch: 2 branches
BranchTrueFalseTotal
unless length $name 0 764 764
unless length $name 0 0 0
68 return $class->new(
69 name => $name,
70 description => ( $hash->{description} // '' ),
71 0 ▶ input_schema => ( $hash->{inputSchema} || $hash->{input_schema} || $class->_empty_schema ),
Condition18%3/16
$hash->{"description"} // ""
l!l
7640
$hash->{'inputSchema'} || $hash->{'input_schema'} || $class->_empty_schema
l!l&&r!l&&!r
76400
$hash->{"inputSchema"} or $hash->{"input_schema"}
l!l&&r!l&&!r
76400
$$hash{"description"} // ""
l!l
00
$$hash{'inputSchema'} || $$hash{'input_schema'} || $class->_empty_schema
l!l&&r!l&&!r
000
$$hash{"inputSchema"} or $$hash{"input_schema"}
l!l&&r!l&&!r
000
MC/DC0%0/1
$hash->{"description"} // ""
$hash->{"description"}
MC/DC0%0/3
$hash->{'inputSchema'} || $hash->{'input_schema'} || $class->_empty_schema
$hash->{"inputSchema"} $hash->{"input_schema"} $class->_empty_schema
MC/DC0%0/1
$$hash{"description"} // ""
$$hash{"description"}
MC/DC0%0/3
$$hash{'inputSchema'} || $$hash{'input_schema'} || $class->_empty_schema
$$hash{"inputSchema"} $$hash{"input_schema"} $class->_empty_schema
Truth table50%1/2
A
A= $hash->{"description"}
Aresult
11
00
Truth table25%1/4
A or B || C
A= $hash->{"inputSchema"}B= $hash->{"input_schema"}C= $class->_empty_schema
ABCresult
1XX1
01X1
0011
0000
Truth table0%0/2
A
A= $$hash{"description"}
Aresult
11
00
Truth table0%0/4
A or B || C
A= $$hash{"inputSchema"}B= $$hash{"input_schema"}C= $class->_empty_schema
ABCresult
1XX1
01X1
0011
0000
72 );
73 }
74  
75 # Gemini functionDeclarations: name + description + parameters (flat), or
76 # the JSON-Schema parametersJsonSchema (both spellings, ADR 0018).
77 17 ▶sub from_gemini {
Subroutine from_gemini: called CC=8 SCAR=32.0
Pod undocumented
78 0 ▶ my ($class, $hash) = @_;
Subroutine from_gemini: not called CC=8 SCAR=32.0
Pod undocumented
79 0 ▶ return undef unless ref($hash) eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $hash eq "HASH" 0 17 17
unless ref $hash eq "HASH" 0 0 0
80 0 ▶ my $name = $hash->{name} // '';
Condition25%1/4
$hash->{"name"} // ""
l!l
170
$$hash{"name"} // ""
l!l
00
MC/DC0%0/1
$hash->{"name"} // ""
$hash->{"name"}
MC/DC0%0/1
$$hash{"name"} // ""
$$hash{"name"}
Truth table50%1/2
A
A= $hash->{"name"}
Aresult
11
00
Truth table0%0/2
A
A= $$hash{"name"}
Aresult
11
00
81 0 ▶ return undef unless length $name;
Branch: 2 branches
BranchTrueFalseTotal
unless length $name 0 17 17
unless length $name 0 0 0
82 return $class->new(
83 name => $name,
84 description => ( $hash->{description} // '' ),
85 input_schema => ( $hash->{parameters} || $hash->{parametersJsonSchema}
86 0 ▶ || $hash->{parameters_json_schema} || $class->_empty_schema ),
Condition36%8/22
$hash->{"description"} // ""
l!l
143
$hash->{'parameters'} || $hash->{'parametersJsonSchema'} || $hash->{'parameters_json_schema'} || $class->_empty_schema
l!l&&r!l&&!r
1700
$hash->{"parameters"} or $hash->{"parametersJsonSchema"} or $hash->{"parameters_json_schema"}
l!l&&r!l&&!r
1340
$hash->{"parameters"} or $hash->{"parametersJsonSchema"}
l!l&&r!l&&!r
944
$$hash{"description"} // ""
l!l
00
$$hash{'parameters'} || $$hash{'parametersJsonSchema'} || $$hash{'parameters_json_schema'} || $class->_empty_schema
l!l&&r!l&&!r
000
$$hash{"parameters"} or $$hash{"parametersJsonSchema"} or $$hash{"parameters_json_schema"}
l!l&&r!l&&!r
000
$$hash{"parameters"} or $$hash{"parametersJsonSchema"}
l!l&&r!l&&!r
000
MC/DC100%1/1
$hash->{"description"} // ""
$hash->{"description"}
MC/DC0%0/4
$hash->{'parameters'} || $hash->{'parametersJsonSchema'} || $hash->{'parameters_json_schema'} || $class->_empty_schema
$hash->{"parameters"} $hash->{"parametersJsonSchema"} $hash->{"parameters_json_schema"} $class->_empty_schema
MC/DC0%0/1
$$hash{"description"} // ""
$$hash{"description"}
MC/DC0%0/4
$$hash{'parameters'} || $$hash{'parametersJsonSchema'} || $$hash{'parameters_json_schema'} || $class->_empty_schema
$$hash{"parameters"} $$hash{"parametersJsonSchema"} $$hash{"parameters_json_schema"} $class->_empty_schema
Truth table100%2/2
A
A= $hash->{"description"}
Aresult
11
00
Truth table60%3/5
A or B or C || D
A= $hash->{"parameters"}B= $hash->{"parametersJsonSchema"}C= $hash->{"parameters_json_schema"}D= $class->_empty_schema
ABCDresult
1XXX1
01XX1
001X1
00011
00000
Truth table0%0/2
A
A= $$hash{"description"}
Aresult
11
00
Truth table0%0/5
A or B or C || D
A= $$hash{"parameters"}B= $$hash{"parametersJsonSchema"}C= $$hash{"parameters_json_schema"}D= $class->_empty_schema
ABCDresult
1XXX1
01XX1
001X1
00011
00000
87 );
88 }
89  
90 # Generic: figure out the wire shape and route accordingly. Order matters —
91 # we test the most specific markers first.
92 1477 ▶sub from_hash {
Subroutine from_hash: called CC=11 SCAR=35.1
Pod documented
93 0 ▶ my ($class, $hash) = @_;
Subroutine from_hash: not called CC=11 SCAR=35.1
Pod documented
94 0 ▶ return $hash if ref($hash) && eval { $hash->isa(__PACKAGE__) };
Branch: 2 branches
BranchTrueFalseTotal
if ref $hash and eval { do { $hash->isa(__PACKAGE__) } } 35 1442 1477
if ref $hash and eval { do { $hash->isa(__PACKAGE__) } } 0 0 0
Condition33%2/6
ref $hash and eval { do { $hash->isa(__PACKAGE__) } }
!ll&&!rl&&r
0144235
ref $hash and eval { do { $hash->isa(__PACKAGE__) } }
!ll&&!rl&&r
000
MC/DC50%1/2
ref $hash and eval { do { $hash->isa(__PACKAGE__) } }
ref $hash eval { do { $hash->isa(__PACKAGE__) } }
MC/DC0%0/2
ref $hash and eval { do { $hash->isa(__PACKAGE__) } }
ref $hash eval { do { $hash->isa(__PACKAGE__) } }
Truth table66%2/3
A and B
A= ref $hashB= eval { do { $hash->isa(__PACKAGE__) } }
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $hashB= eval { do { $hash->isa(__PACKAGE__) } }
ABresult
0X0
100
111
95 croak "Langertha::Tool: a Langertha::ServerTool is not a function tool; "
96 . "format_list and the engine's tools list take it, Langertha::Tool does not"
97 0 ▶ if ref($hash) && eval { $hash->isa('Langertha::ServerTool') };
Branch: 2 branches
BranchTrueFalseTotal
if ref $hash and eval { do { $hash->isa("Langertha::ServerTool") } } 0 1442 1442
if ref $hash and eval { do { $hash->isa("Langertha::ServerTool") } } 0 0 0
Condition16%1/6
ref $hash and eval { do { $hash->isa("Langertha::ServerTool") } }
!ll&&!rl&&r
014420
ref $hash and eval { do { $hash->isa("Langertha::ServerTool") } }
!ll&&!rl&&r
000
MC/DC0%0/2
ref $hash and eval { do { $hash->isa("Langertha::ServerTool") } }
ref $hash eval { do { $hash->isa("Langertha::ServerTool") } }
MC/DC0%0/2
ref $hash and eval { do { $hash->isa("Langertha::ServerTool") } }
ref $hash eval { do { $hash->isa("Langertha::ServerTool") } }
Truth table33%1/3
A and B
A= ref $hashB= eval { do { $hash->isa("Langertha::ServerTool") } }
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $hashB= eval { do { $hash->isa("Langertha::ServerTool") } }
ABresult
0X0
100
111
98 0 ▶ return undef unless ref($hash) eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $hash eq "HASH" 0 1442 1442
unless ref $hash eq "HASH" 0 0 0
99 0 $class->_croak_unless_function_tool($hash);
100 0 ▶ return $class->from_openai($hash) if ( $hash->{type} // '' ) eq 'function';
Branch: 2 branches
BranchTrueFalseTotal
if ($hash->{"type"} // "") eq "function" 39 845 884
if ($$hash{"type"} // "") eq "function" 0 0 0
Condition50%2/4
$hash->{"type"} // ""
l!l
48836
$$hash{"type"} // ""
l!l
00
MC/DC100%1/1
$hash->{"type"} // ""
$hash->{"type"}
MC/DC0%0/1
$$hash{"type"} // ""
$$hash{"type"}
Truth table100%2/2
A
A= $hash->{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $$hash{"type"}
Aresult
11
00
101 0 ▶ return $class->from_mcp($hash) if ref( $hash->{inputSchema} ) eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
if ref $hash->{"inputSchema"} eq "HASH" 763 82 845
if ref $$hash{"inputSchema"} eq "HASH" 0 0 0
102 0 ▶ return $class->from_anthropic($hash) if ref( $hash->{input_schema} ) eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
if ref $hash->{"input_schema"} eq "HASH" 54 28 82
if ref $$hash{"input_schema"} eq "HASH" 0 0 0
103 return $class->from_gemini($hash)
104 0 ▶ if grep { ref( $hash->{$_} ) eq 'HASH' } qw( parameters parametersJsonSchema parameters_json_schema );
Branch: 2 branches
BranchTrueFalseTotal
if grep {ref $hash->{$_} eq "HASH";} "parameters", "parametersJsonSchema", "parameters_json_schema" 17 11 28
if grep {ref $$hash{$_} eq "HASH";} "parameters", "parametersJsonSchema", "parameters_json_schema" 0 0 0
105 # Last resort: name-only / schemaless
106 0 return $class->from_anthropic($hash);
107 }
108  
109 # Only function tools pass this door; since k210 (ADR 0001) everything else
110 # croaks instead of being dropped or turned into a function tool. The decision
111 # is classify()'s -- the one source of truth, also used by
112 # Role::ResponsesCompatible and by sibling callers that must not croak.
113 1442 ▶sub _croak_unless_function_tool {
Subroutine _croak_unless_function_tool: called CC=7 SCAR=25.7
114 0 ▶ my ($class, $hash) = @_;
Subroutine _croak_unless_function_tool: not called CC=7 SCAR=25.7
115 0 my ( $category, $wire, $label ) = $class->classify($hash);
116 0 ▶ return if $category eq 'function';
Branch: 2 branches
BranchTrueFalseTotal
if $category eq "function" 884 558 1442
if $category eq "function" 0 0 0
117 0 my $tail = '(refusing to drop it or send it as a function tool)';
118 0 ▶ croak "Langertha::Tool: '$label' is a server-side tool ($wire), not a function "
Branch: 4 branches
BranchTrueFalseTotal
if $category eq "server" 304 254 558
$wire eq 'responses' ? : 121 183 304
if $category eq "server" 0 0 0
$wire eq 'responses' ? : 0 0 0
119 . "tool $tail; "
120 . ( $wire eq 'responses'
121 ? "pass it in the tools list of an engine that supports('server_tools'), "
122 . "or wrap it in Langertha::ServerTool"
123 : "Langertha::ServerTool does not support the $wire wire yet" )
124 if $category eq 'server';
125 0 ▶ croak "Langertha::Tool: '$label' is a client-executed built-in tool ($wire), "
Branch: 2 branches
BranchTrueFalseTotal
if $category eq "client_builtin" 169 85 254
if $category eq "client_builtin" 0 0 0
126 . "not a server tool, and Langertha cannot run it $tail"
127 if $category eq 'client_builtin';
128 croak "Langertha::Tool: unsupported tool type '$label': not a function tool $tail"
129 0 ▶ if length( $hash->{type} // '' );
Branch: 2 branches
BranchTrueFalseTotal
if length($hash->{"type"} // "") 44 41 85
if length($$hash{"type"} // "") 0 0 0
Condition50%2/4
$hash->{"type"} // ""
l!l
4441
$$hash{"type"} // ""
l!l
00
MC/DC100%1/1
$hash->{"type"} // ""
$hash->{"type"}
MC/DC0%0/1
$$hash{"type"} // ""
$$hash{"type"}
Truth table100%2/2
A
A= $hash->{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $$hash{"type"}
Aresult
11
00
130 0 croak "Langertha::Tool: tool hash has no type and no name (keys: $label): "
131 . "not a function tool $tail";
132 }
133  
134 # Built-in tools, recognised explicitly per wire (spec k206 section 3.4,
135 # llm-advisor against the provider references, 2026-09-25). Typed wires match
136 # on `type` (plus `execution` / `environment` where that decides who runs it);
137 # Gemini's built-ins are keyed, not typed ({ google_search => {} }), in both
138 # snake and camel case (ADR 0018). Documentation-derived, not capture-verified.
139 204 my %RESPONSES_SERVER_TYPE = map { $_ => 1 } qw(
140 web_search file_search code_interpreter image_generation mcp
141 x_search collections_search
142 );
143 204 my %RESPONSES_CLIENT_TYPE = map { $_ => 1 } qw(
144 local_shell computer computer_use_preview apply_patch
145 );
146 204 my @GEMINI_SERVER_KEY = qw(
147 google_search googleSearch google_search_retrieval googleSearchRetrieval
148 code_execution codeExecution url_context urlContext google_maps googleMaps
149 enterprise_web_search enterpriseWebSearch file_search fileSearch retrieval
150 );
151 204 my @GEMINI_CLIENT_KEY = qw( computer_use computerUse );
152  
153 # The inbound mirror of %RESPONSES_CLIENT_TYPE: Responses output[] items the
154 # CLIENT must answer and Langertha does not map into Response.tool_calls
155 # (llm-advisor must-change 1 on k206, OpenAI create-response reference). A
156 # known one croaks rather than being skipped -- skipped, a tool loop ends as if
157 # the model were done and a chat_f caller never learns it is waiting. A
158 # tool_search_call is client-actionable only with execution => 'client'.
159 # Unknown item types stay skipped (values open); ADR 0030.
160 204 my %RESPONSES_CLIENT_ITEM = (
161 custom_tool_call => 'a custom tool call',
162 computer_call => 'a computer-use action',
163 local_shell_call => 'a local shell command',
164 apply_patch_call => 'a patch to apply',
165 mcp_approval_request => "an MCP approval request; send the mcp tool with require_approval => 'never'",
166 tool_search_call => 'a client-side tool search',
167 );
168  
169 173 ▶sub _croak_on_client_item {
Subroutine _croak_on_client_item: called CC=7 SCAR=29.6
170 0 ▶ my ( $class, $item ) = @_;
Subroutine _croak_on_client_item: not called CC=7 SCAR=29.6
171 0 ▶ return unless ref $item eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $item eq "HASH" 0 173 173
unless ref $item eq "HASH" 0 0 0
172 0 ▶ my $type = $item->{type} // '';
Condition25%1/4
$item->{"type"} // ""
l!l
1730
$$item{"type"} // ""
l!l
00
MC/DC0%0/1
$item->{"type"} // ""
$item->{"type"}
MC/DC0%0/1
$$item{"type"} // ""
$$item{"type"}
Truth table50%1/2
A
A= $item->{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $$item{"type"}
Aresult
11
00
173 0 ▶ my $what = $RESPONSES_CLIENT_ITEM{$type} or return;
Branch: 2 branches
BranchTrueFalseTotal
my $what = $RESPONSES_CLIENT_ITEM{$type} or return 13 160 173
my $what = $RESPONSES_CLIENT_ITEM{$type} or return 0 0 0
174 0 ▶ return if $type eq 'tool_search_call' && ( $item->{execution} // '' ) ne 'client';
Branch: 2 branches
BranchTrueFalseTotal
if $type eq "tool_search_call" and ($item->{"execution"} // "") ne "client" 0 13 13
if $type eq "tool_search_call" and ($$item{"execution"} // "") ne "client" 0 0 0
Condition30%3/10
$type eq "tool_search_call" and ($item->{"execution"} // "") ne "client"
!ll&&!rl&&r
1120
$item->{"execution"} // ""
l!l
20
$type eq "tool_search_call" and ($$item{"execution"} // "") ne "client"
!ll&&!rl&&r
000
$$item{"execution"} // ""
l!l
00
MC/DC50%1/2
$type eq "tool_search_call" and ($item->{"execution"} // "") ne "client"
$type eq "tool_search_call" $item->{"execution"}
MC/DC0%0/2
$type eq "tool_search_call" and ($$item{"execution"} // "") ne "client"
$type eq "tool_search_call" $$item{"execution"}
Truth table66%2/3
A and B
A= $type eq "tool_search_call"B= $item->{"execution"}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= $type eq "tool_search_call"B= $$item{"execution"}
ABresult
0X0
100
111
175 0 croak "Langertha: the reply contains a '$type' output item ($what) that the "
176 . "client must answer, and Langertha cannot; refusing to end the turn as if the "
177 . "model were done";
178 }
179  
180 # ($category, $wire) for a recognised built-in, else ().
181 2819 ▶sub _builtin_kind {
Subroutine _builtin_kind: called CC=21 SCAR=43.7
182 0 ▶ my ($hash) = @_;
Subroutine _builtin_kind: not called CC=21 SCAR=43.7
183 0 ▶ my $type = $hash->{type} // '';
Condition50%2/4
$hash->{"type"} // ""
l!l
11701649
$$hash{"type"} // ""
l!l
00
MC/DC100%1/1
$hash->{"type"} // ""
$hash->{"type"}
MC/DC0%0/1
$$hash{"type"} // ""
$$hash{"type"}
Truth table100%2/2
A
A= $hash->{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $$hash{"type"}
Aresult
11
00
184 0 ▶ if ( length $type ) {
Branch: 2 branches
BranchTrueFalseTotal
if (length $type) 1170 1649 2819
if (length $type) 0 0 0
185 0 ▶ if ( $type eq 'tool_search' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq "tool_search") 77 1093 1170
if ($type eq "tool_search") 0 0 0
186 0 ▶ return ( ( $hash->{execution} // '' ) eq 'client' ? 'client_builtin' : 'server', 'responses' );
Branch: 2 branches
BranchTrueFalseTotal
($hash->{'execution'} // '') eq 'client' ? : 27 50 77
($$hash{'execution'} // '') eq 'client' ? : 0 0 0
Condition50%2/4
$hash->{"execution"} // ""
l!l
5126
$$hash{"execution"} // ""
l!l
00
MC/DC100%1/1
$hash->{"execution"} // ""
$hash->{"execution"}
MC/DC0%0/1
$$hash{"execution"} // ""
$$hash{"execution"}
Truth table100%2/2
A
A= $hash->{"execution"}
Aresult
11
00
Truth table0%0/2
A
A= $$hash{"execution"}
Aresult
11
00
187 }
188 0 ▶ if ( $type eq 'shell' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq "shell") 128 965 1093
if ($type eq "shell") 0 0 0
189 # Hosted only in one of the two container environments; a bare, local
190 # or unrecognised environment runs on the client (spec k206 3.4, Q3).
191 0 ▶ my $env = ref $hash->{environment} eq 'HASH' ? ( $hash->{environment}{type} // '' ) : '';
Branch: 2 branches
BranchTrueFalseTotal
ref $hash->{'environment'} eq 'HASH' ? : 102 26 128
ref $$hash{'environment'} eq 'HASH' ? : 0 0 0
Condition25%1/4
$hash->{"environment"}{"type"} // ""
l!l
1020
$$hash{"environment"}{"type"} // ""
l!l
00
MC/DC0%0/1
$hash->{"environment"}{"type"} // ""
$hash->{"environment"}{"type"}
MC/DC0%0/1
$$hash{"environment"}{"type"} // ""
$$hash{"environment"}{"type"}
Truth table50%1/2
A
A= $hash->{"environment"}{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $$hash{"environment"}{"type"}
Aresult
11
00
192 0 ▶ return ( ( $env eq 'container_auto' || $env eq 'container_reference' )
Branch: 2 branches
BranchTrueFalseTotal
$env eq 'container_auto' || $env eq 'container_reference' ? : 50 78 128
$env eq 'container_auto' || $env eq 'container_reference' ? : 0 0 0
Condition50%3/6
$env eq "container_auto" or $env eq "container_reference"
l!l&&r!l&&!r
262478
$env eq "container_auto" or $env eq "container_reference"
l!l&&r!l&&!r
000
MC/DC100%2/2
$env eq "container_auto" or $env eq "container_reference"
$env eq "container_auto" $env eq "container_reference"
MC/DC0%0/2
$env eq "container_auto" or $env eq "container_reference"
$env eq "container_auto" $env eq "container_reference"
Truth table100%3/3
A or B
A= $env eq "container_auto"B= $env eq "container_reference"
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $env eq "container_auto"B= $env eq "container_reference"
ABresult
1X1
011
000
193 ? 'server' : 'client_builtin', 'responses' );
194 }
195 return ( server => 'responses' )
196 0 ▶ if $RESPONSES_SERVER_TYPE{$type}
Branch: 2 branches
BranchTrueFalseTotal
if $RESPONSES_SERVER_TYPE{$type} or $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/ 337 628 965
if $RESPONSES_SERVER_TYPE{$type} or $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/ 0 0 0
Condition50%3/6
$RESPONSES_SERVER_TYPE{$type} or $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/
l!l&&r!l&&!r
28750628
$RESPONSES_SERVER_TYPE{$type} or $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/
l!l&&r!l&&!r
000
MC/DC100%2/2
$RESPONSES_SERVER_TYPE{$type} or $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/
$RESPONSES_SERVER_TYPE{$type} $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/
MC/DC0%0/2
$RESPONSES_SERVER_TYPE{$type} or $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/
$RESPONSES_SERVER_TYPE{$type} $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/
Truth table100%3/3
A or B
A= $RESPONSES_SERVER_TYPE{$type}B= $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $RESPONSES_SERVER_TYPE{$type}B= $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/
ABresult
1X1
011
000
197 || $type =~ /\Aweb_search_(?:preview|\d{4}_\d{2}_\d{2}\z)/;
198 0 ▶ return ( client_builtin => 'responses' ) if $RESPONSES_CLIENT_TYPE{$type};
Branch: 2 branches
BranchTrueFalseTotal
if $RESPONSES_CLIENT_TYPE{$type} 106 522 628
if $RESPONSES_CLIENT_TYPE{$type} 0 0 0
199 0 ▶ return ( server => 'anthropic' )
Branch: 2 branches
BranchTrueFalseTotal
if $type eq "mcp_toolset" or $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/ 138 384 522
if $type eq "mcp_toolset" or $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/ 0 0 0
Condition50%3/6
$type eq "mcp_toolset" or $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/
l!l&&r!l&&!r
26112384
$type eq "mcp_toolset" or $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/
l!l&&r!l&&!r
000
MC/DC100%2/2
$type eq "mcp_toolset" or $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/
$type eq "mcp_toolset" $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/
MC/DC0%0/2
$type eq "mcp_toolset" or $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/
$type eq "mcp_toolset" $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/
Truth table100%3/3
A or B
A= $type eq "mcp_toolset"B= $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $type eq "mcp_toolset"B= $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/
ABresult
1X1
011
000
200 if $type eq 'mcp_toolset'
201 || $type =~ /\A(?:web_search|web_fetch|code_execution|tool_search_tool_\w+?)_\d{8}\z/;
202 0 ▶ return ( client_builtin => 'anthropic' )
Branch: 2 branches
BranchTrueFalseTotal
if $type =~ /\A(?:bash|text_editor|computer|memory)_\d{8}\z/ 104 280 384
if $type =~ /\A(?:bash|text_editor|computer|memory)_\d{8}\z/ 0 0 0
203 if $type =~ /\A(?:bash|text_editor|computer|memory)_\d{8}\z/;
204 0 return ();
205 }
206 0 ▶ for my $key (@GEMINI_SERVER_KEY) { return ( server => 'gemini' ) if exists $hash->{$key} }
Branch: 2 branches
BranchTrueFalseTotal
if exists $hash->{$key} 230 22663 22893
if exists $$hash{$key} 0 0 0
207 0 ▶ for my $key (@GEMINI_CLIENT_KEY) { return ( client_builtin => 'gemini' ) if exists $hash->{$key} }
Branch: 2 branches
BranchTrueFalseTotal
if exists $hash->{$key} 24 2790 2814
if exists $$hash{$key} 0 0 0
208 0 return ();
209 }
210  
211  
212 204 my %KNOWN_FMT = map { $_ => 1 } qw( openai anthropic gemini ollama responses mcp hermes );
213 204 my %CARPED_FMT;
214  
215 2824 ▶sub classify {
Subroutine classify: called CC=26 SCAR=48.5
Pod documented
216 0 ▶ my ( $class, $hash, $fmt ) = @_;
Subroutine classify: not called CC=26 SCAR=48.5
Pod documented
217 0 ▶ if ( defined $fmt && !$KNOWN_FMT{$fmt} && !$CARPED_FMT{$fmt}++ ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $fmt and not $KNOWN_FMT{$fmt} and not $CARPED_FMT{$fmt}++) 1 2823 2824
if (defined $fmt and not $KNOWN_FMT{$fmt} and not $CARPED_FMT{$fmt}++) 0 0 0
Condition50%6/12
defined $fmt and not $KNOWN_FMT{$fmt} and not $CARPED_FMT{$fmt}++
!ll&&!rl&&r
282211
defined $fmt and not $KNOWN_FMT{$fmt}
!ll&&!rl&&r
182110012
defined $fmt and not $KNOWN_FMT{$fmt} and not $CARPED_FMT{$fmt}++
!ll&&!rl&&r
000
defined $fmt and not $KNOWN_FMT{$fmt}
!ll&&!rl&&r
000
MC/DC100%3/3
defined $fmt and not $KNOWN_FMT{$fmt} and not $CARPED_FMT{$fmt}++
defined $fmt not $KNOWN_FMT{$fmt} not $CARPED_FMT{$fmt}++
MC/DC0%0/3
defined $fmt and not $KNOWN_FMT{$fmt} and not $CARPED_FMT{$fmt}++
defined $fmt not $KNOWN_FMT{$fmt} not $CARPED_FMT{$fmt}++
Truth table100%4/4
A and not(B) and not(C)
A= defined $fmtB= not $KNOWN_FMT{$fmt}C= not $CARPED_FMT{$fmt}++
ABCresult
0XX0
10X0
1100
1111
Truth table0%0/4
A and not(B) and not(C)
A= defined $fmtB= not $KNOWN_FMT{$fmt}C= not $CARPED_FMT{$fmt}++
ABCresult
0XX0
10X0
1100
1111
218 0 carp "Langertha::Tool->classify: unknown tool_wire_format '$fmt'; "
219 . "every built-in counts as foreign for it";
220 }
221 0 my @none = ( undef, undef );
222 0 ▶ if ( ref($hash) && eval { $hash->isa(__PACKAGE__) } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $hash and eval { do { $hash->isa(__PACKAGE__) } }) 2 2822 2824
if (ref $hash and eval { do { $hash->isa(__PACKAGE__) } }) 0 0 0
Condition50%3/6
ref $hash and eval { do { $hash->isa(__PACKAGE__) } }
!ll&&!rl&&r
228202
ref $hash and eval { do { $hash->isa(__PACKAGE__) } }
!ll&&!rl&&r
000
MC/DC100%2/2
ref $hash and eval { do { $hash->isa(__PACKAGE__) } }
ref $hash eval { do { $hash->isa(__PACKAGE__) } }
MC/DC0%0/2
ref $hash and eval { do { $hash->isa(__PACKAGE__) } }
ref $hash eval { do { $hash->isa(__PACKAGE__) } }
Truth table100%3/3
A and B
A= ref $hashB= eval { do { $hash->isa(__PACKAGE__) } }
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $hashB= eval { do { $hash->isa(__PACKAGE__) } }
ABresult
0X0
100
111
223 0 ▶ return wantarray ? ( 'function', @none ) : 'function';
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 0 2 2
wantarray ? : 0 0 0
224 }
225 0 ▶ unless ( ref($hash) eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
unless (ref $hash eq "HASH") 3 2819 2822
unless (ref $hash eq "HASH") 0 0 0
226 0 ▶ return wantarray ? ( 'unknown', undef, ref($hash) || 'non-reference' ) : 'unknown';
Branch: 4 branches
BranchTrueFalseTotal
wantarray ? : 0 3 3
ref $hash or "non-reference" 0 0 0
wantarray ? : 0 0 0
ref $hash or "non-reference" 0 0 0
227 }
228 0 ▶ my $type = $hash->{type} // '';
Condition50%2/4
$hash->{"type"} // ""
l!l
11701649
$$hash{"type"} // ""
l!l
00
MC/DC100%1/1
$hash->{"type"} // ""
$hash->{"type"}
MC/DC0%0/1
$$hash{"type"} // ""
$$hash{"type"}
Truth table100%2/2
A
A= $hash->{"type"}
Aresult
11
00
Truth table0%0/2
A
A= $$hash{"type"}
Aresult
11
00
229 0 my ( $category, $wire ) = _builtin_kind($hash);
230 my $label = length $type ? $type
231 0 ▶ : $category ? ( grep { exists $hash->{$_} } @GEMINI_SERVER_KEY, @GEMINI_CLIENT_KEY )[0]
Branch: 4 branches
BranchTrueFalseTotal
length $type ? : 1170 1649 2819
$category ? : 254 1395 1649
length $type ? : 0 0 0
$category ? : 0 0 0
232 : undef;
233 0 ▶ if ($category) {
Branch: 4 branches
BranchTrueFalseTotal
if ($category) { } 1144 1675 2819
elsif ($type eq 'function' or $type eq 'custom' and ref $hash->{'input_schema'} eq 'HASH' or $type eq '' and not ref $hash->{'name'} and length($hash->{'name'} // '')) { } 1490 185 1675
if ($category) { } 0 0 0
elsif ($type eq 'function' or $type eq 'custom' and ref $$hash{'input_schema'} eq 'HASH' or $type eq '' and not ref $$hash{'name'} and length($$hash{'name'} // '')) { } 0 0 0
234 0 ▶ $category = 'foreign' if defined $fmt && $wire ne $fmt;
Branch: 2 branches
BranchTrueFalseTotal
if defined $fmt and $wire ne $fmt 197 947 1144
if defined $fmt and $wire ne $fmt 0 0 0
Condition50%3/6
defined $fmt and $wire ne $fmt
!ll&&!rl&&r
712235197
defined $fmt and $wire ne $fmt
!ll&&!rl&&r
000
MC/DC100%2/2
defined $fmt and $wire ne $fmt
defined $fmt $wire ne $fmt
MC/DC0%0/2
defined $fmt and $wire ne $fmt
defined $fmt $wire ne $fmt
Truth table100%3/3
A and B
A= defined $fmtB= $wire ne $fmt
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= defined $fmtB= $wire ne $fmt
ABresult
0X0
100
111
235 }
236 ▶ elsif ( $type eq 'function'
Condition47%16/34
$type eq "function" or $type eq "custom" and ref $hash->{"input_schema"} eq "HASH" or $type eq "" and not ref $hash->{"name"} and length($hash->{"name"} // "")
l!l&&r!l&&!r
1791311185
$type eq "function" or $type eq "custom" and ref $hash->{"input_schema"} eq "HASH"
l!l&&r!l&&!r
164151496
$type eq "custom" and ref $hash->{"input_schema"} eq "HASH"
!ll&&!rl&&r
14712515
$type eq "" and not ref $hash->{"name"} and length($hash->{"name"} // "")
!ll&&!rl&&r
101841311
$type eq "" and not ref $hash->{"name"}
!ll&&!rl&&r
10101395
$hash->{"name"} // ""
l!l
131184
$type eq "function" or $type eq "custom" and ref $$hash{"input_schema"} eq "HASH" or $type eq "" and not ref $$hash{"name"} and length($$hash{"name"} // "")
l!l&&r!l&&!r
000
$type eq "function" or $type eq "custom" and ref $$hash{"input_schema"} eq "HASH"
l!l&&r!l&&!r
000
$type eq "custom" and ref $$hash{"input_schema"} eq "HASH"
!ll&&!rl&&r
000
$type eq "" and not ref $$hash{"name"} and length($$hash{"name"} // "")
!ll&&!rl&&r
000
$type eq "" and not ref $$hash{"name"}
!ll&&!rl&&r
000
$$hash{"name"} // ""
l!l
00
MC/DC83%5/6
$type eq "function" or $type eq "custom" and ref $hash->{"input_schema"} eq "HASH" or $type eq "" and not ref $hash->{"name"} and length($hash->{"name"} // "")
$type eq "function" $type eq "custom" ref $hash->{"input_schema"} eq "HASH" $type eq "" not ref $hash->{"name"} $hash->{"name"}
MC/DC0%0/6
$type eq "function" or $type eq "custom" and ref $$hash{"input_schema"} eq "HASH" or $type eq "" and not ref $$hash{"name"} and length($$hash{"name"} // "")
$type eq "function" $type eq "custom" ref $$hash{"input_schema"} eq "HASH" $type eq "" not ref $$hash{"name"} $$hash{"name"}
Truth table60%6/10
A or B and C or D and not(E) and F
A= $type eq "function"B= $type eq "custom"C= ref $hash->{"input_schema"} eq "HASH"D= $type eq ""E= not ref $hash->{"name"}F= $hash->{"name"}
ABCDEFresult
1XXXXX1
011XXX1
00X1111
0101111
00X0XX0
00X10X0
00X1100
0100XX0
01010X0
0101100
Truth table0%0/10
A or B and C or D and not(E) and F
A= $type eq "function"B= $type eq "custom"C= ref $$hash{"input_schema"} eq "HASH"D= $type eq ""E= not ref $$hash{"name"}F= $$hash{"name"}
ABCDEFresult
1XXXXX1
011XXX1
00X1111
0101111
00X0XX0
00X10X0
00X1100
0100XX0
01010X0
0101100
237 || ( $type eq 'custom' && ref( $hash->{input_schema} ) eq 'HASH' )
238 || ( $type eq '' && !ref( $hash->{name} ) && length( $hash->{name} // '' ) ) ) {
239 0 $category = 'function';
240 0 $label = undef;
241 }
242 else {
243 0 $category = 'unknown';
244 0 ▶ $label //= join( ',', sort keys %$hash ) || '(empty)';
Condition50%4/8
$label //= join(",", sort(keys %$hash)) || "(empty)"
l!l
10184
join(',', sort(keys %$hash)) || '(empty)'
l!l
5925
$label //= join(",", sort(keys %$hash)) || "(empty)"
l!l
00
join(',', sort(keys %$hash)) || '(empty)'
l!l
00
MC/DC100%1/1
$label //= join(",", sort(keys %$hash)) || "(empty)"
$label
MC/DC0%0/1
$label //= join(",", sort(keys %$hash)) || "(empty)"
$label
Truth table100%2/2
A
A= $label
Aresult
11
00
Truth table0%0/2
A
A= $label
Aresult
11
00
245 }
246 0 ▶ return wantarray ? ( $category, $wire, $label ) : $category;
Branch: 2 branches
BranchTrueFalseTotal
wantarray ? : 1636 1183 2819
wantarray ? : 0 0 0
247 }
248  
249 # Build from a list of any-shape tool definitions. A plain hash that is not a
250 # function tool croaks in from_hash (k210). Anything that is not a plain HASH
251 # and not a Langertha::Tool -- a string, an array ref, a blessed non-Tool
252 # object even if it is hash-based -- is still skipped silently.
253 1289 ▶sub from_list {
Subroutine from_list: called CC=4 SCAR=19.9
Pod undocumented
254 0 ▶ my ($class, $list) = @_;
Subroutine from_list: not called CC=4 SCAR=19.9
Pod undocumented
255 0 ▶ return [] unless ref($list) eq 'ARRAY';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $list eq "ARRAY" 0 1289 1289
unless ref $list eq "ARRAY" 0 0 0
256 0 my @out;
257 0 for my $item (@$list) {
258 0 my $tool = $class->from_hash($item);
259 0 ▶ push @out, $tool if $tool;
Branch: 2 branches
BranchTrueFalseTotal
if $tool 831 0 831
if $tool 0 0 0
260 }
261 0 return \@out;
262 }
263  
264 # --- Serializers to wire-format hashes ---
265  
266 179 ▶sub to_openai {
Subroutine to_openai: called CC=1 SCAR=1.2
Pod undocumented
267 0 ▶ my ($self) = @_;
Subroutine to_openai: not called CC=1 SCAR=1.2
Pod undocumented
268 return {
269 0 type => 'function',
270 function => {
271 name => $self->name,
272 description => $self->description,
273 parameters => $self->input_schema,
274 },
275 };
276 }
277  
278 84 ▶sub to_anthropic {
Subroutine to_anthropic: called CC=2 SCAR=9.2
Pod undocumented
279 0 ▶ my ($self) = @_;
Subroutine to_anthropic: not called CC=2 SCAR=9.2
Pod undocumented
280 0 my $schema = $self->input_schema;
281 return {
282 0 ▶ name => $self->name,
Branch: 2 branches
BranchTrueFalseTotal
_schema_is_strict($schema) ? : 1 83 84
_schema_is_strict($schema) ? : 0 0 0
283 description => $self->description,
284 input_schema => $schema,
285 # Strict tool use (GA, no beta header): guarantees tool_use.input validates
286 # exactly against input_schema. Anthropic requires a closed schema for it —
287 # additionalProperties:false plus a non-empty required list — so we only
288 # emit strict:true where the schema author opted into that shape, and stay
289 # silent (and lenient) otherwise. Emitting strict on an open schema 400s.
290 ( _schema_is_strict($schema) ? ( strict => JSON->true ) : () ),
291 };
292 }
293  
294 # True when input_schema is closed enough for Anthropic strict tool use:
295 # additionalProperties explicitly false and a non-empty required array.
296 84 ▶sub _schema_is_strict {
Subroutine _schema_is_strict: called CC=6 SCAR=25.0
297 0 ▶ my ($schema) = @_;
Subroutine _schema_is_strict: not called CC=6 SCAR=25.0
298 0 ▶ return 0 unless ref($schema) eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
unless ref $schema eq "HASH" 0 84 84
unless ref $schema eq "HASH" 0 0 0
299 0 ▶ return 0 unless exists $schema->{additionalProperties};
Branch: 2 branches
BranchTrueFalseTotal
unless exists $schema->{"additionalProperties"} 77 7 84
unless exists $$schema{"additionalProperties"} 0 0 0
300 0 ▶ return 0 if $schema->{additionalProperties}; # true / truthy -> open schema
Branch: 2 branches
BranchTrueFalseTotal
if $schema->{"additionalProperties"} 5 2 7
if $$schema{"additionalProperties"} 0 0 0
301 0 ▶ return 0 unless ref($schema->{required}) eq 'ARRAY' && @{$schema->{required}};
Branch: 2 branches
BranchTrueFalseTotal
unless ref $schema->{"required"} eq "ARRAY" and @{$schema->{"required"};} 1 1 2
unless ref $$schema{"required"} eq "ARRAY" and @{$$schema{"required"};} 0 0 0
Condition33%2/6
ref $schema->{"required"} eq "ARRAY" and @{$schema->{"required"};}
!ll&&!rl&&r
101
ref $$schema{"required"} eq "ARRAY" and @{$$schema{"required"};}
!ll&&!rl&&r
000
MC/DC50%1/2
ref $schema->{"required"} eq "ARRAY" and @{$schema->{"required"};}
ref $schema->{"required"} eq "ARRAY" @{$schema->{"required"};}
MC/DC0%0/2
ref $$schema{"required"} eq "ARRAY" and @{$$schema{"required"};}
ref $$schema{"required"} eq "ARRAY" @{$$schema{"required"};}
Truth table66%2/3
A and B
A= ref $schema->{"required"} eq "ARRAY"B= @{$schema->{"required"};}
ABresult
0X0
100
111
Truth table0%0/3
A and B
A= ref $$schema{"required"} eq "ARRAY"B= @{$$schema{"required"};}
ABresult
0X0
100
111
302 0 return 1;
303 }
304  
305 32 ▶sub to_ollama { $_[0]->to_openai }
Subroutine to_ollama: called CC=1 SCAR=0.0
Pod undocumented
306  
307 # Gemini: the schema goes out as parametersJsonSchema (v1beta), which takes JSON
308 # Schema as-is -- `parameters` is an OpenAPI-subset proto that 400s on MCP's
309 # additionalProperties, $ref/$defs, const. The two are mutually exclusive, so
310 # `parameters` is never sent; no sanitizer. Only a top-level $schema is dropped,
311 # and a tool without arguments declares no schema at all (karr k330, ADR 0001).
312 204 my %NO_ARG_KEY = map { $_ => 1 } qw( type properties required additionalProperties );
313  
314 87 ▶sub _gemini_schema {
Subroutine _gemini_schema: called CC=5 SCAR=16.3
315 87 my ($self) = @_;
316 87 my $schema = $self->input_schema;
317 87 ▶ return undef unless ref $schema eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $schema eq "HASH" 0 87 87
318 87 my %schema = %$schema;
319 87 delete $schema{'$schema'};
320 87 my $props = $schema{properties};
321 my $no_args = !( ref $props eq 'HASH' && %$props )
322 87 ▶ && !grep { !$NO_ARG_KEY{$_} } keys %schema;
Condition66%4/6
ref $props eq 'HASH' && %$props || grep({not $NO_ARG_KEY{$_};} keys %schema)
l!l&&r!l&&!r
61026
ref $props eq "HASH" and %$props
!ll&&!rl&&r
02661
MC/DC33%1/3
ref $props eq 'HASH' && %$props || grep({not $NO_ARG_KEY{$_};} keys %schema)
ref $props eq "HASH" %$props grep({not $NO_ARG_KEY{$_};} keys %schema)
Truth table40%2/5
A and B || C
A= ref $props eq "HASH"B= %$propsC= grep({not $NO_ARG_KEY{$_};} keys %schema)
ABCresult
11X1
0X11
1011
0X00
1000
323 87 ▶ return $no_args ? undef : \%schema;
Branch: 1 branch
BranchTrueFalseTotal
$no_args ? : 26 61 87
324 }
325  
326 87 ▶sub to_gemini {
Subroutine to_gemini: called CC=2 SCAR=6.9
Pod undocumented
327 87 my ($self) = @_;
328 87 my $schema = $self->_gemini_schema;
329 return {
330 87 ▶ name => $self->name,
Branch: 1 branch
BranchTrueFalseTotal
$schema ? : 61 26 87
331 description => $self->description,
332 ( $schema ? ( parametersJsonSchema => $schema ) : () ),
333 };
334 }
335  
336 # OpenAI Responses API: flat tool objects, no {type:'function',function:{...}} wrapper
337 182 ▶sub to_responses {
Subroutine to_responses: called CC=1 SCAR=0.0
Pod undocumented
338 182 my ($self) = @_;
339 return {
340 182 type => 'function',
341 name => $self->name,
342 description => $self->description,
343 parameters => $self->input_schema,
344 };
345 }
346  
347 198 ▶sub to_mcp {
Subroutine to_mcp: called CC=1 SCAR=0.0
Pod undocumented
348 198 my ($self) = @_;
349 return {
350 198 name => $self->name,
351 description => $self->description,
352 inputSchema => $self->input_schema,
353 };
354 }
355  
356 # Shape used inside OpenAI's response_format => { type=>'json_schema',
357 # json_schema => { ... } } — and the basis of the chat_f forced-tool
358 # fallback path.
359 22 ▶sub to_json_schema {
Subroutine to_json_schema: called CC=1 SCAR=0.0
Pod undocumented
360 22 my ($self) = @_;
361 return {
362 22 name => $self->name,
363 description => $self->description,
364 schema => $self->input_schema,
365 };
366 }
367  
368 # Canonical hash (matches the legacy Input::Tools->normalize_tools shape).
369 5 ▶sub to_hash {
Subroutine to_hash: called CC=1 SCAR=0.0
Pod undocumented
370 5 my ($self) = @_;
371 return {
372 5 name => $self->name,
373 description => $self->description,
374 input_schema => $self->input_schema,
375 };
376 }
377  
378 # Make the object transparent to any JSON encoder configured with
379 # convert_blessed => 1 (the house default, see Langertha::Plugin::Langfuse).
380 # to_hash is the complete canonical representation, so this is a plain
381 # delegator — nothing is dropped.
382 1 ▶sub TO_JSON { shift->to_hash }
Subroutine TO_JSON: called CC=1 SCAR=0.0
Pod undocumented
383  
384 # --- Tag-driven dispatch ---
385  
386 # Maps a tool_wire_format tag to the per-tool serializer method.
387 204 my %TO_METHOD = (
388 openai => 'to_openai',
389 anthropic => 'to_anthropic',
390 gemini => 'to_gemini',
391 ollama => 'to_ollama',
392 responses => 'to_responses',
393 mcp => 'to_mcp',
394 hermes => 'to_mcp', # Hermes injects raw MCP defs into the prompt as JSON
395 );
396  
397 # Serialize this single tool to the given wire format.
398 693 ▶sub to {
Subroutine to: called CC=4 SCAR=14.3
Pod documented
399 693 my ($self, $fmt) = @_;
400 693 ▶ my $method = $TO_METHOD{ $fmt // '' }
Branch: 1 branch
BranchTrueFalseTotal
my $method = $TO_METHOD{$fmt // ""} or croak(q[Langertha::Tool: unknown wire format '] . ($fmt // "") . q[']) 692 1 693
Condition50%2/4
$fmt // ""
l!l
6930
$fmt // ""
l!l
10
MC/DC0%0/1
$fmt // ""
$fmt
MC/DC0%0/1
$fmt // ""
$fmt
Truth table50%1/2
A
A= $fmt
Aresult
11
00
Truth table50%1/2
A
A= $fmt
Aresult
11
00
401 or croak "Langertha::Tool: unknown wire format '" . ( $fmt // '' ) . "'";
402 692 return $self->$method;
403 }
404  
405 # Class method: turn a list of any-shape (usually MCP) tool hashrefs into the
406 # full wire `tools` payload for the given format. Handles collection-level
407 # shaping (Gemini wraps its declarations) that a per-tool serializer cannot.
408 #
409 # A server-side tool (a Langertha::ServerTool, or a hash ServerTool->from_hash
410 # recognises for $fmt) keeps its place in the list and goes out as its native
411 # hash; ServerTool->to croaks when its wire is not $fmt (k206, ADR 0030).
412 # Everything else goes through from_list, so a server tool of another wire, a
413 # client-executed built-in or an unknown type still croaks at the Tool door.
414 987 ▶sub format_list {
Subroutine format_list: called CC=5 SCAR=16.1
Pod undocumented
415 987 my ($class, $fmt, $tools) = @_;
416 987 ▶ $fmt //= '';
Condition50%1/2
$fmt //= ""
l!l
9870
MC/DC0%0/1
$fmt //= ""
$fmt
Truth table50%1/2
A
A= $fmt
Aresult
11
00
417 987 require Langertha::ServerTool;
418 my @items = map {
419 987 my $st = Langertha::ServerTool->from_hash( $fmt, $_ );
420 1217 ▶ $st ? $st : @{ $class->from_list([$_]) };
Branch: 2 branches
BranchTrueFalseTotal
$st ? : 35 1182 1217
ref $tools eq 'ARRAY' ? : 987 0 987
421 } ( ref($tools) eq 'ARRAY' ? @$tools : () );
422 573 ▶ if ( $fmt eq 'gemini' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fmt eq "gemini") 53 520 573
423 53 return [ { functionDeclarations => [ map { $_->to('gemini') } @items ] } ];
424 }
425 520 return [ map { $_->to($fmt) } @items ];
426 }
427  
428 # --- A caller's request tools list (k227, ADR 0001) ---
429 #
430 # chat_f and chat_stream_realtime_f take a tools list the caller built by
431 # hand: Tool objects, ServerTool objects and hashes of any shape, often mixed.
432 # Unlike format_list (whose callers only ever emit function tools), this keeps
433 # everything the caller meant and decides per item, in place:
434 # - a Tool or ServerTool object goes through its own to($fmt);
435 # - a function-tool hash already in $fmt's own shape goes out verbatim, so
436 # the extras the value object does not model survive (function.strict,
437 # cache_control, Gemini's declaration fields);
438 # - a function-tool hash in another shape (MCP inputSchema, canonical
439 # input_schema, the other dialect's shape) is converted, carrying over
440 # the extras $fmt takes (%CARRY);
441 # - anything else -- a built-in, a typed item Langertha does not know, a
442 # Gemini { functionDeclarations => [...] } -- goes out verbatim: the
443 # provider judges it, as the Responses envelope does for typed items
444 # (k210). Nothing is dropped and nothing becomes a function tool.
445 # Gemini keeps all function declarations in ONE functionDeclarations entry
446 # (k221 review M4), placed where the first declaration came from; a later
447 # raw functionDeclarations (or function_declarations) entry gives up its
448 # declarations to it and keeps its other fields.
449  
450 # True when a function-tool hash is already in $fmt's own tools-list shape.
451 80 ▶sub _is_wire_function {
Subroutine _is_wire_function: called CC=12 SCAR=25.8
452 80 my ( $hash, $fmt ) = @_;
453 80 ▶ my $type = $hash->{type} // '';
Condition100%2/2
$hash->{"type"} // ""
l!l
3446
MC/DC100%1/1
$hash->{"type"} // ""
$hash->{"type"}
Truth table100%2/2
A
A= $hash->{"type"}
Aresult
11
00
454 80 ▶ return $type eq 'function' && ref $hash->{function} eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
if $fmt eq "openai" or $fmt eq "ollama" 53 27 80
Condition83%5/6
$fmt eq "openai" or $fmt eq "ollama"
l!l&&r!l&&!r
421127
$type eq 'function' && ref $hash->{'function'} eq 'HASH'
!ll&&!rl&&r
21032
MC/DC100%2/2
$fmt eq "openai" or $fmt eq "ollama"
$fmt eq "openai" $fmt eq "ollama"
MC/DC50%1/2
$type eq 'function' && ref $hash->{'function'} eq 'HASH'
$type eq 'function' ref $hash->{'function'} eq 'HASH'
Truth table100%3/3
A or B
A= $fmt eq "openai"B= $fmt eq "ollama"
ABresult
1X1
011
000
Truth table66%2/3
A && B
A= $type eq 'function'B= ref $hash->{'function'} eq 'HASH'
ABresult
0X0
100
111
455 if $fmt eq 'openai' || $fmt eq 'ollama';
456 return ( $type eq '' || $type eq 'custom' )
457 && ref $hash->{input_schema} eq 'HASH' && !exists $hash->{inputSchema}
458 27 ▶ if $fmt eq 'anthropic';
Branch: 1 branch
BranchTrueFalseTotal
if $fmt eq "anthropic" 13 14 27
Condition77%7/9
($type eq '' || $type eq 'custom') && ref $hash->{'input_schema'} eq 'HASH' && !exists $hash->{'inputSchema'}
!ll&&!rl&&r
805
$type eq "" || $type eq "custom" and ref $hash->{"input_schema"} eq "HASH"
!ll&&!rl&&r
265
$type eq "" or $type eq "custom"
l!l&&r!l&&!r
1102
MC/DC50%2/4
($type eq '' || $type eq 'custom') && ref $hash->{'input_schema'} eq 'HASH' && !exists $hash->{'inputSchema'}
$type eq "" $type eq "custom" ref $hash->{"input_schema"} eq "HASH" !exists $hash->{'inputSchema'}
Truth table42%3/7
A or B and C && not(D)
A= $type eq ""B= $type eq "custom"C= ref $hash->{"input_schema"} eq "HASH"D= !exists $hash->{'inputSchema'}
ABCDresult
00XX0
1X0X0
010X0
1X100
01100
1X111
01111
459 # A Gemini declaration (name + parameters, and fields such as behavior).
460 return $type eq '' && !exists $hash->{inputSchema} && !exists $hash->{input_schema}
461 14 ▶ if $fmt eq 'gemini';
Branch: 1 branch
BranchTrueFalseTotal
if $fmt eq "gemini" 14 0 14
Condition66%4/6
$type eq '' && !exists $hash->{'inputSchema'} && !exists $hash->{'input_schema'}
!ll&&!rl&&r
1103
$type eq "" and not exists $hash->{"inputSchema"}
!ll&&!rl&&r
0113
MC/DC33%1/3
$type eq '' && !exists $hash->{'inputSchema'} && !exists $hash->{'input_schema'}
$type eq "" not exists $hash->{"inputSchema"} !exists $hash->{'input_schema'}
Truth table50%2/4
A and not(B) && not(C)
A= $type eq ""B= not exists $hash->{"inputSchema"}C= !exists $hash->{'input_schema'}
ABCresult
0XX0
10X0
1100
1111
462 0 return 0;
463 }
464  
465 # The extras a converted hash keeps, per target wire. strict may sit on the
466 # hash or in OpenAI's nested function; an explicit value beats the schema
467 # guess of to_anthropic.
468 40 ▶sub _carry_extras {
Subroutine _carry_extras: called CC=8 SCAR=20.8
469 40 my ( $hash, $out, $fmt ) = @_;
470 40 ▶ my $fn = ref $hash->{function} eq 'HASH' ? $hash->{function} : {};
Branch: 1 branch
BranchTrueFalseTotal
ref $hash->{'function'} eq 'HASH' ? : 2 38 40
471 40 ▶ my $strict = exists $hash->{strict} ? $hash->{strict} : $fn->{strict};
Branch: 1 branch
BranchTrueFalseTotal
exists $hash->{'strict'} ? : 1 39 40
472 40 ▶ if ( $fmt eq 'openai' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($fmt eq 'openai') { } 13 27 40
elsif ($fmt eq 'anthropic') { } 8 19 27
473 13 ▶ $out->{function}{strict} = $strict if defined $strict;
Branch: 1 branch
BranchTrueFalseTotal
if defined $strict 1 12 13
474 }
475 elsif ( $fmt eq 'anthropic' ) {
476 8 ▶ $out->{strict} = $strict if defined $strict;
Branch: 1 branch
BranchTrueFalseTotal
if defined $strict 1 7 8
477 8 ▶ $out->{cache_control} = $hash->{cache_control} if exists $hash->{cache_control};
Branch: 1 branch
BranchTrueFalseTotal
if exists $hash->{"cache_control"} 1 7 8
478 }
479 40 return $out;
480 }
481  
482 # One item on $fmt; for gemini, a function tool comes back as a declaration.
483 114 ▶sub _request_item {
Subroutine _request_item: called CC=6 SCAR=18.2
484 114 my ( $class, $item, $fmt ) = @_;
485 114 ▶ return $item->to($fmt)
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($item) and $item->isa(__PACKAGE__) || $item->isa("Langertha::ServerTool") 20 94 114
Condition50%3/6
builtin::blessed($item) and $item->isa(__PACKAGE__) || $item->isa("Langertha::ServerTool")
!ll&&!rl&&r
94020
$item->isa(__PACKAGE__) or $item->isa("Langertha::ServerTool")
l!l&&r!l&&!r
2000
MC/DC33%1/3
builtin::blessed($item) and $item->isa(__PACKAGE__) || $item->isa("Langertha::ServerTool")
builtin::blessed($item) $item->isa(__PACKAGE__) $item->isa("Langertha::ServerTool")
Truth table50%2/4
A and B or C
A= builtin::blessed($item)B= $item->isa(__PACKAGE__)C= $item->isa("Langertha::ServerTool")
ABCresult
0XX0
1000
11X1
1011
486 if blessed($item) && ( $item->isa(__PACKAGE__) || $item->isa('Langertha::ServerTool') );
487 94 ▶ return $item unless _is_function_hash($item);
Branch: 1 branch
BranchTrueFalseTotal
unless _is_function_hash($item) 14 80 94
488 80 ▶ return $item if _is_wire_function( $item, $fmt );
Branch: 1 branch
BranchTrueFalseTotal
if _is_wire_function($item, $fmt) 40 40 80
489 40 return _carry_extras( $item, $class->from_hash($item)->to($fmt), $fmt );
490 }
491  
492 126 ▶sub _is_function_hash {
Subroutine _is_function_hash: called CC=2 SCAR=7.1
493 126 my ($item) = @_;
494 126 ▶ return ref $item eq 'HASH' && scalar __PACKAGE__->classify($item) eq 'function';
Condition66%2/3
ref $item eq 'HASH' && scalar __PACKAGE__->classify($item) eq 'function'
!ll&&!rl&&r
03294
MC/DC50%1/2
ref $item eq 'HASH' && scalar __PACKAGE__->classify($item) eq 'function'
ref $item eq 'HASH' scalar __PACKAGE__->classify($item) eq 'function'
Truth table66%2/3
A && B
A= ref $item eq 'HASH'B= scalar __PACKAGE__->classify($item) eq 'function'
ABresult
0X0
100
111
495 }
496  
497 # The key a raw Gemini tool entry keeps its declarations under; the REST API
498 # reads both spellings (ADR 0018), the merged entry is written in camelCase.
499 18 ▶sub _declarations_key {
Subroutine _declarations_key: called CC=4 SCAR=13.9
500 18 my ($item) = @_;
501 18 ▶ return undef unless ref $item eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $item eq "HASH" 0 18 18
502 18 for my $key (qw( functionDeclarations function_declarations )) {
503 26 ▶ return $key if ref $item->{$key} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $item->{$key} eq "ARRAY" 12 14 26
504 }
505 6 return undef;
506 }
507  
508 93 ▶sub request_list {
Subroutine request_list: called CC=13 SCAR=25.7
Pod documented
509 93 my ( $class, $fmt, $tools ) = @_;
510 93 ▶ return $tools unless ref $tools eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $tools eq "ARRAY" 0 93 93
511 93 ▶ return [ map { $class->_request_item( $_, $fmt ) } @$tools ] unless $fmt eq 'gemini';
Branch: 1 branch
BranchTrueFalseTotal
unless $fmt eq "gemini" 69 24 93
512 24 my ( @out, @decls, $group );
513 24 for my $item (@$tools) {
514 40 ▶ if ( ( blessed($item) && $item->isa(__PACKAGE__) ) || _is_function_hash($item) ) {
Branch: 2 branches
BranchTrueFalseTotal
if (builtin::blessed($item) and $item->isa(__PACKAGE__) or _is_function_hash($item)) { } 22 18 40
elsif (my $key = _declarations_key($item)) { } 12 6 18
Condition83%5/6
builtin::blessed($item) and $item->isa(__PACKAGE__) or _is_function_hash($item)
l!l&&r!l&&!r
81418
builtin::blessed($item) and $item->isa(__PACKAGE__)
!ll&&!rl&&r
3208
MC/DC66%2/3
builtin::blessed($item) and $item->isa(__PACKAGE__) or _is_function_hash($item)
builtin::blessed($item) $item->isa(__PACKAGE__) _is_function_hash($item)
Truth table60%3/5
A and B or C
A= builtin::blessed($item)B= $item->isa(__PACKAGE__)C= _is_function_hash($item)
ABCresult
11X1
0X11
1011
0X00
1000
515 22 push @decls, $class->_request_item( $item, $fmt );
516 22 ▶ push @out, $group = {} unless $group;
Branch: 1 branch
BranchTrueFalseTotal
unless $group 17 5 22
517 }
518 elsif ( my $key = _declarations_key($item) ) {
519 12 push @decls, @{ $item->{$key} };
520 12 my %rest = %$item;
521 12 delete $rest{$key};
522 12 ▶ push @out, \%rest if !$group || %rest;
Branch: 1 branch
BranchTrueFalseTotal
if not $group or %rest 9 3 12
Condition100%3/3
not $group or %rest
l!l&&r!l&&!r
723
MC/DC100%2/2
not $group or %rest
not $group %rest
Truth table100%3/3
not(A) or B
A= not $groupB= %rest
ABresult
1X1
011
000
523 12 ▶ $group //= \%rest;
Condition100%2/2
$group //= \%rest
l!l
57
MC/DC100%1/1
$group //= \%rest
$group
Truth table100%2/2
A
A= $group
Aresult
11
00
524 }
525 else {
526 6 push @out, $class->_request_item( $item, $fmt );
527 }
528 }
529 24 ▶ $group->{functionDeclarations} = \@decls if $group;
Branch: 1 branch
BranchTrueFalseTotal
if $group 24 0 24
530 24 return \@out;
531 }
532  
533  
534 204 __PACKAGE__->meta->make_immutable;
535 204 1;
536  
537 __END__
« blib/lib/Langertha/Role/Tools.pm ↑ Summary blib/lib/Langertha/Engine/LMStudio.pm »