Skip to content

Cligent

Unified TypeScript SDK for AI agents - Claude Code, Codex, Gemini CLI, OpenCode, and more

Install

$npm install @sublang/cligent

Install command taken from the project's README or registry entry. Always review code before running it.

cligent

Unified TypeScript SDK for AI coding agent CLIs (Claude Code, Codex CLI, Gemini CLI, Kimi Code, OpenCode, and more).

Register an adapter, send a prompt, and consume a single async event stream — regardless of which agent runs underneath.

Install

npm install @sublang/cligent

The agent SDKs are optional peer dependencies — add the one(s) for the adapters you use:

# `>=` keeps the declaration open so a cligent upgrade can carry the runtime
# forward. A bare `npm install ` writes a caret instead, and for a
# `0.MINOR.PATCH` package a caret pins the minor: `^0.139.0` never reaches
# `0.159.0`, however often you run `npm update`.
npm install "@anthropic-ai/claude-agent-sdk@>=0.3.284"   # Claude Code
npm install "@openai/codex-sdk@>=0.156.1"                # Codex
npm install "@opencode-ai/sdk@>=1.18.29"                 # OpenCode

Gemini and default managed-mode OpenCode also need their CLI on PATH. External-mode OpenCode connects to a caller-owned server and needs only the SDK. Kimi has its own pinned CLI setup below.

npm install -g @google/gemini-cli   # Gemini CLI
npm install -g opencode-ai          # OpenCode managed server

cligent owns which versions of those runtimes work. It refuses one it does not support, naming the version it found, the version it needs, and the command that repairs it — before an agent call rather than in the middle of one. @sublang/cligent/runtime-targets publishes the supported and tested version of every runtime, so a tool built on cligent inherits the policy by upgrading cligent and carries no agent-SDK version knowledge of its own. For Claude, those fields classify the Claude Agent SDK itself; that SDK owns its Claude Code executable selection, and repository conformance checks only the selected-binary identity and version its own metadata reports. Missing metadata fields stay unreported rather than being guessed from PATH or another installed package. Codex explicitly names its SDK-owned executable package and resolves that version from inside the Codex SDK's dependency tree. Note pnpm rewrites >= back into a caret on pnpm update; there, move the pin deliberately and let the lockfile hold it.

The Kimi adapter targets the maintained Kimi Code CLI through ACP. Install the exact conformance target. The external Kimi CLI itself requires Node.js 22.19 or newer to install and run, then authenticate once:

npm install -g @moonshot-ai/kimi-code@2.1.1
kimi login

Adapters reuse each vendor's own authentication from your environment — a signed-in CLI (e.g. claude, codex) or its API-key variable (e.g. ANTHROPIC_API_KEY, OPENAI_API_KEY). Kimi Code 2.1.1 ACP accepts any of three: stored OAuth material resolved from the default model or reported by any logged-in provider, including after kimi login; a configured default-model alias resolving to non-OAuth credentials; or KIMI_MODEL_NAME plus KIMI_MODEL_API_KEY. A bare MOONSHOT_API_KEY is not one of them, because it names no default model. Cligent stores no credentials and never starts an authentication flow itself.

Runtime and declaration requirements:

  • Node.js 18.3.0 or newer for Cligent itself; using the Kimi adapter also requires the external Kimi CLI to run under Node.js 22.19 or newer.
  • TypeScript 5.4 or newer when consuming the package declarations.

Quick start

Similar plugs

Orca is the ADE for working with a fleet of parallel agents. Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies

Documented system prompts from Anthropic - Claude Fable 5.1, Opus 5.5, Claude Design, Claude Code. OpenAI - ChatGPT GPT-6-Astra, Codex. Google - Gemini 3.8 Flash, 3.1 Pro,…

Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Devin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini…

Explore related