Skip to content
47 changes: 36 additions & 11 deletions dsl/extdeps/llm/anthropic.dag
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ data anthropic_assistant_content_block_wire_contract: CoproductWireContract = {
encoding: InternallyTaggedObject { tag_field: "type", naming: StripPrefixSuffixAndSnakeCase { prefix: "Assistant", suffix: "Block" } }
}

data anthropic_messages_200_content_block_wire_contract: CoproductWireContract = {
coproduct: "AnthropicMessages200ContentBlock",
encoding: InternallyTaggedObject { tag_field: "type", naming: StripPrefixSuffixAndSnakeCase { prefix: "Messages", suffix: "Block" } }
}

// -- Models --------------------------------------------------------

type AnthropicModel
Expand Down Expand Up @@ -145,11 +150,29 @@ type AnthropicMessages200Citation
| WebSearchResultLocation { cited_text: String, encrypted_index: String, title: String?, url: String }
| SearchResultLocation { cited_text: String, source: String, title: String?, search_result_index: Int, start_block_index: Int, end_block_index: Int }

type AnthropicMessages200TextBlock {
type: String
text: String
citations: List<AnthropicMessages200Citation>?
}
// 🟡 SCAFFOLD provider-domain coproduct for Anthropic Messages 200 `content[]`
// response rows. The outer wire shape is already stable and `type`-tagged, so
// these arms belong as a coproduct instead of optional coordinates on a text
// record. Scaffold triggers (also tracked in
// `structural_coverage_gap_anthropic_messages_200_residual` below):
// `MessagesWebSearchToolResultBlock.content` remains `Json` until the
// web-search result/error payload gains a structural payload coproduct, and
// `AnthropicMessages200Body.content/0/text` output projection needs
// variant-aware typed REST response-path support.
type AnthropicMessages200ContentBlock
= MessagesTextBlock { text: String, citations: List<AnthropicMessages200Citation>? }
| MessagesThinkingBlock { thinking: String, signature: String }
| MessagesRedactedThinkingBlock { data: String }
| MessagesToolUseBlock { id: String, name: String, input: Json, caller: Json? }
| MessagesServerToolUseBlock { id: String, name: AnthropicServerToolName, input: Json, caller: Json? }
| MessagesWebSearchToolResultBlock { tool_use_id: String, content: Json, caller: Json? }

// 🟡 SCAFFOLD provider-domain enum for Anthropic `server_tool_use.name`
// values mirrored from Anthropic's generated OpenAPI SDK schema. Scaffold
// trigger: retire or extend this row when Anthropic publishes additional
// `server_tool_use.name` values; per-tool input payload typing remains tracked
// by `server_tool_input_payloads_unmodeled`.
type AnthropicServerToolName = WebSearch | WebFetch | CodeExecution | BashCodeExecution | TextEditorCodeExecution | ToolSearchToolRegex | ToolSearchToolBm25 | Advisor

type AnthropicMessages200Usage {
input_tokens: Int
Expand All @@ -169,15 +192,12 @@ type AnthropicStopReason = EndTurn | MaxTokens | StopSequence | ToolUse | PauseT

// Message object envelope for POST /v1/messages 200 responses per Anthropic docs
// (https://docs.anthropic.com/en/api/messages): `id`, `type`, `role`, `content`,
// `model`, `stop_reason`, optional `stop_sequence`, `usage`. `AnthropicMessages200TextBlock`
// remains the narrow text slice inside `content[]`; thinking, tool_use, images,
// and server tools stay gap-carried on the narrower downstream API-surface
// receipts below.
// `model`, `stop_reason`, optional `stop_sequence`, `usage`.
type AnthropicMessages200Body {
id: String
type: String
role: String
content: List<AnthropicMessages200TextBlock>
content: List<AnthropicMessages200ContentBlock>
model: String
stop_reason: AnthropicStopReason
stop_sequence: String?
Expand All @@ -186,7 +206,12 @@ type AnthropicMessages200Body {
}

data structural_coverage_gap_anthropic_messages_200_residual: List<String> = [
"closure:anthropic_messages_200_residual|AnthropicMessages200Body|json_pending:container|AnthropicMessages200TextBlock|variant_pending:thinking|variant_pending:tool_use|variant_pending:redacted_thinking|variant_pending:web_search|variant_pending:server_tool_use|trigger:content block coproduct plus container-management response surface"
"closure:anthropic_messages_200_residual|AnthropicMessages200Body|json_pending:container|AnthropicMessages200ContentBlock.MessagesWebSearchToolResultBlock.content|AnthropicMessages200ContentBlock.MessagesWebSearchToolResultBlock.caller|json_pending:web_search_tool_result_payload|trigger:container-management response surface plus web search result/error payload coproduct plus typed caller carrier for web search tool result",
"closure:anthropic_messages_200_residual|AnthropicMessages200ContentBlock.MessagesToolUseBlock|residue:client_tool_name_input_and_optional_caller_payloads_not_bound_to_declared_tool_schema|trigger:tool_use response block references declared AnthropicToolDefinition through typed caller carrier and input payload schema",
"closure:anthropic_messages_200_residual|AnthropicMessages200ContentBlock.MessagesServerToolUseBlock|residue:server_tool_input_and_optional_caller_payloads_unmodeled|trigger:fold server_tool_use name and input into a server-tool-use coproduct keyed by AnthropicServerToolName",
"closure:anthropic_messages_200_residual|AnthropicServerToolName|external_spec_watch:server_tool_use_name_set|trigger:Anthropic publishes additional server_tool_use.name values beyond the generated SDK literal set",
"closure:anthropic_messages_200_residual|AnthropicMessages200ContentBlock|variant_pending:web_fetch_tool_result|variant_pending:code_execution_tool_result|variant_pending:bash_code_execution_tool_result|variant_pending:text_editor_code_execution_tool_result|variant_pending:tool_search_tool_result|variant_pending:advisor_tool_result|variant_pending:mcp_tool_use|variant_pending:mcp_tool_result|variant_pending:container_upload|trigger:Anthropic beta/server-tool content-block surface modeled structurally",
"closure:anthropic_messages_200_residual|llm.Anthropic.Messages.output.content|blocked:variant_aware_typed_rest_response_projection|path:content/0/text|requires_arm:AnthropicMessages200ContentBlock.MessagesTextBlock|trigger:structural projection metadata carrier lands"
]

// Request wire: Messages API expects string `role` + flat `content[]` objects
Expand Down
Loading
Loading