Skip to content

Commit 29dee94

Browse files
committed
initial sdk package
1 parent cf3283e commit 29dee94

File tree

8 files changed

+106
-1
lines changed

8 files changed

+106
-1
lines changed

bun.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"web",
1212
"packages/*",
1313
"scripts",
14-
"evals"
14+
"evals",
15+
"sdk"
1516
],
1617
"scripts": {
1718
"dev": "bash scripts/dev.sh",

sdk/package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "@codebuff/sdk",
3+
"version": "1.0.0",
4+
"private": true,
5+
"license": "UNLICENSED",
6+
"type": "module",
7+
"exports": {
8+
".": {
9+
"bun": "./src/index.ts",
10+
"import": "./src/index.ts",
11+
"types": "./src/index.ts",
12+
"default": "./src/index.ts"
13+
},
14+
"./*": {
15+
"bun": "./src/*.ts",
16+
"import": "./src/*.ts",
17+
"types": "./src/*.ts",
18+
"default": "./src/*.ts"
19+
}
20+
},
21+
"scripts": {
22+
"typecheck": "tsc --noEmit -p .",
23+
"test": "bun test"
24+
},
25+
"sideEffects": false,
26+
"engines": {
27+
"bun": ">=1.2.11"
28+
},
29+
"dependencies": {
30+
"@codebuff/common": "workspace:*"
31+
},
32+
"devDependencies": {
33+
"@types/node": "22",
34+
"@types/bun": "^1.2.11"
35+
}
36+
}

sdk/src/client.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type {
2+
CodebuffClientOptions,
3+
Context,
4+
ContinueChatOptions,
5+
NewChatOptions,
6+
} from './types'
7+
8+
export class CodebuffClient {
9+
private authToken: string
10+
private abortController: AbortController
11+
12+
public cwd: string
13+
14+
constructor({ apiKey, cwd, abortController }: CodebuffClientOptions) {
15+
this.authToken =
16+
apiKey.type === 'string'
17+
? apiKey.value
18+
: process.env.CODEBUFF_API_KEY ?? ''
19+
this.cwd = cwd
20+
this.abortController = abortController
21+
}
22+
23+
public newChat(options: NewChatOptions): Context {
24+
return {}
25+
}
26+
27+
public continueChat(options: ContinueChatOptions): Context {
28+
return {}
29+
}
30+
}

sdk/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export { CodebuffClient } from './client'
2+
3+
export * from './types'

sdk/src/types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export type CodebuffClientOptions = {
2+
apiKey: { type: 'string'; value: string } | { type: 'env' }
3+
cwd: string
4+
abortController: AbortController
5+
}
6+
7+
export type Context = {}
8+
9+
export type NewChatOptions = {}
10+
11+
export type ContinueChatOptions = {}

sdk/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../tsconfig.base.json",
3+
"compilerOptions": {
4+
"types": ["bun", "node"]
5+
},
6+
"include": ["src/**/*.ts"],
7+
"exclude": ["node_modules"]
8+
}

tsconfig.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@codebuff/backend/*": ["./backend/src/*"],
99
"@codebuff/web/*": ["./web/src/*"],
1010
"@codebuff/evals/*": ["./evals/*"],
11+
"@codebuff/sdk/*": ["./sdk/*"],
1112
"@codebuff/billing/*": ["./packages/billing/src/*"],
1213
"@codebuff/bigquery/*": ["./packages/bigquery/src/*"],
1314
"@codebuff/internal/*": ["./packages/internal/src/*"],
@@ -21,6 +22,7 @@
2122
{ "path": "./npm-app" },
2223
{ "path": "./web" },
2324
{ "path": "./evals" },
25+
{ "path": "./sdk" },
2426
{ "path": "./packages/billing" },
2527
{ "path": "./packages/bigquery" },
2628
{ "path": "./packages/internal" },

0 commit comments

Comments
 (0)