The Universal Agent Toolkit. One TypeScript API to connect to any Agent — detect it, read its sessions and token usage, follow its hooks, install into it, drive it over ACP — and to coordinate many Agents working side by side.
Think of it as lodash for cross-Agent tools: small typed functions, one entry per task, and the same call for every Agent. Built-in providers cover Claude Code, Codex, Cursor and more; any other Agent plugs in as a provider of your own, so your code does not change when a new Agent arrives.
Guides and the API reference, in English and Chinese: perfectpan.github.io/agent-kit.
| Package | Role | What it holds |
|---|---|---|
@rivus/agent-kit |
Connection: one Agent at a time | Agent detection, sessions and transcripts, token usage and cost (with a LiteLLM price snapshot), hook events, harness installation, ACP, redaction |
@rivus/agent-kit-collab |
Coordination: many Agents at once | Single-instance process locks, fenced leases, keyed scheduling lanes |
Both packages release together at one version. Status: 0.x; a minor release may contain breaking changes. This README
follows main, and the npm release can lag behind it until the next release; each package's CHANGELOG.md lists what
shipped.
npm install @rivus/agent-kit
npm install @rivus/agent-kit-collab # coordination primitives, optionalESM only, no side effects, Node.js 22.13 or later. Every entry except /node, /node/effect and /testing also
bundles for browsers: files, processes and the environment come from a Platform object the caller passes in. The
Effect entries (/acp, /harness, */effect, and collab's /lease and /lanes) need a single copy of effect
satisfying peerDependencies.effect (npm view @rivus/agent-kit peerDependencies.effect); the other entries do not
load it.
List the sessions of three Agents and read each one:
import { createNodePlatform } from "@rivus/agent-kit/node";
import { isSessionHead, listSessions } from "@rivus/agent-kit/sessions";
import { loadTranscript } from "@rivus/agent-kit/transcript";
const platform = createNodePlatform();
for await (const item of listSessions(platform, { agents: ["claude-code", "codex", "grok"] })) {
if (!isSessionHead(item)) continue; // a missing or unreadable root, or an unreadable file, with item.error
const result = await loadTranscript(platform, item.ref);
if (!result.ok) continue; // result.error._tag names the failure
const { events } = result.value;
const toolCalls = events.filter((event) => event.kind === "tool_call").length;
console.log(item.ref.agent, item.title ?? item.ref.path, `${events.length} events, ${toolCalls} tool calls`);
}The same call reads an Agent of your own once you pass its provider:
const myAgent = { id: "my-agent", sessions: mySessionAdapter };
listSessions(platform, { agents: ["my-agent"], providers: [myAgent] });Keep one instance of a worker running:
import { createNodePlatform } from "@rivus/agent-kit/node";
import { acquireProcessLock } from "@rivus/agent-kit-collab/process-lock";
const lock = await acquireProcessLock(createNodePlatform(), "/var/run/my-daemon/daemon.lock");
if (!lock.ok) {
console.error(`already running (pid ${lock.error.holder?.pid ?? "unknown"})`);
process.exit(1);
}
// ... run; the kernel releases the lock if the process dies, or call:
await lock.value.release();Hook events, harness installation, usage records, cost, Effect and ACP each have an example in the
@rivus/agent-kit reference; leases and lanes are in the
@rivus/agent-kit-collab reference.
| Agent | discovery | hooks | install | sessions | usage | acp |
|---|---|---|---|---|---|---|
Antigravity CLI (agy) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Amp (amp) |
✓ | ✓ | ✓ | — | — | — |
Auggie CLI (auggie) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Claude Code (claude-code) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Cline CLI (cline) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Codex (codex) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
GitHub Copilot CLI (copilot) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Cursor (cursor) |
✓ | ✓ | ✓ | — | — | ✓ |
DimCode (dim) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Factory Droid (droid) |
✓ | ✓ | ✓ | — | — | ✓ |
DeepSeek Harness (dsh) |
✓ | — | ◐ | ✓ | ✓ | ✓ |
Gemini CLI (gemini-cli) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Goose (goose) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Grok Build (grok) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Kilo CLI (kilo) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Kimi Code (kimi) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
opencode (opencode) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Pi (pi) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Qoder CLI (qoder) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Qwen Code (qwen-code) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
ZCode (zcode) |
✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
Every built-in provider also ships identity. ✓ supported · ◐ partial · — not supported:
- Cline CLI: native file hooks, shared skills, ACP and version-1 local session snapshots are supported. Usage preserves input, cache and cost; upstream omits reasoning counts needed for inclusive output totals, and imported-history accounting is unsupported; see the provider README.
- Auggie CLI: version-3
sessions-v2transcripts and persisted usage are supported. Fork accounting requires the parent file; subagent aggregates lack cache reads, model and cost. See the provider README for upstream limits. - Kilo CLI: local SQLite sessions and token usage, native plugin hooks, shared skills and
kilo acpare supported. See the Kilo provider README for verified storage generations and limitations. - Amp: hooks require the native plugin API (current CLI); sessions and usage have no verified local storage readers. No native ACP server is verified; the official
@ampcode/sdkexecution stream is not ACP. - Factory Droid (
droid): persisted transcript schemas and per-request usage/cache/deduplication semantics are unverified; sessions and usage remain unavailable. - Cursor: the Grok Build desktop app (Cursor's IDE, Agents Window) with its
~/.cursorhome and plugin hooks; session storage has no supported reader and usage storage no supported decoder. Its CLI (cursor-agent) is legacy and converges into the Grok Build CLI thatgrokmodels. - DeepSeek Harness (
dsh): no supported hook dialect;installsupports skills only (no command-hook strategies). - Goose (
goose): native Open Plugins hooks, shared skills, SQLite sessions and usage ledger, andgoose acp. The readers target the verified v1.61.1 schema; historical counters without ledger entries are not billed. See the provider README. - Qwen Code (
qwen-code): stable 0.29.1 ChatRecord transcripts and version-1 token ledger; private Managed session storage and 1.0 Preview are unsupported. Runtime directory overrides require explicithomes. Cache-write and raw usage provenance are unavailable; stored counters can include upstream defaults or estimates.
| You want to | Entry |
|---|---|
| Detect installed Agents and their login state | /discovery |
| List sessions and read transcripts | /sessions, /transcript |
| Scan token usage; price it | /transcript/usage, /cost, /cost/prices |
| Read a hook payload inside a hook process | /harness/events |
| Install and remove hooks and skills | /harness (Effect) |
| Drive an Agent over ACP | /acp (Effect) |
| Hide home paths and secrets before showing logs | /redact |
| Look up the built-in Agents and their services | /providers, /catalog |
| Provide files, processes and environment | /platform, /node, /platform/effect, /node/effect |
| Test your own adapter, hook dialect or probe recipe | /testing, /testing/effect |
| Keep one instance of a worker running | collab /process-lock |
| Give one worker a task, with a fencing token | collab /lease (Effect) |
| Run one turn per key under a concurrency cap | collab /lanes (Effect) |
Entries are @rivus/agent-kit/<entry>, and @rivus/agent-kit-collab/<entry> for collab. /cost, /cost/prices,
/redact, /harness/events and /transcript/usage import nothing outside the package, so a host that cannot install dependencies
can bundle them alone. The package references list each entry's main exports, where it runs and how it fails.
- agent-presence: the Agents running on a machine, and their token usage, in a Feishu signature preview.
- agent-task-loop: Agents taken through task execution, review, rework and pull-request handoff.
A pnpm workspace. Each bounded context is a private package under packages/; packages/agent-kit re-exports their
public names and bundles them into dist, and infra/architecture/boundaries.ts declares which package and layer may
import what.
pnpm install
pnpm run check # format, build, lint, knip, knip:production, typecheck, test, package checks
pnpm run knip # unused files, exports or dependencies fail CICONTRIBUTING.md: workflow, Change Design Gate and Plan rules, required checks.docs/architecture/conventions.md: how a context package is laid out.docs/development/adoption.md: migrating an application, verification and rollback.docs/development/release.md: releases.CONTEXT.md: glossary.
MIT. See LICENSE.