blib/lib/SignalWire/Agents/Skills/Builtin/Spider.pm

filter: Statementstmt 84.2% 32 / 38 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 12 / 14 Podpod 0.0% 0 / 4 totaltotal 78.5% 44 / 56 CC 1 SCAR 1.4
CC
1
Cov
84%
__ANON__
2.0
__ANON__
2.0
register_tools
1.1
CRAP 1.1
« blib/lib/SignalWire/Agents/Skills/Builtin/WebSearch.pm ↑ Summary blib/lib/SignalWire/Agents/Relay/Event.pm »
1 package SignalWire::Agents::Skills::Builtin::Spider;
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 extends 'SignalWire::Agents::Skills::SkillBase';
6  
7 3 ▶use SignalWire::Agents::Skills::SkillRegistry;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 SignalWire::Agents::Skills::SkillRegistry->register_skill('spider', __PACKAGE__);
9  
10 6 ▶has '+skill_name' => (default => sub { 'spider' });
Subroutine __ANON__: called CC=1 SCAR=0.0
11 6 ▶has '+skill_description' => (default => sub { 'Fast web scraping and crawling capabilities' });
Subroutine __ANON__: called CC=1 SCAR=0.0
12 6 ▶has '+supports_multiple_instances' => (default => sub { 1 });
Subroutine __ANON__: called CC=1 SCAR=0.0
13  
14 4 ▶sub setup { 1 }
Subroutine setup: called CC=1 SCAR=0.0
Pod undocumented
15  
16 3 ▶sub register_tools {
Subroutine register_tools: called CC=1 SCAR=0.9
Pod undocumented
17 3 my ($self) = @_;
18  
19 $self->define_tool(
20 name => 'scrape_url',
21 description => 'Scrape content from a URL',
22 parameters => {
23 type => 'object',
24 properties => {
25 url => { type => 'string', description => 'The URL to scrape' },
26 },
27 required => ['url'],
28 },
29 1 ▶ handler => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
30 1 my ($args, $raw) = @_;
31 1 require SignalWire::Agents::SWAIG::FunctionResult;
32 1 return SignalWire::Agents::SWAIG::FunctionResult->new(
33 response => "Scraped content from: $args->{url}"
34 );
35 },
36 3 );
37  
38 $self->define_tool(
39 name => 'crawl_site',
40 description => 'Crawl a website starting from a URL',
41 parameters => {
42 type => 'object',
43 properties => {
44 start_url => { type => 'string', description => 'Starting URL for crawl' },
45 },
46 required => ['start_url'],
47 },
48 0 ▶ handler => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
49 0 my ($args, $raw) = @_;
50 0 require SignalWire::Agents::SWAIG::FunctionResult;
51 0 return SignalWire::Agents::SWAIG::FunctionResult->new(
52 response => "Crawling site from: $args->{start_url}"
53 );
54 },
55 3 );
56  
57 $self->define_tool(
58 name => 'extract_structured_data',
59 description => 'Extract structured data from a URL',
60 parameters => {
61 type => 'object',
62 properties => {
63 url => { type => 'string', description => 'URL to extract data from' },
64 },
65 required => ['url'],
66 },
67 0 ▶ handler => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
68 0 my ($args, $raw) = @_;
69 0 require SignalWire::Agents::SWAIG::FunctionResult;
70 0 return SignalWire::Agents::SWAIG::FunctionResult->new(
71 response => "Extracted structured data from: $args->{url}"
72 );
73 },
74 3 );
75 }
76  
77 1 ▶sub get_hints {
Subroutine get_hints: called CC=1 SCAR=0.0
Pod undocumented
78 1 return ['scrape', 'crawl', 'extract', 'web page', 'website', 'spider'];
79 }
80  
81 1 ▶sub get_parameter_schema {
Subroutine get_parameter_schema: called CC=1 SCAR=0.0
Pod undocumented
82 return {
83 1 %{ SignalWire::Agents::Skills::SkillBase->get_parameter_schema },
84 delay => { type => 'number' },
85 concurrent_requests => { type => 'integer' },
86 timeout => { type => 'integer' },
87 max_pages => { type => 'integer' },
88 max_depth => { type => 'integer' },
89 };
90 }
91  
92 3 1;
« blib/lib/SignalWire/Agents/Skills/Builtin/WebSearch.pm ↑ Summary blib/lib/SignalWire/Agents/Relay/Event.pm »