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

@makaio/adapter-claude-agent-sdk

v1.0.0-dev-1779051654000

Published

Claude Agent SDK adapter using the three-layer architecture.

Downloads

62

Readme

@makaio/adapter-claude-agent-sdk

Claude Agent SDK adapter using the three-layer architecture.

Quick Start

import { createClaudeAdapter, ClaudeCodeAdapter } from '@makaio/adapter-claude-agent-sdk';
import { AdapterSubjects } from '@makaio/contracts';
import { MakaioBus } from '@makaio/bus-core';

// Using the factory (recommended)
const adapter = await createClaudeAdapter();

// Or instantiate directly
const directAdapter = new ClaudeCodeAdapter();
await directAdapter.init();

const result = await MakaioBus.request(AdapterSubjects.startAgent, {
  adapterId: adapter.adapterId,
  role: 'lead',
  initialMessage: 'Build a todo app',
  model: 'sonnet',
});

Architecture

The adapter follows a three-layer architecture:

ClaudeCodeAdapter extends AIAdapter
    -> creates via agentFactory
ClaudeCodeAgent extends AIAgent
    -> creates via connectorFactory
ClaudeSdkConnector extends AIAgentConnector

Layer Responsibilities

| Layer | Class | Responsibility | |-------|-------|----------------| | Adapter | ClaudeCodeAdapter | Lifecycle, agent factory, model listing | | Agent | ClaudeCodeAgent | Event wiring, tool approval routing, usage tracking | | Connector | ClaudeSdkConnector | SDK query lifecycle, session management, message handling |

Key Concepts

Event Flow

  1. ClaudeSdkConnector emits SDK events to scoped bus (adapter:claude-code.*)
  2. ClaudeCodeAgent processes and routes to global bus (agent.*)
  3. Downstream consumers subscribe to normalized agent.* subjects

Namespace Subjects

The adapter registers adapter:claude-code namespace with typed subjects:

| Subject | Description | |---------|-------------| | sdk.event | Catch-all for raw SDK events | | system | System messages (init, compact_boundary) | | assistant | Assistant content blocks | | user | User messages and tool results | | result | Query completion (success/error) | | stream_event | Streaming deltas | | turn.* | Turn lifecycle events | | can_use_tool | Tool approval RPC |

Exports

Classes

| Export | Description | |--------|-------------| | ClaudeCodeAdapter | Main adapter class | | ClaudeCodeAgent | Agent layer for event routing | | ClaudeSdkConnector | SDK connector layer |

Functions

| Export | Description | |--------|-------------| | createClaudeAdapter | Factory that creates and initializes adapter | | createTestConfig | Conformance test configuration | | registerToolApprovalHandler | Set up tool approval routing | | requestToolApproval | Request approval for a tool call |

Namespace

| Export | Description | |--------|-------------| | ClaudeCodeConnectorNamespace | Full namespace definition | | ClaudeCodeConnectorSubjects | Subject definitions for typed subscriptions | | ClaudeCodeAdapterName | Adapter identifier constant |

Types

| Export | Description | |--------|-------------| | ClaudeCodeAdapterConfig | Adapter configuration options | | ClaudeAgentConfig | Agent configuration | | ClaudeCodeProviderConfig | Provider-specific settings | | ClaudeCodeConnectorBus | Typed scoped bus | | ClaudePermissionResult | Tool approval permission result | | ToolApprovalContext | Tool approval context type |

Session/Turn

| Export | Description | |--------|-------------| | ClaudeConnectorTurn | Turn state machine | | ClaudeTurnState | Turn state type | | UserMessageQueue | Internal connector queue from adapter core |

Schemas

| Export | Description | |--------|-------------| | ClaudeCodeProviderConfigSchema | Zod schema for provider config | | CONTENT_BLOCK_HANDLERS | Discriminated handlers for content blocks |

Adapter Definition

Runtime registration is contributed by @makaio/adapter-claude-agent-sdk/server. That entrypoint default-exports the claudeAgentSdkPackage MakaioExtension descriptor, whose adapters[] entry wraps the internal definition from src/definition.ts.

Supported Models

| Name | Friendly Name | Reasoning Levels | |------|---------------|-----------------| | sonnet | Sonnet 4.5 | none, low, medium, high, extra-high | | haiku | Haiku 4.5 | none, low, medium, high, extra-high | | opus | Opus 4.6 | none, low, medium, high, extra-high |

Capabilities

  • tools - Tool use support
  • vision - Image/vision input
  • chat:inTurnMessages - Multi-turn conversation
  • structuredOutput - Native structured output support through the Agent SDK
  • systemPrompt:override - Replace/set the system prompt

File Structure

src/
├── index.ts                       # Package exports
├── adapter.ts                     # ClaudeCodeAdapter
├── agent.ts                       # ClaudeCodeAgent
├── connector.ts                   # ClaudeSdkConnector
├── session.ts                     # Session abstraction
├── turn.ts                        # Turn state machine
├── config.ts                      # Configuration resolution
├── constants.ts                   # Adapter name constant
├── definition.ts                  # Internal adapter definition
├── package.ts                     # MakaioExtension package descriptor
├── provider.ts                    # Provider registration
├── provider.fetcher.ts            # Model fetcher
├── server.ts                      # Server entrypoint exporting the package descriptor
├── schemas.ts                     # Provider config schemas
├── mcp-integration.ts             # MCP tool integration
├── account-observation.ts         # Account observation
├── account-observation-requester.ts
├── on-turn-complete.ts            # Post-turn hooks
├── namespace/
│   └── index.ts                   # Namespace + subjects
├── types/
│   └── index.ts                   # Internal types
├── utils/                         # Helper functions
└── __tests__/                     # Unit tests + fixtures