Skip to content

Commit e6da943

Browse files
committed
chore: sync SDK packages with monorepo
Full sync of all 6 SDK packages (agent, cli, docs, nextjs, node, react) from monorepo source of truth. Updates repo name references from an-sdk to 21st-sdk. Fixes workspace:* dep in nextjs package.json.
1 parent f6e18da commit e6da943

56 files changed

Lines changed: 890 additions & 440 deletions

Some content is hidden

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

README.md

Lines changed: 68 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,95 @@
1-
# AN SDK
1+
# 21st SDK — Internal Dev Guide
22

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.
3+
This directory contains the 21st SDK packages. Source of truth lives here in the monorepo. The public open-source repo is at [github.com/21st-dev/21st-sdk](https://github.com/21st-dev/21st-sdk).
64

75
## Packages
86

9-
| Package | Description | npm |
7+
| Directory | npm package | What it does |
108
|---|---|---|
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-
```
9+
| `agent/` | `@21st-sdk/agent` | Agent + tool definition (types only) |
10+
| `react/` | `@21st-sdk/react` | React chat UI components |
11+
| `node/` | `@21st-sdk/node` | Node.js API client |
12+
| `nextjs/` | `@21st-sdk/nextjs` | Next.js integration (server + client) |
13+
| `cli/` | `@21st-sdk/cli` | `an login` + `an deploy` CLI |
14+
| `docs/` || Documentation (bundled into each package on publish) |
15+
16+
> **Note:** `agent-runtime` used to be here but was moved to `packages/agent-runtime/` — it's private and should never be in the public repo.
4017
41-
### 2. Deploy
18+
## Day-to-day development
19+
20+
Just work in the monorepo as normal. Edit files, run builds, test locally.
4221

4322
```bash
44-
npx @an-sdk/cli login
45-
npx @an-sdk/cli deploy
23+
# Build all SDK packages
24+
pnpm --filter "@21st-sdk/*" build
25+
26+
# Build a specific package
27+
pnpm --filter @21st-sdk/react build
4628
```
4729

48-
### 3. Embed in your app
30+
## Publishing to the open-source repo
4931

50-
```tsx
51-
import { AnAgentChat } from "@an-sdk/react"
32+
When you're ready to push changes to the public [github.com/21st-dev/21st-sdk](https://github.com/21st-dev/21st-sdk):
5233

53-
export default function Page() {
54-
return <AnAgentChat agent="your-agent-slug" />
55-
}
34+
### Prerequisites (one-time setup)
35+
36+
Clone the public repo as a sibling of the monorepo:
37+
38+
```bash
39+
cd /Users/sergeybunas/Develop/21/
40+
git clone git@github.com:21st-dev/21st-sdk.git
5641
```
5742

58-
## Architecture
43+
So your directory structure looks like:
5944

6045
```
61-
Developer → CLI → AN Platform → E2B Sandbox (agent runs here)
62-
63-
Client → @an-sdk/react → AN Relay → SSE Streaming
46+
Develop/21/
47+
├── 21st/ ← monorepo (this repo)
48+
└── an-sdk/ ← public repo
6449
```
6550

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.
51+
### Releasing
6852

69-
Same model as Next.js (open-source) + Vercel (managed platform).
53+
From the monorepo root:
7054

71-
## Documentation
55+
```bash
56+
# Option 1: Auto-generate commit message from recent monorepo commits
57+
./scripts/release-sdk.sh
7258

73-
See the [`docs/`](./packages/docs) directory or visit [an.dev/docs](https://an.dev/docs).
59+
# Option 2: Custom commit message
60+
./scripts/release-sdk.sh -m "feat: add theme customization API to @21st-sdk/react"
7461

75-
## Examples
62+
# Option 3: Tagged release (creates a git tag)
63+
./scripts/release-sdk.sh -t v0.2.0 -m "v0.2.0 — streaming improvements and new tool renderers"
64+
```
7665

77-
- [`examples/basic-agent`](./examples/basic-agent) — Minimal agent with a custom tool
66+
Then push:
7867

79-
## Contributing
68+
```bash
69+
cd ../an-sdk && git push # regular release
70+
cd ../an-sdk && git push --tags # if you created a tag
71+
```
72+
73+
### What the script does
74+
75+
1. Copies `agent/`, `react/`, `node/`, `nextjs/`, `cli/`, `docs/` to the public repo
76+
2. Excludes `node_modules/`, `dist/`, `.turbo/`, `CLAUDE.md` (private dev notes)
77+
3. If no `-m` flag, pulls recent commit messages from the monorepo that touched `packages/an-sdk/` and uses them as the commit message
78+
4. Creates a commit in the public repo (skips if nothing changed)
79+
5. Optionally tags the commit with `-t`
80+
81+
### What NOT to do
8082

81-
See [CONTRIBUTING.md](./CONTRIBUTING.md).
83+
- Don't develop directly in the public repo — always work in the monorepo
84+
- Don't manually copy files — always use the release script
85+
- Don't include `agent-runtime` — the script only copies the 6 listed packages
8286

83-
## License
87+
## Publishing to npm
88+
89+
npm publishing still happens from the monorepo, not the public repo:
90+
91+
```bash
92+
pnpm --filter @21st-sdk/agent build && npm publish --access public
93+
```
8494

85-
MIT — see [LICENSE](./LICENSE).
95+
See the [NPM Publishing notes](../../.claude/projects/-Users-sergeybunas-Develop-21-21st/memory/MEMORY.md) for auth details.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "an-sdk",
2+
"name": "21st-sdk",
33
"private": true,
44
"description": "The open-source SDK for building, deploying, and embedding AI coding agents.",
55
"repository": {
66
"type": "git",
7-
"url": "https://github.com/21st-dev/an-sdk.git"
7+
"url": "https://github.com/21st-dev/21st-sdk.git"
88
},
99
"license": "MIT",
1010
"scripts": {

packages/agent/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
# @an-sdk/agent
1+
# @21st-sdk/agent
22

3-
Define AI agents with full type inference. The config layer for [AN](https://an.dev).
3+
Define AI agents with full type inference. The config layer for [21st Agents](https://21st.dev/agents).
44

55
## Install
66

77
```bash
8-
npm install @an-sdk/agent zod
8+
npm install @21st-sdk/agent zod
99
```
1010

1111
## Quick Start
1212

1313
Create `src/agent.ts`:
1414

1515
```ts
16-
import { agent, tool } from "@an-sdk/agent"
16+
import { agent, tool } from "@21st-sdk/agent"
1717
import { z } from "zod"
1818

1919
export default agent({
@@ -31,11 +31,11 @@ export default agent({
3131
})
3232
```
3333

34-
Then deploy with the [AN CLI](https://www.npmjs.com/package/@an-sdk/cli):
34+
Then deploy with the [21st SDK CLI](https://www.npmjs.com/package/@21st-sdk/cli):
3535

3636
```bash
37-
npx @an-sdk/cli login
38-
npx @an-sdk/cli deploy
37+
npx @21st-sdk/cli login
38+
npx @21st-sdk/cli deploy
3939
```
4040

4141
## API
@@ -85,7 +85,7 @@ export default agent({
8585
Creates a tool definition with Zod schema validation.
8686

8787
```ts
88-
import { tool } from "@an-sdk/agent"
88+
import { tool } from "@21st-sdk/agent"
8989
import { z } from "zod"
9090

9191
const myTool = tool({
@@ -132,7 +132,7 @@ onFinish: async ({ result }) => {
132132

133133
## How It Works
134134

135-
`agent()` and `tool()` are identity functions — they return exactly what you pass in, with type inference added. The actual execution happens in the AN runtime (E2B sandbox) using the Claude Agent SDK.
135+
`agent()` and `tool()` are identity functions — they return exactly what you pass in, with type inference added. The actual execution happens in the 21st Agents runtime (E2B sandbox) using the Claude Agent SDK.
136136

137137
Your code runs in a secure cloud sandbox with full access to Node.js, git, and system tools.
138138

packages/agent/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"name": "@an-sdk/agent",
3-
"version": "0.0.4",
2+
"name": "@21st-sdk/agent",
3+
"version": "0.0.6",
44
"license": "MIT",
5-
"description": "Define AI agents and tools with full type inference — the config layer for AN",
6-
"homepage": "https://an.dev",
5+
"description": "Define AI agents and tools with full type inference for 21st Agents",
6+
"homepage": "https://21st.dev/agents",
77
"publishConfig": {
88
"access": "public"
99
},
@@ -39,8 +39,8 @@
3939
"ai",
4040
"agent",
4141
"tools",
42-
"an",
43-
"an.dev",
42+
"21st",
43+
"21st.dev",
4444
"sdk",
4545
"claude",
4646
"codex"

packages/cli/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
# @an-sdk/cli
1+
# @21st-sdk/cli
22

3-
Deploy AI agents to [AN](https://an.dev) from your terminal.
3+
Deploy AI agents to [21st Agents](https://21st.dev/agents) from your terminal.
44

55
## Quick Start
66

77
```bash
8-
# 1. Login with your API key (get one at an.dev)
9-
npx @an-sdk/cli login
8+
# 1. Login with your API key (get one at https://21st.dev/agents/api-keys)
9+
npx @21st-sdk/cli login
1010

1111
# 2. Create your agent
12-
npm init -y && npm install @an-sdk/agent zod
12+
npm init -y && npm install @21st-sdk/agent zod
1313
```
1414

1515
Create `src/agent.ts`:
1616

1717
```ts
18-
import { agent, tool } from "@an-sdk/agent"
18+
import { agent, tool } from "@21st-sdk/agent"
1919
import { z } from "zod"
2020

2121
export default agent({
@@ -35,7 +35,7 @@ export default agent({
3535

3636
```bash
3737
# 3. Deploy
38-
npx @an-sdk/cli deploy
38+
npx @21st-sdk/cli deploy
3939
```
4040

4141
That's it. Your agent is live.
@@ -44,10 +44,10 @@ That's it. Your agent is live.
4444

4545
### `an login`
4646

47-
Authenticate with the AN platform.
47+
Authenticate with your API key.
4848

4949
```bash
50-
npx @an-sdk/cli login
50+
npx @21st-sdk/cli login
5151
# Enter your API key: an_sk_...
5252
# Authenticated as John (team: my-team)
5353
```
@@ -59,7 +59,7 @@ Your key is saved to `~/.an/credentials`.
5959
Bundle and deploy your agent.
6060

6161
```bash
62-
npx @an-sdk/cli deploy
62+
npx @21st-sdk/cli deploy
6363
# Bundling src/agent.ts...
6464
# Bundled (12.3kb)
6565
# Deploying my-agent...
@@ -89,7 +89,7 @@ After first deploy, the CLI saves `.an/project.json` in your project directory.
8989

9090
## Environment Variables
9191

92-
`AN_API_URL` — Override the API endpoint (default: `https://an.dev/api/v1`)
92+
`API_URL_21ST` — Override the API endpoint (default: `https://an.dev/api/v1`)
9393

9494
## License
9595

packages/cli/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{
2-
"name": "@an-sdk/cli",
3-
"version": "0.0.11",
4-
"description": "AN CLI — deploy AI agents",
2+
"name": "@21st-sdk/cli",
3+
"version": "0.0.15",
4+
"description": "CLI for deploying AI agents to 21st Agents",
5+
"publishConfig": {
6+
"access": "public"
7+
},
58
"type": "module",
69
"bin": {
710
"an": "dist/index.js"

packages/cli/src/bundler.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export async function findAgentEntryPoints(): Promise<AgentEntryPoint[]> {
77
const { join, basename, extname } = await import("path")
88

99
if (!existsSync("agents") || !statSync("agents").isDirectory()) {
10-
throw new Error("No agents/ directory found. See https://an.dev/docs to get started.")
10+
throw new Error("No agents/ directory found. See https://21st.dev/agents/docs to get started.")
1111
}
1212

1313
const entries: AgentEntryPoint[] = []
@@ -34,7 +34,7 @@ export async function findAgentEntryPoints(): Promise<AgentEntryPoint[]> {
3434
}
3535

3636
if (entries.length === 0) {
37-
throw new Error("No agents found in agents/ directory. See https://an.dev/docs to get started.")
37+
throw new Error("No agents found in agents/ directory. See https://21st.dev/agents/docs to get started.")
3838
}
3939

4040
return entries
@@ -48,7 +48,7 @@ export async function bundleAgent(entryPoint: string): Promise<Buffer> {
4848
target: "node22",
4949
format: "esm",
5050
write: false,
51-
external: ["@an-sdk/agent"],
51+
external: ["@21st-sdk/agent"],
5252
minify: true,
5353
sourcemap: false,
5454
})
@@ -66,7 +66,7 @@ async function importBundle(bundle: Buffer): Promise<Record<string, unknown> | n
6666
const { writeFileSync, unlinkSync, mkdirSync } = await import("fs")
6767
const { join } = await import("path")
6868

69-
// Write to .an-tmp/ in cwd so ESM can resolve @an-sdk/agent from node_modules
69+
// Write to .an-tmp/ in cwd so ESM can resolve @21st-sdk/agent from node_modules
7070
const tmpDir = join(process.cwd(), ".an-tmp")
7171
mkdirSync(tmpDir, { recursive: true })
7272
const tmpPath = join(tmpDir, `an-bundle-${Date.now()}.mjs`)

0 commit comments

Comments
 (0)