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

@chatroy/core

v0.2.0

Published

Roy — TypeScript LLM chat library core. Multi-provider, rolling compaction, multi-agent, plan mode.

Readme

@chatroy/core

Core package for Roy, a TypeScript LLM chat runtime with multi-provider streaming, tool calls, rolling context compaction, memory extraction, explicit plan approval, handoff context primitives, host-app run events, and cost tracking.

Current release: 0.2.0.

Install

pnpm add @chatroy/core

Install only the provider SDKs you use:

pnpm add openai
pnpm add @anthropic-ai/sdk
pnpm add @google/generative-ai

Quick Start

import { createChat } from '@chatroy/core'

const roy = createChat({
  agents: [
    {
      id: 'assistant',
      name: 'Assistant',
      provider: {
        type: 'openai',
        apiKey: process.env.OPENAI_API_KEY!,
      },
      model: 'gpt-4o-mini',
      systemPrompt: 'You are concise and helpful.',
    },
  ],
})

for await (const chunk of roy.send({ input: 'Say hello' })) {
  if (chunk.type === 'text') process.stdout.write(chunk.delta)
}

Included

  • OpenAI, Anthropic, Gemini, OpenRouter, and Ollama provider adapters.
  • Tool definition and tool-loop orchestration.
  • Rolling compaction with tool truncation, summaries, rollovers, and events.
  • Structured memory extraction through user-defined Zod schemas.
  • Handoff validation/context primitives; host apps own workflow loops.
  • Explicit plan approval primitives. Roy does not infer gates from assistant prose.
  • Stable run events for agent start/end, tool calls/results, handoffs, approval requests, cost updates, completion, and errors.
  • In-memory and file session stores.
  • Cost estimation helpers.

Compaction

Roy uses the current prompt budget to trigger compaction. The compactor can include pending user input in the preflight estimate without compacting that fresh message.

Compaction strategies return source messages through compactedMessages, so host apps can extract durable memory before detail is removed from active context.

Plan Mode

Plan mode is explicit. In plan mode, tools are disabled until the host requests a plan and the approval callback approves it.

roy.on('approval-requested', ({ plan }) => {
  showApprovalUi(plan)
})

await roy.requestPlan(sessionId)

Roy does not watch for [PLAN_READY] or any other text heuristic.

Run Events

Roy emits typed events for host supervision and UI state:

  • agent-start / agent-end
  • tool-call / tool-result
  • handoff
  • plan-ready / approval-requested / plan-approved / plan-rejected
  • cost-updated
  • done
  • error

Prefer these events over parsing assistant text when building logs, approval surfaces, or workflow state machines.

Handoffs

Roy exposes handoff validation and optional compact context events. It does not run a full durable multi-agent workflow; keep retries, pause/resume/cancel, durable run state, event logs, and UI supervision in your host application.

Published Artifacts

This package intentionally publishes dist, src, declaration maps, and JavaScript source maps.

License

MIT