feat: prepare VS Code LM API for image support

- Updated VS Code engine requirement to 1.95.0 for image API support
- Added TODO comment in vscode-lm.ts for future image capability detection
- Improved image placeholder messages in convertToVsCodeLmMessages
- Updated tests to match new placeholder format

This prepares the codebase for when VS Code fully exposes the image
support capabilities through the LanguageModelChat interface.
This commit is contained in:
Roo Code 2025-09-18 02:00:21 +00:00
parent 87b45def18
commit 5eb87d8c9b
5 changed files with 26 additions and 9 deletions

11
pnpm-lock.yaml generated
View file

@ -880,8 +880,8 @@ importers:
specifier: ^5.0.5
version: 5.0.5
'@types/vscode':
specifier: ^1.84.0
version: 1.100.0
specifier: ^1.104.0
version: 1.104.0
'@vscode/test-electron':
specifier: ^2.5.2
version: 2.5.2
@ -4136,6 +4136,9 @@ packages:
'@types/vscode@1.103.0':
resolution: {integrity: sha512-o4hanZAQdNfsKecexq9L3eHICd0AAvdbLk6hA60UzGXbGH/q8b/9xv2RgR7vV3ZcHuyKVq7b37IGd/+gM4Tu+Q==}
'@types/vscode@1.104.0':
resolution: {integrity: sha512-0KwoU2rZ2ecsTGFxo4K1+f+AErRsYW0fsp6A0zufzGuhyczc2IoKqYqcwXidKXmy2u8YB2GsYsOtiI9Izx3Tig==}
'@types/ws@8.18.1':
resolution: {integrity: sha512-ThVF6DCVhA8kUGy+aazFQ4kXQ7E1Ty7A3ypFOe0IcJV8O/M511G99AW24irKrW56Wt44yG9+ij8FaqoBGkuBXg==}
@ -13667,6 +13670,8 @@ snapshots:
'@types/vscode@1.103.0': {}
'@types/vscode@1.104.0': {}
'@types/ws@8.18.1':
dependencies:
'@types/node': 24.2.1
@ -13842,7 +13847,7 @@ snapshots:
sirv: 3.0.1
tinyglobby: 0.2.14
tinyrainbow: 2.0.0
vitest: 3.2.4(@types/debug@4.1.12)(@types/node@20.17.57)(@vitest/ui@3.2.4)(jiti@2.4.2)(jsdom@26.1.0)(lightningcss@1.30.1)(tsx@4.19.4)(yaml@2.8.0)
vitest: 3.2.4(@types/debug@4.1.12)(@types/node@20.17.50)(@vitest/ui@3.2.4)(jiti@2.4.2)(jsdom@26.1.0)(lightningcss@1.30.1)(tsx@4.19.4)(yaml@2.8.0)
'@vitest/utils@3.2.4':
dependencies:

View file

@ -510,7 +510,10 @@ export class VsCodeLmHandler extends BaseProvider implements SingleCompletionHan
typeof this.client.maxInputTokens === "number"
? Math.max(0, this.client.maxInputTokens)
: openAiModelInfoSaneDefaults.contextWindow,
supportsImages: false, // VSCode Language Model API currently doesn't support image inputs
// TODO: Enable image support when VS Code LM API provides capability detection
// The newer VS Code API (1.95+) includes LanguageModelChatInformation.capabilities.imageInput
// but it's not directly accessible from the LanguageModelChat interface yet
supportsImages: false,
supportsPromptCache: true,
inputPrice: 0,
outputPrice: 0,

View file

@ -170,7 +170,9 @@ describe("convertToVsCodeLmMessages", () => {
expect(result).toHaveLength(1)
const imagePlaceholder = result[0].content[1] as MockLanguageModelTextPart
expect(imagePlaceholder.value).toContain("[Image (base64): image/png not supported by VSCode LM API]")
expect(imagePlaceholder.value).toContain(
"[Image placeholder: base64 (image/png) - VS Code LM API image support pending]",
)
})
})

View file

@ -85,8 +85,12 @@ export function convertToVsCodeLmMessages(
// Convert non-tool messages to TextParts after tool messages
...nonToolMessages.map((part) => {
if (part.type === "image") {
// TODO: When VS Code LM API adds LanguageModelImagePart support, convert images properly
// For now, we provide a placeholder text description
const imageType = part.source?.type || "unknown"
const mediaType = part.source?.media_type || "unknown"
return new vscode.LanguageModelTextPart(
`[Image (${part.source?.type || "Unknown source-type"}): ${part.source?.media_type || "unknown media-type"} not supported by VSCode LM API]`,
`[Image placeholder: ${imageType} (${mediaType}) - VS Code LM API image support pending]`,
)
}
return new vscode.LanguageModelTextPart(part.text)
@ -129,7 +133,10 @@ export function convertToVsCodeLmMessages(
// Convert non-tool messages to TextParts after tool messages
...nonToolMessages.map((part) => {
if (part.type === "image") {
return new vscode.LanguageModelTextPart("[Image generation not supported by VSCode LM API]")
// Assistant-generated images are not yet supported
return new vscode.LanguageModelTextPart(
"[Image generation not yet supported by VS Code LM API]",
)
}
return new vscode.LanguageModelTextPart(part.text)
}),

View file

@ -10,7 +10,7 @@
"theme": "dark"
},
"engines": {
"vscode": "^1.84.0",
"vscode": "^1.95.0",
"node": "20.19.2"
},
"author": {
@ -531,7 +531,7 @@
"@types/string-similarity": "^4.0.2",
"@types/tmp": "^0.2.6",
"@types/turndown": "^5.0.5",
"@types/vscode": "^1.84.0",
"@types/vscode": "^1.104.0",
"@vscode/test-electron": "^2.5.2",
"@vscode/vsce": "3.3.2",
"esbuild": "^0.25.0",