From f3f4420027ed009d6e1c8f0c19a473327c4be3b4 Mon Sep 17 00:00:00 2001 From: QQ Date: Tue, 17 Nov 2026 08:38:37 +0800 Subject: [PATCH] Import apps/vscode/src/remote.ts --- apps/vscode/src/remote.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/vscode/src/remote.ts b/apps/vscode/src/remote.ts index 232871c..2f0fcc8 100644 --- a/apps/vscode/src/remote.ts +++ b/apps/vscode/src/remote.ts @@ -155,9 +155,20 @@ export class RemoteConnection { return this.call('session.create', options.workspaceId ? { workspaceId: options.workspaceId } : options.cwd ? { cwd: options.cwd } : {}) } - async prompt(sessionId: string, text: string): Promise { - if (this.alpha !== undefined) return this.alpha.sessionPrompt(sessionId, text) - await this.call('session.prompt', { sessionId, mode: 'queue', content: [{ type: 'text', text }] }) + async prompt(sessionId: string, text: string, images: { mediaType: string; data: string; name?: string }[] = []): Promise { + const promptImages = images.filter(image => ['image/png', 'image/jpeg', 'image/webp', 'image/gif'].includes(image.mediaType)) + const attachments = images.filter(image => !promptImages.includes(image)) + if (this.alpha !== undefined) { + const files: { receiptId: string }[] = [] + for (const file of attachments) { + const uploaded = await this.alpha.sessionUploadFile(sessionId, file.data, file.name) + if (typeof uploaded.receiptId !== 'string' || uploaded.receiptId.length === 0) throw new Error('Host returned an invalid file receipt.') + files.push({ receiptId: uploaded.receiptId }) + } + return this.alpha.sessionPrompt(sessionId, text, undefined, promptImages, files) + } + if (attachments.length > 0) throw new Error('File attachments require an updated Harness Remote Host.') + await this.call('session.prompt', { sessionId, mode: 'queue', content: [...(text ? [{ type: 'text', text }] : []), ...images.map(image => ({ type: 'image', ...image }))] }) } async cancelSession(sessionId: string): Promise {