open-index/open-npm huggingface dataset:
npm package: @21gram-consulting/ts-codec
Description: TypeScript library providing a set of contracts for encoding and decoding values in a strongly-typed way.
Author: Adam Laszlo Rocska
Latest version: 1.2.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# 21Gram's TypeScript Codec Library
![Image](https://repository-images.githubusercontent.com/619929257/c3a52046-1d31-4f9a-ac02-47872cb914c2)

Provides a convenient & strongly-typed API to perform coding and decoding operations between datatypes in TypeScript.

Conceptually inspired by Swift's Codable API, however it's nowhere near it. The first version's goal is to provide a basic yet convenient functional API for these tasks.

See this repo's GitHub Pages for an API doc'.

## Disclaimer

Since this repo is an initial step in open-sourcing our more robust internal `ts-codec` solution:
* More features are to be expected
* Though we do our best to avoid them, some hiccups may occur.

The end goal is to switch our dependency direction from internal first
to external first. Internall we do use the migrated code but in a different environment, so differences could happen.

2023 is the Open-Sourcing year for 21Gram.
npm package: @21st-sdk/nextjs
Description: Next.js integration for 21st Agents chat
Latest version: 0.0.11

# @21st-sdk/nextjs

Next.js integration for [21st Agents](https://21st.dev/agents) AI agent chat. Provides a server-side token handler so your API key never reaches the client.

## Install

```bash
npm install @21st-sdk/nextjs @21st-sdk/react ai @ai-sdk/react
```

## Quick Start

### 1. Set your API key

```env
# .env.local
API_KEY_21ST=an_sk_your_key_here
```

Get your API key from [the API keys page](https://21st.dev/agents/api-keys).

### 2. Create the token route (one line)

```ts
// app/api/agent/token/route.ts
import { createTokenHandler } from "@21st-sdk/nextjs/server"

export const POST = createTokenHandler({
  apiKey: process.env.API_KEY_21ST!,
})
```

### 3. Use in your page

```tsx
// app/page.tsx
"use client"

import { useChat } from "@ai-sdk/react"
import { AgentChat, createAgentChat } from "@21st-sdk/nextjs"
import "@21st-sdk/react/styles.css"
import { useMemo } from "react"

export default function Chat() {
  const chat = useMemo(
    () => createAgentChat({
      agent: "your-agent-slug",
      tokenUrl: "/api/agent/token",
    }),
    [],
  )

  const { messages, sendMessage, status, stop, error } = useChat({ chat })

  return (
    <AgentChat
      messages={messages}
      onSend={(msg) =>
        sendMessage({ parts: [{ type: "text", text: msg.content }] })
      }
      status={status}
      onStop={stop}
      error={error}
    />
  )
}
```

That's it. Your `an_sk_` API key stays on the server. The client only receives short-lived JWTs.

## How It Works

```
Browser                     Your Next.js Server              Relay
  |                                |                            |
  |-- POST /api/agent/token ------>|                            |
  |                                |-- POST /v1/tokens -------->|
  |                                |   (with an_sk_ key)        |
  |                                |<-- { token, expiresAt } ---|
  |<-- { token, expiresAt } ------|                            |
  |                                                             |
  |-- POST /v1/chat/:agent ------(with short-lived JWT)------->|
  |<-- streaming response -----(SSE)---------------------------|
```

## License

MIT
npm package: @21st-sdk/node
Description: Server-side Node.js SDK for 21st Agents
Latest version: 0.0.9

# @21st-sdk/node

Server-side Node.js SDK for [21st Agents](https://21st.dev/agents). Manage sandboxes, threads, and tokens programmatically.

## Install

```bash
npm install @21st-sdk/node
```

## Quick Start

```ts
import { AgentClient } from "@21st-sdk/node"

const client = new AgentClient({
  apiKey: process.env.API_KEY_21ST!, // an_sk_...
})

// Create a sandbox for your agent
const sandbox = await client.sandboxes.create({ agent: "my-agent" })

// Create a thread
const thread = await client.threads.create({
  sandboxId: sandbox.sandboxId,
  name: "Review PR #42",
})

// Generate a short-lived token for browser clients
const { token, expiresAt } = await client.tokens.create({
  agent: "my-agent",
  expiresIn: "1h",
})
```

## API

### `new AgentClient(config)`

```ts
new AgentClient({
  apiKey: string     // Your an_sk_ API key
  baseUrl?: string   // Default: "https://relay.an.dev"
})
```

### `client.sandboxes`

| Method | Description |
|--------|-------------|
| `create({ agent })` | Create a new sandbox for an agent |
| `get(sandboxId)` | Get sandbox details (status, threads, agent info) |
| `delete(sandboxId)` | Delete a sandbox |

### `client.threads`

| Method | Description |
|--------|-------------|
| `list({ sandboxId })` | List all threads in a sandbox |
| `create({ sandboxId, name? })` | Create a new thread |
| `get({ sandboxId, threadId })` | Get thread with messages |
| `delete({ sandboxId, threadId })` | Delete a thread |

### `client.tokens`

| Method | Description |
|--------|-------------|
| `create({ agent?, userId?, expiresIn? })` | Create a short-lived JWT (default: 1h) |

## License

MIT