Skip to content

Commit f6e18da

Browse files
committed
initial release
AN SDK — the open-source framework for building, deploying, and embedding AI coding agents. Packages: - @an-sdk/agent — type-safe agent definitions - @an-sdk/react — drop-in React chat UI - @an-sdk/node — Node.js API client - @an-sdk/nextjs — Next.js integration - @an-sdk/cli — deploy CLI
0 parents  commit f6e18da

122 files changed

Lines changed: 9364 additions & 0 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.

.github/workflows/ci.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: pnpm/action-setup@v4
16+
with:
17+
version: 9
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
cache: pnpm
23+
24+
- run: pnpm install --frozen-lockfile
25+
- run: pnpm build

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
node_modules/
2+
dist/
3+
.turbo/
4+
.env
5+
.env.*
6+
.DS_Store
7+
*.tgz
8+
CLAUDE.md

CONTRIBUTING.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Contributing to AN SDK
2+
3+
Thanks for your interest in contributing to AN SDK!
4+
5+
## Reporting Issues
6+
7+
Found a bug or have a feature request? [Open an issue](https://github.com/21st-dev/an-sdk/issues/new) with:
8+
9+
- A clear description of the problem or feature
10+
- Steps to reproduce (for bugs)
11+
- Which package is affected (`@an-sdk/agent`, `@an-sdk/react`, etc.)
12+
13+
## Pull Requests
14+
15+
We welcome PRs for bug fixes, documentation improvements, and new features.
16+
17+
1. Fork the repo and create your branch from `main`
18+
2. Install dependencies: `pnpm install`
19+
3. Make your changes
20+
4. Run the build to verify: `pnpm build`
21+
5. Open a PR with a clear description
22+
23+
### Development Setup
24+
25+
```bash
26+
git clone https://github.com/21st-dev/an-sdk.git
27+
cd an-sdk
28+
pnpm install
29+
pnpm build
30+
```
31+
32+
### Code Style
33+
34+
- TypeScript throughout
35+
- Follow existing patterns in the codebase
36+
- Keep changes focused — one feature or fix per PR
37+
38+
## How This Repo Works
39+
40+
This repo contains the open-source SDK packages for the AN platform. The source of truth is maintained internally, and this repo is synced periodically. We review and merge community PRs, then sync them back.
41+
42+
## Questions?
43+
44+
Join the discussion in [GitHub Issues](https://github.com/21st-dev/an-sdk/issues) or reach out at [an.dev](https://an.dev).

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 21st.dev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# AN SDK
2+
3+
The open-source SDK for building, deploying, and embedding AI coding agents.
4+
5+
**AN** is the "Vercel for agents" — a framework + hosting platform for AI agents. Define agents in code, deploy with one command, embed anywhere.
6+
7+
## Packages
8+
9+
| Package | Description | npm |
10+
|---|---|---|
11+
| [`@an-sdk/agent`](./packages/agent) | Define agents with full type safety | [![npm](https://img.shields.io/npm/v/@an-sdk/agent)](https://www.npmjs.com/package/@an-sdk/agent) |
12+
| [`@an-sdk/react`](./packages/react) | Drop-in React chat UI for agents | [![npm](https://img.shields.io/npm/v/@an-sdk/react)](https://www.npmjs.com/package/@an-sdk/react) |
13+
| [`@an-sdk/node`](./packages/node) | Node.js client for the AN API | [![npm](https://img.shields.io/npm/v/@an-sdk/node)](https://www.npmjs.com/package/@an-sdk/node) |
14+
| [`@an-sdk/nextjs`](./packages/nextjs) | Next.js integration (server + client) | [![npm](https://img.shields.io/npm/v/@an-sdk/nextjs)](https://www.npmjs.com/package/@an-sdk/nextjs) |
15+
| [`@an-sdk/cli`](./packages/cli) | CLI for deploying agents | [![npm](https://img.shields.io/npm/v/@an-sdk/cli)](https://www.npmjs.com/package/@an-sdk/cli) |
16+
17+
## Quickstart
18+
19+
### 1. Define an agent
20+
21+
```ts
22+
// agents/my-agent.ts
23+
import { agent, tool } from "@an-sdk/agent"
24+
import { z } from "zod"
25+
26+
export default agent({
27+
model: "claude-sonnet-4-6",
28+
systemPrompt: "You are a helpful coding assistant.",
29+
tools: {
30+
greet: tool({
31+
description: "Greet the user",
32+
inputSchema: z.object({ name: z.string() }),
33+
execute: async ({ name }) => ({
34+
content: [{ type: "text", text: `Hello, ${name}!` }],
35+
}),
36+
}),
37+
},
38+
})
39+
```
40+
41+
### 2. Deploy
42+
43+
```bash
44+
npx @an-sdk/cli login
45+
npx @an-sdk/cli deploy
46+
```
47+
48+
### 3. Embed in your app
49+
50+
```tsx
51+
import { AnAgentChat } from "@an-sdk/react"
52+
53+
export default function Page() {
54+
return <AnAgentChat agent="your-agent-slug" />
55+
}
56+
```
57+
58+
## Architecture
59+
60+
```
61+
Developer → CLI → AN Platform → E2B Sandbox (agent runs here)
62+
63+
Client → @an-sdk/react → AN Relay → SSE Streaming
64+
```
65+
66+
- **SDK packages** (this repo): Open-source. Define agents, build UIs, deploy.
67+
- **AN Platform**: Managed infrastructure. Runs agents in sandboxes, handles billing, auth, scaling.
68+
69+
Same model as Next.js (open-source) + Vercel (managed platform).
70+
71+
## Documentation
72+
73+
See the [`docs/`](./packages/docs) directory or visit [an.dev/docs](https://an.dev/docs).
74+
75+
## Examples
76+
77+
- [`examples/basic-agent`](./examples/basic-agent) — Minimal agent with a custom tool
78+
79+
## Contributing
80+
81+
See [CONTRIBUTING.md](./CONTRIBUTING.md).
82+
83+
## License
84+
85+
MIT — see [LICENSE](./LICENSE).

examples/basic-agent/README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Basic Agent Example
2+
3+
A minimal AN agent that reviews code using ESLint.
4+
5+
## Setup
6+
7+
```bash
8+
npm install
9+
```
10+
11+
## Deploy
12+
13+
```bash
14+
# Login with your API key (get one at https://an.dev/api-keys)
15+
npx @an-sdk/cli login
16+
17+
# Deploy the agent
18+
npx @an-sdk/cli deploy
19+
```
20+
21+
The CLI will detect your agent in `agents/code-reviewer.ts`, bundle it, and deploy to the AN platform.
22+
23+
## What's happening
24+
25+
1. `agents/code-reviewer.ts` defines the agent using `@an-sdk/agent`
26+
2. `an deploy` bundles the code and uploads it to AN
27+
3. AN runs the agent in an isolated sandbox
28+
4. You can interact with it via the AN dashboard or embed it in your app with `@an-sdk/react`
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { agent, tool } from "@an-sdk/agent"
2+
import { z } from "zod"
3+
4+
export default agent({
5+
model: "claude-sonnet-4-6",
6+
systemPrompt: "You are a code reviewer. Review files for bugs, style issues, and improvements.",
7+
tools: {
8+
lint: tool({
9+
description: "Run ESLint on a file",
10+
inputSchema: z.object({ path: z.string().describe("File path to lint") }),
11+
execute: async ({ path }) => {
12+
const { execSync } = await import("child_process")
13+
try {
14+
const output = execSync(`npx eslint ${path}`, { encoding: "utf-8" })
15+
return { content: [{ type: "text", text: output || "No issues found." }] }
16+
} catch (error: any) {
17+
return { content: [{ type: "text", text: error.stdout || error.message }] }
18+
}
19+
},
20+
}),
21+
},
22+
})

examples/basic-agent/package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "basic-agent-example",
3+
"private": true,
4+
"type": "module",
5+
"dependencies": {
6+
"@an-sdk/agent": "latest",
7+
"zod": "^3.24"
8+
}
9+
}

package.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "an-sdk",
3+
"private": true,
4+
"description": "The open-source SDK for building, deploying, and embedding AI coding agents.",
5+
"repository": {
6+
"type": "git",
7+
"url": "https://github.com/21st-dev/an-sdk.git"
8+
},
9+
"license": "MIT",
10+
"scripts": {
11+
"build": "turbo run build",
12+
"dev": "turbo run dev",
13+
"ts:check": "turbo run ts:check"
14+
},
15+
"devDependencies": {
16+
"turbo": "^2.3.0"
17+
},
18+
"packageManager": "pnpm@9.15.4"
19+
}

packages/agent/AGENTS.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# @an-sdk/agent
2+
3+
Config layer for defining AI agents and tools with full type inference.
4+
5+
## Docs
6+
7+
Full documentation: `./docs/` directory (8 guides covering the entire AN platform).
8+
9+
## Source
10+
11+
Source code: `./src/` directory.
12+
13+
## Key Entry Points
14+
15+
- `src/index.ts` — Barrel exports (`agent`, `tool`, all types)
16+
- `src/agent.ts``agent()` factory function (sets defaults, returns `AgentConfig`)
17+
- `src/tool.ts``tool()` factory function (returns `ToolDefinition<TInput>`)
18+
- `src/types.ts` — All type definitions (`AgentConfig`, `ToolDefinition`, `ToolSet`, hooks)
19+
20+
## Quick Example
21+
22+
```ts
23+
import { agent, tool } from "@an-sdk/agent"
24+
import { z } from "zod"
25+
26+
export default agent({
27+
model: "claude-sonnet-4-6",
28+
systemPrompt: "You are a helpful assistant.",
29+
tools: {
30+
greet: tool({
31+
description: "Greet a user",
32+
inputSchema: z.object({ name: z.string() }),
33+
execute: async ({ name }) => ({
34+
content: [{ type: "text", text: `Hello, ${name}!` }],
35+
}),
36+
}),
37+
},
38+
})
39+
```

0 commit comments

Comments
 (0)