Repository navigation
VS Code Language Model (vscode.lm) & Chat Participant (vscode.chat) API Bridge #37203
codeCraft-Ritik
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Feature 1: VS Code Language Model (
vscode.lm) & Chat Participant (vscode.chat) API Bridge1. Feature Title
Bidirectional RPC Extension Host Bridge for VS Code Language Model (
vscode.lm) and Chat Participant (vscode.chat) APIs2. Problem / Gap
Theia's primary architectural differentiator is full compatibility with the VS Code extension ecosystem. Over 2024–2026, the extension ecosystem underwent an AI revolution: tools such as GitHub Copilot Chat, Continue, Cline, Roo Code, AWS Q Developer, and GitLab Duo standardized on two official VS Code APIs:
vscode.lm— To discover available language models (selectChatModels), stream completions (LanguageModelChat.sendRequest), and count tokens.vscode.chat— To register interactive chat participants (createChatParticipant), custom prompt handlers, and mapped edit providers.In Theia's current extension host implementation (
packages/plugin-ext/src/plugin/plugin-context.ts#L1353-L1402), these core APIs are hardcoded as dead stubs:Furthermore:
packages/plugin-ext/src/main/browser/lm-main.ts, onlyMcpServerDefinitionRegistryMainImplis implemented; there is noLanguageModelChatMainImplorChatParticipantMainImpl.packages/plugin-ext/src/common/plugin-api-rpc.ts,LM_TOOLS_MAINandLM_TOOLS_EXTexist for tools, but no RPC channel exists for chat models or chat participants.Consequence: When users or enterprise adopters install modern AI extensions into Theia or Theia-based products (such as Arduino IDE 2.0, Eclipse Che, or Gitpod), the extensions fail silently or become completely unusable because no models are reported and chat participants are never wired into Theia's UI.
3. Proposed Solution
Build the bidirectional RPC bridge between Theia's extension host plugin process (
@theia/plugin-ext) and Theia's existing native AI subsystem (@theia/ai-coreand@theia/ai-chat):vscode.lm.selectChatModels()via RPC toLanguageModelRegistryin@theia/ai-core. Streaming responses returned byLanguageModel.sendRequest()are streamed across the RPC channel usingLanguageModelStreamResponsechunks.vscode.chat.createChatParticipant()to Theia'sChatAgentService. When an extension registers a participant, it is registered as an active chat agent, appearing in@theia/ai-chat-uiautocomplete (@<participantId>). User prompts directed to that participant are dispatched via RPC to the extension's handler.4. Why it is Useful
LanguageModelRegistry(which supports Anthropic, OpenAI, Ollama, Gemini, and local LLMs) to power VS Code extensions.5. Relevant Code / Files
packages/plugin-ext/src/plugin/plugin-context.ts#L1353-L1402: Remove stubbed implementations fortheia.chatandtheia.lm.packages/plugin-ext/src/common/plugin-api-rpc.ts: DefineMAIN_RPC_CONTEXT.LANGUAGE_MODEL_MAINandEXT_RPC_CONTEXT.LANGUAGE_MODEL_EXT, plusCHAT_PARTICIPANT_MAINandCHAT_PARTICIPANT_EXT.packages/plugin-ext/src/common/lm-protocol.ts: Declare RPC contractsLanguageModelChatMain,LanguageModelChatExt,ChatParticipantMain, andChatParticipantExt.packages/plugin-ext/src/main/browser/lm-main.ts: ImplementLanguageModelChatMainImplandChatParticipantMainImplconsumingLanguageModelRegistryandChatAgentService.packages/plugin-ext/src/plugin/lm-ext.ts: ImplementLanguageModelChatExtImplwithsendRequest()token generator andCancellationTokenbinding.packages/ai-core/src/common/language-model.ts#L761-L770: Reference existingLanguageModelRegistrymethods (selectLanguageModels,getLanguageModels).6. Implementation Idea
LanguageModelChatMainImpl):Inject
FrontendLanguageModelRegistry(orLanguageModelRegistry). Map Theia'sLanguageModelobjects toLanguageModelChatDto(id, vendor, family, name, version, maxInputTokens). On$sendChatRequest, invokemodel.sendRequest(), listen to the stream, and push chunks across RPC via$acceptChatResponseChunk.ChatParticipantMainImpl):Implement an adapter that implements Theia's
ChatAgentinterface. When an extension calls$registerChatParticipant(id, name), register an agent withChatAgentService. When the user types@participant <prompt>in Theia's AI Chat, invoke$handleChatParticipantRequeston the extension host.7. Acceptance Criteria
vscode.lm.selectChatModels()from a sample VS Code extension returns all active models configured in Theia'sLanguageModelRegistry.chat.sendRequest(messages)stream tokens progressively to the extension without stalling the UI thread.vscode.CancellationTokenaborts the in-flight request cleanly in Theia's backend provider.vscode.chat.createChatParticipant('copilot', handler)dynamically register@copilotin Theia's Chat UI input dropdown.@participantdispatches the request to the extension's handler and streams the response markdown into the active chat session.All reactions