blib/lib/SignalWire/Agents/Prefabs/Concierge.pm

filter: Statementstmt 96.8% 61 / 63 Branchbran 87.5% 14 / 16 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 1 totaltotal 92.5% 87 / 94 CC 12 SCAR 19.5
CC
12
Cov
95%
BUILD
12.0
__ANON__
1.1
__ANON__
1.1
CRAP 7.0
« blib/lib/SignalWire/Agents/Security/SessionManager.pm ↑ Summary blib/lib/SignalWire/Agents/Relay/Message.pm »
1 package SignalWire::Agents::Prefabs::Concierge;
2 # Copyright (c) 2025 SignalWire
3 # Licensed under the MIT License.
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use JSON qw(encode_json);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 extends 'SignalWire::Agents::Agent::AgentBase';
10  
11 2 has venue_name => (is => 'ro', required => 1);
12 0 ▶has services => (is => 'ro', default => sub { [] });
Subroutine __ANON__: not called CC=1 SCAR=1.2
13 0 ▶has amenities => (is => 'ro', default => sub { {} });
Subroutine __ANON__: not called CC=1 SCAR=1.2
14 9 ▶has hours_of_operation => (is => 'ro', default => sub { {} });
Subroutine __ANON__: called CC=1 SCAR=0.0
15 9 ▶has special_instructions => (is => 'ro', default => sub { [] });
Subroutine __ANON__: called CC=1 SCAR=0.0
16 10 ▶has welcome_message => (is => 'ro', default => sub { undef });
Subroutine __ANON__: called CC=1 SCAR=0.0
17  
18 11 ▶sub BUILD {
Subroutine BUILD: called CC=12 SCAR=24.9
Pod undocumented
19 11 my ($self, $args) = @_;
20  
21 11 ▶ $self->name('concierge') if $self->name eq 'agent';
Branch: 1 branch
BranchTrueFalseTotal
if $self->name eq "agent" 11 0 11
22 11 ▶ $self->route('/concierge') if $self->route eq '/';
Branch: 1 branch
BranchTrueFalseTotal
if $self->route eq "/" 11 0 11
23 11 $self->use_pom(1);
24  
25 11 ▶ my $welcome = $self->welcome_message
Condition100%2/2
$self->welcome_message // "Welcome to ${\$self->venue_name;}. How can I assist you today?"
l!l
110
MC/DC100%1/1
$self->welcome_message // "Welcome to ${\$self->venue_name;}. How can I assist you today?"
$self->welcome_message
Truth table100%2/2
A
A= $self->welcome_message
Aresult
11
00
26 10 // "Welcome to ${\$self->venue_name}. How can I assist you today?";
27  
28 11 $self->set_global_data({
29 venue_name => $self->venue_name,
30 services => $self->services,
31 amenities => $self->amenities,
32 });
33  
34 11 $self->prompt_add_section(
35 'Concierge Role',
36 11 "You are the virtual concierge for ${\$self->venue_name}. $welcome",
37 bullets => [
38 'Welcome users and explain available services',
39 'Answer questions about amenities, hours, and directions',
40 'Help with bookings and reservations',
41 'Provide personalized recommendations',
42 ],
43 );
44  
45 # Services
46 11 ▶ if (@{ $self->services }) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->services;}) 10 1 11
47 10 $self->prompt_add_section(
48 'Available Services',
49 '',
50 bullets => $self->services,
51 );
52 }
53  
54 # Amenities
55 11 ▶ if (%{ $self->amenities }) {
Branch: 1 branch
BranchTrueFalseTotal
if (%{$self->amenities;}) 9 2 11
56 9 my @amenity_bullets;
57 9 for my $name (sort keys %{ $self->amenities }) {
58 10 my $info = $self->amenities->{$name};
59 10 my $desc = "$name";
60 10 ▶ $desc .= " - Hours: $info->{hours}" if $info->{hours};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"hours"} 5 5 10
61 10 ▶ $desc .= " - Location: $info->{location}" if $info->{location};
Branch: 1 branch
BranchTrueFalseTotal
if $info->{"location"} 3 7 10
62 10 push @amenity_bullets, $desc;
63 }
64 $self->prompt_add_section(
65 9 'Amenities',
66 '',
67 bullets => \@amenity_bullets,
68 );
69 }
70  
71 # Hours
72 11 ▶ if (%{ $self->hours_of_operation }) {
Branch: 1 branch
BranchTrueFalseTotal
if (%{$self->hours_of_operation;}) 2 9 11
73 2 my @hour_bullets;
74 2 for my $day (sort keys %{ $self->hours_of_operation }) {
75 3 push @hour_bullets, "$day: $self->{hours_of_operation}{$day}";
76 }
77 $self->prompt_add_section(
78 2 'Hours of Operation',
79 '',
80 bullets => \@hour_bullets,
81 );
82 }
83  
84 # Special instructions
85 11 ▶ if (@{ $self->special_instructions }) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->special_instructions;}) 2 9 11
86 2 $self->prompt_add_section(
87 'Special Instructions',
88 '',
89 bullets => $self->special_instructions,
90 );
91 }
92  
93 # Register check availability tool
94 $self->define_tool(
95 name => 'check_availability',
96 description => 'Check availability for a service or amenity',
97 parameters => {
98 type => 'object',
99 properties => {
100 service => { type => 'string', description => 'Service or amenity to check' },
101 date => { type => 'string', description => 'Date to check (optional)' },
102 },
103 required => ['service'],
104 },
105 1 ▶ handler => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
106 1 my ($a, $raw) = @_;
107 1 require SignalWire::Agents::SWAIG::FunctionResult;
108 1 return SignalWire::Agents::SWAIG::FunctionResult->new(
109 1 response => "Checking availability for $a->{service} at ${\$self->venue_name}",
110 );
111 },
112 11 );
113 }
114  
115 2 1;
« blib/lib/SignalWire/Agents/Security/SessionManager.pm ↑ Summary blib/lib/SignalWire/Agents/Relay/Message.pm »