@@ -28,21 +28,22 @@ async function main() {
2828
2929 // First run
3030 const run1 = await client .run ({
31- agent: ' base' ,
31+ // The agent id. Any agent on the store (https://codebuff.com/store)
32+ agent: ' codebuff/base@0.0.16' ,
3233 prompt: ' Create a simple calculator class' ,
3334 handleEvent : (event ) => {
3435 // All events that happen during the run: agent start/finish, tool calls/results, text responses, errors.
35- console .log (' Event' , event )
36+ console .log (' Codebuff Event' , JSON . stringifiy ( event ) )
3637 },
3738 })
3839
3940 // Continue the same session with a follow-up
4041 const run2 = await client .run ({
41- agent: ' base' ,
42+ agent: ' codebuff/ base@0.0.16 ' ,
4243 prompt: ' Add unit tests for the calculator' ,
4344 previousRun: run1 , // <-- this is where your next run differs from the previous run
4445 handleEvent : (event ) => {
45- console .dir ( event , { depth: null } )
46+ console .log ( ' Codebuff Event ' , JSON . stringifiy ( event ) )
4647 },
4748 })
4849}
@@ -70,18 +71,20 @@ async function main() {
7071 cwd: process .cwd (),
7172 })
7273
73- // This is a custom agent that can be used instead of the `base` agent or other agents on the Codebuff store (https://codebuff.com/store).
74+ // Define your own custom agents!
7475 const myCustomAgent: AgentDefinition = {
7576 id: ' my-custom-agent' ,
76- model: ' openai/gpt-5 ' ,
77+ model: ' x-ai/grok-4-fast ' ,
7778 displayName: ' Sentiment analyzer' ,
79+ toolNames: [' fetch_api_data' ] // Defined below!
7880 instructionsPrompt : `
79811. Describe the different sentiments in the given prompt.
80822. Score the prompt along the following 5 dimensions:
8183 happiness, sadness, anger, fear, and surprise. ` ,
8284 // ... other AgentDefinition properties
8385 }
8486
87+ // And define your own custom tools!
8588 const myCustomTool = getCustomToolDefinition ({
8689 toolName: ' fetch_api_data' ,
8790 description: ' Fetch data from an API endpoint' ,
@@ -106,13 +109,17 @@ async function main() {
106109 })
107110
108111 const { output } = await client .run ({
112+ // Run a custom agent by id. Must match an id in the agentDefinitions field below.
109113 agent: ' my-custom-agent' ,
110114 prompt: " Today I'm feeling very happy!" ,
115+
116+ // Provide custom agent and tool definitions:
111117 agentDefinitions: [myCustomAgent ],
112118 customToolDefinitions: [myCustomTool ],
119+
113120 handleEvent : (event ) => {
114121 // All events that happen during the run: agent start/finish, tool calls/results, text responses, errors.
115- console .log (' Event' , event )
122+ console .log (' Codebuff Event' , JSON . stringify ( event ) )
116123 },
117124 })
118125
0 commit comments