MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / main

Function main

sdk/examples/readme-example-1.ts:3–31  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import { CodebuffClient } from '@codebuff/sdk'
2
3async function main() {
4 const client = new CodebuffClient({
5 // You need to pass in your own API key here.
6 // Get one here: https://www.codebuff.com/api-keys
7 apiKey: process.env.CODEBUFF_API_KEY,
8 cwd: process.cwd(),
9 })
10
11 // First run
12 const runState1 = await client.run({
13 // The agent id. Any agent on the store (https://codebuff.com/store)
14 agent: 'codebuff/base@0.0.16',
15 prompt: 'Create a simple calculator class',
16 handleEvent: (event) => {
17 // All events that happen during the run: agent start/finish, tool calls/results, text responses, errors.
18 console.log('Codebuff Event', JSON.stringify(event))
19 },
20 })
21
22 // Continue the same session with a follow-up
23 const _runOrError2 = await client.run({
24 agent: 'codebuff/base@0.0.16',
25 prompt: 'Add unit tests for the calculator',
26 previousRun: runState1, // <-- this is where your next run differs from the previous run
27 handleEvent: (event) => {
28 console.log('Codebuff Event', JSON.stringify(event))
29 },
30 })
31}
32
33main()

Callers 1

Calls 1

runMethod · 0.95

Tested by

no test coverage detected