| 1130 | }; |
| 1131 | |
| 1132 | const renderedInAppResult = (input: { |
| 1133 | readonly code: string; |
| 1134 | readonly artifactId: string; |
| 1135 | readonly title: string; |
| 1136 | readonly url?: string | undefined; |
| 1137 | }): McpToolResult => ({ |
| 1138 | content: [ |
| 1139 | { |
| 1140 | type: "text", |
| 1141 | text: [ |
| 1142 | `Rendered "${input.title}" as an interactive UI component. Saved as artifact ${input.artifactId}.`, |
| 1143 | // The link rides along even though the widget rendered: clients lose |
| 1144 | // rendered widgets in ways the server never sees (a transcript |
| 1145 | // reopened without re-reading the ui:// resource shows raw JSON), and |
| 1146 | // when that happens this URL in the conversation is the only path |
| 1147 | // back to the artifact the model can offer. |
| 1148 | ...(input.url ? [`It also stays available at ${input.url}`] : []), |
| 1149 | ].join("\n"), |
| 1150 | }, |
| 1151 | ], |
| 1152 | structuredContent: { |
| 1153 | code: input.code, |
| 1154 | artifactId: input.artifactId, |
| 1155 | ...(input.url ? { url: input.url } : {}), |
| 1156 | }, |
| 1157 | }); |
| 1158 | |
| 1159 | const renderedAsLinkResult = (input: { |
| 1160 | readonly url: string; |