char-slop/berry
multipurpose self-modifiable agentic harness
git clone https://git.t4t.associates/char-slop/berry
2c34403
main
1import type { EntryRecord } from "@earendil-works/pi-durable" ; 2import type { JsonValue } from "@berry/api" ; 3import { extensionRenderers } from "./renderers.ts" ; 4 5/** An extension event, whether queued or already in the transcript. */ 6export function event ( data :EntryRecord [ "data" ]) :Node | null { 7const { ext, event} = data as { ext :string ; event :JsonValue }; 8const custom = extensionRenderers ( ext )?. event ?.( event ); 9if ( custom === null ) return null ; 10// the harness's own events are the codemode store's writes 11if ( ext === "berry" && custom === undefined ) { 12const write = event as { set :Record < string , JsonValue >; delete :string [] }; 13return ( 14< div class = "event" > 15store · {[ ...Object . keys ( write . set ), ...write . delete . map (( k ) => `- ${ k } ` )]. join ( 16", " , 17)} 18</ div > 19); 20} 21// and the machine and directory it works in 22if ( ext === "environment" && custom === undefined ) { 23const { environment , cwd } = event as { environment : string ; cwd : string }; 24return ( 25< div class = "event" > 26cd → < code >{ environment === "local" ? cwd : ` ${ environment } : ${ cwd } ` }</ code > 27< / div> 28); 29} 30// and the models it delegates to 31if ( ext === "subagent" && custom === undefined ) { 32const { type , conversationId , models } = event as { 33type ?: string ; 34conversationId ?: number ; 35models ?: { provider : string ; modelId : string }[]; 36}; 37if ( type === "spawned" || type === "settled" ) { 38return < div class = "event" > subagent { type } · conversation { String ( conversationId )}< / div > ; 39} 40if ( models !== undefined ) { 41return ( 42< div class = "event" > 43subagent models → { models . length === 0 44? "those enabled in settings" 45: < code >{ models . map (( m ) => ` ${ m . provider } / ${ m . modelId } ` ). join ( ", " )}</ code >} 46</ div > 47); 48} 49} 50return ( 51< div class = "event" > 52{ custom ?? [ 53< span class = "event-ext" >{ ext }< / span>, 54< code >{ JSON . stringify ( event )}</ code >, 55]} 56</ div > 57); 58}