char-slop/berry
multipurpose self-modifiable agentic harness
git clone https://git.t4t.associates/char-slop/berry
cb11725
main
1import { assert , assertEquals , assertStringIncludes } from "@std/assert" ; 2import { BACKGROUND_CONTEXT as context } from "@earendil-works/chord/context" ; 3import { fauxAssistantMessage , fauxToolCall } from "@earendil-works/pi-ai/providers/faux" ; 4import { LiveDoc } from "@earendil-works/pi-durable" ; 5import code from "../extensions/code/mod.ts" ; 6import { lastToolResult , setup , turn } from "./fixture.ts" ; 7import { tempDir } from "@berry/util" ; 8 9Deno . test ( "direct bash calls preserve live ANSI output despite harness stream sanitization" , async () => { 10await usingrootDir = await tempDir ({ prefix :"bash-stream-test-" }); 11const root = rootDir . path ; 12await usingharness = await setup (); 13let running :ReturnType < typeof turn > | undefined ; 14try { 15await harness . berry . install ( code ); 16const tid = await harness . berry . create ({ 17extensions :{ environment :{ cwd :root }, code :{} }, 18model :harness . model , 19}); 20const conversation = ( await harness . berry . conversation ( tid )) ! ; 21running = turn ( harness , tid , [ 22fauxAssistantMessage ( 23fauxToolCall ( "bash" , { 24command : 25"printf '\\033[31mred'; while [ ! -f release ]; do sleep 0.01; done; printf '\\033[0m plain\\n'" , 26timeout :5 , 27}), 28{ stopReason :"toolUse" }, 29), 30]); 31let slot ; 32for ( let i = 0 ; i < 200 ; i ++ ) { 33slot = ( await harness . berry . harness . snapshot ( LiveDoc , conversation . id , context ))?. tools ?.[ 0 ]; 34if (( slot ?. details as { rawOutput ?:string } | undefined )?. rawOutput === "\x1b[31mred" ) break ; 35await new Promise (( resolve ) => setTimeout ( resolve , 10 )); 36} 37assert ( slot ); 38assertEquals ( slot . status , "running" ); 39assertEquals (( slot . details as { rawOutput :string }). rawOutput , "\x1b[31mred" ); 40assertEquals ( slot . output , "[31mred" ); 41await Deno . writeTextFile ( ` ${ root } /release` , "" ); 42const seen = await running ; 43assertStringIncludes ( lastToolResult ( seen [ 1 ]). text , "\x1b[31mred\x1b[0m plain" ); 44} finally { 45await Deno . writeTextFile ( ` ${ root } /release` , "" ); 46await running ; 47} 48});