@@ -25,30 +25,37 @@ async function main() {
2525 // Get one here: https://www.codebuff.com/api-keys
2626 apiKey: process .env .CODEBUFF_API_KEY ,
2727 cwd: process .cwd (),
28- onError : (e ) => console .error (' Codebuff error:' , e .message ),
2928 })
3029
3130 // First run
31+ console .log (' ------- First run started -------' )
3232 const run1 = await client .run ({
3333 agent: ' base' ,
3434 prompt: ' Create a simple calculator class' ,
3535 handleEvent : (event ) => {
3636 // This will fire for all events that happen during the run, like when each agent starts/stops and when they respond.
37- console .log (event ) // Log all events
37+ console .dir (event , { depth: null } ) // Log all events
3838 },
3939 })
40+ console .log (' ------- First run ended -------' )
41+
42+ if (! run1 ) {
43+ // The previous run failed, handleEvent should have been called with an error
44+ console .error (' First run failed.' )
45+ process .exit (1 )
46+ }
4047
4148 // Continue the same session with a follow-up
49+ console .log (' ------- Second run started -------' )
4250 const run2 = await client .run ({
4351 agent: ' base' ,
4452 prompt: ' Add unit tests for the calculator' ,
4553 previousRun: run1 , // <-- this is where your next run differs from the previous run
4654 handleEvent : (event ) => {
47- console .log (event )
55+ console .dir (event , { depth: null } )
4856 },
4957 })
50-
51- client .closeConnection ()
58+ console .log (' ------- Second run ended -------' )
5259}
5360
5461main ()
0 commit comments