{"version":3,"sources":["../../../src/modelgarden/v2/anthropic.ts"],"sourcesContent":["/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *     http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type {\n  ContentBlock as AnthropicContent,\n  ImageBlockParam,\n  Message,\n  MessageCreateParamsBase,\n  MessageParam,\n  TextBlock,\n  TextBlockParam,\n  TextDelta,\n  Tool,\n  ToolResultBlockParam,\n  ToolUseBlock,\n  ToolUseBlockParam,\n} from '@anthropic-ai/sdk/resources/messages';\nimport { AnthropicVertex } from '@anthropic-ai/vertex-sdk';\nimport {\n  ActionMetadata,\n  z,\n  type GenerateRequest,\n  type Part as GenkitPart,\n  type MessageData,\n  type ModelReference,\n  type ModelResponseData,\n  type Part,\n} from 'genkit';\nimport {\n  GenerationCommonConfigSchema,\n  ModelInfo,\n  getBasicUsageStats,\n  modelRef,\n  type ModelAction,\n} from 'genkit/model';\nimport { model as pluginModel } from 'genkit/plugin';\nimport { getGenkitClientHeader } from '../../common/index.js';\nimport { PluginOptions } from './types.js';\nimport { checkModelName } from './utils.js';\n\nexport const AnthropicConfigSchema = GenerationCommonConfigSchema.extend({\n  location: z.string().optional(),\n}).passthrough();\nexport type AnthropicConfigSchemaType = typeof AnthropicConfigSchema;\nexport type AnthropicConfig = z.infer<AnthropicConfigSchemaType>;\n\n// All the config schema types\ntype ConfigSchemaType = AnthropicConfigSchemaType;\n\nfunction commonRef(\n  name: string,\n  info?: ModelInfo,\n  configSchema: ConfigSchemaType = AnthropicConfigSchema\n): ModelReference<ConfigSchemaType> {\n  return modelRef({\n    name: `vertex-model-garden/${name}`,\n    configSchema,\n    info: info ?? {\n      supports: {\n        multiturn: true,\n        media: true,\n        tools: true,\n        systemRole: true,\n        output: ['text'],\n      },\n    },\n  });\n}\n\nexport const GENERIC_MODEL = commonRef('anthropic');\n\nexport const KNOWN_MODELS = {\n  'claude-sonnet-4-6': commonRef('claude-sonnet-4-6'),\n  'claude-opus-4-6': commonRef('claude-opus-4-6'),\n  'claude-haiku-4-5@20251001': commonRef('claude-haiku-4-5@20251001'),\n  'claude-sonnet-4-5@20250929': commonRef('claude-sonnet-4-5@20250929'),\n  'claude-sonnet-4@20250514': commonRef('claude-sonnet-4@20250514'),\n  'claude-opus-4-5@20251101': commonRef('claude-opus-4-5@20251101'),\n  'claude-opus-4-1@20250805': commonRef('claude-opus-4-1@20250805'),\n  'claude-opus-4@20250514': commonRef('claude-opus-4@20250514'),\n};\nexport type KnownModels = keyof typeof KNOWN_MODELS;\nexport type AnthropicModelName = `claude-${string}`;\nexport function isAnthropicModelName(\n  value?: string\n): value is AnthropicModelName {\n  return !!value?.startsWith('claude-');\n}\n\nexport function model(\n  version: string,\n  options: AnthropicConfig = {}\n): ModelReference<AnthropicConfigSchemaType> {\n  const name = checkModelName(version);\n\n  return modelRef({\n    name: `vertex-model-garden/${name}`,\n    config: options,\n    configSchema: AnthropicConfigSchema,\n    info: {\n      ...GENERIC_MODEL.info,\n    },\n  });\n}\n\nexport interface ClientOptions {\n  location: string; // e.g. 'us-central1' or 'global'\n  projectId: string;\n}\n\nexport function listActions(clientOptions: ClientOptions): ActionMetadata[] {\n  // TODO: figure out where to get the list of models.\n  return [];\n}\n\nexport function listKnownModels(\n  clientOptions: ClientOptions,\n  pluginOptions?: PluginOptions\n) {\n  return Object.keys(KNOWN_MODELS).map((name) =>\n    defineModel(name, clientOptions, pluginOptions)\n  );\n}\n\nexport function defineModel(\n  name: string,\n  clientOptions: ClientOptions,\n  pluginOptions?: PluginOptions\n): ModelAction {\n  const clients: Record<string, AnthropicVertex> = {};\n  const clientFactory = (region: string): AnthropicVertex => {\n    if (!clients[region]) {\n      clients[region] = new AnthropicVertex({\n        region: region,\n        projectId: clientOptions.projectId,\n        defaultHeaders: {\n          'X-Goog-Api-Client': getGenkitClientHeader(),\n        },\n      });\n    }\n    return clients[region];\n  };\n  const ref = model(name);\n\n  return pluginModel(\n    {\n      name: ref.name,\n      ...ref.info,\n      configSchema: ref.configSchema,\n    },\n    async (request, { streamingRequested, sendChunk }) => {\n      const client = clientFactory(\n        request.config?.location || clientOptions.location\n      );\n      const modelVersion = checkModelName(ref.name);\n      const anthropicRequest = toAnthropicRequest(modelVersion, request);\n      if (!streamingRequested) {\n        // Non-streaming\n        const response = await client.messages.create({\n          ...anthropicRequest,\n          stream: false,\n        });\n        return fromAnthropicResponse(request, response);\n      } else {\n        // Streaming\n        const stream = await client.messages.stream(anthropicRequest);\n        for await (const event of stream) {\n          if (event.type === 'content_block_delta') {\n            sendChunk({\n              index: 0,\n              content: [\n                {\n                  text: (event.delta as TextDelta).text,\n                },\n              ],\n            });\n          }\n        }\n        return fromAnthropicResponse(request, await stream.finalMessage());\n      }\n    }\n  );\n}\n\nexport function toAnthropicRequest(\n  model: string,\n  input: GenerateRequest<typeof AnthropicConfigSchema>\n): MessageCreateParamsBase {\n  let system: string | undefined = undefined;\n  const messages: MessageParam[] = [];\n  for (const msg of input.messages) {\n    if (msg.role === 'system') {\n      system = msg.content\n        .map((c) => {\n          if (!c.text) {\n            throw new Error(\n              'Only text context is supported for system messages.'\n            );\n          }\n          return c.text;\n        })\n        .join();\n    }\n    // If the last message is a tool response, we need to add a user message.\n    // https://docs.anthropic.com/en/docs/build-with-claude/tool-use#handling-tool-use-and-tool-result-content-blocks\n    else if (msg.content[msg.content.length - 1].toolResponse) {\n      messages.push({\n        role: 'user',\n        content: toAnthropicContent(msg.content),\n      });\n    } else {\n      messages.push({\n        role: toAnthropicRole(msg.role),\n        content: toAnthropicContent(msg.content),\n      });\n    }\n  }\n  const request = {\n    model,\n    messages,\n    // https://docs.anthropic.com/claude/docs/models-overview#model-comparison\n    max_tokens: input.config?.maxOutputTokens ?? 4096,\n  } as MessageCreateParamsBase;\n  if (system) {\n    request['system'] = system;\n  }\n  if (input.tools) {\n    request.tools = input.tools?.map((tool) => {\n      return {\n        name: tool.name,\n        description: tool.description,\n        input_schema: tool.inputSchema,\n      };\n    }) as Array<Tool>;\n  }\n  if (input.config?.stopSequences) {\n    request.stop_sequences = input.config?.stopSequences;\n  }\n  if (input.config?.temperature) {\n    request.temperature = input.config?.temperature;\n  }\n  if (input.config?.topK) {\n    request.top_k = input.config?.topK;\n  }\n  if (input.config?.topP) {\n    request.top_p = input.config?.topP;\n  }\n  return request;\n}\n\nfunction toAnthropicContent(\n  content: GenkitPart[]\n): Array<\n  TextBlockParam | ImageBlockParam | ToolUseBlockParam | ToolResultBlockParam\n> {\n  return content.map((p) => {\n    if (p.text) {\n      return {\n        type: 'text',\n        text: p.text,\n      };\n    }\n    if (p.media) {\n      let b64Data = p.media.url;\n      if (b64Data.startsWith('data:')) {\n        b64Data = b64Data.substring(b64Data.indexOf(',')! + 1);\n      }\n\n      return {\n        type: 'image',\n        source: {\n          type: 'base64',\n          data: b64Data,\n          media_type: p.media.contentType as\n            | 'image/jpeg'\n            | 'image/png'\n            | 'image/gif'\n            | 'image/webp',\n        },\n      };\n    }\n    if (p.toolRequest) {\n      return toAnthropicToolRequest(p.toolRequest);\n    }\n    if (p.toolResponse) {\n      return toAnthropicToolResponse(p);\n    }\n    throw new Error(`Unsupported content type: ${JSON.stringify(p)}`);\n  });\n}\n\nfunction toAnthropicRole(role): 'user' | 'assistant' {\n  if (role === 'model') {\n    return 'assistant';\n  }\n  if (role === 'user') {\n    return 'user';\n  }\n  if (role === 'tool') {\n    return 'assistant';\n  }\n  throw new Error(`Unsupported role type ${role}`);\n}\n\nfunction fromAnthropicTextPart(part: TextBlock): Part {\n  return {\n    text: part.text,\n  };\n}\n\nfunction fromAnthropicToolCallPart(part: ToolUseBlock): Part {\n  return {\n    toolRequest: {\n      name: part.name,\n      input: part.input,\n      ref: part.id,\n    },\n  };\n}\n\n// Converts an Anthropic part to a Genkit part.\nfunction fromAnthropicPart(part: AnthropicContent): Part {\n  if (part.type === 'text') return fromAnthropicTextPart(part);\n  if (part.type === 'tool_use') return fromAnthropicToolCallPart(part);\n  throw new Error(\n    'Part type is unsupported/corrupted. Either data is missing or type cannot be inferred from type.'\n  );\n}\n\n// Converts an Anthropic response to a Genkit response.\nexport function fromAnthropicResponse(\n  input: GenerateRequest<typeof AnthropicConfigSchema>,\n  response: Message\n): ModelResponseData {\n  const parts = response.content as AnthropicContent[];\n  const message: MessageData = {\n    role: 'model',\n    content: parts.map(fromAnthropicPart),\n  };\n  return {\n    message,\n    finishReason: toGenkitFinishReason(\n      response.stop_reason as\n        | 'end_turn'\n        | 'max_tokens'\n        | 'stop_sequence'\n        | 'tool_use'\n        | null\n    ),\n    custom: {\n      id: response.id,\n      model: response.model,\n      type: response.type,\n    },\n    usage: {\n      ...getBasicUsageStats(input.messages, message),\n      inputTokens: response.usage.input_tokens,\n      outputTokens: response.usage.output_tokens,\n    },\n  };\n}\n\nfunction toGenkitFinishReason(\n  reason: 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | null\n): ModelResponseData['finishReason'] {\n  switch (reason) {\n    case 'end_turn':\n      return 'stop';\n    case 'max_tokens':\n      return 'length';\n    case 'stop_sequence':\n      return 'stop';\n    case 'tool_use':\n      return 'stop';\n    case null:\n      return 'unknown';\n    default:\n      return 'other';\n  }\n}\n\nfunction toAnthropicToolRequest(tool: Record<string, any>): ToolUseBlock {\n  if (!tool.name) {\n    throw new Error('Tool name is required');\n  }\n  // Validate the tool name, Anthropic only supports letters, numbers, and underscores.\n  // https://docs.anthropic.com/en/docs/build-with-claude/tool-use#specifying-tools\n  if (!/^[a-zA-Z0-9_-]{1,64}$/.test(tool.name)) {\n    throw new Error(\n      `Tool name ${tool.name} contains invalid characters.\n      Only letters, numbers, and underscores are allowed,\n      and the name must be between 1 and 64 characters long.`\n    );\n  }\n  const declaration: ToolUseBlock = {\n    type: 'tool_use',\n    id: tool.ref,\n    name: tool.name,\n    input: tool.input,\n  };\n  return declaration;\n}\n\nfunction toAnthropicToolResponse(part: Part): ToolResultBlockParam {\n  if (!part.toolResponse?.ref) {\n    throw new Error('Tool response reference is required');\n  }\n\n  if (!part.toolResponse.output) {\n    throw new Error('Tool response output is required');\n  }\n\n  return {\n    type: 'tool_result',\n    tool_use_id: part.toolResponse.ref,\n    content: JSON.stringify(part.toolResponse.output),\n  };\n}\n"],"mappings":"AA8BA,SAAS,uBAAuB;AAChC;AAAA,EAEE;AAAA,OAOK;AACP;AAAA,EACE;AAAA,EAEA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,SAAS,mBAAmB;AACrC,SAAS,6BAA6B;AAEtC,SAAS,sBAAsB;AAExB,MAAM,wBAAwB,6BAA6B,OAAO;AAAA,EACvE,UAAU,EAAE,OAAO,EAAE,SAAS;AAChC,CAAC,EAAE,YAAY;AAOf,SAAS,UACP,MACA,MACA,eAAiC,uBACC;AAClC,SAAO,SAAS;AAAA,IACd,MAAM,uBAAuB,IAAI;AAAA,IACjC;AAAA,IACA,MAAM,QAAQ;AAAA,MACZ,UAAU;AAAA,QACR,WAAW;AAAA,QACX,OAAO;AAAA,QACP,OAAO;AAAA,QACP,YAAY;AAAA,QACZ,QAAQ,CAAC,MAAM;AAAA,MACjB;AAAA,IACF;AAAA,EACF,CAAC;AACH;AAEO,MAAM,gBAAgB,UAAU,WAAW;AAE3C,MAAM,eAAe;AAAA,EAC1B,qBAAqB,UAAU,mBAAmB;AAAA,EAClD,mBAAmB,UAAU,iBAAiB;AAAA,EAC9C,6BAA6B,UAAU,2BAA2B;AAAA,EAClE,8BAA8B,UAAU,4BAA4B;AAAA,EACpE,4BAA4B,UAAU,0BAA0B;AAAA,EAChE,4BAA4B,UAAU,0BAA0B;AAAA,EAChE,4BAA4B,UAAU,0BAA0B;AAAA,EAChE,0BAA0B,UAAU,wBAAwB;AAC9D;AAGO,SAAS,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