Skip to content

Commit cc59da3

Browse files
committed
sdk docs: Use getCustomToolDefinition. Fix typo. Flip default to endsAgentStep: true. Make description required.
1 parent 7029390 commit cc59da3

File tree

4 files changed

+24
-16
lines changed

4 files changed

+24
-16
lines changed

sdk/README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ import {
7373
CodebuffClient,
7474
generateInitialRunState,
7575
withAdditionalMessage,
76+
getCustomToolDefinition,
7677
} from '@codebuff/sdk'
7778

7879
// Available after running `codebuff login`
@@ -124,23 +125,30 @@ const result = await client.run({
124125

125126
// Custom tool definitions
126127
customToolDefinitions: [
127-
{
128+
getCustomToolDefinition({
128129
toolName: 'fetch_api_data',
129-
zodSchema: z
130-
.object({
131-
url: z.string().url(),
132-
method: z.enum(['GET', 'POST']).default('GET'),
133-
headers: z.record(z.string()).optional(),
134-
})
135-
.describe('Fetch data from an API endpoint'),
130+
description: 'Fetch data from an API endpoint',
131+
inputSchema: z.object({
132+
url: z.string().url(),
133+
method: z.enum(['GET', 'POST']).default('GET'),
134+
headers: z.record(z.string()).optional(),
135+
}),
136+
exampleInputs: [
137+
{ url: 'https://api.example.com/data', method: 'GET' },
138+
{
139+
url: 'https://api.example.com/submit',
140+
method: 'POST',
141+
headers: { 'Content-Type': 'application/json' },
142+
},
143+
],
136144
handler: async ({ url, method, headers }) => {
137145
const response = await fetch(url, { method, headers })
138146
const data = await response.text()
139147
return {
140-
toolResultMessage: `API Response: ${data.slice(0, 500)}...`,
148+
toolResultMessage: `API Response: ${data.slice(0, 5000)}...`,
141149
}
142150
},
143-
},
151+
}),
144152
],
145153

146154
handleEvent: (event) => {

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@codebuff/sdk",
33
"private": false,
44
"access": "public",
5-
"version": "0.1.15",
5+
"version": "0.1.16",
66
"description": "Official SDK for Codebuff — AI coding agent & framework",
77
"license": "MIT",
88
"type": "module",

sdk/src/custom-tool.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ export type CustomToolDefinition<
1010
toolName: N
1111
zodSchema: z.ZodType<Output, Input>
1212
inputJsonSchema: JSONSchema.BaseSchema
13-
description?: string
13+
description: string
1414
endsAgentStep: boolean
1515
exampleInputs: Input[]
1616
handler: (params: Output) => Promise<{
1717
toolResultMessage: string
1818
}>
1919
}
2020

21-
export function getCustomToolDefinintion<
21+
export function getCustomToolDefinition<
2222
ToolName extends string,
2323
Output,
2424
Input,
2525
>({
2626
toolName,
2727
inputSchema,
2828
description,
29-
endsAgentStep = false,
29+
endsAgentStep = true,
3030
exampleInputs = [],
3131
handler,
3232
}: {
3333
toolName: ToolName
3434
inputSchema: z.ZodType<Output, Input>
35-
description?: string
35+
description: string
3636
endsAgentStep?: boolean
3737
exampleInputs?: Input[]
3838
handler: (params: Output) => Promise<{

sdk/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export { CodebuffClient } from './client'
2-
export { getCustomToolDefinintion } from './custom-tool'
2+
export { getCustomToolDefinition } from './custom-tool'
33
export {
44
generateInitialRunState,
55
initialSessionState,

0 commit comments

Comments
 (0)