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

@gaunt-sloth/api

v0.0.3

Published

API server for Gaunt Sloth

Readme

@gaunt-sloth/api

API server and agent integration layer for Gaunt Sloth.

Contents

  • AG-UI server module (apiAgUiModule) — starts an HTTP server implementing the AG-UI protocol
  • Interactive session module (interactiveSessionModule)
  • A2A client wrapper (A2AClientWrapper) and agent tool (A2AAgentTool) — Agent-to-Agent protocol support
  • MCP utilities (mcpUtils) — Model Context Protocol server connection helpers
  • OAuth client provider (OAuthClientProviderImpl)
  • show_a2ui_surface tool
  • Resolvers (createResolvers) — wires built-in tools, MCP servers, and A2A agents into the tool registry

CLI

The package ships a standalone binary gaunt-sloth-api that starts an AG-UI server.

Dependencies

  • @gaunt-sloth/core
  • @gaunt-sloth/tools
  • express
  • @ag-ui/core, @ag-ui/encoder
  • @langchain/mcp-adapters, @modelcontextprotocol/sdk
  • @a2a-js/sdk

Exports

import { apiAgUiModule } from '@gaunt-sloth/api/apiAgUiModule.js';
import { interactiveSessionModule } from '@gaunt-sloth/api/interactiveSessionModule.js';
import { A2AClientWrapper, A2AAgentTool } from '@gaunt-sloth/api/a2a.js';
import { OAuthClientProviderImpl } from '@gaunt-sloth/api/OAuthClientProviderImpl.js';
import { mcpUtils } from '@gaunt-sloth/api/mcpUtils.js';
import { createResolvers } from '@gaunt-sloth/api/resolvers.js';

Frontend-fulfilled tools (AG-UI)

Tools whose execution belongs in the client (e.g. capturing a webcam frame, prompting the user, querying the browser DOM) are declared in RunAgentInput.tools and registered server-side with metadata.client === true. The agent then suspends instead of executing them, the client fulfills the call, and the run is resumed.

Server-side declaration

Add the tool to your GthConfig.tools and tag it with metadata: { client: true }:

import { tool } from '@langchain/core/tools';
import { z } from 'zod';

export const captureImageTool = tool(
  async () => 'client-fulfilled',
  {
    name: 'capture_image',
    description: 'Capture a frame from the client webcam.',
    schema: z.object({}),
  }
);
(captureImageTool as unknown as { metadata: Record<string, unknown> }).metadata = {
  client: true,
};

GthLangChainAgent wraps any tool with metadata.client === true so its body calls interrupt({ name }) from @langchain/langgraph. The graph suspends; streamWithEvents catches the resulting GraphInterrupt and ends the stream cleanly. The AG-UI run finishes with TOOL_CALL_START/ARGS/END but no TOOL_CALL_RESULT. State persists in the configured checkpointer keyed by thread_id.

Client-side resume

To resume, the client posts a new run on the same thread carrying the tool result via forwardedProps:

forwardedProps: {
  command: {
    resume: '<string returned by the client tool>',
    interruptEvent: { toolCallId, runId }
  }
}

apiAgUiModule.ts detects forwardedProps.command.resume and routes to agent.streamWithEventsResume(resumeValue, runConfig), which calls the underlying graph with new Command({ resume }). The interrupt returns the resume value, the wrapped tool returns it (stringified if non-string), and a ToolMessage is appended to graph state.

Returning binary content

ToolMessage.content is string only across AG-UI and most LangChain providers. To pass an image back, serialize a JSON envelope (e.g. { mimeType, data } for base64) as the resume value, then add a beforeModel middleware that detects the ToolMessage for your tool and appends a HumanMessage with multimodal content blocks before the next model call. The binary-content-injection middleware (in @gaunt-sloth/tools) is a working reference for the same pattern keyed on gth_read_binary with a different envelope format.

Body limit

The AG-UI server uses express.json({ limit: '5mb' }) to accommodate base64 envelopes that round-trip through forwardedProps.

Related packages