2250
*/
2251
private async _rewriteUserMessageAttachments<T extends ChatTurnStartedAction | ChatPendingMessageSetAction>(channel: string, action: T, clientId: string): Promise<T> {
2253
>
if (!attachments?.length) {
2254
return action;
2255
}
2256
>
const attachmentsRoot = this._attachmentsRoot(channel);
agentService.ts
2257
>
const attachmentsRootStr = attachmentsRoot.toString();
2258
>
const rewritten = await Promise.all(attachments.map(a => this._rewriteSingleAttachment(a, attachmentsRoot, attachmentsRootStr, clientId)));
2259
>
return {
2260
>
...action,
2261
>
message: { ...action.message, attachments: rewritten },
2262
>
};
2263
>
}
2264
2265
private async _rewriteSingleAttachment(attachment: MessageAttachment, attachmentsRoot: URI, attachmentsRootStr: string, clientId: string): Promise<MessageAttachment> {
2267
>
if (attachment.type === MessageAttachmentKind.EmbeddedResource) {
2268
const bytes = decodeBase64(attachment.data).buffer;
2269
const basename = this._attachmentBasename(attachment.label, attachment.contentType);
2270
return this._writeAndRewrite(attachment, bytes, basename, attachmentsRoot);
2271
}
2272
>
if (attachment.type === MessageAttachmentKind.Resource && this._isRewritableAttachment(attachment, attachmentsRootStr)) {
agentService.ts
2273
const originalUri = URI.parse(attachment.uri);
2274
// If the attachment references a file that already exists on the agent