| 1 | package Langertha::Manifest::Endpoint; | ||||||||||
| 2 | # ABSTRACT: One endpoint of a provider manifest: wire dialect, base URL, auth reference | ||||||||||
| 3 | 8 | our $VERSION = '0.505'; | |||||||||
| 4 | 8 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 8 | with 'Langertha::Manifest::Validation'; | |||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | # The v1 dialect vocabulary, derived from the engine hierarchy (ADR 0006: | ||||||||||
| 9 | # inheritance encodes the wire dialect) and named after the tool_wire_format | ||||||||||
| 10 | # tag where the two coincide. openai-chat carries a suffix because OpenAI | ||||||||||
| 11 | # ships two envelopes (/chat/completions and /responses). | ||||||||||
| 12 | # anthropic-compat is the /anthropic shim variant of the Messages envelope: | ||||||||||
| 13 | # same envelope, but structured output is emulated with a synthetic tool plus | ||||||||||
| 14 | # a forced tool_choice instead of first-party output_config.format. | ||||||||||
| 15 | 8 | my @KNOWN_DIALECTS = qw( | |||||||||
| 16 | openai-chat responses perplexity-agent anthropic anthropic-compat gemini ollama aki lmstudio | ||||||||||
| 17 | ); | ||||||||||
| 18 | 8 | my %KNOWN_DIALECT = map { $_ => 1 } @KNOWN_DIALECTS; | |||||||||
| 19 | |||||||||||
| 20 | 8 | has id => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 21 | 8 | has dialect => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 22 | 8 | has base_url => ( is => 'ro', isa => 'Str', required => 1 ); | |||||||||
| 23 | 25 | ▶ | has auth_ref => ( is => 'ro', isa => 'Maybe[Str]', default => sub { undef } ); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 24 | |||||||||||
| 25 | |||||||||||
| 26 | 120 | ▶ | sub BUILD { | ||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 27 | 120 | my ($self) = @_; | |||||||||
| 28 | 120 | $self->_check_id( 'id', $self->id ); | |||||||||
| 29 | 119 | $self->_check_token( 'dialect', $self->dialect ); | |||||||||
| 30 | 118 | $self->_check_url( 'base_url', $self->base_url ); | |||||||||
| 31 | 114 | ▶ | $self->_check_id( 'auth_ref', $self->auth_ref ) if defined $self->auth_ref; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 114 | return; | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 1 | ▶ | sub known_dialects { return @KNOWN_DIALECTS } | ||||||||
|
Subroutine
known_dialects: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 36 | |||||||||||
| 37 | |||||||||||
| 38 | 3 | ▶ | sub is_known_dialect { return $KNOWN_DIALECT{ $_[0]->dialect } ? 1 : 0 } | ||||||||
|
Subroutine
is_known_dialect: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 39 | |||||||||||
| 40 | |||||||||||
| 41 | 87 | ▶ | sub from_hash { | ||||||||
|
Subroutine
from_hash: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 42 | 87 | my ( $class, $data ) = @_; | |||||||||
| 43 | 87 | $class->_check_fields( $data, | |||||||||
| 44 | required => [qw( id dialect base_url )], | ||||||||||
| 45 | optional => [qw( auth_ref )], | ||||||||||
| 46 | ); | ||||||||||
| 47 | return $class->new( | ||||||||||
| 48 | 82 | ▶ | map { exists $data->{$_} ? ( $_ => $class->_string( $_, $data->{$_} ) ) : () } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 49 | qw( id dialect base_url auth_ref ) | ||||||||||
| 50 | ); | ||||||||||
| 51 | } | ||||||||||
| 52 | |||||||||||
| 53 | |||||||||||
| 54 | 47 | ▶ | sub to_hash { | ||||||||
|
Subroutine
to_hash: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||
| 55 | 47 | my ($self) = @_; | |||||||||
| 56 | return { | ||||||||||
| 57 | 47 | ▶ | id => $self->id, | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | dialect => $self->dialect, | ||||||||||
| 59 | base_url => $self->base_url, | ||||||||||
| 60 | ( defined $self->auth_ref ? ( auth_ref => $self->auth_ref ) : () ), | ||||||||||
| 61 | }; | ||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | |||||||||||
| 65 | 0 | ▶ | sub TO_JSON { shift->to_hash } | ||||||||
|
Subroutine
TO_JSON: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 66 | |||||||||||
| 67 | 8 | __PACKAGE__->meta->make_immutable; | |||||||||
| 68 | |||||||||||
| 69 | |||||||||||
| 70 | 8 | 1; | |||||||||
| 71 | |||||||||||
| 72 | __END__ | ||||||||||