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

@anureo/adapter-codex

v0.3.16

Published

Anureo SDK adapter for the Codex CLI app-server protocol over stdio JSONL

Readme

@anureo/adapter-codex

Adapter connecting the Anureo SDK to the Codex CLI's app-server mode over stdio JSONL. It spawns the binary, speaks Codex's native protocol, and maps requests, events, items, and usage onto the unified AHP session model.

Part of the Anureo SDK workspace. Install with npm install @anureo/adapter-codex.

Usage

This shows the revised workspace API, not the published 0.2.0 API. The lifecycle revision updates AHP v1 and package root entries in place. The root implementation and tests use the revised lifecycle; parallel versioned entries have been removed. Root migration and local validation are complete, including passing local conformance and clean-install checks.

import { createClient } from '@anureo/sdk'
import { createCodexAdapter } from '@anureo/adapter-codex'

const client = await createClient({
  adapter: createCodexAdapter({
    command: 'codex',        // required; args default to ['app-server']
    cwd: '/workspace',
    env: { OPENAI_API_KEY: '...' },
  }),
  identity: { adapterId: 'codex', runtimeConfigId: 'local' },
})
try {
  const session = await client.sessions.create({ cwd: '/workspace' })
  const turn = await session.submit({ input: 'Summarize this repository.' })
  console.log(await turn.result())
} finally {
  await client.dispose()
}

The adapter probes the binary's version during initialization (or trusts an explicit options.version from a host probe) and derives its capabilities from a native behavior profile.

Version profiles

Codex's native protocol changes between releases. The adapter selects the newest profile whose minimum version is no higher than the reported version. Below 0.148.0, nothing is known about the native schema: only the safe baseline capability set is published.

| Profile since | Native methods used | |---|---| | 0.148.0 | thread/read turns, thread/rollback revert, history from turns, per-turn settings | | 0.164.0 | thread/turns/list, thread/revert(beforeTurnId), paged thread/items/list, live thread/settings/update |

  • Versions 0.148.0 and 0.164.0 are verified against the pinned native schemas in protocol/ — bun run protocol:check (also wired as the workspace-level protocol:check) validates their hashes and provenance on every run.
  • Any other version is reported as unverified; optional native methods that the runtime rejects as method-not-found are closed at call time, not guessed from the version number.

Use resolveCodexProfile(version) and codexCapabilities(version) to inspect the mapping without spawning a process.

Exports

| Entry | Contents | |---|---| | @anureo/adapter-codex | createCodexAdapter, CodexNativeAdapter (the factory result implementation), CodexAdapterOptions, CodexProfile, resolveCodexProfile, codexCapabilities, createCodexCatalogSession, CodexModel, CodexThreadSummary, CodexThreadListParams, CodexThreadPage, CodexJsonlClient, CodexRpcError, mapItems, mapUsage | | @anureo/adapter-codex/jsonl | The low-level JSONL client over the child process | | @anureo/adapter-codex/mapping | Native record → AHP item/usage mapping helpers | | @anureo/adapter-codex/catalog | Model catalog session (createCodexCatalogSession) |

CodexModel preserves the native ID and display name, optional picker description, inputModalities, default/hidden flags, supported efforts with descriptions, defaultEffort, and serviceTiers. These describe discovery results, not account prices, measured quality, or the effective settings of a running thread. Applications may use them to build model selection guidance without inferring capability from model names.

CodexAdapterOptions extends the JSONL options (timeoutMs, maxFrameBytes, maxPending, maxServerRequests) with command, args, cwd, env, version, processFactory (for injected transports and tests), diagnostic, and maxHistoryItems.

Code structure

| Path | Responsibility | |---|---| | src/index.ts | Assembles the package root exports. The root also re-exports CodexNativeAdapter, the implementation returned by createCodexAdapter(). | | src/adapter.ts, src/options.ts | Own adapter initialization, native client ownership and host launch configuration. | | src/session.ts | Dispatches session requests and routes native notifications into SDK events. | | src/jsonl.ts | Implements the ./jsonl entry: request correlation, server requests and stdio connection cleanup. | | src/mapping.ts, src/usage.ts, src/file-changes.ts | Implement item, usage and file-change projections; ./mapping exposes the mapping helpers. | | src/catalog.ts, src/models.ts, src/account.ts | Own the ./catalog query lifecycle and model/account projections. | | src/profile.ts, src/version.ts, src/settings.ts | Select native behavior profiles, probe executable versions and translate session settings. | | protocol/, scripts/protocol-check.ts | Retain and verify pinned native schemas and their provenance. |

