@@ -3,7 +3,7 @@ import fs from 'fs'
33import path from 'path'
44
55import type { Runner , RunnerResult , AgentStep } from './runner'
6- import type { CodebuffClient } from '@codebuff/sdk'
6+ import type { CodebuffClient , TerminalCommandBroker } from '@codebuff/sdk'
77
88
99const DEBUG_ERROR = true
@@ -17,6 +17,9 @@ export class CodebuffRunner implements Runner {
1717 private printEvents : boolean
1818 private commitId : string
1919 private parentSha : string
20+ private terminalCommandBroker ?: TerminalCommandBroker
21+ private overrideTools ?: Parameters < CodebuffClient [ 'run' ] > [ 0 ] [ 'overrideTools' ]
22+ private collectDiff : boolean
2023
2124 constructor ( options : {
2225 cwd : string
@@ -27,6 +30,9 @@ export class CodebuffRunner implements Runner {
2730 printEvents : boolean
2831 commitId : string
2932 parentSha : string
33+ terminalCommandBroker ?: TerminalCommandBroker
34+ overrideTools ?: Parameters < CodebuffClient [ 'run' ] > [ 0 ] [ 'overrideTools' ]
35+ collectDiff ?: boolean
3036 } ) {
3137 this . cwd = options . cwd
3238 this . env = options . env
@@ -36,6 +42,9 @@ export class CodebuffRunner implements Runner {
3642 this . printEvents = options . printEvents
3743 this . commitId = options . commitId
3844 this . parentSha = options . parentSha
45+ this . terminalCommandBroker = options . terminalCommandBroker
46+ this . overrideTools = options . overrideTools
47+ this . collectDiff = options . collectDiff ?? true
3948 }
4049
4150 async run ( prompt : string ) : Promise < RunnerResult > {
@@ -49,6 +58,14 @@ export class CodebuffRunner implements Runner {
4958 agentDefinitions : this . localAgentDefinitions ,
5059 cwd : this . cwd ,
5160 env : this . env ,
61+ terminalCommandBroker : this . terminalCommandBroker ,
62+ overrideTools : this . overrideTools ,
63+ fileFilter : ( filePath ) => ( {
64+ status :
65+ path . isAbsolute ( filePath ) || filePath . split ( / [ \\ / ] / ) . includes ( '..' )
66+ ? 'blocked'
67+ : 'allow' ,
68+ } ) ,
5269 maxAgentSteps,
5370 handleEvent : ( event ) => {
5471 if (
@@ -117,17 +134,20 @@ export class CodebuffRunner implements Runner {
117134
118135 totalCostUsd = ( result . sessionState ?. mainAgentState . creditsUsed ?? 0 ) / 100
119136
120- // Get git diff after Codebuff has made changes
137+ // Get git diff after Codebuff has made changes. Sponsored evals disable
138+ // this host-side path and collect through their scrubbed OS broker instead.
121139 let diff = ''
122- try {
123- execSync ( 'git add .' , { cwd : this . cwd , stdio : 'ignore' } )
124- diff = execSync ( `git diff ${ this . parentSha } ` , {
125- cwd : this . cwd ,
126- encoding : 'utf-8' ,
127- maxBuffer : 10 * 1024 * 1024 ,
128- } )
129- } catch {
130- // Ignore git errors
140+ if ( this . collectDiff ) {
141+ try {
142+ execSync ( 'git add .' , { cwd : this . cwd , stdio : 'ignore' } )
143+ diff = execSync ( `git diff ${ this . parentSha } ` , {
144+ cwd : this . cwd ,
145+ encoding : 'utf-8' ,
146+ maxBuffer : 10 * 1024 * 1024 ,
147+ } )
148+ } catch {
149+ // Ignore git errors
150+ }
131151 }
132152
133153 return {
0 commit comments