Skip to content

Commit cda0250

Browse files
committed
allow passing in agent definitions into run
1 parent 3d29edc commit cda0250

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@codebuff/sdk",
33
"private": false,
4-
"version": "0.3.5",
4+
"version": "0.3.6",
55
"description": "Official SDK for Codebuff — AI coding agent & framework",
66
"license": "Apache-2.0",
77
"type": "module",

sdk/src/run.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import path from 'path'
22

3+
import { cloneDeep } from 'lodash'
4+
35
import { initialSessionState, applyOverridesToSessionState } from './run-state'
46
import { changeFile } from './tools/change-file'
57
import { codeSearch } from './tools/code-search'
@@ -61,7 +63,7 @@ export type CodebuffClientOptions = {
6163
}
6264

6365
export type RunOptions = {
64-
agent: string
66+
agent: string | AgentDefinition
6567
prompt: string
6668
params?: Record<string, any>
6769
previousRun?: RunState
@@ -163,6 +165,13 @@ export async function run({
163165
})
164166

165167
// Init session state
168+
let agentId
169+
if (typeof agent !== 'string') {
170+
agentDefinitions = [...(cloneDeep(agentDefinitions) ?? []), agent]
171+
agentId = agent.id
172+
} else {
173+
agentId = agent
174+
}
166175
let sessionState: SessionState
167176
if (previousRun?.sessionState) {
168177
// applyOverridesToSessionState handles deep cloning and applying any provided overrides
@@ -201,7 +210,7 @@ export async function run({
201210
costMode: 'normal',
202211
sessionState,
203212
toolResults: extraToolResults ?? [],
204-
agentId: agent,
213+
agentId,
205214
})
206215

207216
const result = await promise

0 commit comments

Comments
 (0)