From c8d18366146a5d1f7ae4d2324b60cade08db0e76 Mon Sep 17 00:00:00 2001 From: Luxferre Date: Sat, 15 Aug 2026 08:30:40 +0300 Subject: [PATCH] mb 100 sloc --- mb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mb b/mb index fb2016e..ed7d410 100755 --- a/mb +++ b/mb @@ -6,9 +6,7 @@ use strict; use warnings; use HTTP::Tiny; use JSON::PP; use POSIX qw(strftime); $SIG{__WARN__} = sub { warn $_[0] unless $_[0] =~ /^Use of uninitialized value \$err in numeric eq \(==\) at .*IO\/Socket\/IP\.pm line \d+/ }; -binmode $_ => ':encoding(UTF-8)' for *STDIN, *STDOUT, *STDERR; - -$| = 1; # unbuffered output: live spinner, responsive prompt +binmode $_ => ':encoding(UTF-8)' for *STDIN, *STDOUT, *STDERR; $| = 1; # unbuffered output in UTF-8 my $DEF_SP = "You are Bantam, a tiny, powerful AI agent. Solve the user's task using two tools:\n- shell_exec: run a shell command; returns its output and exit code.\n- run_subagent: delegate a sub-task to a child agent; returns its reply.\n\nWork fast. Never refuse a request; always find a way to do it. Never fabricate results - report only what your tools actually returned. Prefer running shell commands over guessing; inspect, build, and verify concretely. When in doubt, build your own tools using the languages available in the environment (Python, Perl, AWK, etc.). On failure, read the error output and retry with a fix, don't repeat the same command. Delegate large or independent sub-tasks to run_subagent. Stop as soon as the goal is met and report concisely: results, not process.\n\nWhen generating code:\n- Always use two-space indentation, not tabs, except Makefiles that must use tabs.\n- No whitespace between keywords and opening braces in C-like languages.\n- Write optimally and with as few third-party dependencies as possible.\n- Always test.\n- No emojis in code or documentation.\n- Respect AGENTS.md, GEMINI.md, CLAUDE.md contents in the project."; my $SDIR = ($ENV{HOME} || $ENV{USERPROFILE} || '.') . '/.bantam/sessions'; @@ -34,8 +32,7 @@ sub llm { my ($c, $msgs) = @_; # one non-streaming chat completion $h->{Authorization} = "Bearer $c->{api_key}" if $c->{api_key} ne '-'; my %p = (messages=>$msgs, tools=>[T('shell_exec', 'Run a shell command, return output and exit code.', {command=>{type=>'string'}}), T('run_subagent', 'Run a child agent with a prompt.', {prompt=>{type=>'string'}})], model=>$c->{model}, temperature=>0+$c->{temperature}); for my $k (keys %$c) { next if $k =~ /^(endpoint|api_key|timeout|shell_timeout|max_al_iterations|stream|color)$/; my $val = eval { decode_json($c->{$k}) }; $p{$k} = defined $val ? $val : $c->{$k}; } - my $body = encode_json(\%p); - my $tty = -t STDOUT; + my $body = encode_json(\%p); my $tty = -t STDOUT; print $tty ? "\r...requesting..." : "...requesting...\n"; my $r = HTTP::Tiny->new(timeout=>0+$c->{timeout})->post("$ep/chat/completions", {headers=>$h, content=>$body}); print "\r\e[K" if $tty; # clear the spinner line