{"version":3,"sources":["../../src/client/message.ts"],"sourcesContent":["/**\n * Copyright 2024 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 { PromptMessage } from '@modelcontextprotocol/sdk/types.js' with { 'resolution-mode': 'import' };\nimport { MessageData, Part } from 'genkit';\n\nconst ROLE_MAP = {\n  user: 'user',\n  assistant: 'model',\n} as const;\n\nexport function fromMcpPromptMessage(message: PromptMessage): MessageData {\n  return {\n    role: ROLE_MAP[message.role],\n    content: [fromMcpPart(message.content)],\n  };\n}\n\nexport function fromMcpPart(part: PromptMessage['content']): Part {\n  switch (part.type) {\n    case 'text':\n      return { text: part.text };\n    case 'image':\n      return {\n        media: {\n          contentType: part.mimeType,\n          url: `data:${part.mimeType};base64,${part.data}`,\n        },\n      };\n    case 'resource':\n      return {};\n  }\n}\n"],"mappings":"AAmBA,MAAM,WAAW;AAAA,EACf,MAAM;AAAA,EACN,WAAW;AACb;AAEO,SAAS,qBAAqB,SAAqC;AACxE,SAAO;AAAA,IACL,MAAM,SAAS,QAAQ,IAAI;AAAA,IAC3B,SAAS,CAAC,YAAY,QAAQ,OAAO,CAAC;AAAA,EACxC;AACF;AAEO,SAAS,YAAY,MAAsC;AAChE,UAAQ,KAAK,MAAM;AAAA,IACjB,KAAK;AACH,aAAO,EAAE,MAAM,KAAK,KAAK;AAAA,IAC3B,KAAK;AACH,aAAO;AAAA,QACL,OAAO;AAAA,UACL,aAAa,KAAK;AAAA,UAClB,KAAK,QAAQ,KAAK,QAAQ,WAAW,KAAK,IAAI;AAAA,QAChD;AAAA,MACF;AAAA,IACF,KAAK;AACH,aAAO,CAAC;AAAA,EACZ;AACF;","names":[]}