Configuration options

The adapter exposes session-scoped config options through AHP: permissionMode (read-only / agent / agent-full-access, mapped onto Codex approval policies and sandboxes), model, effort, summary, approvalPolicy, and fastMode (mapped to Codex's priority service tier). Turn-level overrides are supported for model, effort, summary, approval/sandbox policy, and service tier.

Subagent protocol

Codex spawns subagent threads from the model through collab tools (there is no client-side spawn method). The adapter surfaces them on three planes, gated by the subagents capability (events: 'nested', plus threadDiscovery and tree flags per profile):

  • Nested items. collabAgentToolCall items expand into one nested SubagentItem per receiver thread (state, task, parentItemId), with raw evidence such as tool, model, reasoningEffort, senderThreadId and per-agent errorMessage/resultMessage under item.extensions.native. subAgentActivity lifecycle items (started/interacted/interrupted/completed, carrying agentThreadId/agentPath) project into the same vocabulary. Documented singular legacy wire words (receiverThreadId, newThreadId, agentStatus) are tolerated as a fallback.
  • Discovery. thread/started notifications for spawned children surface as a session notice event with code SUBAGENT_THREAD_STARTED; its extensions carry the child's nativeThreadId, parentThreadId, agentNickname, agentRole and forkedFromId. Spawn children that declare canAcceptDirectInput: false (parent-owned Multi-Agent V2) degrade the advertised input capability to no delivery — direct input is rejected natively for them, and the mapped error is SUBAGENT_DIRECT_INPUT_REJECTED (definite, non-retryable). turn/interrupt remains available for such threads.
  • Thread tree. adapter.listThreads(params) pages stored threads with optional relation filters (parentThreadId for direct children, ancestorThreadId for any-depth descendants — mutually exclusive), sourceKinds, cwd and cursor pagination, returning CodexThreadSummary entries (parentThreadId/agentNickname/agentRole where native supplies them, enriched from locally observed spawns when the page omits them). Review and guardian threads never participate in relation filters (native behavior). Method-not-found downgrades every registered session's subagents.tree capability.

Session metadata exposes the same linkage on opened and resumed threads via snapshot.metadata.extensions (parentThreadId, agentNickname, agentRole, forkedFromId, nativeSource). Resumed child threads keep Codex's paginated-history semantics: their history contains only their own turns.

Late native completions (subAgentActivity completed arriving after the spawning turn completed) keep their original turn attribution; the core admits them as late completions of tracked items instead of rejecting the event stream.

Native hook events

Synchronous Codex hook runs with an active turn appear as hook items. Session-level runs appear as NATIVE_HOOK_STARTED and NATIVE_HOOK_COMPLETED notices. See Codex App Server for native notification coverage and Codex Hooks for configuration and trust management.

Code structure

| Source | Responsibility | | --- | --- | | src/index.ts, src/adapter.ts | Assemble the package exports and manage native App Server sessions. | | src/session.ts, src/mapping.ts | Dispatch session requests and project native turns, items, and hook notifications. | | src/jsonl.ts, src/profile.ts | Run the JSON-RPC transport and resolve version-specific native capabilities. | | src/catalog.ts, src/threads.ts | Discover models and list native threads. |

Development

cd packages/adapter/codex
bun run typecheck
bun test tests
bun run protocol:check   # verify pinned native schema hashes and mappings
bun run smoke            # optional live smoke against a local binary

Documentation

AHP v1 lifecycle revision

Use await turn.steer({ input }) before await turn.result() for exact guidance. The adapter maps the target to native expectedTurnId, preserving native target validation; a stale target rejects. An input receipt alone does not prove that a new execution has started or completed.

See the design and implementation plan. See the complete example.