{"version":3,"file":"createSendMessageFunction.mjs","sources":["../../../../../src/runtime/internals/ai/createSendMessageFunction.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { customOpFactory } from '../operations/custom';\nimport { convertItemToConversationMessage } from './convertItemToConversationMessage';\nimport { serializeAiContext, serializeContent, serializeToolConfiguration, } from './conversationMessageSerializers';\nimport { AiAction, getCustomUserAgentDetails, } from './getCustomUserAgentDetails';\nexport const createSendMessageFunction = (client, modelIntrospection, conversationId, conversationRouteName, getInternals) => async (input) => {\n    const { conversations } = modelIntrospection;\n    // Safe guard for standalone function. When called as part of client generation, this should never be falsy.\n    if (!conversations) {\n        return {};\n    }\n    const processedInput = typeof input === 'string' ? { content: [{ text: input }] } : input;\n    const { content, aiContext, toolConfiguration } = processedInput;\n    const sendSchema = conversations[conversationRouteName].message.send;\n    const sendOperation = customOpFactory(client, modelIntrospection, 'mutation', sendSchema, false, getInternals, getCustomUserAgentDetails(AiAction.SendMessage));\n    const { data, errors } = await sendOperation({\n        conversationId,\n        content: serializeContent(content),\n        ...(aiContext && { aiContext: serializeAiContext(aiContext) }),\n        ...(toolConfiguration && {\n            toolConfiguration: serializeToolConfiguration(toolConfiguration),\n        }),\n    });\n    return {\n        data: data ? convertItemToConversationMessage(data) : data,\n        errors,\n    };\n};\n"],"names":[],"mappings":";;;;;AAAA;AACA;AAKY,MAAC,yBAAyB,GAAG,CAAC,MAAM,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,YAAY,KAAK,OAAO,KAAK,KAAK;AAC/I,IAAI,MAAM,EAAE,aAAa,EAAE,GAAG,kBAAkB;AAChD;AACA,IAAI,IAAI,CAAC,aAAa,EAAE;AACxB,QAAQ,OAAO,EAAE;AACjB,IAAI;AACJ,IAAI,MAAM,cAAc,GAAG,OAAO,KAAK,KAAK,QAAQ,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,KA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