{"version":3,"sources":["../src/list.ts"],"sourcesContent":["/**\n * Copyright 2024 Bloom Labs Inc\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 Anthropic from '@anthropic-ai/sdk';\nimport { modelActionMetadata } from 'genkit/plugin';\n\nimport { ActionMetadata } from 'genkit';\nimport { claudeModelReference } from './models.mjs';\n\n/**\n * Retrieves available Anthropic models from the API and converts them into Genkit action metadata.\n *\n * This function queries the Anthropic API for the list of available models and generates metadata\n * for all discovered models.\n *\n * @param client - The Anthropic API client instance\n * @returns A promise that resolves to an array of action metadata for all discovered models\n */\nexport async function listActions(\n  client: Anthropic\n): Promise<ActionMetadata[]> {\n  // Use beta.models.list to get the list of ALL (stable and beta) models\n  const clientModels = (await client.beta.models.list()).data;\n  const seenNames = new Set<string>();\n\n  return clientModels\n    .filter((modelInfo) => {\n      const modelId = modelInfo.id;\n      if (!modelId) {\n        return false;\n      }\n\n      const ref = claudeModelReference(modelId);\n      const name = ref.name;\n\n      // Deduplicate by name\n      if (seenNames.has(name)) {\n        return false;\n      }\n      seenNames.add(name);\n      return true;\n    })\n    .map((modelInfo) => {\n      const modelId = modelInfo.id!;\n      const ref = claudeModelReference(modelId);\n\n      return modelActionMetadata({\n        name: ref.name,\n        info: ref.info,\n        configSchema: ref.configSchema,\n      });\n    });\n}\n"],"mappings":"AAkBA,SAAS,2BAA2B;AAGpC,SAAS,4BAA4B;AAWrC,eAAsB,YACpB,QAC2B;AAE3B,QAAM,gBAAgB,MAAM,OAAO,KAAK,OAAO,KAAK,GAAG;AACvD,QAAM,YAAY,oBAAI,IAAY;AAElC,SAAO,aACJ,OAAO,CAAC,cAAc;AACrB,UAAM,UAAU,UAAU;AAC1B,QAAI,CAAC,SAAS;AACZ,aAAO;AAAA,IACT;AAEA,UAAM,MAAM,qBAAqB,OAAO;AACxC,UAAM,OAAO,IAAI;AAGjB,QAAI,UAAU,IAAI,IAAI,GAAG;AACvB,aAAO;AAAA,IACT;AACA,cAAU,IAAI,IAAI;AAClB,WAAO;AAAA,EACT,CAAC,EACA,IAAI,CAAC,cAAc;AAClB,UAAM,UAAU,UAAU;AAC1B,UAAM,MAAM,qBAAqB,OAAO;AAExC,WAAO,oBAAoB;AAAA,MACzB,MAAM,IAAI;AAAA,MACV,MAAM,IAAI;AAAA,MACV,cAAc,IAAI;AAAA,IACpB,CAAC;AAAA,EACH,CAAC;AACL;","names":[]}