@alint-js/model-adapter-acp

中文文档
0.7.3发布于 2026/09/29MITTypeScriptES Module近 30 天下载 9.4万

OpenAI-compatible HTTP gateway for Agent Client Protocol coding agents

原始使用文档
文档目录5 节
  1. What it does
  2. How to use with a command
  3. How to embed an ACP connection
  4. When to use
  5. When not to use

@alint-js/model-adapter-acp

An OpenAI-compatible HTTP gateway for ACP coding agents.

What it does

The package keeps ACP session semantics outside alint. It exposes configured ACP agents as OpenAI-compatible models and implements:

  • GET /v1/models
  • non-streaming and SSE text chat completions
  • request-scoped OpenAI function tools exposed to ACP through MCP Streamable HTTP
  • deferred tool_calls continuation through a later role: tool message
  • tool_choice, usage, abort, continuation TTL, and permission-denial handling

The integration suite also runs a real runAlint file rule through ctx.model(), xsAI generateStructured, this HTTP gateway, an ACP session, and the MCP reportFindings tool before asserting the diagnostic returned by alint.

The MCP bridge uses a random route and bearer token for each completion turn. When the public gateway address is not loopback, configure mcpBaseUrl; request Host headers are not trusted to choose the authenticated MCP destination.

ACP has no equivalent for OpenAI temperature, and final ACP usage is unavailable while a deferred tool call is pending. Use onCompatibilityDiagnostic to observe those cases. Pending tool-call responses report zero usage because xsAI requires the OpenAI usage object.

How to use with a command

createCommandModel uses tinyexec to start one ACP process per completion. startGateway owns the loopback HTTP server and closes active ACP processes when it shuts down.

import { createCommandModel, startGateway } from '@alint-js/model-adapter-acp'

const gateway = await startGateway({
  cwd: process.cwd(),
  models: [createCommandModel({
    command: 'codex-acp',
    cwd: process.cwd(),
    id: 'codex',
    name: 'Codex ACP',
  })],
})

console.info(gateway.endpoint)
await gateway.shutdown()

The alint CLI wraps this interface. Users normally set driver = "acp" on a provider model in global setup or .alint/config.toml instead of starting the gateway themselves.

How to embed an ACP connection

import { createGateway } from '@alint-js/model-adapter-acp'
import { serve } from 'h3/node'

const app = createGateway({
  cwd: process.cwd(),
  mcpBaseUrl: 'http://127.0.0.1:7419',
  models: [{
    id: 'reviewer',
    name: 'Review Agent',
    openConnection: async () => ({
      kind: 'stream',
      stream: await openYourAcpStream(),
    }),
  }],
})

const server = await serve(app, { hostname: '127.0.0.1', port: 7419 }).ready()

// On shutdown, stop accepting HTTP first, then cancel retained ACP continuations.
await server.close()
await app.shutdown()

openConnection accepts either an official ACP AgentApp or Stream. An embedding application can own a different transport or lifecycle policy without using the command adapter.

Other OpenAI-compatible consumers can use the resulting ordinary provider endpoint:

[[providers]]
id = "acp"
type = "openai-compatible"
endpoint = "http://127.0.0.1:7419/v1"

When to use

  • You need existing OpenAI-compatible consumers to call an ACP coding agent.
  • The ACP agent supports MCP over HTTP when request tools are used.
  • The OpenAI client executes function calls and returns role: tool messages.

When not to use

  • Use an alint agent adapter when a rule intentionally depends on agent-specific behavior.
  • Do not use this package as an OpenAI Responses, realtime, audio, or image compatibility layer.
  • Sequential tool calls work with streaming and non-streaming chat completions.
  • Parallel tool calls are not supported.

版本与发布记录

@alint-js/model-adapter-acp 共发布 7 个版本,首次发布于 2026/08/08;过去 12 个月发布了 7 个版本。

版本发布日期距今
0.7.3latest2026/09/291 个月前
0.7.22026/09/281 个月前
0.7.12026/08/292 个月前
0.7.02026/08/292 个月前
0.6.02026/08/192 个月前
0.5.02026/08/162 个月前

关于 @alint-js/model-adapter-acp 的常见问题

@alint-js/model-adapter-acp 是什么?

OpenAI-compatible HTTP gateway for Agent Client Protocol coding agents

如何安装 @alint-js/model-adapter-acp?

在项目目录运行 npm install @alint-js/model-adapter-acp,或使用 pnpm add / yarn add / bun add。

@alint-js/model-adapter-acp 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@alint-js/model-adapter-acp 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@alint-js/model-adapter-acp 可以商用吗?

@alint-js/model-adapter-acp 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@alint-js/model-adapter-acp 的下载量有多少?

根据 npm 官方下载统计,@alint-js/model-adapter-acp 在 2026/10/06 – 2026/11/04 这 30 天内被下载 93,600 次,日均约 3,120 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@alint-js/model-adapter-acp 还在维护吗?

最新版本 0.7.3 发布于 2026/09/29(1 个月前);至今共发布 7 个版本,其中过去 12 个月发布了 7 个;首次发布于 2026/08/08。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。