| 1 | package Langertha::Knarr::CLI::Cmd::Check; | ||||||||||||||||||||||||||||
| 2 | 2 | our $VERSION = '1.100'; | |||||||||||||||||||||||||||
| 3 | # ABSTRACT: Validate Knarr configuration file | ||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use MooX::Cmd; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use MooX::Options protect_argv => 0, usage_string => 'USAGE: knarr check [options]'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | sub execute { | ||||||||||||||||||||||||||||
| 10 | 1 | ▶ | my ($self, $args, $chain) = @_; | ||||||||||||||||||||||||||
|
Subroutine
execute: called CC=15 SCAR=35.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 11 | 1 | my $main = $chain->[0]; | |||||||||||||||||||||||||||
| 12 | 1 | my $config_file = $main->config; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | unless (-f $config_file) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | 0 | print STDERR "Config file not found: $config_file\n"; | |||||||||||||||||||||||||||
| 16 | 0 | exit 1; | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | require Langertha::Knarr::Config; | |||||||||||||||||||||||||||
| 20 | 1 | my $config = eval { Langertha::Knarr::Config->new(file => $config_file) }; | |||||||||||||||||||||||||||
| 21 | 1 | ▶ | if ($@) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | 0 | print STDERR "Failed to parse config: $@\n"; | |||||||||||||||||||||||||||
| 23 | 0 | exit 1; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | my @errors = $config->validate; | |||||||||||||||||||||||||||
| 27 | 1 | ▶ | if (@errors) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 0 | print "Configuration INVALID:\n"; | |||||||||||||||||||||||||||
| 29 | 0 | print " - $_\n" for @errors; | |||||||||||||||||||||||||||
| 30 | 0 | 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
| |||||||||||||||||||||||||||||
| 40 | 1 | ▶ | print " Auto-discover: ", ($config->auto_discover ? 'enabled' : 'disabled'), "\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 1 | ▶ | print " Proxy auth: ", ($config->has_proxy_api_key && $config->proxy_api_key ? 'enabled' : 'disabled'), "\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$config->has_proxy_api_key and $config->proxy_api_key
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
| |||||||||||||||||||||||||||||
| 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"}
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"}
| |||||||||||||||||||||||||||||
| 46 | 1 | ▶ | my $lf_sec = $lf->{secret_key} // $ENV{LANGFUSE_SECRET_KEY}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$lf->{"secret_key"} // $ENV{"LANGFUSE_SECRET_KEY"}
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"}
| |||||||||||||||||||||||||||||
| 47 | 1 | ▶ | if ($lf_pub && $lf_sec) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$lf_pub and $lf_sec
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
| |||||||||||||||||||||||||||||
| 48 | 0 | ▶ | print " Langfuse: enabled (", ($lf->{url} // $ENV{LANGFUSE_URL} // 'cloud.langfuse.com'), ")\n"; | ||||||||||||||||||||||||||
|
Condition0%0/5
($lf->{"url"} // $ENV{"LANGFUSE_URL"}) // "cloud.langfuse.com"
$lf->{"url"} // $ENV{"LANGFUSE_URL"}
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"}
| |||||||||||||||||||||||||||||
| 49 | } else { | ||||||||||||||||||||||||||||
| 50 | 1 | print " Langfuse: disabled (set LANGFUSE_PUBLIC_KEY + LANGFUSE_SECRET_KEY to enable)\n"; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 2 | 1; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | __END__ | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =pod | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head1 NAME | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | Langertha::Knarr::CLI::Cmd::Check - Validate Knarr configuration file | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | =head1 VERSION | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | version 1.100 | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | Implements the C<knarr check> command. Parses the config file, runs | ||||||||||||||||||||||||||||
| 73 | L<Langertha::Knarr::Config/validate>, and prints a status summary including | ||||||||||||||||||||||||||||
| 74 | listen addresses, model count, auto-discover state, proxy auth state, and | ||||||||||||||||||||||||||||
| 75 | Langfuse tracing state. Exits with a non-zero code on invalid config. | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | See L<knarr> for option details and L<Langertha::Knarr> for full documentation. | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =over | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =item * L<knarr> — CLI synopsis and option reference | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =item * L<Langertha::Knarr::Config/validate> — Validation logic | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =back | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | =head2 Issues | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | Please report bugs and feature requests on GitHub at | ||||||||||||||||||||||||||||
| 94 | L<https://github.com/Getty/langertha-knarr/issues>. | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =head2 IRC | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head1 CONTRIBUTING | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/> | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | This software is copyright (c) 2026 by Torsten Raudssus. | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 113 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =cut | ||||||||||||||||||||||||||||