Transformers.js for Chrome Extensions
Key point
Outlines the structure for attaching local AI to Manifest V3 Chrome extensions using Transformers.js.
Details
Outlines an architecture for attaching Transformers.js to a Chrome extension under Manifest V3 constraints.
- The background service worker handles model hosting, agent state, and tool execution.
- The side panel handles the chat UI and streaming responses.
- The content script handles page extraction and highlighting.
Models are split into two roles. Gemma 4 E2B ONNX handles text generation and tool selection, while all-MiniLM-L6-v2 ONNX handles embeddings for search. All inference runs in the background, and the cache is shared and stored under the chrome-extension:// origin to reduce redundant loading. Since the service worker can be suspended, model state must be handled in a re-initializable way.
The execution loop works by parsing tool_call from model output and converting it into deterministic tool execution. webMcp normalizes extension tools into a name / description / inputSchema / execute format, and extractToolCalls separates messages from tool calls. Example tools include tab control, opening URLs, history search, querying web pages, and highlighting elements.
State is separated by purpose.
- Conversation history: background memory
- Settings:
chrome.storage.local - Vector history: IndexedDB
- Page content: background cache
The key point is that local AI extensions need a background-executor-centric structure, a strict messaging contract, and a model caching strategy.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.