Skip to content

@makaio/ai-adapters-anthropic-sdk

Anthropic SDK AI adapter for the Makaio framework. Provides direct access to Claude models via the @anthropic-ai/sdk streaming API.

import { createAnthropicSdkAdapter } from '@makaio/ai-adapters-anthropic-sdk';
import { MakaioBus } from '@makaio/bus-core';
import { AdapterSubjects } from '@makaio/contracts';
const adapter = await createAnthropicSdkAdapter();
const result = await MakaioBus.request(AdapterSubjects.startAgent, {
adapterId: adapter.adapterId,
role: 'lead',
initialMessage: 'Inspect this repository',
});

Three-layer design matching the framework adapter contract:

LayerClassResponsibility
DomainAnthropicSdkAdapterHandles adapter.* bus subjects, lifecycle
AgentAnthropicSdkAgentHandles agent.* subjects, routes connector events
ConnectorAnthropicSdkConnectorOwns the SDK streaming session, tool calling

The connector drives an AnthropicSdkSession and AnthropicSdkConnectorTurn pair for each user turn, streaming events into the framework event bus.

Provider configuration is resolved from the ProviderContext supplied on adapter.startAgent and the canonical provider definitions in provider.ts. The public package root does not expose a config factory for callers to use directly.

Runtime discovery loads @makaio/ai-adapters-anthropic-sdk/server, whose default export is a MakaioExtension package descriptor with an adapters[] contribution.

Tool approval is wired internally by the agent layer. The connector emits the scoped tool_approval RPC, and AnthropicSdkAgent forwards it to the global AgentSubjects.toolApprove subject with the full approval context (adapterId, adapterName, agentId, adapterSessionId, and sessionId).

Runtime capabilities declared by the adapter:

CapabilityMeaning
toolsTool/function calling support
streamingIncremental stream events
systemPrompt:overrideReplace/set the system prompt
systemPrompt:appendAppend to the adapter’s default system prompt

Conformance-test capabilities returned by createTestConfig():

FeatureSupported
supportsReplaceYes — streaming replace delivery mode
supportsInterruptYes — connector.interrupt()
supportsUsageMetricsYes — token usage tracked via stream events
import { createTestConfig } from '@makaio/ai-adapters-anthropic-sdk';
// Returns a ConformanceTestConfig ready for the shared adapter test suite
const config = await createTestConfig();
FilePurpose
src/adapter.tsAnthropicSdkAdapter and createAnthropicSdkAdapter factory
src/agent.tsAnthropicSdkAgent — event routing layer
src/connector.tsAnthropicSdkConnector — SDK streaming bridge
src/session.tsAnthropicSdkSession — session state for a single agent run
src/turn.tsAnthropicSdkConnectorTurn — turn state machine for one user/assistant exchange
src/stream-bridge.tsStreaming event parsing bridge
src/provider.tsProvider presets and model configuration
src/config.tsInternal adapter config factory
src/schemas.tsAnthropicSdkProviderConfigSchema and credential schema
src/tool-handling.tsTool approval bridging and tool format conversion
src/definition.tsInternal adapter definition consumed by the package descriptor
src/package.tsMakaioExtension package descriptor with adapters[] contribution
src/server.tsServer entrypoint that re-exports the package descriptor as default
src/namespaces/Bus namespace, subjects, and event schemas
src/types/Internal type definitions
src/utils/Utility functions (message history, error classification, etc.)