MCPcopy
hub / github.com/CodebuffAI/codebuff / CodebuffRunner

Class CodebuffRunner

evals/buffbench/runners/codebuff.ts:11–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9const DEBUG_ERROR = true
10
11export class CodebuffRunner implements Runner {
12 private cwd: string
13 private env?: Record<string, string>
14 private client: CodebuffClient
15 private agentId: string
16 private localAgentDefinitions: any[]
17 private printEvents: boolean
18 private commitId: string
19 private parentSha: string
20
21 constructor(options: {
22 cwd: string
23 env?: Record<string, string>
24 client: CodebuffClient
25 agentId: string
26 localAgentDefinitions: any[]
27 printEvents: boolean
28 commitId: string
29 parentSha: string
30 }) {
31 this.cwd = options.cwd
32 this.env = options.env
33 this.client = options.client
34 this.agentId = options.agentId
35 this.localAgentDefinitions = options.localAgentDefinitions
36 this.printEvents = options.printEvents
37 this.commitId = options.commitId
38 this.parentSha = options.parentSha
39 }
40
41 async run(prompt: string): Promise<RunnerResult> {
42 const steps: AgentStep[] = []
43 let totalCostUsd = 0
44
45 const maxAgentSteps = 40
46 const result = await this.client.run({
47 agent: this.agentId,
48 prompt,
49 agentDefinitions: this.localAgentDefinitions,
50 cwd: this.cwd,
51 env: this.env,
52 maxAgentSteps,
53 handleEvent: (event) => {
54 if (
55 (event.type === 'tool_call' || event.type === 'tool_result') &&
56 event.toolName === 'set_messages'
57 ) {
58 return
59 }
60 if (event.type === 'error') {
61 console.error(
62 `[${this.commitId}:${this.agentId}] Error event:`,
63 event.message,
64 )
65 if (DEBUG_ERROR && !event.message.startsWith('Invalid JSON')) {
66 // Save errors in a file, but not tool calls with invalid json.
67 fs.writeFileSync(
68 path.join(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected