You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// event includes streamed updates like assistant messages and tool calls
61
61
console.log('event:', event)
62
62
},
63
+
64
+
// Custom agents (optional)
65
+
agentConfigs: [
66
+
{
67
+
id: 'my-awesome-agent',
68
+
model: 'openai/gpt-5',
69
+
displayName: 'My awesome agent'
70
+
instructionsPrompt: 'Do something awesome'
71
+
// ... other AgentConfig properties
72
+
},
73
+
],
63
74
})
64
75
```
65
76
@@ -85,13 +96,13 @@ Runs a Codebuff agent with the specified options.
85
96
86
97
-**`knowledgeFiles`** (object, optional): Knowledge files to inject into every `run()` call. Uses the same schema as `projectFiles` - keys are file paths and values are file contents. These files are added directly to the agent's context.
87
98
88
-
-**`agentConfig`** (object, optional): If you defined your own custom agent, pass the agent configuration here. The key should be the agent ID (e.g., 'my-custom-agent'), and the value should be the compiled agent configuration. We should provide a utility function to load and compile agents in the future to make this easier.
89
-
99
+
-**`agentConfigs`** (array, optional): Array of custom agent configurations. Each object should satisfy the AgentConfig type.
90
100
-**`maxAgentSteps`** (number, optional): Maximum number of steps the agent can take before stopping. Use this as a safety measure in case your agent starts going off the rails. A reasonable number is around 20.
91
101
92
102
#### Returns
93
103
94
104
Returns a Promise that resolves to a `RunState` object containing:
105
+
95
106
-`sessionState`: The current session state that can be passed to subsequent runs
96
107
-`toolResults`: Results from any tools that were executed during the run
* @param previousRun - (Optional) JSON state returned from a previous run() call. Use this to continue a conversation or session with the agent, maintaining context from previous interactions.
117
118
* @param projectFiles - (Optional) All the files in your project as a plain JavaScript object. Keys should be the full path from your current directory to each file, and values should be the string contents of the file. Example: { "src/index.ts": "console.log('hi')" }. This helps Codebuff pick good source files for context.
118
119
* @param knowledgeFiles - (Optional) Knowledge files to inject into every run() call. Uses the same schema as projectFiles - keys are file paths and values are file contents. These files are added directly to the agent's context.
119
-
* @paramagentConfig - (Optional) If you defined your own custom agent, pass the agent configuration here. The key should be the agent ID (e.g., 'my-custom-agent'), and the value should be the compiled agent configuration. We will provide a utility function to load and compile agents in the future to make this easier.
120
+
* @paramagentConfigs - (Optional) Array of custom agent configurations. Each object should satisfy the AgentConfig type.
120
121
* @param maxAgentSteps - (Optional) Maximum number of steps the agent can take before stopping. Use this as a safety measure in case your agent starts going off the rails. A reasonable number is around 20.
121
122
*
122
123
* @returns A Promise that resolves to a RunState JSON object which you can pass to a subsequent run() call to continue the run.
@@ -129,7 +130,7 @@ export class CodebuffClient {
129
130
previousRun,
130
131
projectFiles,
131
132
knowledgeFiles,
132
-
agentConfig,
133
+
agentConfigs,
133
134
maxAgentSteps,
134
135
}: {
135
136
agent: string
@@ -139,7 +140,7 @@ export class CodebuffClient {
139
140
previousRun?: RunState
140
141
projectFiles?: Record<string,string>
141
142
knowledgeFiles?: Record<string,string>
142
-
agentConfig?: Record<string,any>
143
+
agentConfigs?: AgentConfig[]
143
144
maxAgentSteps?: number
144
145
}): Promise<RunState>{
145
146
awaitthis.websocketHandler.connect()
@@ -149,7 +150,7 @@ export class CodebuffClient {
149
150
previousRun?.sessionState??
150
151
initialSessionState(this.cwd,{
151
152
knowledgeFiles,
152
-
agentConfig,
153
+
agentConfigs,
153
154
projectFiles,
154
155
maxAgentSteps,
155
156
})
@@ -271,11 +272,26 @@ function initialSessionState(
271
272
// TODO: Parse projectFiles into fileTree, fileTokenScores, tokenCallers
0 commit comments