Skip to content

Commit 55ea75e

Browse files
authored
Merge pull request #13 from chatbotkit/next
Next
2 parents c4ac40f + 6d8e034 commit 55ea75e

135 files changed

Lines changed: 3394 additions & 272 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/agent/.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

packages/agent/CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# @chatbotkit/agent
2+
3+
## 1.21.0
4+
5+
### Minor Changes
6+
7+
- eb6ccd2: API updates, agents, and improved CLI.
8+
9+
### Patch Changes
10+
11+
- Updated dependencies [eb6ccd2]
12+
- @chatbotkit/sdk@1.21.0
13+
14+
## 0.0.1
15+
16+
### Patch Changes
17+
18+
- Initial release

packages/agent/README.md

Lines changed: 187 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
[![Follow on Twitter](https://img.shields.io/twitter/follow/chatbotkit.svg?logo=twitter)](https://twitter.com/chatbotkit)
2+
[![ChatBotKit](https://img.shields.io/badge/credits-ChatBotKit-blue.svg)](https://chatbotkit.com)
3+
[![CBK.AI](https://img.shields.io/badge/credits-CBK.AI-blue.svg)](https://cbk.ai)
4+
[![NPM](https://img.shields.io/npm/v/@chatbotkit/agent.svg)](https://www.npmjs.com/package/@chatbotkit/agent)
5+
[![Email](https://img.shields.io/badge/Email-Support-blue?logo=mail.ru)](mailto:support@chatbotkit.com)
6+
[![Discord](https://img.shields.io/badge/Discord-Support-blue?logo=discord)](https://go.cbk.ai/discord)
7+
8+
# ChatBotKit Agent SDK
9+
10+
Build autonomous AI agents that can use custom tools and execute complex tasks with the full power of the ChatBotKit platform.
11+
12+
## Installation
13+
14+
```bash
15+
npm install @chatbotkit/agent @chatbotkit/sdk
16+
```
17+
18+
## Features
19+
20+
### Tool Integration
21+
22+
Define custom tools with type-safe inputs using Zod schemas. Tools are automatically exposed to the AI agent with proper validation and error handling.
23+
24+
### Platform Capabilities
25+
26+
Agents run with complete ChatBotKit platform integration:
27+
28+
- Access to configured integrations and 3rd-party services
29+
- Authenticated sessions with external APIs
30+
- Dataset connections and skillsets
31+
- Custom abilities and functions
32+
33+
### Execution Modes
34+
35+
- **`complete`** - Stream agent responses with tool execution
36+
- **`execute`** - Run agents with built-in planning, progress tracking, and controlled exit
37+
38+
## Usage
39+
40+
### Advanced Example: Local Development Monitor with Remote Sync
41+
42+
Build agents that watch your local development environment and sync insights to remote platforms:
43+
44+
```javascript
45+
import { execute } from '@chatbotkit/agent'
46+
import { ChatBotKit } from '@chatbotkit/sdk'
47+
48+
import { exec } from 'child_process'
49+
import { promisify } from 'util'
50+
import { z } from 'zod'
51+
52+
const execAsync = promisify(exec)
53+
54+
const client = new ChatBotKit({ secret: process.env.CHATBOTKIT_API_TOKEN })
55+
56+
const localTools = {
57+
analyzeGitDiff: {
58+
description: 'Get detailed git diff for uncommitted changes',
59+
input: z.object({
60+
staged: z.boolean().default(false),
61+
}),
62+
handler: async ({ staged }) => {
63+
const cmd = staged ? 'git diff --cached' : 'git diff'
64+
const { stdout } = await execAsync(cmd)
65+
return { diff: stdout, lines: stdout.split('\n').length }
66+
},
67+
},
68+
getProcessMetrics: {
69+
description: 'Get local system metrics (CPU, memory, running processes)',
70+
input: z.object({}),
71+
handler: async () => {
72+
const { stdout } = await execAsync('ps aux --sort=-%mem | head -10')
73+
return { topProcesses: stdout }
74+
},
75+
},
76+
scanDependencies: {
77+
description: 'Scan local node_modules for vulnerabilities and size',
78+
input: z.object({
79+
directory: z.string().default('./node_modules'),
80+
}),
81+
handler: async ({ directory }) => {
82+
const { stdout: auditResult } = await execAsync('npm audit --json')
83+
const { stdout: sizeResult } = await execAsync(`du -sh ${directory}`)
84+
return { audit: JSON.parse(auditResult), size: sizeResult.trim() }
85+
},
86+
},
87+
}
88+
89+
// The agent has access to ChatBotKit's remote integrations:
90+
// - Jira: Create tickets for critical issues found locally
91+
// - Slack: Alert team about deployment readiness
92+
// - Linear: Track technical debt discovered in code
93+
// - Google Sheets: Log build metrics over time
94+
// - Custom datasets: Match local code patterns against best practices
95+
96+
const stream = execute({
97+
client,
98+
tools: localTools,
99+
model: 'claude-4.5',
100+
101+
messages: [
102+
{
103+
type: 'user',
104+
text: `Monitor my local development: check git changes, scan \
105+
dependencies for vulnerabilities, analyze system resources. If you find \
106+
critical security issues, create a Jira ticket. Track dependency sizes in our \
107+
Google Sheet. Alert #deploys Slack channel when everything looks ready for \
108+
production.`,
109+
},
110+
],
111+
112+
maxIterations: 25,
113+
})
114+
115+
for await (const event of stream) {
116+
if (event.type === 'token') {
117+
process.stdout.write(event.data.token)
118+
} else if (event.type === 'iteration') {
119+
console.log(`\n[Iteration ${event.data.iteration}]`)
120+
} else if (event.type === 'exit') {
121+
console.log(`\n${event.data.message}`)
122+
}
123+
}
124+
```
125+
126+
**Why this is powerful:**
127+
128+
The agent bridges local-only operations with remote collaboration:
129+
130+
1. **Monitors local state** - Git changes, processes, file system (can't be done remotely)
131+
2. **Analyzes dependencies** - Scans your actual node_modules directory
132+
3. **Creates Jira tickets** - Via ChatBotKit's Jira integration (no API setup!)
133+
4. **Updates Google Sheets** - Logs metrics automatically (OAuth handled by ChatBotKit)
134+
5. **Sends Slack alerts** - Team notifications (authenticated via ChatBotKit)
135+
136+
ChatBotKit handles all remote authentication, rate limiting, and API complexity - you focus on building tools for local development insights that get automatically synced to your team's collaboration platforms.
137+
138+
### Simple Tool Definition
139+
140+
```javascript
141+
import { complete } from '@chatbotkit/agent'
142+
import { ChatBotKit } from '@chatbotkit/sdk'
143+
144+
import { z } from 'zod'
145+
146+
const client = new ChatBotKit({ secret: process.env.CHATBOTKIT_API_TOKEN })
147+
148+
const tools = {
149+
calculateSum: {
150+
description: 'Add two numbers together',
151+
input: z.object({
152+
a: z.number(),
153+
b: z.number(),
154+
}),
155+
handler: async ({ a, b }) => ({ result: a + b }),
156+
},
157+
}
158+
159+
const stream = complete({
160+
client,
161+
tools,
162+
model: 'gpt-4o',
163+
messages: [{ type: 'user', text: 'What is 234 plus 567?' }],
164+
})
165+
166+
for await (const chunk of stream) {
167+
if (chunk.type === 'token') {
168+
process.stdout.write(chunk.data.token)
169+
}
170+
}
171+
```
172+
173+
### Built-in System Tools
174+
175+
The `execute` mode provides system tools for task management:
176+
177+
- **`plan`** - Create or update task execution plan
178+
- **`progress`** - Track completion status and blockers
179+
- **`exit`** - Signal task completion with status code
180+
181+
## Documentation
182+
183+
For comprehensive information about the ChatBotKit Agent SDK, including detailed documentation on its functionalities, helper methods, and configuration options, please visit our [type documentation page](https://chatbotkit.github.io/node-sdk/modules/_chatbotkit_agent.html).
184+
185+
## Contributing
186+
187+
If you find a bug or would like to contribute to the ChatBotKit SDK, please open an issue or submit a pull request on the [official GitHub repository](https://github.com/chatbotkit/node-sdk).

packages/agent/docs/.nojekyll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.

0 commit comments

Comments
 (0)