blib/lib/Langertha/Knarr/CLI/Cmd/Check.pm

filter: Statementstmt 88.6% 39 / 44 Branchbran 57.1% 8 / 14 Conditioncond 23.5% 4 / 17 MC/DCmcdc 0.0% 0 / 10 Subroutinesub 100% 4 / 4 Podpod 0.0% 0 / 1 totaltotal 61.1% 55 / 90 CC 15 SCAR 31.4
CC
15
Cov
68%
execute
27.4
BEGIN
1.0
BEGIN
1.0
CRAP 23.0
« blib/lib/Langertha/Knarr/Handler/A2AClient.pm ↑ Summary blib/lib/Langertha/Knarr/PSGI.pm »
1 package Langertha::Knarr::CLI::Cmd::Check;
2 39 our $VERSION = '1.102';
3 # ABSTRACT: Validate Knarr configuration file
4 39 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 39 with 'Langertha::Knarr::CLI::Role::GlobalOptions';
6 39 ▶use MooX::Cmd;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 39 ▶use MooX::Options protect_argv => 0, usage_string => 'USAGE: knarr check [options]';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9  
10 2 ▶sub execute {
Subroutine execute: called CC=15 SCAR=33.1
Pod undocumented
11 2 my ($self, $args, $chain) = @_;
12 2 my $config_file = $self->config_file($chain);
13  
14 2 ▶ unless (-f $config_file) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $config_file) 0 2 2
15 0 print STDERR "Config file not found: $config_file\n";
16 0 exit 1;
17 }
18  
19 2 require Langertha::Knarr::Config;
20 2 my $config = eval { Langertha::Knarr::Config->new(file => $config_file) };
21 2 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 2 2
22 0 print STDERR "Failed to parse config: $@\n";
23 0 exit 1;
24 }
25  
26 2 my @errors = $config->validate;
27 2 ▶ if (@errors) {
Branch: 1 branch
BranchTrueFalseTotal
if (@errors) 1 1 2
28 1 print "Configuration INVALID:\n";
29 1 print " - $_\n" for @errors;
30 1 exit 1;
31 }
32  
33 1 my $models = $config->models;
34 1 my $model_count = scalar keys %$models;
35 1 print "Configuration OK\n";
36 1 print " File: $config_file\n";
37 1 print " Listen: ", join(', ', @{$config->listen}), "\n";
38 1 print " Models: $model_count configured\n";
39 1 ▶ print " Default engine: ", ($config->default_engine ? $config->default_engine->{engine} : 'none'), "\n";
Branch: 1 branch
BranchTrueFalseTotal
$config->default_engine ? : 0 1 1
40 1 ▶ print " Auto-discover: ", ($config->auto_discover ? 'enabled' : 'disabled'), "\n";
Branch: 1 branch
BranchTrueFalseTotal
$config->auto_discover ? : 0 1 1
41 1 ▶ print " Proxy auth: ", ($config->has_proxy_api_key && $config->proxy_api_key ? 'enabled' : 'disabled'), "\n";
Branch: 1 branch
BranchTrueFalseTotal
$config->has_proxy_api_key && $config->proxy_api_key ? : 0 1 1
Condition33%1/3
$config->has_proxy_api_key and $config->proxy_api_key
!ll&&!rl&&r
100
MC/DC0%0/2
$config->has_proxy_api_key and $config->proxy_api_key
$config->has_proxy_api_key $config->proxy_api_key
Truth table33%1/3
A and B
A= $config->has_proxy_api_keyB= $config->proxy_api_key
ABresult
0X0
100
111
42  
43 # Check Langfuse
44 1 my $lf = $config->langfuse;
45 1 ▶ my $lf_pub = $lf->{public_key} // $ENV{LANGFUSE_PUBLIC_KEY};
Condition33%1/3
$lf->{"public_key"} // $ENV{"LANGFUSE_PUBLIC_KEY"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$lf->{"public_key"} // $ENV{"LANGFUSE_PUBLIC_KEY"}
$lf->{"public_key"} $ENV{"LANGFUSE_PUBLIC_KEY"}
Truth table33%1/3
A // B
A= $lf->{"public_key"}B= $ENV{"LANGFUSE_PUBLIC_KEY"}
ABresult
1X1
011
000
46 1 ▶ my $lf_sec = $lf->{secret_key} // $ENV{LANGFUSE_SECRET_KEY};
Condition33%1/3
$lf->{"secret_key"} // $ENV{"LANGFUSE_SECRET_KEY"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$lf->{"secret_key"} // $ENV{"LANGFUSE_SECRET_KEY"}
$lf->{"secret_key"} $ENV{"LANGFUSE_SECRET_KEY"}
Truth table33%1/3
A // B
A= $lf->{"secret_key"}B= $ENV{"LANGFUSE_SECRET_KEY"}
ABresult
1X1
011
000
47 1 ▶ if ($lf_pub && $lf_sec) {
Branch: 1 branch
BranchTrueFalseTotal
if ($lf_pub and $lf_sec) { } 0 1 1
Condition33%1/3
$lf_pub and $lf_sec
!ll&&!rl&&r
100
MC/DC0%0/2
$lf_pub and $lf_sec
$lf_pub $lf_sec
Truth table33%1/3
A and B
A= $lf_pubB= $lf_sec
ABresult
0X0
100
111
48 0 ▶ print " Langfuse: enabled (", ($lf->{url} // $ENV{LANGFUSE_URL} // 'cloud.langfuse.com'),
Condition0%0/5
($lf->{"url"} // $ENV{"LANGFUSE_URL"}) // "cloud.langfuse.com"
l!l
00
$lf->{"url"} // $ENV{"LANGFUSE_URL"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($lf->{"url"} // $ENV{"LANGFUSE_URL"}) // "cloud.langfuse.com"
$lf->{"url"} $ENV{"LANGFUSE_URL"}
Truth table0%0/3
A // B
A= $lf->{"url"}B= $ENV{"LANGFUSE_URL"}
ABresult
1X1
011
000
49 ", ", $config->langfuse_transport, ")\n";
50 } else {
51 1 print " Langfuse: disabled (set LANGFUSE_PUBLIC_KEY + LANGFUSE_SECRET_KEY to enable)\n";
52 }
53 }
54  
55 39 1;
56  
57 __END__
58  
59 =pod
60  
61 =encoding UTF-8
62  
63 =head1 NAME
64  
65 Langertha::Knarr::CLI::Cmd::Check - Validate Knarr configuration file
66  
67 =head1 VERSION
68  
69 version 1.102
70  
71 =head1 DESCRIPTION
72  
73 Implements the C<knarr check> command. Parses the config file, runs
74 L<Langertha::Knarr::Config/validate>, and prints a status summary including
75 listen addresses, model count, auto-discover state, proxy auth state, and
76 Langfuse tracing state. Exits with a non-zero code on invalid config.
77  
78 See L<knarr> for option details and L<Langertha::Knarr::Config> for the
79 configuration file format.
80  
81 =head1 SEE ALSO
82  
83 =over
84  
85 =item * L<knarr> — CLI synopsis and option reference
86  
87 =item * L<Langertha::Knarr::Config/validate> — Validation logic
88  
89 =back
90  
91 =head1 SUPPORT
92  
93 =head2 Issues
94  
95 Please report bugs and feature requests on GitHub at
96 L<https://github.com/Getty/langertha-knarr/issues>.
97  
98 =head2 IRC
99  
100 Join C<#langertha> on C<irc.perl.org> or message Getty directly.
101  
102 =head1 CONTRIBUTING
103  
104 Contributions are welcome! Please fork the repository and submit a pull request.
105  
106 =head1 AUTHOR
107  
108 Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/>
109  
110 =head1 COPYRIGHT AND LICENSE
111  
112 This software is copyright (c) 2026 by Torsten Raudssus.
113  
114 This is free software; you can redistribute it and/or modify it under
115 the same terms as the Perl 5 programming language system itself.
116  
117 =cut
« blib/lib/Langertha/Knarr/Handler/A2AClient.pm ↑ Summary blib/lib/Langertha/Knarr/PSGI.pm »