@harness-one/anthropic
v0.1.1
Published
Anthropic SDK adapter for harness-one
Maintainers
Readme
@harness-one/anthropic
Anthropic Messages API adapter for the harness-one AgentAdapter interface. Supports chat, streaming, and tool_use.
Install
pnpm add @harness-one/anthropic @anthropic-ai/sdkPeer Dependencies
@anthropic-ai/sdk>= 0.30.0harness-one(workspace)
Quick Start
import Anthropic from '@anthropic-ai/sdk';
import { createAnthropicAdapter } from '@harness-one/anthropic';
import { createAgentLoop } from 'harness-one';
const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
const adapter = createAnthropicAdapter({
client,
model: 'claude-sonnet-4-20250514',
});
const loop = createAgentLoop({ adapter });
for await (const ev of loop.run([
{ role: 'user', content: 'Write a haiku about TypeScript.' },
])) {
if (ev.type === 'text_delta') process.stdout.write(ev.text);
if (ev.type === 'done') break;
}The adapter:
- Maps harness-one
Messageto Anthropic content blocks (text +tool_use+tool_result). - Forwards
ChatParams.signalso the loop'sAbortSignalcancels in-flight requests. - Surfaces
cache_read_input_tokens/cache_creation_input_tokensasTokenUsage.cacheReadTokens/cacheWriteTokens. - Accepts an optional
logger(Pick<Logger, 'warn' | 'error'>) for non-fatal warnings.
See the main repository README.
