58 Commits

Author SHA1 Message Date
Akarshan Biswas
1d0bb53f2a
feat: add support for querying available backend devices (#5877)
* feat: add support for querying available backend devices

This change introduces a new `get_devices` method to the `llamacpp_extension` engine that allows the frontend to query and display a list of available devices (e.g., Vulkan, CUDA, SYCL) from the compiled `llama-server` binary.

* Added `DeviceList` interface to represent GPU/device metadata.
* Implemented `getDevices(): Promise<DeviceList[]>` method.

  * Splits `version/backend`, ensures backend is ready.
  * Invokes the new Tauri command `get_devices`.

* Introduced a new `get_devices` Tauri command.
* Parses `llama-server --list-devices` output to extract available devices with memory info.
* Introduced `DeviceInfo` struct (`id`, `name`, `mem`, `free`) and exposed it via serialization.
* Robust parsing logic using string processing (non-regex) to locate memory stats.
* Registered the new command in the `tauri::Builder` in `lib.rs`.

* Fixed logic to correctly parse multiple devices from the llama-server output.
* Handles common failure modes: binary not found, malformed memory info, etc.

This sets the foundation for device selection, memory-aware model loading, and improved diagnostics in Jan AI engine setup flows.

* Update extensions/llamacpp-extension/src/index.ts

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-07-23 19:20:12 +05:30
Akarshan
449bf17692
Add process aliveness check 2025-07-02 12:29:03 +07:00
Akarshan
ad06b2a903
Move llama-server cleanup code to a separate file 2025-07-02 12:27:42 +07:00
Akarshan
7de694c0cd
add missing import during rebase 2025-07-02 12:27:42 +07:00
Akarshan
62ba503b86
chore: cleanup llama-server processes upon app exit 2025-07-02 12:27:42 +07:00
Akarshan
01d49a4b28
fix: Update server process handling for Windows and Unix systems 2025-07-02 12:27:42 +07:00
Akarshan
6c769c5db9
feat: refactor llama server process storage to use HashMap
Change the llama_server_process state from an Option<Child> to a HashMap<String, Child> to support managing multiple server instances by PID. This allows precise process tracking and termination, replacing the previous single-process limitation.

Previously, only one server process could be tracked at a time. Now, each process is stored with its PID as the key, enabling:
- Accurate session matching during unloading
- Proper termination of specific processes
- Better error handling for mismatched PIDs

The load_llama_model function now inserts processes into the map, and unload_llama_model removes them by PID.
2025-07-02 12:27:34 +07:00
Thien Tran
8bf4a5eb7d
remove migration 2025-07-02 12:27:34 +07:00
Thien Tran
1eb49350e9
add is_library_available command 2025-07-02 12:27:17 +07:00
Thien Tran
40cd7e962a
feat: download backend for llama.cpp extension (#5123)
* wip

* update

* add download logic

* add decompress. support delete file

* download backend upon selecting setting

* add some logging and nootes

* add note on race condition

* remove then catch

* default to none backend. only download if it's not installed

* merge version and backend. fetch version from GH

* restrict scope of output_dir

* add note on unpack
2025-07-02 12:27:13 +07:00
Akarshan Biswas
da23673a44
feat: Add API key generation for Llama.cpp
This commit introduces API key generation for the Llama.cpp extension.  The API key is now generated on the server side using HMAC-SHA256 and a secret key to ensure security and uniqueness.  The frontend now passes the model ID and API secret to the server to generate the key. This addresses the requirement for secure model access and authorization.
2025-07-02 12:27:12 +07:00
Thien Tran
5803fcdb99
add read_yaml. use buffered reader/writer 2025-07-02 12:27:11 +07:00
Thien Tran
ded9ae733a
feat: Model import (download + local import) for llama.cpp extension (#5087)
* add pull and abortPull

* add model import (download only)

* write model.yaml. support local model import

* remove cortex-related command

* add TODO

* remove cortex-related command
2025-07-02 12:27:09 +07:00
Akarshan Biswas
a7a2dcc8d8
refactor load/unload again; move types to core and refactor AIEngine abstract class 2025-07-02 12:27:09 +07:00
Akarshan Biswas
a8abc9f9aa
Resolved conflicts by keeping HEAD changes 2025-07-02 12:27:07 +07:00
Thien Tran
15f0b11c0d
make it compile 2025-07-02 12:26:38 +07:00
Akarshan Biswas
9016fbff68
feat: inference-llamacpp-extension: backend implementation 2025-07-02 12:26:37 +07:00
Sam Hoang Van
64a7822cc8
Feat: auto restart mcp (#5226)
* feat: implement retry mechanism for MCP server activation with exponential backoff

feat: enhance MCP server activation with configurable retry attempts

feat: implement MCP server restart monitoring and cleanup functionality

feat: enhance MCP server restart logic with improved monitoring and configuration handling

feat: add manual deactivation for MCP servers to prevent automatic restarts

* feat: enhance MCP server startup with initial attempt tracking and health monitoring
2025-06-23 12:20:05 +07:00
Louis
22396111be
fix: stop api server on page unload (#5356)
* fix: stop api server on page unload

* fix: check api server status on reload

* refactor: api server state

* fix: should not pop the guard
2025-06-19 00:12:03 +07:00
Sam Hoang Van
e22452b26e
fix: add cortex_killed_intentionally state to manage sidecar process termination (#5255)
* fix: add cortex_killed_intentionally state to manage sidecar process termination

* fix: improve handling of intentionally killed sidecar process
2025-06-12 19:20:27 +07:00
Louis
6d6790d5e0
fix: clean up cortex processes (#5215)
* fix: clean up cortex processes

* chore: clean up

* chore: does not need output shell
2025-06-09 22:23:07 +07:00
Louis
919b6671a1
enahancement: mcp server activation response and error handling (#5220)
* fix: mcp server error handling

* fix: custom installation path of MCP package managers

* chore: clean up

* chore: clean up

* chore: append mcp server errors to app logs

* fix: logs reading

* chore: typo
2025-06-09 19:43:16 +07:00
Louis
a3e78dd563
refactor: clean up migrations (#5187) 2025-06-04 00:41:14 +07:00
Louis
ecef9d7df6
feat: handle open Jan on HF GGUF repo (#5173)
* feat: handle open Jan on HF GGUF repo

* chore: reset retry attempts
2025-06-03 01:09:36 +07:00
Louis
1a0f643d87
refactor: clean up repo (#5165)
* chore: remove legacy themes

* refactor: clean up dependencies

* chore: remove cuda 11 dependency - fix linux LD_LIBRARY_PATH

* fix: load models issue on Linux

# Conflicts:
#	src-tauri/src/core/setup.rs

* chore: do not download cuda 11 by default

* chore: remove cuda 11 from installer

* fix: cuda lookup on Linux
2025-06-02 19:03:06 +07:00
Faisal Amir
b98c31b184
enhancement: open folder log and change data folder dialog confirm (#5159)
* enhancement: ux change data folder with confirmation and reveal in finder logs

* chore: update button open logs local api server

* Update web-app/src/components/ui/button.tsx

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* chore: handle error when change location data folder failed

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-06-02 08:54:16 +07:00
Louis
573e667c34
feat: migrate legacy local storage data to new app (#5156)
* feat: migrate legacy local storage data to new app

* chore: refactor localstorage db read

* chore: clean up

* chore: migrate api key setting

* chore: apply proxy configs

* chore: fix key
2025-06-01 22:57:01 +07:00
Louis
4672754b81
chore: persist assistants settings (#5127)
* chore: assistant settings

* chore: fix model sources issue after deleted models

* chore: assistants as files

* chore: clean up
2025-05-28 19:33:13 +07:00
Louis
26154941ca
fix: chore UI issues (#5116)
* fix: app log outputs with debug level

* fix: reasoning block still show loading indicator when stopped

* chore: fix mistral AI base url
2025-05-27 19:38:21 +07:00
Louis
b8de48c9e9
fix: enhance tool use and model provider not persisted issues (#5094)
* chore: enhance tool use loop

* fix: create new custom provider is not saved

* chore: bump llama.cpp b5488

* chore: normalize reasoning assistant response

* chore: fix tool call parse in stream mode

* fix: give tool call default generated id

* fix: system instruction should be on top of the history

* chore: allow users to add parameters
2025-05-26 15:12:55 +07:00
Thien Tran
56f4ec3b61
feat: improve download extension (#5073) 2025-05-23 16:49:41 +08:00
Thien Tran
c324ed592a
feat: Hardware info replacement for cortex (#4925) 2025-05-23 12:59:19 +08:00
Louis
2dda66390d
fix: close side windows should not kill background processes (#5076) 2025-05-23 09:34:29 +07:00
Sam Hoang Van
7df7d8ffa0
feat: Implement Cortex server auto-restart and webview notification (#5074)
* feat: Implement Cortex server auto-restart and webview notification

Implements a robust auto-restart mechanism for the Cortex server (sidecar)
managed by the Tauri backend.

Key changes:

Backend (src-tauri):
- Modified `core/setup.rs` to:
  - Loop sidecar spawning, attempting up to `MAX_RESTARTS` (5) times with a
    `RESTART_DELAY_MS` (5 seconds) between attempts.
  - Monitor the sidecar process for unexpected termination (crashes or
    non-zero exit codes).
  - Reset the restart attempt count to 0 in `AppState` upon a successful
    server spawn.
  - Emit a "cortex_max_restarts_reached" event to the webview if the
    server fails to start after `MAX_RESTARTS`.
- Updated `core/state.rs` to include `cortex_restart_count: Arc<Mutex<u32>>`
  in `AppState` to track restart attempts.
- Added a new Tauri command `reset_cortex_restart_count` in `core/cmd.rs`
  to allow the webview (or other parts of the app) to reset this counter.
- Registered the new command and initialized the `cortex_restart_count`
  in `lib.rs`.

Frontend (web-app):
- Created a new component `CortexFailureDialog.tsx` in
  `src/containers/dialogs/` to:
  - Listen for the "cortex_max_restarts_reached" event from Tauri.
  - Display a dialog informing the user that the local AI engine (Cortex)
    failed to start after multiple attempts.
  - Offer options to "Contact Support" (opens jan.ai/support),
    "Restart Jan" (invokes the `relaunch` Tauri command), or "Okay"
    (dismisses the dialog).
- Integrated the `CortexFailureDialog` into the `RootLayout` in
  `src/routes/__root.tsx` so it's globally available.
- Corrected button variants in `__root.tsx` to use `variant="default"`
  with appropriate classNames for outline styling, resolving TypeScript
  errors.

* refactor: Improve async handling and logging in setup_sidecar function
2025-05-22 23:09:43 +07:00
vansangpfiev
e43b109291
fix: tauri updater (#5051)
* fix: updater

* chore: sync latest nightly

* chore: ignore electron updater config

* chore: upload signatures

* chore: update connect-src

* chore: add log

* chore: correct path macos s3

* fix: close cortex before restarting

* chore: clean

* chore: comment

* Revert "chore: update connect-src"

This reverts commit a592845c0b5293c121fb17671c14bb1f9958bf00.

* chore: update lastest.yml

* chore: cleanup

* chore: stop uploading yml for electron

* chore: linux workflow
2025-05-22 14:16:10 +07:00
Faisal Amir
434abaaca6
chore: app updater UI (#5054)
* chore: initial app updater UI and download management enhance

* chore: revert package version

* chore: update conditional app updater

* chore: remove console

* chore: add utils isDev

* chore: close popup when user click download

* revert yarn lock
2025-05-22 11:54:06 +07:00
Louis
6676e0ced8
chore: add relocate jan data folder function to new FE (#5043)
* chore: typo

* fix: linter issues

* chore: fix linter

* chore: fix linter

* chore: add relocate data folder
2025-05-21 10:48:10 +07:00
Faisal Amir
4adaeed3da chore: show location data folder and prepare ui for let user change folder 2025-05-20 14:10:49 +07:00
Louis
28c7e0d105
chore: stream app logs to log window (#5019)
* chore: stream app logs to log window

* chore: remove unused states
2025-05-19 22:51:37 +07:00
Louis
2ae7417e10
feat: add MCP server connection status (#5018) 2025-05-19 15:17:19 +07:00
Thien Tran
4bde6645d0
feat: Download manager for llama.cpp extension (#4933) 2025-05-16 15:01:42 +08:00
Faisal Amir
852ea84cd8
epic: Jan with new UI/UX (#4964)
* chore: initial new FE setup

* chore: update namespace text-left-panel foreground variable

* chore: enable dynamic mainview color

* chore: remove greetings new chat

* chore: fix chat input style

* chore: simplify hook useAppearance

* chore: enable internationalization

* chore: prepare vn locale

* chore: keyboardshortcut layout

* chore: update keyboard shortcut exclude pathname

* chore: update state active setting route

* chore: fix update theme by system

* chore: handle dynamic primary color

* chore: fix left panel navigation active state and styled item privacy analytic

* chore: reorder general setting being a first

* chore: add function reset appearance

* chore: update scrollbar

* chore: update delete thread with dialog confirmation

* chore: update state dialog inside dropdown menu

* chore: wip thread detail or chat page

* chore: wip model dropdown

* chore: prepare model dropdown select

* chore: update model providers setting

* chore: show provider on model dropdown based isActive toogle

* chore: update layout model provider

* chore: update state active on storage

* chore: update gap of item dropdown model

* chore: update select model base on id

* chore: update edit model capabilities

* chore: add dialog to add model

* chore: update sheet for model setting

* chore: add sheet setting each model

* chore: make dynamic syntax highlight

* chore: fix menu setting appearance theme

* chore: markdown render support emoji

* chore: markdown support latex

* chore: change codeblock default theme

* chore: update ui codeblock

* chore: custom render link taget new window

* chore: fix copy button codeblock

* chore: update accent and desctructive color

* chore: setup user chat message

* chore: prepare some page settings

* chore: simple list extension and prepare mcp, local api, and hardware

* chore: mcp-serve

* chore: MCP server UI

* chore: update local api server config

* chore: adjust chat input

* chore: update local api server log

* chore: prepare hub page

* chore: remove help page

* chore: update mock

* chore: prepare http proxy setting UI

* chore: adjust local api server and title every action

* fix: chore FE package (#4962)

* fix: update command which referred to non-existent web app

* fix: added commented out macos platform for now

* fix: remove the platform name as macos

* fix: remove unnecessary line for platform name in HeaderPage component

* fix: update dev script to specify port 3000 for Vite

* feat: model providers and chat completion

* enhancement: threads performance

* fix: thread content update

* chore: clean up threads

* fix: performance issue with streaming and state loop

* fix: streaming

* fix: react markdow

* feat: extension manager

* chore: add nodePolyfills include path

* chore: improve performance avoid unhandle rejection

* chore: update pre margin bottom

* chore: swith thread should be deafult scroll to bottom

* chore: wip scroll to bottom

* chore: add model loader

* chore: add platform utils

* feat: threads functionality

* chore: setup toaster

* chore: persist threads deletion

* fix: create thread with new message

* chore: create new thread should change route path

* chore: navigate after delet dialog thread

* chore: thread favorites and orders

* chore: dismiss deleting modal on delete

* chore: remove undefined properties

* chore: remove deprecated run step

* chore: fix delete thread

* chore: create empty thread content on started streaming

* chore: correct messages store key

* chore: stuck at generating state

* chore: preapre chat toolbar

* chore: introduce in-memory app state

* chore: update extensions migration logic

* chore: remove redundant extensions migration gate

* chore: message toolbar user and assistant

* chore: add logo gemini

* feat: remote providers with model capabilities

* chore: maintain provider settings

* chore: move speed token into chat input

* chore: temp harcoded model loader

* chore: make chat text selectable and truncate model list

* chore: update shortcut UI

* Feat/implement threads (#4977)

* chore: add fuse.js library for enhanced search functionality

* feat: implement thread filtering with Fuse.js for improved search capabilities

* fix: update the fuseOptions

* feat: add search functionality to LeftPanel and refactor thread retrieval logic

* refactor: optimize thread filtering and improve search functionality in LeftPanel

* fix: more edits

* refactor: remove duplicate import of useAppState in StreamingContent component

* chore: update navigate after delete all thread

* chore: pass prop speedToken from new chat input

* chore: persist provider general settings

* chore: styling search left panel

* chore: cleanup margin

* chore: update size icon

* chore: improve chat input

* chore: imprve list markdown

* chore: animate border

* feat: local model provider work

* chore: persist manually added model

* chore: prepare download management ui and show version on general setting

* chore: improve pre tag

* chore: remove buton install extension and improve light theme download

* chore: add missing hardware information handler

* chore: cleanup small ui

* chore: update default provider settings

* fix: missing fs commands

* chore: correct provider models

* chore: prepare delete model

* chore: handle thinking block

* chore: fix conditional message toolbar

* chore: pophover download select none

* enhancement: add prune mode

* chore: model settings

* chore: bump engine version tauri

* chore: update style thinking

* chore: add indicator and toogle mcp server

* chore: wip hub

* chore: update model settings

* chore: mvp hub

* chore: add function rename title

* chore: update function delete message

* chore: update rename title

* chore: update model settings

* chore: persist MCP configs

* refactor: clean up utils

* chore: add tools to completion request

* chore: clean up

* chore: ignore assets

---------

Co-authored-by: Ivan Leo <ivanleomk@gmail.com>
Co-authored-by: Louis <louis@jan.ai>
2025-05-15 19:38:59 +07:00
vansangpfiev
dea29ff8c4
fix: Jan supports cortex with llama-server (#4904)
* fix: update logic to pull llama-cpp engine

* chore: bump cortex version

* fix: chat macos

* chore: bump llama.cpp

* chore: download windows

* chore: download linux

* chore: bump cortex to 1.0.13-rc6

* fix: stop cortex before exit

* chore: bum llama.cpp engine to b5350

---------

Co-authored-by: vansangpfiev <sang@jan.ai>
2025-05-15 17:11:18 +07:00
Louis
19146fec6a
feat: restart MCP servers to reflect config updates (#4917) 2025-05-15 17:10:54 +07:00
Louis
80d11e1057
chore: add mcp write and read commands 2025-05-15 17:10:53 +07:00
Louis
6f53f1056a
refactor: Jan manages threads for a better performance (#4912)
* refactor: Jan manages threads for a better performance

* test: add tests
2025-05-15 17:10:52 +07:00
Louis
3173328396
chore: differentiate debug and release logging destination 2025-05-15 17:10:21 +07:00
Louis
baee71dd8e
refactor: app logging - script-src access in release 2025-05-15 17:10:21 +07:00
Louis
9467834c29
chore: improve startup time 2025-05-15 17:10:19 +07:00
Louis
4f7af0a10d
feat: Jan supports MCP as a client host 2025-05-15 17:10:18 +07:00