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

@agentex/adapters

v0.0.2

Published

Programmatic execution of AI coding agents (Claude Code, Codex, OpenClaw)

Readme

@agentex/adapters

Programmatic execution of AI coding agents. Spawn and manage Claude Code, Codex, OpenClaw, or any CLI-based agent as a child process with streaming output, session resume, and a unified interface.

Install

npm install @agentex/adapters

Quick Start

import { getAdapter } from "@agentex/adapters";

const claude = getAdapter("claude");

const result = await claude.execute({
  runId: "my-task-1",
  prompt: "Add error handling to server.ts",
  cwd: "/path/to/project",
  config: {
    skipPermissions: true,
    maxTurns: 5,
    timeoutSec: 120,
  },
  onEvent: (event) => {
    if (event.type === "assistant") process.stdout.write(event.text);
    if (event.type === "tool_call") console.log(`Tool: ${event.name}`);
  },
});

console.log(result.exitCode); // 0
console.log(result.summary);  // "Added try/catch to all route handlers..."
console.log(result.costUsd);  // 0.0342

Built-in Adapters

| Adapter | CLI | Description | | ---------- | ---------------- | ----------------------------------- | | claude | claude | Claude Code (Anthropic) | | codex | codex | Codex CLI (OpenAI) | | openclaw | openclaw | OpenClaw agent | | process | any executable | Generic process executor |

Custom Adapters

import { registerAdapter } from "@agentex/adapters";
import type { AdapterModule } from "@agentex/adapters";

const myAdapter: AdapterModule = {
  type: "my-agent",
  async execute(ctx) {
    // Spawn your agent, stream events via ctx.onEvent, return result
    return { exitCode: 0, summary: "Done" };
  },
};

registerAdapter(myAdapter);

API

getAdapter(type: string): AdapterModule

Returns a registered adapter by name. Throws if not found.

listAdapters(): string[]

Returns all registered adapter type names.

registerAdapter(adapter: AdapterModule): void

Registers a custom adapter, making it available via getAdapter().

renderTemplate(template: string, context: Record<string, string>): string

Renders a template string with {{variable}} interpolation.

redactEnvForLogs(env: Record<string, string>): Record<string, string>

Returns a copy of env vars with sensitive values redacted for safe logging.

Execution Context

interface ExecutionContext {
  runId: string;
  prompt: string;
  cwd: string;
  config?: AdapterConfig;
  onEvent?: (event: StreamEvent) => void;
  sessionCodec?: SessionCodec;
  signal?: AbortSignal;
}

Execution Result

interface ExecutionResult {
  exitCode: number | null;
  summary: string | null;
  costUsd: number | null;
  model: string | null;
  errorMessage: string | null;
  durationMs?: number;
  sessionParams?: Record<string, unknown>;
  clearSession?: boolean;
}

Stream Events

Events emitted during execution via onEvent:

  • assistant — Text output from the agent (event.text)
  • tool_call — Agent invoked a tool (event.name, event.input)
  • tool_result — Tool returned a result (event.output)
  • result — Final result text (event.text)
  • system — System info like session ID and model (event.sessionId, event.model)
  • error — Error during execution (event.message)

Requirements

  • Node.js >= 18
  • The CLI for each adapter must be installed and on $PATH (e.g., claude for the Claude adapter)

License

MIT