/** * AnthropicMessagesAdapter — governed Anthropic Messages binding. * * The concrete provider binding for {@link ../lib/model-gateway!GovernedModelGateway}. * It maps the Anthropic Messages API (refusals, `output_config.effort`, * fallback-credit redemption) to the gateway's normalized shapes, then exposes * one governed `executeAgent` that absorbs the refusal → fallback → billing * chain behind the standard adapter interface. * * Dependency-free (BYOC): you inject an `AnthropicMessagesClient`; the adapter * never imports the Anthropic SDK. Build and test it against Claude Opus 4.8, * which is also Claude Fable 5's fallback target. * * @module AnthropicMessagesAdapter * @version 1.0.0 */ import type { AgentPayload, AgentContext, AgentResult, AdapterCapabilities } from '../types/agent-adapter'; import { BaseAdapter } from './base-adapter'; import { type ModelCaller, type ModelResponse, type EffortLevel, type BudgetSink, type AuditSink, type RefusalTelemetrySink, type ThinkingSink, type EffortSink } from '../lib/model-gateway'; /** Raw Anthropic Messages response (the subset this adapter reads). */ export interface AnthropicRawResponse { id?: string; model: string; content: Array<{ type: string; text?: string; thinking?: string; signature?: string; [k: string]: unknown; }>; stop_reason: string | null; stop_details?: { type?: string; category?: string | null; explanation?: string; fallback_credit_token?: string | null; fallback_has_prefill_claim?: boolean | null; recommended_model?: string | null; } | null; usage?: { input_tokens?: number; output_tokens?: number; cache_read_input_tokens?: number; cache_creation_input_tokens?: number; }; } /** Bring-your-own Anthropic Messages client (e.g. `client.beta.messages`). */ export interface AnthropicMessagesApiClient { create(params: { model: string; max_tokens: number; system?: string; messages: Array<{ role: string; content: unknown; }>; tools?: Array>; output_config?: { effort?: string; }; fallback_credit_token?: string; betas?: string[]; }): Promise; } /** Per-agent configuration for {@link AnthropicMessagesAdapter.registerModelAgent}. */ export interface AnthropicMessagesAgentConfig { /** The injected Anthropic Messages client. */ client: AnthropicMessagesApiClient; /** Primary model (default: `claude-fable-5`). */ model?: string; /** Ordered fallback models (default: `['claude-opus-4-8']`). */ fallbackModels?: string[]; /** System prompt. */ systemPrompt?: string; /** Max tokens per call (default: 1024). */ maxTokens?: number; /** Default effort level. */ effort?: EffortLevel; /** Cross-model budget. */ budget?: BudgetSink; /** Audit destination. */ audit?: AuditSink; /** Refusal/fallback telemetry. */ telemetry?: RefusalTelemetrySink; /** Thinking-block lifecycle manager. */ thinking?: ThinkingSink; /** Effort governance policy. */ effortPolicy?: EffortSink; } /** * Map a raw Anthropic response to the gateway's normalized {@link ModelResponse}. * * @param raw The native response. * @param requestedModel The model that was requested (fallback when `raw.model` is absent). */ export declare function normalizeAnthropicResponse(raw: AnthropicRawResponse, requestedModel: string): ModelResponse; /** * Build a normalized {@link ModelCaller} from an Anthropic Messages client. * * Uses **client-side** fallback (the gateway drives the chain), so it never * sets the server-side `fallbacks` parameter. When a fallback-credit token is * present it is forwarded with the `fallback-credit-2026-06-01` beta header so * the retry is repriced as a cache read. * * @param client The injected Anthropic Messages client. * @returns A `ModelCaller` the gateway can drive. */ export declare function createAnthropicCaller(client: AnthropicMessagesApiClient): ModelCaller; /** * Governed Anthropic Messages adapter. * * Each registered agent runs through its own {@link GovernedModelGateway}, so a * single `executeAgent` call transparently handles refusals, cross-model * fallback, fallback-credit billing, and thinking-block handoff. * * @example * ```typescript * const adapter = new AnthropicMessagesAdapter(); * await adapter.initialize({}); * adapter.registerModelAgent('analyst', { * client, // your Anthropic client * model: 'claude-fable-5', * fallbackModels: ['claude-opus-4-8'], * budget, audit, telemetry, * }); * const result = await adapter.executeAgent('analyst', { action: 'Summarize…', params: {} }, ctx); * ``` */ export declare class AnthropicMessagesAdapter extends BaseAdapter { readonly name = "anthropic-messages"; readonly version = "1.0.0"; private agents; get capabilities(): AdapterCapabilities; /** * Register a model-backed agent. Builds a {@link GovernedModelGateway} wired * with the supplied budget/audit/telemetry/thinking/effort collaborators. */ registerModelAgent(agentId: string, config: AnthropicMessagesAgentConfig): void; executeAgent(agentId: string, payload: AgentPayload, _context: AgentContext): Promise; } //# sourceMappingURL=anthropic-messages-adapter.d.ts.map