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

@kenkaiiii/gg-agent

v4.2.35

Published

Agentic loop system with tool execution for LLMs

Readme

@kenkaiiii/gg-agent

Give an LLM tools. It calls them. Results go back in. It loops until it's done. That's it.

Built on top of @kenkaiiii/gg-ai. Part of the GG Framework monorepo.


Install

npm i @kenkaiiii/gg-agent

How it works

Create an Agent with a provider, model, and tools. Call agent.prompt() to start a conversation.

  • for await gives you streaming events (text_delta, tool_call_start, tool_call_end, agent_done, etc.)
  • await gives you the final result (message, totalTurns, totalUsage)

Same dual-nature pattern as @kenkaiiii/gg-ai. The Agent class maintains conversation history — each prompt() call continues the conversation.

For full control, use agentLoop() directly — a pure async generator that takes a messages array and options.

Tools

Define tools with a name, description, Zod schema for parameters, and an execute function. The execute function receives typed args and a ToolContext with signal, toolCallId, and onUpdate.

Return a string, or a { content, details } object for structured results. If execute throws, the error becomes a tool result (not a crash). The agent sees the error and can retry or adjust.

Safety

  • maxTurns (default: 100) prevents runaway loops
  • AbortSignal support for cancellation
  • Zod validation on tool args
  • maxContinuations (default: 5) caps consecutive pause_turn continuations

Events

| Event | Description | |---|---| | text_delta | Incremental text output | | thinking_delta | Extended thinking output | | tool_call_start | Tool invocation started (name, args) | | tool_call_update | Progress update from a running tool | | tool_call_end | Tool finished (result, duration, isError) | | server_tool_call | Server-side tool invocation | | server_tool_result | Server-side tool result | | turn_end | One LLM call completed (stop reason, usage) | | agent_done | All turns finished (total turns, total usage) | | error | Fatal error |


Options

| Option | Type | Description | |---|---|---| | provider | "anthropic" \| "openai" \| "glm" \| "moonshot" | Required | | model | string | Required | | system | string | System prompt | | tools | AgentTool[] | Tools with Zod schemas and execute functions | | serverTools | ServerToolDefinition[] | Server-side tool definitions | | maxTurns | number | Max LLM calls (default: 100) | | maxTokens | number | Max output tokens per turn | | temperature | number | Sampling temperature | | thinking | "low" \| "medium" \| "high" \| "max" | Extended thinking | | apiKey | string | Provider API key | | baseUrl | string | Custom endpoint | | signal | AbortSignal | Cancellation | | cacheRetention | "none" \| "short" \| "long" | Prompt cache preference | | compaction | boolean | Server-side compaction (Anthropic only) | | maxContinuations | number | Max pause_turn continuations (default: 5) | | transformContext | (messages) => messages | Transform messages before each LLM call |

transformContext is called before each LLM call. Use it for compaction, truncation, or injecting dynamic context.


License

MIT