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

@pdhaku0/gemini-cli-agent-sdk

v0.1.4

Published

A high-level SDK for building AI Agent chat interfaces using Gemini ACP

Readme

Agent Chat SDK

A TypeScript SDK for building chat UIs on top of the Gemini CLI Agent via ACP (Agent Chat Protocol). It provides a browser-safe client, a bridge for the CLI, and a UI-friendly event model.

Features

  • WebSocket transport with reconnect + ACP framing
  • Client event model tuned for UI rendering
  • Tool call parsing (permissions, inputs, diff rendering)
  • Replay support for late joiners / infinite scroll
  • Bridge process to run Gemini CLI via stdio
  • Optional store (AgentChatStore) for React/GUI state

Installation

npm install @pdhaku0/gemini-cli-agent-sdk

Requirements

  • Node.js 18+ (bridge and any server usage)
  • Gemini CLI with --experimental-acp
  • Browser client or Node with ws

Quick Start

1) Start the bridge

npm run start:bridge

By default this enables SYS tag capture and emits bridge/structured_event. You can control it with:

SYS_TAG_MODE=raw   npm run start:bridge   # disable capture
SYS_TAG_MODE=both  npm run start:bridge   # keep tags + emit events

2) Connect a client

import { AgentChatClient } from '@pdhaku0/gemini-cli-agent-sdk/client';

const client = new AgentChatClient({
  url: 'ws://localhost:4444',
  cwd: '/path/to/project',
  replay: { limit: 15 },
});

client.on('text_delta', ({ delta }) => process.stdout.write(delta));
client.on('tool_update', ({ toolCall }) => {
  console.log(`[tool] ${toolCall.name} ${toolCall.status}`);
});

await client.connect();
await client.sendMessage('List files in the current directory.');

3) Replay older turns (infinite scroll)

const older = await AgentChatClient.fetchReplay('ws://localhost:4444', {
  before: oldestTimestampMs,
  limit: 10,
});
client.prependMessages(older);

4) Optional SYS tags (structured capture)

Use SYS tags in assistant output and capture them on the bridge:

import { GeminiBridge } from '@pdhaku0/gemini-cli-agent-sdk/server';
import { createSysTagTransform } from '@pdhaku0/gemini-cli-agent-sdk/extras';

const bridge = new GeminiBridge({
  outgoingTransform: createSysTagTransform({ mode: 'event' }),
});
bridge.start();

5) Hidden initial prompt

await client.sendMessage('System priming...', { hidden: 'turn' });

Examples

  • examples/next-app — full Next.js App Router UI (auth, approvals, replay, session persistence)
  • examples/cli — minimal Node CLI (streaming + tool approvals)

Examples are kept in the repo but excluded from npm to keep the package lean.

Documentation

  • docs/USAGE.md — full end-to-end guide
  • docs/API.md — API surface
  • docs/EVENTS.md — event model + rendering rules
  • docs/INTEGRATION.md — Next/Node integration patterns
  • docs/TROUBLESHOOTING.md — common pitfalls

Development

  • Build: npm run build
  • Bridge: npm run start:bridge
  • CLI example: node examples/cli/index.js

Notes

  • The bridge keeps in-memory replay only. Restarting the bridge clears replay history.
  • Reusing sessions across reloads is supported by passing a saved sessionId to the client.
  • Replay limit is turns, not messages.