npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@headless-coder-sdk/acp-server

v0.26.0

Published

The **ACP Server** is a Next.js application that exposes the **Headless Coder SDK** via the [Agent Communication Protocol (ACP)](https://agentcommunicationprotocol.dev/introduction/welcome). It dynamically loads available adapters from `acp.config.json`

Readme

🚀 Headless Coder ACP Server

The ACP Server is a Next.js application that exposes the Headless Coder SDK via the Agent Communication Protocol (ACP).
It dynamically loads available adapters from acp.config.json, registers enabled providers (Codex, Claude, Gemini), and exposes ACP-compatible REST + streaming endpoints under /api/acp/*.


✨ Key Features

  • ⚙️ Dynamic provider configuration using acp.config.json
  • 🔄 NDJSON streaming for real-time AI-coder responses
  • 🔐 Optional Bearer token authentication via ACP_TOKEN
  • 🧠 Structured output support via JSON schemas
  • 🧰 Unified interface across Codex, Claude, and Gemini adapters
  • 🚀 Built with Next.js (Node runtime) — deploy anywhere

🧩 Prerequisites

  • Node.js 20+
  • Headless Coder SDK installed (pnpm install or npm install at repo root)
  • Optional: environment variable ACP_TOKEN for authentication
  • Provider-specific credentials available (e.g. Codex binary, Claude API key, Gemini CLI)

⚙️ Configuration

  1. Open and edit apps/acp-next/acp.config.json to enable or disable adapters.
    The config is validated against acp.config.schema.json at runtime.

    Example:

    {
      "enabledAgents": ["codex", "gemini"],
      "defaults": {
        "workingDirectory": ".",
        "model": null,
        "sandboxMode": "read-only"
      }
    }
  2. (Optional) To enforce authentication, add an ACP_TOKEN variable in your environment:

    ACP_TOKEN=my-secret-token

    Copy .env.local.example.env.local and fill in your desired values.


▶️ Running the Server

From the repository root:

# Start the ACP server on port 8000
pnpm --filter acp-next dev
# or
npm run dev --workspace acp-next

Once started, the API will serve the following routes:

| Method | Endpoint | Description | |---------|-----------|-------------| | GET | /api/acp/agents | Lists enabled agents defined in acp.config.json. | | POST | /api/acp/sessions | Creates a new Headless Coder thread/session. | | POST | /api/acp/messages?stream=true | Streams Headless Coder events as NDJSON frames. |

Sample NDJSON stream output:

{"type":"delta","text":"Hello world!"}
{"type":"done"}

🏗️ Building and Deploying

pnpm --filter acp-next build
pnpm --filter acp-next start

Deployment options

  • Vercel — ideal for quick serverless deployment (runtime: nodejs required).
  • Docker — portable containerized deployment.
  • Render / Fly.io / AWS — any Node 20+ runtime will work.

Make sure your deployment includes:

  • ACP_TOKEN (if auth required)
  • Correct provider credentials (Codex CLI, Claude, Gemini)

🧪 Testing & Client Example

An example TypeScript client is available under apps/acp-next/client.

Run built-in tests

pnpm --filter acp-next dev   # start server
pnpm run acp:e2e             # execute client integration tests

The E2E test:

  1. Calls GET /api/acp/agents
  2. Opens a session for the first provider
  3. Sends a structured output request
  4. Streams and validates NDJSON frames

Minimal standalone client

import fetch from 'node-fetch';

const BASE_URL = process.env.ACP_BASE_URL ?? 'http://localhost:8000';
const headers = process.env.ACP_TOKEN
  ? { Authorization: `Bearer ${process.env.ACP_TOKEN}`, 'Content-Type': 'application/json' }
  : { 'Content-Type': 'application/json' };

async function main() {
  const agents = await (await fetch(`${BASE_URL}/api/acp/agents`, { headers })).json();
  const provider = agents.agents[0].id;

  const session = await (await fetch(`${BASE_URL}/api/acp/sessions`, {
    method: 'POST',
    headers,
    body: JSON.stringify({ provider }),
  })).json();

  const schema = {
    type: 'object',
    properties: {
      summary: { type: 'string' },
      risks: { type: 'array', items: { type: 'string' }, minItems: 1 },
    },
    required: ['summary', 'risks'],
  };

  const response = await fetch(`${BASE_URL}/api/acp/messages?stream=true`, {
    method: 'POST',
    headers,
    body: JSON.stringify({
      sessionId: session.sessionId,
      content: 'Review the latest commit and explain key risks.',
      outputSchema: schema,
    }),
  });

  const reader = response.body!.getReader();
  const decoder = new TextDecoder();
  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    process.stdout.write(decoder.decode(value));
  }
}

main().catch(console.error);

📊 API Flow Overview

sequenceDiagram
  participant Client
  participant ACP-Next Server
  participant HeadlessCoder SDK
  participant Provider (Codex/Claude/Gemini)

  Client->>ACP-Next Server: POST /api/acp/sessions
  ACP-Next Server->>HeadlessCoder SDK: createCoder() + startThread()
  ACP-Next Server-->>Client: { sessionId }

  Client->>ACP-Next Server: POST /api/acp/messages?stream=true
  ACP-Next Server->>HeadlessCoder SDK: thread.runStreamed()
  HeadlessCoder SDK->>Provider: execute task
  loop Streaming NDJSON
    ACP-Next Server-->>Client: {"type":"delta","text":"..."}
  end
  ACP-Next Server-->>Client: {"type":"done"}

🛠️ Development Notes

  • Dynamic imports ensure only enabled adapters are bundled.
  • Routes export runtime = 'nodejs' for CLI-based adapters (Codex, Gemini).
  • Sessions are in-memory by default; add Redis/Postgres for persistence.
  • Works with official ACP SDK clients (e.g. BeeAI, Zed).

🧾 License

MIT © 2025 Ohad Assulin


🤝 Contributing

Pull requests and issues are welcome!
If you encounter a bug or have ideas for improvement, open an issue on GitHub: 👉 https://github.com/OhadAssulin/headless-coder-sdk/issues