# nexgenr

NexgenR CLI is a terminal AI coding agent wired to the **NexgenR red-team** surface.

## Install

Requires Node.js 22.19.0 or later.

```sh
npm install -g nexgenr
```

Or with pnpm:

```sh
pnpm add -g nexgenr
```

## Configure

NexgenR signs in with an API key. There is no OAuth and no device flow:

```sh
export NEXGENR_API_KEY="<your key>"
# optional, defaults to https://redteam.nexgen.systems/v1
export NEXGENR_BASE_URL="https://redteam.nexgen.systems/v1"
```

```sh
nexgenr login                       # reads NEXGENR_API_KEY
nexgenr login --api-key <your key>  # or pass it explicitly
```

The same key works on both surfaces; the header is what changes:

| Surface | Send the key as | Rejected |
|---|---|---|
| `/v1/…` inference and catalog | `Authorization: Bearer <key>` or `x-api-key: <key>` | `x-bf-vk` answers 401 here |
| `/mcp` gateway | `x-bf-vk: <key>` or `Authorization: Bearer <key>` | — |

The key must be provisioned for the `vllm` provider and the `nexgen-redteam` model.
Without that grant `GET /v1/models` answers 200 with an empty catalog and chat fails
with `400 modelo-desconocido`.

`nexgenr login` writes `~/.nexgenr/config.toml` with the `redteam` provider and its single
model `nexgen-redteam` (262 144 tokens of context), and `~/.nexgenr/mcp.json` with the
gateway. It does not call the catalog: the model list is static.

## Quick start

```sh
cd your-project
nexgenr -p "Summarize this repository"
nexgenr            # interactive terminal UI
```

## What it talks to

| Capability | Endpoint |
|---|---|
| Chat, streaming only | `POST /v1/chat/completions` |
| Model catalog | `GET /v1/models` |
| Health and published limits | `GET /health`, no credential |
| MCP gateway | `POST /mcp` — 24 tools (8 Brave_Search, 16 Crawl4AI) |

`POST /v1/completions` and `POST /v1/embeddings` are in the edge allowlist but the engine
answers 404: `POST /v1/chat/completions` is the only inference route.

Limits, as published by `GET /health`: 4 requests in flight per consumer with `429` and
`Retry-After: 10` beyond that, a 12 MiB request body, and 262 144 tokens of context. A
prefill can take minutes, so requests stream and wait up to 3 600 s for the first byte.

## Features

- Terminal UI, headless `-p` mode, ACP server, and a local REST/WS API (`nexgenr web`).
- Sessions persisted under `~/.nexgenr/sessions`, with `wire.jsonl` as the source of truth.
- Permissions and approvals with `manual`, `yolo`, and `auto` modes.
- Agent Skills, MCP servers, subagents, goals, cron tasks, and Swarm fan-out.
- Provider/model configuration for any OpenAI-, Anthropic-, or Gemini-compatible endpoint.

## Not included in this build

- Remote Control (requires a relay service).
- CDN-based auto-update; upgrade with `npm install -g nexgenr@latest`.
- The bundled browser UI; `nexgenr web` serves the API plus a minimal landing page.
- SSO: NexgenR signs in with an API key only.

## License

MIT. See `LICENSE` and `NOTICE` for the upstream attribution.
