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

dumbagent

v0.0.1

Published

Fake API server for testing tools that use coding agent CLIs

Readme

dumbagent

Fake API server for testing tools that use coding agent CLIs (Claude Code, OpenAI Codex, opencode, Pi). Intercepts LLM requests, gives you deterministic instant responses.

Why

You built a tool that spawns claude or codex as a subprocess. You want to test it without hitting real APIs, spending money, waiting seconds, or getting nondeterministic output.

Install

npm install dumbagent

Usage

Directly

npx dumbagent codex
npx dumbagent opencode
npx dumbagent claude
npx dumbagent pi

By default the wrapped agent talks to a local fake API that returns the bundled sarcastic responder preset.

Set DUMBAGENT_PRESET=eliza to use the bundled ELIZA responder instead.

DUMBAGENT_PRESET=eliza npx dumbagent claude

The default CLI also recognizes tool:["readFile","<path>"] and replies with the wrapped agent's read-file tool call shape.

In tests

import {createDumbAgent, parseRequest} from 'dumbagent'

const api = await createDumbAgent({
  async fetch(request) {
    const parsed = await parseRequest(request)
    if (parsed.lastMessage.match(/review.*pr/i)) {
      return parsed.respond.text('LGTM, no issues found.')
    }
    return parsed.respond.text('Done.')
  },
})

// spawn your tool, which internally runs `claude -p "review this PR"`
const result = await myTool.reviewPR({
  command: `node my-cli.js --agent-command="${api.spawnCommand('claude')}"`,
})

expect(result.summary).toContain('LGTM')

await api[Symbol.asyncDispose]()

As a CLI wrapper

// fake-claude.ts
import {createDumbAgent, parseRequest} from 'dumbagent'

const api = await createDumbAgent({
  async fetch(request) {
    const parsed = await parseRequest(request)
    if (parsed.lastMessage.match(/one plus two/)) {
      return parsed.respond.text('three')
    }
    return Response.json({error: 'no match'}, {status: 400})
  },
})

api.createCli().run() // reads agent name from argv
node fake-claude.ts claude      # opens claude TUI pointed at your fake server
node fake-claude.ts opencode    # same for opencode
node fake-claude.ts codex       # same for codex
node fake-claude.ts pi          # same for pi

Supported agents

| Agent | Protocol | Redirect mechanism | |-------|----------|--------------------| | codex | OpenAI Responses API (WebSocket) | config.toml with openai_base_url | | opencode | OpenAI Chat Completions | Custom provider via OPENCODE_CONFIG_CONTENT | | claude | Anthropic Messages API | ANTHROPIC_BASE_URL + --bare | | pi | OpenAI Chat Completions | Isolated models.json via PI_CODING_AGENT_DIR |

API

createDumbAgent(options)

Starts an HTTP (+ WebSocket) server on a random port.

const api = await createDumbAgent({
  port: 8080, // optional, default: random
  fetch(request) { // standard Request -> Response
    return new Response('hello')
  },
})

Returns DumbAgent (implements AsyncDisposable):

  • api.port - server port
  • api.spawn(agent, args?, options?) - spawn agent CLI as child process
  • api.createCli() - returns {run()}, reads agent name from process.argv
  • api.getSpawnArgs(agent) - raw {command, args, env, spawnOptions} for manual spawning

parseRequest(request)

Detects protocol from URL path, parses body.

const parsed = await parseRequest(request)

parsed.lastMessage              // last user message, plain string
parsed.respond.text('hello')    // Response in the right format for the detected protocol

parsed.openai?.lastMessage      // non-null for /v1/chat/completions
parsed.anthropic?.lastMessage   // non-null for /v1/messages
parsed.codex?.lastMessage       // non-null for /v1/responses

parsed.body                     // raw parsed JSON

responses

For explicit protocol control:

import {responses} from 'dumbagent'

responses.openai.text('hello')     // OpenAI chat completion Response
responses.anthropic.text('hello')  // Anthropic message Response
responses.codex.text('hello')      // OpenAI responses API Response

JSON responses are auto-converted to SSE/streaming when the client requests it.