| 1 | package Langertha::Raider::ToolEffects; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Internal static table of what each built-in tool can do (effect classes) | ||||||||||||||||||||||||||||
| 3 | 75 | our $VERSION = '0.503'; | |||||||||||||||||||||||||||
| 4 | 75 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 75 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 75 | ▶ | use Carp qw( croak ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 75 | my %EFFECTS = ( | |||||||||||||||||||||||||||
| 10 | # files | ||||||||||||||||||||||||||||
| 11 | list_files => [qw( read )], | ||||||||||||||||||||||||||||
| 12 | read_file => [qw( read )], | ||||||||||||||||||||||||||||
| 13 | write_file => [qw( write )], | ||||||||||||||||||||||||||||
| 14 | edit_file => [qw( write )], | ||||||||||||||||||||||||||||
| 15 | # shell | ||||||||||||||||||||||||||||
| 16 | bash => [qw( code )], | ||||||||||||||||||||||||||||
| 17 | # web | ||||||||||||||||||||||||||||
| 18 | web_search => [qw( network )], | ||||||||||||||||||||||||||||
| 19 | web_fetch => [qw( network )], | ||||||||||||||||||||||||||||
| 20 | # perl | ||||||||||||||||||||||||||||
| 21 | perl_eval => [qw( code )], | ||||||||||||||||||||||||||||
| 22 | perl_check => [qw( code )], | ||||||||||||||||||||||||||||
| 23 | perl_cpanm => [qw( network code )], | ||||||||||||||||||||||||||||
| 24 | # hall | ||||||||||||||||||||||||||||
| 25 | telegram_reply => [qw( message )], | ||||||||||||||||||||||||||||
| 26 | hall_status => [qw( read )], | ||||||||||||||||||||||||||||
| 27 | hall_spawn => [qw( message code )], | ||||||||||||||||||||||||||||
| 28 | # raider self-tools | ||||||||||||||||||||||||||||
| 29 | raider_ask_user => [qw( message )], | ||||||||||||||||||||||||||||
| 30 | raider_wait => [], | ||||||||||||||||||||||||||||
| 31 | raider_wait_for => [qw( code )], | ||||||||||||||||||||||||||||
| 32 | raider_pause => [], | ||||||||||||||||||||||||||||
| 33 | raider_abort => [], | ||||||||||||||||||||||||||||
| 34 | raider_session_history => [qw( read )], | ||||||||||||||||||||||||||||
| 35 | raider_manage_mcps => [qw( code )], | ||||||||||||||||||||||||||||
| 36 | raider_switch_engine => [qw( network )], | ||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 75 | my @CLASSES = qw( read write network code message ); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | ▶ | sub classes { my ($self) = @_; return @CLASSES } | ||||||||||||||||||||||||||
|
Subroutine
classes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | sub tool_names { my ($self) = @_; return sort keys %EFFECTS } | ||||||||||||||||||||||||||
|
Subroutine
tool_names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 748 | ▶ | sub effects_for { | ||||||||||||||||||||||||||
|
Subroutine
effects_for: called CC=4 SCAR=14.6
Pod
documented
| |||||||||||||||||||||||||||||
| 47 | 748 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||
| 48 | 748 | ▶ | croak __PACKAGE__.'->effects_for needs a tool name' unless defined $name && length $name; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $name and length $name
MC/DC0%0/2
defined $name and length $name
defined $name
length $name
Truth table33%1/3
A and B
A= defined $nameB= length $name
| |||||||||||||||||||||||||||||
| 49 | 748 | ▶ | my $effects = $EFFECTS{$name} or return; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 50 | 738 | return [ @$effects ]; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 75 | 1; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | __END__ | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =pod | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =head1 NAME | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | Langertha::Raider::ToolEffects - Internal static table of what each built-in tool can do (effect classes) | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | =head1 VERSION | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | version 0.503 | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | B<Internal module.> Its interface may change without notice. | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | One place that says what each built-in tool of raider can do to the world, | ||||||||||||||||||||||||||||
| 74 | in five effect classes (ADR 0005, information only -- nothing here allows or | ||||||||||||||||||||||||||||
| 75 | refuses a call): | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =over | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | =item C<read> -- reads local files or state | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =item C<write> -- changes local files | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =item C<network> -- talks to the internet | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =item C<code> -- runs arbitrary code; it can do anything the other classes do | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | =item C<message> -- sends something to a person or to another agent | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | =back | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | A tool with an empty list has no effect outside the run (pure control flow). | ||||||||||||||||||||||||||||
| 92 | A tool that is not in the table has no answer: L</effects_for> returns undef | ||||||||||||||||||||||||||||
| 93 | and reports say C<unknown>. The table is keyed by name, so ask it only about | ||||||||||||||||||||||||||||
| 94 | tools the caller knows to be built-in -- an external MCP server may use any | ||||||||||||||||||||||||||||
| 95 | name, and its C<read_file> is not ours. C<explain_config> asks about the tools | ||||||||||||||||||||||||||||
| 96 | raider itself mounted; a later policy (the gate of ADR 0005) must combine it | ||||||||||||||||||||||||||||
| 97 | with the tool's source. | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | C<perl_eval> and C<perl_check> are C<code>: C<perl -c> runs C<BEGIN> blocks and | ||||||||||||||||||||||||||||
| 100 | C<use>. C<perl_cpanm> is C<network> and C<code>: it downloads and then runs | ||||||||||||||||||||||||||||
| 101 | distribution build and test code. C<bash> is C<code> alone, as the class | ||||||||||||||||||||||||||||
| 102 | covers the rest. C<hall_spawn> starts another raider with a mission, so it | ||||||||||||||||||||||||||||
| 103 | is C<message> and C<code>. C<raider_wait_for> is C<code>: the host runs a | ||||||||||||||||||||||||||||
| 104 | callback of its own for the condition and raider cannot say what it does, so | ||||||||||||||||||||||||||||
| 105 | the table takes the cautious reading. C<raider_manage_mcps> is C<code> | ||||||||||||||||||||||||||||
| 106 | (activating starts a tool server) and C<raider_switch_engine> is C<network> | ||||||||||||||||||||||||||||
| 107 | (later prompts go to another provider). | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | =head2 classes | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | The effect classes, in display order. | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =head2 tool_names | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | All built-in tool names of the table, sorted. | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =head2 effects_for | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | my $classes = Langertha::Raider::ToolEffects->effects_for('write_file'); # ['write'] | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | A new array ref of effect classes (empty: no effect outside the run), or | ||||||||||||||||||||||||||||
| 122 | undef for a tool that is not in the table. | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =head2 Issues | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | Please report bugs and feature requests on GitHub at | ||||||||||||||||||||||||||||
| 129 | L<https://github.com/Getty/langertha-raider/issues>. | ||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | =head2 IRC | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | Join C<#langertha> on C<irc.perl.org> or message Getty directly. | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =head1 CONTRIBUTING | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | Contributions are welcome! Please fork the repository and submit a pull request. | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | Torsten Raudssus <torsten@raudssus.de> L<https://raudssus.de/> | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | This software is copyright (c) 2026 by Torsten Raudssus. | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 148 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | =cut | ||||||||||||||||||||||||||||