{"version":3,"file":"deepseek.cjs","names":["_isString"],"sources":["../../../src/messages/block_translators/deepseek.ts"],"sourcesContent":["import { AIMessage } from \"../ai.js\";\nimport { ContentBlock } from \"../content/index.js\";\nimport type { StandardContentBlockTranslator } from \"./index.js\";\nimport { _isString } from \"./utils.js\";\n\n/**\n * Converts a DeepSeek AI message to an array of v1 standard content blocks.\n *\n * This function processes an AI message from DeepSeek's API format\n * and converts it to the standardized v1 content block format. It handles\n * both string content and the reasoning_content in additional_kwargs.\n *\n * @param message - The AI message containing DeepSeek-formatted content\n * @returns Array of content blocks in v1 standard format\n *\n * @example\n * ```typescript\n * const message = new AIMessage({\n *   content: \"The answer is 42\",\n *   additional_kwargs: { reasoning_content: \"Let me think about this...\" }\n * });\n * const standardBlocks = convertToV1FromDeepSeekMessage(message);\n * // Returns:\n * // [\n * //   { type: \"reasoning\", reasoning: \"Let me think about this...\" },\n * //   { type: \"text\", text: \"The answer is 42\" }\n * // ]\n * ```\n */\nexport function convertToV1FromDeepSeekMessage(\n  message: AIMessage\n): Array<ContentBlock.Standard> {\n  const blocks: Array<ContentBlock.Standard> = [];\n\n  // Extract reasoning from additional_kwargs.reasoning_content\n  const reasoningContent = message.additional_kwargs?.reasoning_content;\n  if (_isString(reasoningContent) && reasoningContent.length > 0) {\n    blocks.push({\n      type: \"reasoning\",\n      reasoning: reasoningContent,\n    });\n  }\n\n  // Handle text content\n  if (typeof message.content === \"string\") {\n    if (message.content.length > 0) {\n      blocks.push({\n        type: \"text\",\n        text: message.content,\n      });\n    }\n  } else {\n    for (const block of message.content) {\n      if (\n        typeof block === \"object\" &&\n        \"type\" in block &&\n        block.type === \"text\" &&\n        \"text\" in block &&\n        _isString(block.text)\n      ) {\n        blocks.push({\n          type: \"text\",\n          text: block.text,\n        });\n      }\n    }\n  }\n\n  // Add tool calls if present\n  for (const toolCall of message.tool_calls ?? []) {\n    blocks.push({\n      type: \"tool_call\",\n      id: toolCall.id,\n      name: toolCall.name,\n      args: toolCall.args,\n    });\n  }\n\n  return blocks;\n}\n\nexport const ChatDeepSeekTranslator: StandardContentBlockTranslator = {\n  translateContent: convertToV1FromDeepSeekMessage,\n  translateContentChunk: convertToV1FromDeepSeekMessage,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,+BACd,SAC8B;CAC9B,MAAM,SAAuC,EAAE;CAG/C,MAAM,mBAAmB,QAAQ,mBAAmB;AACpD,KAAIA,cAAAA,UAAU,iBAAiB,IAAI,iBAAiB,SAAS,EAC3D,QAAO,KAAK;EACV,MAAM;EACN,WAAW;EACZ,CAAC;AAIJ,KAAI,OAAO,QAAQ,YAAY;MACzB,QAAQ,QAAQ,SAAS,EAC3B,QAAO,KAAK;GACV,MAAM;GACN,MAAM,QAAQ;GACf,CAAC;OAGJ,MAAK,MAAM,SAAS,QAAQ,QAC1B,KACE,OAAO,UAAU,YACjB,UAAU,SACV,MAAM,SAAS,UACf,UAAU,SACVA,cAAAA,UAAU,MAAM,KAAK,CAErB,QAAO,KAAK;EACV,MAAM;EACN,MAAM,MAAM;EACb,CAAC;AAMR,MAAK,MAAM,YAAY,QAAQ,cAAc,EAAE,CAC7C,QAAO,KAAK;EACV,MAAM;EACN,IAAI,SAAS;EACb,MAAM,SAAS;EACf,MAAM,SAAS;EAChB,CAAC;AAGJ,QAAO;;AAGT,MAAa,yBAAyD;CACpE,kBAAkB;CAClB,uBAAuB;CACxB"}