char-slop/berry
multipurpose self-modifiable agentic harness
git clone https://git.t4t.associates/char-slop/berry
e6df845
main
1// A model for working on berry itself without spending tokens. 2 3import type { MutableModels } from "@earendil-works/pi-ai" ; 4import { 5fauxAssistantMessage , 6type FauxResponseFactory , 7fauxText , 8fauxThinking , 9fauxToolCall , 10} from "@earendil-works/pi-ai/providers/faux" ; 11import { fauxProvider } from "@earendil-works/pi-ai/providers/faux" ; 12 13/** 14* `dev/echo` echoes, thinks a little, and runs a message of the form `js <code>` as a codemode script. Its thinking 15* about a message of the form `quiet <text>` is empty, as encrypted reasoning is. 16*/ 17export function installDevModel ( models :MutableModels ) { 18const faux = fauxProvider ({ 19provider :"dev" , 20models :[{ id :"echo" , name :"dev echo" , reasoning :true }], 21tokensPerSecond :80 , 22}); 23const respond :FauxResponseFactory = ( context ) => { 24faux . appendResponses ([ respond ]); 25// a section patch may follow the message being answered 26const last = context . messages . findLast (( message ) => message . role !== "system" ); 27if ( last ?. role === "toolResult" ) { 28return fauxAssistantMessage ( 29`The script ${ last . isError ? "failed" : "finished" } ; its output is above.` , 30); 31} 32const text = last ?. role !== "user" 33 ?"" 34 :typeof last . content === "string" 35 ?last . content 36 :last . content . flatMap (( block ) => ( block . type === "text" ?[ block . text ] :[])). join ( "\n" ); 37if ( text . startsWith ( "js " )) { 38return fauxAssistantMessage ( 39[ 40fauxThinking ( "Running that in codemode." ), 41fauxToolCall ( "codemode" , { code :text . slice ( 3 ) }), 42], 43{ stopReason :"toolUse" }, 44); 45} 46return fauxAssistantMessage ([ 47fauxThinking ( text . startsWith ( "quiet " ) ?"" :`They wrote ${ text . length } characters.` ), 48fauxText ( `You said:\n\n> ${ text } \n\nTry \`js return await tools.bash({ command: "ls" })\`.` ), 49]); 50}; 51faux . setResponses ([ respond ]); 52models . setProvider ( faux . provider ); 53}