/** * Anthropic tool_use adapter over withCodeRifts (ID632 slice 2 — same thin pattern as OpenAI). * * Thin SHAPE converter only. Guard logic stays in withCodeRifts; this module: * 1. calls withCodeRifts with the same input shape, * 2. maps each ProtectedTool → Anthropic Messages API tool definition, * 3. returns Anthropic-shaped tools PLUS the untouched assurance objects * (registry_report, composition_assurance, receipt_thread). * * Honesty (do not "upgrade" assurance): * - composition_assurance is passed through EXACTLY as the core reported it * (COMPOSITION_CALL_POLICY_COMPLETE may still be false; inescapable_runtime may be false). * - The adapter converts tool SHAPE for the model API; it does not claim product-level * inescapability the core does not claim. * * Only-protected-tools (6/D at the adapter surface): * - `tools` is derived ONLY from the frozen registry's ProtectedTool list. * - Raw tools never appear in the returned Anthropic table. The host may still hold a raw * reference outside this table; that boundary stays the host's responsibility. * * Ergonomics (5–10 lines): pass raw tools + client + operation → Anthropic-ready guarded tools. * Mirrors src/adapters/openai.ts — only the target tool shape differs. */ import type { WithCodeRiftsInput, WithCodeRiftsResult, CompositionAssurance, ReceiptThreadHandle } from '../with-coderifts.js'; import type { CoverageObservedHandle } from '../coverage-observed.js'; import type { ProtectedTool, RegistryCoverageReport } from '../tool-registry.js'; import type { GuardOutcome } from '../types.js'; /** * Anthropic Messages API `tools[]` element (tool_use definition). * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview */ export type AnthropicTool = { name: string; description?: string; /** JSON Schema object for the tool input (Anthropic `input_schema`). */ input_schema: Record; }; /** * Result of withCodeRiftsAnthropic — Anthropic tool definitions + core assurance, unflattened. * * `tools` is the ONLY list intended for the model/runtime tool table. `protected_tools` is the * same guarded list (with execute) for host dispatch after tool_use blocks — never the raw tools. */ export type WithCodeRiftsAnthropicResult = { /** Anthropic-shaped tools for messages.create — only protected/guarded tools. */ tools: AnthropicTool[]; /** * Guarded ProtectedTool list from withCodeRifts (same tools as `tools`, with execute). * Host dispatches model tool_use through these only. Never raw tools. */ protected_tools: ProtectedTool[]; /** Untouched registry report — registry's own truth. */ registry_report: RegistryCoverageReport; /** * Product-level assurance — deliberately narrower than the registry. * Passed through untouched; may still show inescapable_runtime:false and * residual composition_call_policy_incomplete. */ composition_assurance: CompositionAssurance; /** Per-composition receipt cursor — NOT product-truth chain evidence. */ receipt_thread: ReceiptThreadHandle; /** Observed coverage for this withCodeRifts run. Half A always; Half B via reportToolDispatch. */ coverage_observed: CoverageObservedHandle; repository?: string; }; /** * Map one ProtectedTool → Anthropic tool definition (shape only; no execute). * Prefer tool.inputSchema when it is a plain object; otherwise empty object schema. */ export declare function protectedToolToAnthropic(tool: ProtectedTool): AnthropicTool; /** * Convert a list of ProtectedTool into Anthropic tool definitions. * Does NOT call the guard — pure shape map over an already-protected list. */ export declare function toAnthropicTools(protectedTools: readonly ProtectedTool[]): AnthropicTool[]; /** * Build Anthropic-ready guarded tools from raw tools + client + operation. * * Calls withCodeRifts internally (guard logic stays in the core). Returns: * - `tools` — Anthropic messages API shape ({ name, description?, input_schema }) * - `protected_tools` — same guarded tools for host execute dispatch * - assurance objects from the core, passed through untouched * * @param input Same shape as withCodeRifts (WithCodeRiftsInput). */ export declare function withCodeRiftsAnthropic(input: WithCodeRiftsInput): WithCodeRiftsAnthropicResult; /** * Shape-only adapter over an existing WithCodeRiftsResult (composition style). * Prefer withCodeRiftsAnthropic when starting from raw tools. * * Does not re-run the guard; does not invent assurance. */ export declare function anthropicToolAdapter(result: WithCodeRiftsResult): WithCodeRiftsAnthropicResult; /** * Minimal Anthropic tool_result content block. No @anthropic-ai/sdk dependency. * @see https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview */ export type AnthropicToolResult = { type: 'tool_result'; tool_use_id: string; content: string; }; declare const __proofBoundAnthropicBrand: unique symbol; export type ProofBoundAnthropicToolResult = AnthropicToolResult & { readonly __proofBound: typeof __proofBoundAnthropicBrand; }; export type BindAnthropicGuardOutcomeArgs = { /** Anthropic tool_use block id this tool_result answers. */ tool_use_id: string; serialize?: (result: T) => string; /** * Attach the rendered GuardExecutionProof (S4). Default ON. * Pass `false` to opt out. */ attachProof?: boolean; }; export declare function defaultSerializeAnthropicToolResult(result: T): string; /** * Map a full GuardOutcome into an Anthropic tool_result block with proof embedded. * Same arm mapping as bindOpenAIGuardOutcome; id field is tool_use_id. */ export declare function bindAnthropicGuardOutcome(outcome: GuardOutcome, args: BindAnthropicGuardOutcomeArgs): ProofBoundAnthropicToolResult; export {}; //# sourceMappingURL=anthropic.d.ts.map