Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
Contributing to Jan Extensions
<- Back to Main Contributing Guide
Extensions add specific features to Jan as self-contained modules. Every
extension exports activate(ctx) (and optionally deactivate()) and reaches
the app only through ctx. There is no base class to extend.
There are two kinds:
- Built-ins (this folder) run in the main window and receive an
InternalExtensionContextfrom@janhq/core. Next to the stable API they getctx.internal(service registry, fs, downloads, engines, internal tools, secrets), which has no stability guarantee. - Third-party extensions run in a Web Worker each, receive the stable
ExtensionContextfrom@janhq/extension-apiand can use only what their manifest permissions grant.extensions-samples/hello-provideris the reference; start from it.
Current built-ins
| Folder | Id | What it provides |
|---|---|---|
assistant-extension |
jan.assistant |
ServiceKeys.Assistants (assistant CRUD, migrations) |
download-extension |
jan.download |
ServiceKeys.Downloads (model downloads with progress) |
llamacpp-extension |
jan.llamacpp |
llama.cpp engine via ctx.internal.engines, ServiceKeys.Llamacpp |
mlx-extension |
jan.mlx |
MLX engine on Apple Silicon (macOS only), ServiceKeys.Mlx |
vector-db-extension |
jan.vector-db |
ServiceKeys.VectorDB (sqlite-vec with a linear fallback) |
rag-extension |
jan.rag |
ServiceKeys.RAG and the RAG tools; depends on jan.vector-db |
The host activates them from HOST_BUILTINS in
web-app/src/lib/extensions/builtins.ts.
Adding a built-in
extensions/<name>-extension/package.json: name it@janhq/<name>-extension, depend on@janhq/core(workspace:*), and add ajanmanifest field:
User-facing settings go in"jan": { "id": "jan.<name>", "displayName": "My Feature", "publisher": "Jan", "apiVersion": "^1.0.0", "main": "dist/index.js", "permissions": [] }jan.contributes.settings; the host stores them and renders them on Settings > Extensions.rolldown.config.mjs,tsconfig.jsonandvitest.config.ts, copied fromdownload-extension(the smallest).src/index.ts:
A new service needs its interface and aimport { ServiceKeys, type InternalExtensionContext } from '@janhq/core' export async function activate(ctx: InternalExtensionContext): Promise<void> { const service = createMyService(ctx) // Everything added to ctx.subscriptions is disposed on deactivation. ctx.subscriptions.add(ctx.internal.services.provide(ServiceKeys.MyService, service)) }ServiceKeyincore/src/browser/host/services.ts. Callers in the web app read it withgetExtensionHost().services.get(ServiceKeys.MyService).- Wire it up: an entry in
HOST_BUILTINS(withdependsOnif it needs another built-in active first), a module declaration inweb-app/src/types/bundled-extensions.d.ts, and the vitest project in the rootvitest.config.ts.
Lifecycle
- The app starts and the host validates each built-in's manifest.
- Built-ins activate in
dependsOnorder:activate(ctx)is awaited. - Installed third-party extensions then start in their workers.
- On shutdown or disable the host calls
deactivate()and disposesctx.subscriptions.
A failing activate marks only that extension as failed; it never blocks
the others or the UI.
Building and testing
yarn build:extensions # extension-api, runtime, core, every extension, samples
yarn test:ext
make test-extensions-smoke
Test against a fake context rather than the real host; see
rag-extension/src/test/fake-context.ts and
llamacpp-extension/src/test/host.ts.
Rules
- Extensions do not import each other; they share services through
ctx.internal.servicesand declare order withdependsOn. invokecalls belong only in a Tauri plugin'sguest-jslayer.- Release everything you acquire through
ctx.subscriptions. - User-visible strings go through i18next (or manifest
l10nfor third-party extensions).