214 Commits

Author SHA1 Message Date
Akarshan
e11b4c9449
restore extras to its original state 2025-07-31 15:41:44 +07:00
Akarshan
e76d207718
Fixup: tauri::WindowEvent 2025-07-31 15:41:43 +07:00
Akarshan
b3e8201481
Add RunEvent::Exit event to tauri to handle macos context menu exit 2025-07-31 15:41:43 +07:00
Akarshan Biswas
0aaaca05a4
fix: use direct process termination instead of console events on Windows (#5972)
* fix: remove CREATE_NEW_PROCESS_GROUP flag for proper Ctrl-C handling

CREATE_NEW_PROCESS_GROUP prevented GenerateConsoleCtrlEvent from working,
causing graceful shutdown failures. Removed to enable proper signal handling.

* Revert "fix: remove CREATE_NEW_PROCESS_GROUP flag for proper Ctrl-C handling"

This reverts commit 82ace3e72e4bf7338f422d5c79bdd6a0f8a2440e.

* fix: use direct process termination instead of console events

Simplified Windows process cleanup by removing console attachment logic
and using direct child.kill() method. More reliable for headless processes.

* Fix missing imports

* switch to tokio::time

* Don't wait while forcefully terminate process using kill API on Windows

Disabled use of windows-sys crate as graceful shutdown on Windows is unreliable in this context.

Updated cleanup.rs and server.rs to directly call child.kill().await for terminating processes on Windows.

Improved logging for process termination and error handling during kill and wait.

Removed timeout-based graceful shutdown attempt on Windows since TerminateProcess is inherently forceful and immediate.

This ensures more predictable process cleanup behavior on Windows platforms.

* final cleanups
2025-07-30 10:09:20 +05:30
Nguyen Ngoc Minh
ee582a8e52
chore: allow all HTTPS image sources in img-src directive (#5970) 2025-07-29 20:04:35 +07:00
Akarshan Biswas
f61ce886a0
feat: Enhance port selection with availability check (#5966)
This change improves the robustness of the llama.cpp extension's server port selection.

Previously, the `getRandomPort()` method only checked for ports already in use by active sessions, which could lead to model load failures if the chosen port was occupied by another external process.

This change introduces a new Tauri command, `is_port_available`, which performs a system-level check to ensure the randomly selected port is truly free before attempting to start the llama-server. It also adds a retry mechanism with a maximum number of attempts (20,000) to find an available port, throwing an error if no suitable port is found within the specified range after all attempts.

This enhancement prevents port conflicts and improves the reliability and user experience of the llama.cpp extension within Jan.

Closes #5965
2025-07-29 18:01:52 +05:30
Nguyen Ngoc Minh
eb714776ba
fix: csp including img.shields.io and cdn-uploads.huggingface.co in img-src directive (#5967)
* fix: csp including img.shields.io in img-src directive

* fix: add huggingface upload cdn to img-src directive
2025-07-29 16:30:00 +07:00
Louis
812a8082b8
fix: factory reset fail with access denied error (#5952)
* fix: factory reset fail due to access denied error

* fix: unused import

* fix: tests
2025-07-28 23:20:45 +07:00
Nguyen Ngoc Minh
a4e5973573
chore: uninstall when upgrading windows installer (#5945) 2025-07-28 14:09:13 +07:00
Nguyen Ngoc Minh
c3fa04fdd7
chore: revert back to passive mode on windows installer (#5934) 2025-07-26 22:29:58 +07:00
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
Louis
3afdd0fa1d
fix: tmp download file should be removed on cancel (#5849) 2025-07-23 12:52:34 +07:00
Akarshan Biswas
1eaec5e4f6
Fix: engine unable to find dlls on when running on Windows (#5863)
* Fix: Windows llamacpp not picking up dlls from lib repo

* Fix lib path on Windows

* Add debug info about lib_path

* Normalize lib_path for Windows

* fix window lib path normalization

* fix: missing cuda dll files on windows

* throw backend setup errors to UI

* Fix format

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

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

* feat: add logger to llamacpp-extension

* fix: platform check

---------

Co-authored-by: Louis <louis@jan.ai>
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-07-22 20:05:24 +05:30
Nguyen Ngoc Minh
7d3811f879
chore: update build appimage script (#5866)
* chore: update new appimage kit url

* chore: add error handling for appimagetool download
2025-07-22 21:02:25 +07:00
Akarshan Biswas
f59739d2b0
refactor: Improve Llama.cpp backend management and auto-update (#5845)
* refactor: Improve Llama.cpp backend management and auto-update

This commit refactors the Llama.cpp extension to enhance backend management and streamline the auto-update process.

Key changes include:

Refactored configureBackends: The logic for determining the best available backend and populating settings is now more modular, preventing duplicate executions.

Dedicated Auto-update Handling: Introduced a handleAutoUpdate method to encapsulate the auto-update logic, including downloading the latest available backend and updating the internal configuration and settings.

Robust Old Backend Cleanup: The removeOldBackends method is improved to ensure only the currently used backend version and type are kept, effectively managing disk space. A delay is added for Windows to prevent file conflicts during cleanup.

Final Installation Check: A ensureFinalBackendInstallation method is added to guarantee the selected backend is installed, acting as a final safeguard after auto-update or if auto-update is disabled.

Minor Fixes:

Added console.log for save_path during decompression for better debugging.

Ensured the output directory exists before decompression in the Rust backend.

Removed extraneous console log for session info.

Updated Cargo.toml and tauri.conf.json versions.

These changes lead to a more reliable and efficient Llama.cpp backend experience within the application, particularly for users with auto-update enabled.

* fix isBackendInstalled parameters

* Address bot's comments

* Address bot comments of using try finally block
2025-07-22 14:35:34 +05:30
Nguyen Ngoc Minh
fceecffed7
feat: add vcruntime for windows installer (#5852) 2025-07-22 12:38:00 +07:00
Nguyen Ngoc Minh
9ea081576b
fix: custom tauri nsis template CheckIfAppIsRunning macro (#5840)
* fix: update CheckIfAppIsRunning macro to include args
2025-07-21 20:54:06 +07:00
Akarshan Biswas
08de0fa42d
fix: prevent terminal window from opening on model load on WindowsOS (#5837)
On Windows, spawning the llamacpp server was causing an unwanted terminal window
to appear. This is now fixed by combining `CREATE_NO_WINDOW` with
`CREATE_NEW_PROCESS_GROUP` using `.creation_flags(...)`, ensuring that the
process runs in the background without a console window.

This change only applies to 64-bit Windows builds.
2025-07-21 13:24:31 +05:30
Louis
19cb1c96e0
fix: llama.cpp backend download on windows (#5813)
* fix: llama.cpp backend download on windows

* test: add missing cases

* clean: linter

* fix: build
2025-07-20 16:58:09 +07:00
Louis
c550f6cf0d
Merge pull request #5809 from menloresearch/refactor/simplify-proxy-settings
refactor: simplify proxy settings by removing unused SSL verification options
2025-07-19 16:34:37 +07:00
Akarshan
59ad2eb784
Merge branch 'dev' into release/v0.6.6 2025-07-18 18:29:20 +05:30
Louis
8d84c3b884
feat: add model load error handling to improve UX (#5802)
* feat: model load error handling

* chore: clean up

* test: add tests

* fix: provider name
2025-07-18 08:25:54 +05:30
Louis
8ca507c01c
feat: proxy support for the new downloader (#5795)
* feat: proxy support for the new downloader

* test: remove outdated test

* ci: clean up
2025-07-17 23:10:21 +07:00
Louis
32966f9259
Merge pull request #5801 from menloresearch/release/v0.6.5
Sync release/0.6.5 into dev to start new development cycle
2025-07-17 22:22:32 +07:00
Akarshan Biswas
b736d09168
fix: Prevent spamming /health endpoint and improve startup and resolve compiler warnings (#5784)
* fix: Prevent spamming /health endpoint and improve startup and resolve compiler warnings

This commit introduces a delay and improved logic to the /health endpoint checks in the llamacpp extension, preventing excessive requests during model loading.

Additionally, it addresses several Rust compiler warnings by:
- Commenting out an unused `handle_app_quit` function in `src/core/mcp.rs`.
- Explicitly declaring `target_port`, `session_api_key`, and `buffered_body` as mutable in `src/core/server.rs`.
- Commenting out unused `tokio` imports in `src/core/setup.rs`.
- Enhancing the `load_llama_model` function in `src/core/utils/extensions/inference_llamacpp_extension/server.rs` to better monitor stdout/stderr for readiness and errors, and handle timeouts.
- Commenting out an unused `std::path::Prefix` import and adjusting `normalize_path` in `src/core/utils/mod.rs`.
- Updating the application version to 0.6.904 in `tauri.conf.json`.

* fix grammar!

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

* fix grammar 2

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

* reimport prefix but only on Windows

* remove instead of commenting

* remove redundant check

* sync app version in cargo.toml with tauri.conf

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
2025-07-16 18:18:11 +05:30
Louis
f083fafcfd
Merge pull request #5776 from menloresearch/fix/download-icon
🐛fix: download icon when left panel close
2025-07-15 11:44:29 +07:00
Minh141120
65bc24530f fix: change installationmode in nsis template 2025-07-15 10:23:22 +07:00
Louis
8e85c2fd06
fix: bump llama.cpp b5857 on windows 2025-07-15 10:15:03 +07:00
Sam Hoang Van
9a76c94e22
update rmcp to fix issues (#5290) 2025-07-14 16:49:27 +07:00
Akarshan Biswas
dee98f41d1
Feat: Improved llamacpp Server Stability and Diagnostics (#5761)
* feat: Improve llamacpp server error reporting and model load stability

This commit introduces significant improvements to how the llamacpp server
process is managed and how its errors are reported.

Key changes:
- **Enhanced Error Reporting:** The llamacpp server's stdout and stderr
  are now piped and captured. If the llamacpp process exits prematurely
  or fails to start, its stderr output is captured and returned as a
  `LlamacppError`. This provides much more specific and actionable
  diagnostic information for users and developers.
- **Increased Model Load Timeout:** The `waitForModelLoad` timeout has
  been increased from 30 seconds to 240 seconds (4 minutes). This
  addresses issues where larger models or slower systems would
  prematurely time out during the model loading phase.
- **API Secret Update:** The internal API secret for the llamacpp
  extension has been updated from 'Jan' to 'JustAskNow'.
- **Version Bump:** The application version in `tauri.conf.json` has
  been incremented to `0.6.901`.

* fix: should not spam load requests

* test: add test to cover the fix

* refactor: clean up

* test: add more test case

---------

Co-authored-by: Louis <louis@jan.ai>
2025-07-14 11:55:44 +05:30
Louis
a770e08013
test: migrate jest to vitest 2025-07-10 21:14:21 +07:00
Louis
1c7a20be44
fix: linux build 2025-07-10 21:14:20 +07:00
Louis
37718d1e71
fix: build issue with legacy libs 2025-07-10 20:17:20 +07:00
Louis
389721ba89
fix: build step 2025-07-10 16:49:21 +07:00
Louis
6e0218c084
Merge branch 'release/v0.7.0' into feat/inference-llamacpp-extension
# Conflicts:
#	.devcontainer/buildAppImage.sh
#	.github/workflows/template-tauri-build-linux-x64.yml
#	Makefile
#	core/src/node/extension/index.test.ts
#	package.json
#	src-tauri/tauri.conf.json
#	web-app/package.json
2025-07-10 15:36:41 +07:00
Minh141120
3790bd5753 refactor: clean up tauri build workflow for linux 2025-07-10 15:01:52 +07:00
Minh141120
0fd346181c chore: enable active installation for window installer 2025-07-10 14:57:55 +07:00
Louis
10bb8527bd
feat: bump llama.cpp b5857 2025-07-10 11:51:27 +07:00
D. Rect.
a668204cdc refactor: pin linuxdeploy in make/yarn build process instead of github workflow
- pulls fix for #5463 out of the github release workflow and into
  the make/yarn build process
- implements a wrapper script that pins linuxdeploy and injects
  a new location for XDG_CACHE_HOME into the build pipeline,
  allowing manipulating .cache/tauri without tainting the hosts
  .cache
- adds ./.cache (project_root/.cache) to make clean and mise clean
  task
- remove .devcontainer/buildAppImage.sh, obsolete now that extra
  build steps have been removed from the github workflow and
  incorporated in the normal build process
- remove appimagetool from .devcontainer/postCreateCommand.sh,
  as it was only used by .devcontainer/buildAppImage.sh
2025-07-10 04:50:12 +00:00
D. Rect.
7d04d66a0b refactor: pull appimage packaging steps out of github linux release workflow
- pulled appimage packaging steps out of release workflow into new
  src-tauri/build-utils/buildAppImage.sh
- cleaned up yarn scripts:
  - moved multi platform yarn scripts out of yarn build:tauri:<platform>
    into generic yarn build:tauri
  - split yarn build:tauri:linux:win32 into separate yarn scripts so it's
    clearer what is specific to which platform
- added src-tauri/build-utils/buildAppImage.sh to new yarn build:tauri:linux
  yarn script

    This is also a good entry point to add flatpak builds in the future.

    Part of #5641
2025-07-10 04:50:12 +00:00
D. Rect.
4134917a45 refactor: split platform specific config out of tauri.conf.json
Allows for better per platform default config. Currently the
default serves windows/macos fine while it has to be tweaked
in order to build for linux

make build-tauri now successfully runs where it errored out before.
Appimages made with make alone however is incomplete as there are
still post processing steps in the github release workflow to bundle
additional resources.

- split platform specific config out of tauri.conf.json into auxiliary
  platform specific config files, natively supported by tauri

- pull improved defaults out of template-tauri-build-linux-x64.yml
  into new tauri.linux.conf.json

- fix tauri-build-linx-x64.yml to utilize new tauri.linux.conf.json
2025-07-10 04:50:12 +00:00
Louis
a8ed759a06 fix: model download - windows path issue 2025-07-10 09:42:36 +07:00
Louis
46c95ebb97
feat: bump version of llama.cpp - b5833 2025-07-10 08:29:56 +07:00
Louis
2f02a228cc
fix: download on windows 2025-07-08 15:41:17 +07:00
Louis
b26ae7d0a4
ci: remove cortex build steps 2025-07-07 22:39:04 +07:00
Akarshan
d5ffc6a476
feat: Migrate Jan's API server to llamacpp-extension
Things to ponder:
- Now, the v1/models endpoint of the API server will return an empty
  list if no models are loaded
- Streaming v1/chat/completion routing works as well as v1/models; needs
  further testing
2025-07-07 20:52:00 +05:30
Louis
e3faf09ab2
chore: try fixing CI 2025-07-07 21:27:37 +07:00
Louis
6b496ae413
fix: build issues 2025-07-07 18:27:45 +07:00
Akarshan
d4a3d6a0d6
Refactor session PID types from string to number across backend and extension
- Changed `pid` field in `SessionInfo` from `string` to `number`/`i32` in TypeScript and Rust.
- Updated `activeSessions` map key from `string` to `number` to align with new PID type.
- Adjusted process monitoring logic to correctly handle numeric PIDs.
- Removed fallback UUID-based PID generation in favor of numeric fallback (-1).
- Added PID cleanup logic in `is_process_running` when the process is no longer alive.
- Bumped application version from 0.5.16 to 0.6.900 in `tauri.conf.json`.
2025-07-04 21:40:54 +05:30
Akarshan
dbdc031583
chore: store session_info in backend as well for API server(WIP) 2025-07-04 20:31:30 +05:30