@microsoft/teams.api
Version:
<p> <a href="https://www.npmjs.com/package/@microsoft/teams.api" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.api/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.api?activeTab=code" t
1 lines • 3.97 kB
Source Map (JSON)
{"version":3,"sources":["../../../src/models/html-widget/call-tool-result.ts"],"names":[],"mappings":"AAyGO,SAAS,mBAAA,CAAoB,MAAA,GAA+B,EAAC,EAAmC;AACrG,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,MAAA,CAAO,OAAA,IAAW,EAAC;AAAA,IAC5B,iBAAA,EAAmB,MAAA,CAAO,iBAAA,IAAqB,EAAC;AAAA,IAChD,OAAA,EAAS,OAAO,OAAA,IAAW;AAAA,GAC7B;AACF;AAQO,SAAS,qBAAA,CAAsB,MAAA,GAA+B,EAAC,EAAgC;AACpG,EAAA,OAAO;AAAA,IACL,YAAA,EAAc,2BAAA;AAAA,IACd,cAAA,EAAgB,oBAAoB,MAAM;AAAA,GAC5C;AACF","file":"call-tool-result.mjs","sourcesContent":["/**\n * Text content item in an MCP call tool result.\n */\nexport interface IMcpUiTextContent {\n type: 'text';\n text: string;\n}\n\n/**\n * Image content item in an MCP call tool result.\n */\nexport interface IMcpUiImageContent {\n type: 'image';\n /** Base64-encoded image data. */\n data: string;\n /** MIME type of the image (e.g. \"image/png\"). */\n mimeType: string;\n}\n\n/**\n * Audio content item in an MCP call tool result.\n */\nexport interface IMcpUiAudioContent {\n type: 'audio';\n /** Base64-encoded audio data. */\n data: string;\n /** MIME type of the audio (e.g. \"audio/wav\"). */\n mimeType: string;\n}\n\n/**\n * Embedded resource content item in an MCP call tool result.\n */\nexport interface IMcpUiResourceContent {\n type: 'resource';\n resource: {\n uri: string;\n mimeType?: string;\n text?: string;\n blob?: string;\n };\n}\n\n/**\n * A content item in an MCP UI call tool result.\n * Teams currently only renders 'text' content; other types are defined\n * by the MCP spec for forward compatibility.\n */\nexport type IMcpUiCallToolResultContent =\n | IMcpUiTextContent\n | IMcpUiImageContent\n | IMcpUiAudioContent\n | IMcpUiResourceContent;\n\n/**\n * The result of a widget's `tools/call` request, returned by the bot\n * in response to an `htmlwidget/calltool` invoke activity.\n *\n * @experimental This API is in preview and may change in the future.\n * Diagnostic: ExperimentalTeamsHtmlWidget\n */\nexport interface IMcpUiCallToolResult {\n /**\n * An array of content items to return to the widget.\n */\n content?: IMcpUiCallToolResultContent[];\n\n /**\n * Structured data that the widget can render from.\n */\n structuredContent?: unknown;\n\n /**\n * Whether the tool call resulted in an error.\n */\n isError?: boolean;\n}\n\n/**\n * The wire-format response body for an `htmlwidget/calltool` invoke.\n * Teams expects this shape (with `responseType` discriminator) rather than\n * a bare {@link IMcpUiCallToolResult}.\n *\n * @experimental This API is in preview and may change in the future.\n * Diagnostic: ExperimentalTeamsHtmlWidget\n */\nexport interface IHtmlWidgetCallToolResponse {\n /**\n * Discriminator that tells Teams how to interpret the response.\n */\n responseType: 'htmlwidget/calltoolresult';\n\n /**\n * The tool call result payload.\n */\n callToolResult: IMcpUiCallToolResult;\n}\n\n/**\n * Builds a complete tool result.\n * `content`, `structuredContent` and `isError` are always present, defaulting to `[]`, `{}` and `false`, because an omitted field can reach the widget as `null`.\n *\n * @experimental This API is in preview and may change in the future.\n * Diagnostic: ExperimentalTeamsHtmlWidget\n */\nexport function buildCallToolResult(result: IMcpUiCallToolResult = {}): Required<IMcpUiCallToolResult> {\n return {\n content: result.content ?? [],\n structuredContent: result.structuredContent ?? {},\n isError: result.isError ?? false,\n };\n}\n\n/**\n * Builds the `htmlwidget/calltool` invoke response body, applying the defaults of {@link buildCallToolResult}.\n *\n * @experimental This API is in preview and may change in the future.\n * Diagnostic: ExperimentalTeamsHtmlWidget\n */\nexport function buildCallToolResponse(result: IMcpUiCallToolResult = {}): IHtmlWidgetCallToolResponse {\n return {\n responseType: 'htmlwidget/calltoolresult',\n callToolResult: buildCallToolResult(result),\n };\n}\n"]}