char-slop/berry
multipurpose self-modifiable agentic harness
git clone https://git.t4t.associates/char-slop/berry
2c01ad9
main
1import { defineExtension } from "@berry/api" ; 2import { contextCapCommand , registerContextCap } from "./context-cap.ts" ; 3 4export type State = { oaiFast :boolean }; 5export type Event = { type :"oai-fast" ; enabled :boolean }; 6 7export default defineExtension < State , Event >({ 8name :"misc" , 9description :"miscellaneous utilities" , 10alwaysOn :true , 11initial :() => ({ oaiFast :false }), 12apply :( _ , event ) => ({ oaiFast :event . enabled }), 13setup ( ext ) { 14registerContextCap ( ext ); 15return ( conv ) => { 16conv . command ( contextCapCommand ()); 17conv . command ({ 18name :"compact" , 19description :"compact this conversation's context: `/compact [instructions]`" , 20async execute ( args , ctx ) { 21const instructions = args . trim (); 22await ctx . compact ( instructions === "" ?undefined :instructions ); 23return "Compacting context\u2026" ; 24}, 25}); 26conv . command ({ 27name :"oai-fast" , 28description :"toggle or set OpenAI Codex priority processing" , 29async execute ( args , ctx ) { 30const mode = args . trim (); 31if ( mode !== "" && mode !== "on" && mode !== "off" ) { 32return "Usage: /oai-fast [on|off]" ; 33} 34const enabled = mode === "" ?! ctx . state . oaiFast :mode === "on" ; 35await ctx . emit ({ type :"oai-fast" , enabled}); 36return `OpenAI Codex fast mode ${ enabled ? "enabled" : "disabled" } .` ; 37}, 38}); 39conv . onPayload (( payload , model ) => { 40if ( 41! conv . state . oaiFast || 42model . provider !== "openai-codex" || 43typeof payload !== "object" || 44payload === null || 45Array . isArray ( payload ) 46) { 47return ; 48} 49 50// The Codex backend maps the legacy priority tier to Fast mode. 51return { ...payload , service_tier :"priority" }; 52}); 53}; 54}, 55});