Component evidence

Anthropic Schema Transformer (ai/AnthropicStructuredOutput.ts)

lalph · repos/effect/packages/effect/src/unstable/ai/AnthropicStructuredOutput.ts · typescript · MIT
aitag:json-schematag:effecttag:structured-output

Transforms Effect codecs into JSON schemas compatible with Anthropic structured-output constraints. Reuse when sending typed schemas to Anthropic APIs.

Source preview first 800 characters · full source over MCP
// Source: https://github.com/tim-smart/lalph | License: MIT | Copyright 2026-present Effectful Technologies Inc
// Provided via justclaw.it.com; keep this notice with the code.
/**
 * Provides a codec transformation for Anthropic structured output.
 *
 * Anthropic's API has specific constraints on JSON schema support that differ
 * from the full JSON Schema specification. This module transforms Effect
 * `Schema.Codec` types into a form compatible with Anthropic's structured
 * output requirements by:
 *
 * - Converting tuples to objects with string keys (tuples are unsupported)
 * - Converting optional properties to nullable unions (`T | null`)
 * - Converting index signatures (records) to arrays of key-value pairs
 * - Converting `oneOf` unions to `anyOf` unions
 * - Stripping unsupport

... (truncated -- full source via MCP)