Skip to content

Commit 091a224

Browse files
Sync public snapshot from freebuff-private
Source: CodebuffAI/freebuff-private@e078581eb507af9a217573173c2cddd064c275cc
1 parent 7adbd1e commit 091a224

2 files changed

Lines changed: 33 additions & 11 deletions

File tree

bun.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

evals/buffbench/runners/codebuff.ts

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import fs from 'fs'
33
import path from 'path'
44

55
import type { Runner, RunnerResult, AgentStep } from './runner'
6-
import type { CodebuffClient } from '@codebuff/sdk'
6+
import type { CodebuffClient, TerminalCommandBroker } from '@codebuff/sdk'
77

88

99
const 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

Comments
 (0)