({
client,
agentId,
commit,
repoUrl,
initCommand,
env,
localAgentDefinitions,
printEvents,
finalCheckCommands,
externalAgentType,
}: {
client: CodebuffClient
agentId: string
commit: EvalCommitV2
repoUrl: string
initCommand?: string
env?: Record<string, string>
localAgentDefinitions: any[]
printEvents: boolean
finalCheckCommands?: string[]
externalAgentType?: ExternalAgentType
})
| 20 | export type ExternalAgentType = 'claude' | 'codex' | 'opencode' |
| 21 | |
| 22 | export async function runAgentOnCommit({ |
| 23 | client, |
| 24 | agentId, |
| 25 | commit, |
| 26 | repoUrl, |
| 27 | initCommand, |
| 28 | env, |
| 29 | localAgentDefinitions, |
| 30 | printEvents, |
| 31 | finalCheckCommands, |
| 32 | externalAgentType, |
| 33 | }: { |
| 34 | client: CodebuffClient |
| 35 | agentId: string |
| 36 | commit: EvalCommitV2 |
| 37 | repoUrl: string |
| 38 | initCommand?: string |
| 39 | env?: Record<string, string> |
| 40 | localAgentDefinitions: any[] |
| 41 | printEvents: boolean |
| 42 | finalCheckCommands?: string[] |
| 43 | externalAgentType?: ExternalAgentType |
| 44 | }): Promise<{ |
| 45 | diff: string |
| 46 | contextFiles: Record<string, string> |
| 47 | durationMs: number |
| 48 | cost: number |
| 49 | error?: string |
| 50 | trace: AgentStep[] |
| 51 | finalCheckOutputs?: FinalCheckOutput[] |
| 52 | }> { |
| 53 | console.log(`[${commit.id}] Running agent ${agentId}...`) |
| 54 | const startTime = Date.now() |
| 55 | let diff = '' |
| 56 | let contextFiles: Record<string, string> = {} |
| 57 | let error: string | undefined |
| 58 | let cost = 0 |
| 59 | const trace: AgentStep[] = [] |
| 60 | let finalCheckOutputs: FinalCheckOutput[] | undefined |
| 61 | |
| 62 | try { |
| 63 | const timeoutMs = 60 * 60 * 1000 // 60 minutes |
| 64 | await withTimeout( |
| 65 | withTestRepo( |
| 66 | { |
| 67 | repoUrl, |
| 68 | parentSha: commit.parentSha, |
| 69 | initCommand, |
| 70 | env, |
| 71 | }, |
| 72 | async (repoDir) => { |
| 73 | // Select the appropriate runner |
| 74 | let runner: Runner |
| 75 | if (externalAgentType === 'claude') { |
| 76 | runner = new ClaudeRunner(repoDir, env) |
| 77 | } else if (externalAgentType === 'codex') { |
| 78 | runner = new CodexRunner(repoDir, env) |
| 79 | } else if (externalAgentType === 'opencode') { |
no test coverage detected