Import apps/vscode/src/remote.ts
This commit is contained in:
parent
9b1c5da892
commit
f3f4420027
|
|
@ -155,9 +155,20 @@ export class RemoteConnection {
|
||||||
return this.call('session.create', options.workspaceId ? { workspaceId: options.workspaceId } : options.cwd ? { cwd: options.cwd } : {})
|
return this.call('session.create', options.workspaceId ? { workspaceId: options.workspaceId } : options.cwd ? { cwd: options.cwd } : {})
|
||||||
}
|
}
|
||||||
|
|
||||||
async prompt(sessionId: string, text: string): Promise<void> {
|
async prompt(sessionId: string, text: string, images: { mediaType: string; data: string; name?: string }[] = []): Promise<void> {
|
||||||
if (this.alpha !== undefined) return this.alpha.sessionPrompt(sessionId, text)
|
const promptImages = images.filter(image => ['image/png', 'image/jpeg', 'image/webp', 'image/gif'].includes(image.mediaType))
|
||||||
await this.call('session.prompt', { sessionId, mode: 'queue', content: [{ type: 'text', text }] })
|
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<void> {
|
async cancelSession(sessionId: string): Promise<void> {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue